Skip to content

Commit

Permalink
fix font and BG scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Aug 25, 2024
1 parent 0ae7f44 commit feaac79
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/main/java/fi/dy/masa/malilib/render/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ public static void drawRect(int x, int y, int width, int height, int color)
}

public static void drawRect(int x, int y, int width, int height, int color, float zLevel)
{
drawRect(x, y, width, height, color, zLevel, 1.0f);
}

public static void drawRect(int x, int y, int width, int height, int color, float zLevel, float scale)
{
float a = (float) (color >> 24 & 255) / 255.0F;
float r = (float) (color >> 16 & 255) / 255.0F;
Expand All @@ -186,10 +191,10 @@ public static void drawRect(int x, int y, int width, int height, int color, floa

setupBlend();

buffer.vertex(x , y , zLevel).color(r, g, b, a);
buffer.vertex(x , y + height, zLevel).color(r, g, b, a);
buffer.vertex(x + width, y + height, zLevel).color(r, g, b, a);
buffer.vertex(x + width, y , zLevel).color(r, g, b, a);
buffer.vertex(x * scale, y * scale, zLevel).color(r, g, b, a);
buffer.vertex(x * scale, (y + height) * scale, zLevel).color(r, g, b, a);
buffer.vertex((x + width) * scale, (y + height) * scale, zLevel).color(r, g, b, a);
buffer.vertex((x + width) * scale, y * scale , zLevel).color(r, g, b, a);

try
{
Expand Down Expand Up @@ -457,7 +462,7 @@ public static int renderText(int xOff, int yOff, double scale, int textColor, in
}

// RenderSystem's 'modelViewStack' was changed to a Matrix4fStack method
Matrix4fStack global4fStack = RenderSystem.getModelViewStack();
//Matrix4fStack global4fStack = RenderSystem.getModelViewStack();
boolean scaled = scale != 1.0;

if (scaled)
Expand All @@ -468,10 +473,10 @@ public static int renderText(int xOff, int yOff, double scale, int textColor, in
yOff = (int) (yOff * scale);
}

//drawContext.getMatrices().push();
//drawContext.getMatrices().scale((float) scale, (float) scale, 1.0f);
global4fStack.pushMatrix();
global4fStack.scale((float) scale, (float) scale, 1.0f);
drawContext.getMatrices().push();
drawContext.getMatrices().scale((float) scale, (float) scale, 1.0f);
//global4fStack.pushMatrix();
//global4fStack.scale((float) scale, (float) scale, 1.0f);
//RenderSystem.applyModelViewMatrix();
}

Expand Down Expand Up @@ -507,13 +512,13 @@ public static int renderText(int xOff, int yOff, double scale, int textColor, in
}

drawContext.drawText(fontRenderer, line, x, y, textColor, useShadow);
forceDraw(drawContext);
}

if (scaled)
{
//forceDraw(drawContext);
global4fStack.popMatrix();
//drawContext.getMatrices().pop();
//global4fStack.popMatrix();
drawContext.getMatrices().pop();
//RenderSystem.applyModelViewMatrix();
}

Expand Down

0 comments on commit feaac79

Please sign in to comment.