loading gui + converter

This commit is contained in:
Sen 2025-03-16 21:58:40 +01:00
parent 9df6406a93
commit 90de256e04
7 changed files with 259 additions and 178 deletions

View file

@ -1,5 +1,6 @@
package game.renderer;
import game.Game;
import game.color.TextColor;
import game.gui.Font;
import game.gui.FontChar;
@ -531,6 +532,11 @@ public abstract class Drawing {
txt_draw(x, y, x, y, Integer.MAX_VALUE, Integer.MAX_VALUE, color, str);
}
public static void drawTextCentered(String str, int x, int y, int color) {
Vec2i size = getSize(str);
drawText(str, x - size.xpos / 2, y, color);
}
public static void drawTextRight(String str, int x, int y, int color) {
Vec2i size = getSize(str);
drawText(str, x - size.xpos, y, color);
@ -545,4 +551,30 @@ public abstract class Drawing {
return ((((c1 >> 24 & 255) + (c2 >> 24 & 255)) / 2) << 24) | ((((c1 >> 16 & 255) + (c2 >> 16 & 255)) / 2) << 16) | ((((c1 >> 8 & 255) + (c2 >> 8 & 255)) / 2) << 8) |
(((c1 & 255) + (c2 & 255)) / 2);
}
public static void drawScaledBackground(Game gm, String texture) {
drawScaledBackground(gm, texture, 0, 0, gm.fb_x, gm.fb_y);
}
public static void drawScaledBackground(Game gm, String texture, double x, double y, double width, double height) {
GlState.enableTexture2D();
GlState.disableLighting();
GlState.disableFog();
RenderBuffer buf = Tessellator.getBuffer();
gm.getTextureManager().bindTexture(texture);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
double scale = 32.0;
buf.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
buf.pos(x, y + height, 0.0D).tex(0.0D, height / scale)
.color(64, 64, 64, 255).endVertex();
buf.pos(x + width, y + height, 0.0D)
.tex(width / scale, height / scale)
.color(64, 64, 64, 255).endVertex();
buf.pos(x + width, y, 0.0D).tex(width / scale, 0.0)
.color(64, 64, 64, 255).endVertex();
buf.pos(x, y, 0.0D).tex(0.0D, 0.0)
.color(64, 64, 64, 255).endVertex();
Tessellator.draw();
GlState.disableTexture2D();
}
}