fix some gui issues

This commit is contained in:
Sen 2025-08-04 16:52:23 +02:00
parent 03fbf90a68
commit 16889889d4
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
19 changed files with 217 additions and 106 deletions

View file

@ -49,6 +49,7 @@ import client.gui.character.GuiChar;
import client.gui.container.GuiContainer;
import client.gui.container.GuiInventory;
import client.gui.element.Area;
import client.gui.element.InventoryButton;
import client.gui.ingame.GuiGameOver;
import client.gui.ingame.GuiRename;
import client.init.DimensionMapping;
@ -264,8 +265,7 @@ public class Client implements IThreadListener {
public static class FontFunction implements EnumFunction<Font> {
public void apply(EnumVar cv, Font value) {
Font.unload();
Font.load(value);
Font.select(value);
Client.CLIENT.rescale();
}
}
@ -558,6 +558,8 @@ public class Client implements IThreadListener {
private int scaleVar = 2;
@Variable(name = "gui_scale_items", category = CVarCategory.GUI, display = "Gegenstände vergrößern", callback = ItemRedrawFunction.class)
public boolean scaleItems = true;
@Variable(name = "gui_scale_hotbar", category = CVarCategory.GUI, display = "Leiste vergrößern")
public boolean scaleHotbar = true;
@Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%")
private float sensitivity = 1.0f;
@Variable(name = "gui_dclick_delay", category = CVarCategory.INPUT, min = 150, max = 750, display = "Doppelklick bei", unit = "ms")
@ -751,8 +753,9 @@ public class Client implements IThreadListener {
public void refreshResources()
{
this.logFeed("Lade Texturen neu");
Font.unload();
Font.load(this.font);
Font.unloadFonts();
Font.loadFonts();
Font.select(this.font);
this.textureManager.onReload();
this.modelManager.onReload();
this.renderItem.onReload();
@ -1073,10 +1076,13 @@ public class Client implements IThreadListener {
}
int selected = this.player.getSelectedIndex();
int scale = this.scaleHotbar ? 2 : 1;
for(int n = 0; n < 9; n++) {
int x = this.fbX / 2 - 180 + n * 40 + 4;
int y = this.fbY - 40;
Drawing.drawRectBorder(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xff000000, 0xffafafaf, 0xff4f4f4f);
int x = this.fbX / 2 - 90 * scale + n * 20 * scale + 2 * scale;
int y = this.fbY - 20 * scale;
if(selected == n)
Drawing.drawRect(x - scale * 2, y - scale * 2, 20 * scale, 20 * scale, 0xffffffff);
InventoryButton.drawButton(x - scale, y - scale, 18 * scale, 18 * scale, this.scaleHotbar);
}
ItemStack itemstack = this.player.getHeldItem();
@ -1116,8 +1122,8 @@ public class Client implements IThreadListener {
int color = potion.getColor();
String name = (potion.isBadEffect() ? Color.ORANGE : Color.ACID) + effect.getEffectName();
String desc = Color.NEON + effect.getDurationString();
Drawing.drawRectBorder(x, y, 250, Font.YGLYPH + 6, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f);
Drawing.drawGradient(x + 2, y + 2, effect.isInfinite() ? 246 : ((int)(246.0f * ((float)effect.getRemaining() / (float)effect.getDuration()))), Font.YGLYPH + 2, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
Drawing.drawRectBorder(x, y, 250, Font.HEIGHT + 6, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f);
Drawing.drawGradient(x + 2, y + 2, effect.isInfinite() ? 246 : ((int)(246.0f * ((float)effect.getRemaining() / (float)effect.getDuration()))), Font.HEIGHT + 2, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
Drawing.drawText(name, x + 4, y + 3, 0xffffffff);
Drawing.drawTextRight(desc, x + 250 - 4, y + 3, 0xffffffff);
y += 24;
@ -1206,12 +1212,12 @@ public class Client implements IThreadListener {
Drawing.drawRectBorder(this.fbX / 2 - 180, 20, 360, 60, 0xff6f6f6f, 0xff000000, 0xffafafaf, 0xff4f4f4f);
Drawing.drawTextCentered(desc, this.fbX / 2, 24, 0xffffffff);
if(line1 != null)
Drawing.drawTextCentered(line1, this.fbX / 2, 80 - 4 - Font.YGLYPH * 2 - 2, 0xffffffff);
Drawing.drawTextCentered(line1, this.fbX / 2, 80 - 4 - Font.HEIGHT * 2 - 2, 0xffffffff);
if(line2 != null)
Drawing.drawTextCentered(line2, this.fbX / 2, 80 - 4 - Font.YGLYPH, 0xffffffff);
Drawing.drawTextCentered(line2, this.fbX / 2, 80 - 4 - Font.HEIGHT, 0xffffffff);
if(bar >= 0.0f) {
Drawing.drawRect(this.fbX / 2 - 140, 24 + Font.YGLYPH + 2, 280, 6, 0xff202020, 0xffcfcfcf, 0xff3f3f3f);
Drawing.drawGradient(this.fbX / 2 - 140 + 1, 24 + Font.YGLYPH + 2 + 1, (int)(278.0f * bar), 4, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
Drawing.drawRect(this.fbX / 2 - 140, 24 + Font.HEIGHT + 2, 280, 6, 0xff202020, 0xffcfcfcf, 0xff3f3f3f);
Drawing.drawGradient(this.fbX / 2 - 140 + 1, 24 + Font.HEIGHT + 2 + 1, (int)(278.0f * bar), 4, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
}
}
}
@ -1225,8 +1231,10 @@ public class Client implements IThreadListener {
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
ItemRenderer.enableGUIStandardItemLighting();
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.fbX / 2 - 180 + 4 + 1), (float)(this.fbY - 40 + 1), 0.0f);
GL11.glScalef(2.0f, 2.0f, 2.0f);
int scale = this.scaleHotbar ? 2 : 1;
GL11.glTranslatef((float)(this.fbX / 2 - 90 * scale + 2 * scale), (float)(this.fbY - 20 * scale), 0.0f);
if(this.scaleHotbar)
GL11.glScalef(2.0f, 2.0f, 2.0f);
for(int index = 0; index < 9; ++index) {
int xPos = index * 20;
@ -1264,11 +1272,12 @@ public class Client implements IThreadListener {
GlState.enableBlend();
GlState.disableDepth();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
int scale = this.scaleHotbar ? 2 : 1;
for(int index = 0; index < 9; ++index) {
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null) {
GuiContainer.renderItemOverlay(itemstack,
this.fbX / 2 - 180 + 4 + 1 + index * 40, this.fbY - 40 + 1, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), 2);
this.fbX / 2 - 90 * scale + 2 * scale + index * 20 * scale, this.fbY - 20 * scale, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), scale);
}
}
}
@ -1357,7 +1366,7 @@ public class Client implements IThreadListener {
}
Drawing.drawText(sb.toString(), x1 + 240, y1, 0xffffffff);
if(str != null) {
y1 = Font.YGLYPH * 10;
y1 = Font.HEIGHT * 10;
Drawing.drawText(str, x1, y1, 0xffffffff);
}
}
@ -2246,7 +2255,8 @@ public class Client implements IThreadListener {
this.registerDebug();
System.gc();
System.gc();
Font.load(this.font);
Font.loadFonts();
Font.select(this.font);
GlState.enableBlend();
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.initConsole();
@ -2318,7 +2328,7 @@ public class Client implements IThreadListener {
Log.SOUND.info("Audiogerät geschlossen");
Log.flushLog();
this.save();
Font.unload();
Font.unloadFonts();
Window.destroyWindow();
Log.SYSTEM.info("Beendet.");
}
@ -3032,7 +3042,7 @@ public class Client implements IThreadListener {
if(size > 0) {
long fade = 1000000L * (long)this.hudFadeout;
int bg = (this.hudOpacity << 24) | 0x000000;
y = up ? y - Font.YGLYPH : y;
y = up ? y - Font.HEIGHT : y;
for(Iterator<Message> iter = log.iterator(); iter.hasNext();) {
Message msg = iter.next();
if((this.tmr_current - msg.time()) <= fade || (log == this.chat && this.chatPermanent)) {
@ -3042,7 +3052,7 @@ public class Client implements IThreadListener {
Drawing.drawTextboxRight(msg.message(), x, y, bg);
else
Drawing.drawTextboxCentered(msg.message(), x, y, bg);
y += up ? -(Font.YGLYPH) : Font.YGLYPH;
y += up ? -(Font.HEIGHT) : Font.HEIGHT;
}
else {
iter.remove();
@ -3083,7 +3093,7 @@ public class Client implements IThreadListener {
}
Drawing.drawTextRight(color + (ping < 10000 ? String.format("%d", ping) + "ms" : String.format("%.1f", ((float)ping) / 1000.0f) + "s"), x - 18, y, 0xffffffff);
for(int z = 0; z < bars; z++) {
Drawing.drawRect(x - 15 + z * 2, y + 8 - z + Font.YGLYPH - 10 + (Font.YGLYPH < 8 ? 1 : 0), 1, z + 1, 0xff000000 | color.color);
Drawing.drawRect(x - 15 + z * 2, y + 8 - z + Font.HEIGHT - 10 + (Font.HEIGHT < 8 ? 1 : 0), 1, z + 1, 0xff000000 | color.color);
}
}
@ -3097,8 +3107,8 @@ public class Client implements IThreadListener {
int by = 0;
for(Entry<String, Integer> elem : this.playerList.entrySet()) {
int x = this.fbX / 2 - (w * 300) / 2 + bx * 300;
int y = 10 + by * (Font.YGLYPH + 2);
Drawing.drawGradient(x, y, 300, Font.YGLYPH + 2, 0x7f404040, 0x7f101010, 0x7f5f5f5f, 0x7f000000);
int y = 10 + by * (Font.HEIGHT + 2);
Drawing.drawGradient(x, y, 300, Font.HEIGHT + 2, 0x7f404040, 0x7f101010, 0x7f5f5f5f, 0x7f000000);
Drawing.drawText(elem.getKey(), x + 4, y + 1, 0xffffffff);
drawPing(x + 300 - 4, y + 1, elem.getValue());
if(++bx >= w) {

View file

@ -19,20 +19,22 @@ public enum Font implements Identifyable, Displayable {
MEDIUM("medium", "Mittel", 10, 12),
LARGE("large", "Groß", 12, 14);
public static final FontChar[] SIZES = new FontChar[256];
public static int XGLYPH = 12;
public static int YGLYPH = 14;
private static int texture;
public static FontChar[] SIZES;
public static int WIDTH;
public static int HEIGHT;
private static int TEXTURE;
private static Font SELECTED;
private final FontChar[] sizes = new FontChar[256];
private final String name;
private final String display;
private final int width;
private final int height;
private int texture;
public static void bindTexture() {
GlState.bindTexture(texture);
GlState.bindTexture(TEXTURE);
}
private static int stride(int width, int height, int x, int y, int c) {
@ -84,39 +86,65 @@ public enum Font implements Identifyable, Displayable {
glyphs[z] = new FontChar(s, t, u, v);
}
}
public static void load(Font font) {
XGLYPH = font.width;
YGLYPH = font.height;
BufferedImage img = null;
try {
img = TextureUtil.readImage(FileUtils.getResource("textures/font_" + font.name + ".png"));
public static void loadFonts() {
for(Font font : values()) {
int width = font.width;
int height = font.height;
BufferedImage img = null;
try {
img = TextureUtil.readImage(FileUtils.getResource("textures/font_" + font.name + ".png"));
}
catch(FileNotFoundException e) {
Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden");
}
catch(IOException e) {
Log.IO.error(e, "Konnte Font-Textur nicht laden");
}
if(img != null && (img.getWidth() != width * 16 || img.getHeight() != height * 16)) {
Log.IO.error("Konnte Font-Textur nicht laden: Größe ist nicht %dx%d", width * 16, height * 16);
img = null;
}
if(img == null)
img = new BufferedImage(width * 16, height * 16, BufferedImage.TYPE_INT_ARGB);
int[] data = new int[width * 16 * height * 16];
img.getRGB(0, 0, width * 16, height * 16, data, 0, width * 16);
calculate(data, font.sizes, width, height, 0);
font.texture = GL11.glGenTextures();
TextureUtil.uploadImage(font.texture, img);
Log.RENDER.debug("Font-Textur wurde mit ID #%d geladen", font.texture);
}
catch(FileNotFoundException e) {
Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden");
}
catch(IOException e) {
Log.IO.error(e, "Konnte Font-Textur nicht laden");
}
if(img != null && (img.getWidth() != XGLYPH * 16 || img.getHeight() != YGLYPH * 16)) {
Log.IO.error("Konnte Font-Textur nicht laden: Größe ist nicht %dx%d", XGLYPH * 16, YGLYPH * 16);
img = null;
}
if(img == null)
img = new BufferedImage(XGLYPH * 16, YGLYPH * 16, BufferedImage.TYPE_INT_ARGB);
int[] data = new int[XGLYPH * 16 * YGLYPH * 16];
img.getRGB(0, 0, XGLYPH * 16, YGLYPH * 16, data, 0, XGLYPH * 16);
calculate(data, SIZES, XGLYPH, YGLYPH, 0);
texture = GL11.glGenTextures();
TextureUtil.uploadImage(texture, img);
Log.RENDER.debug("Font-Textur wurde mit ID #%d geladen", texture);
}
public static void unload() {
if(texture != 0) {
GL11.glDeleteTextures(texture);
Log.RENDER.debug("Font-Textur mit ID #%d wurde gelöscht", texture);
texture = 0;
public static void select(Font font) {
WIDTH = font.width;
HEIGHT = font.height;
TEXTURE = font.texture;
SIZES = font.sizes;
SELECTED = font;
}
public static void set(Font font) {
WIDTH = font.width;
HEIGHT = font.height;
TEXTURE = font.texture;
SIZES = font.sizes;
}
public static void unset() {
WIDTH = SELECTED.width;
HEIGHT = SELECTED.height;
TEXTURE = SELECTED.texture;
SIZES = SELECTED.sizes;
}
public static void unloadFonts() {
for(Font font : values()) {
if(font.texture != 0) {
GL11.glDeleteTextures(font.texture);
Log.RENDER.debug("Font-Textur mit ID #%d wurde gelöscht", font.texture);
font.texture = 0;
}
}
}
@ -134,4 +162,12 @@ public enum Font implements Identifyable, Displayable {
public String getDisplay() {
return this.display;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
}

View file

@ -158,12 +158,12 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
(this.keypair != null ? "Pubkey " + this.keyDigest : "") + (this.keypair != null && !this.password.isEmpty() ? " + " : "") + (!this.password.isEmpty() ? "Passwort" : ""),
x + width - 2, y, 0xffffffff);
Drawing.drawText(this.address + Color.GRAY + " Port " + Color.RESET + this.port + (this.enforceEncryption ? Color.GRAY + ", nur verschlüsselt" : ""),
x + 2, y + height - Font.YGLYPH * 2, 0xffb0b0b0);
x + 2, y + height - Font.HEIGHT * 2, 0xffb0b0b0);
if(!this.access.isEmpty())
Drawing.drawTextRight((this.keypair != null || !this.password.isEmpty() ? "+ " : "") + "Server-Passwort", x + width - 2, y + height - Font.YGLYPH * 2, 0xffb0b0b0);
Drawing.drawText("Zuletzt verbunden: " + (this.lastConnected == -1L ? "nie" : DATE_FORMAT.format(new Date(this.lastConnected))), x + 2, y + height - Font.YGLYPH, 0xffb0b0b0);
Drawing.drawTextRight((this.keypair != null || !this.password.isEmpty() ? "+ " : "") + "Server-Passwort", x + width - 2, y + height - Font.HEIGHT * 2, 0xffb0b0b0);
Drawing.drawText("Zuletzt verbunden: " + (this.lastConnected == -1L ? "nie" : DATE_FORMAT.format(new Date(this.lastConnected))), x + 2, y + height - Font.HEIGHT, 0xffb0b0b0);
if(this.serverDigest != null)
Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + width - 2, y + height - Font.YGLYPH, 0xffb0b0b0);
Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + width - 2, y + height - Font.HEIGHT, 0xffb0b0b0);
}
}

View file

@ -88,7 +88,7 @@ public class GuiMenu extends Gui {
for(int z = 0; z < 64; z++) {
Drawing.drawText("Hax!", GuiMenu.this.rand.zrange(Math.max(1, this.gm.fbX - width)) +
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + this.gm.getTickFraction()) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
GuiMenu.this.rand.zrange(Math.max(1, this.gm.fbY - Font.YGLYPH)) +
GuiMenu.this.rand.zrange(Math.max(1, this.gm.fbY - Font.HEIGHT)) +
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + this.gm.getTickFraction()) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
0xff0000ff | (GuiMenu.this.rand.zrange(256) << 16));
}

View file

@ -116,7 +116,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ?
0xffffff : this.charinfo.color1 | this.charinfo.color2));
if(this.charinfo != null)
Drawing.drawTextRight(this.charinfo.skin, x + width - 2, y + height - Font.YGLYPH, 0xffc0c0c0);
Drawing.drawTextRight(this.charinfo.skin, x + width - 2, y + height - Font.HEIGHT, 0xffc0c0c0);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -41,7 +41,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
String.format(Color.NEON + "%s " + Color.GRAY + "bei " + Color.ACID + "%d" + Color.GRAY + ", " + Color.ACID + "%d" + Color.GRAY + ", " + Color.ACID + "%d",
character.dim(), character.pos().getX(), character.pos().getY(), character.pos().getZ());
Drawing.drawText(str, x + 3, y, 0xffffffff);
Drawing.drawText(pos, x + 3, y + height - Font.YGLYPH, 0xffffffff);
Drawing.drawText(pos, x + 3, y + height - Font.HEIGHT, 0xffffffff);
}
public void select(boolean dclick, int mx, int my)

View file

@ -16,6 +16,8 @@ import client.gui.Gui;
import client.gui.element.ActButton;
import client.gui.element.ButtonCallback;
import client.gui.element.Field;
import client.gui.element.FontLabel;
import client.gui.element.FontMultiLabel;
import client.gui.element.InventoryButton;
import client.gui.element.Label;
import client.gui.element.MultiLabel;
@ -197,7 +199,7 @@ public abstract class GuiContainer extends Gui
public Label label(String text, int x, int y) {
x = x * this.container_scale + this.container_x;
y = y * this.container_scale + this.container_y;
return this.add(new Label(x, y, 300, 0, text, true));
return this.add(new FontLabel(x, y + 10 * this.container_scale, 300, this.container_scale > 1 ? Font.MEDIUM : Font.SMALL, text, true));
}
public void rect(int x, int y, int width, int height, int color) {
@ -209,7 +211,7 @@ public abstract class GuiContainer extends Gui
}
public InventoryButton slot(int x, int y, int w, int h) {
return this.add(new InventoryButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale));
return this.add(new InventoryButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale, this.container_scale > 1));
}
public ActButton button(int x, int y, int w, int h, ButtonCallback callback, String text) {
@ -279,12 +281,12 @@ public abstract class GuiContainer extends Gui
}
}
if(this.gm.itemCheat) {
this.cheatLabel = this.add(new Label(this.cheatX, this.cheatY, this.cheatWidth * 18, "", true));
this.cheatDesc = this.add(new MultiLabel(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4 + 18, this.cheatWidth * 18, 60, "Vorsicht: Schummeln\nwird mit Keule bestraft!!\n(Halte Strg beim Klick\nfür vollen Stapel)"));
this.cheatLabel = this.add(new FontLabel(this.cheatX, this.cheatY, this.cheatWidth * 18, Font.SMALL, "", true));
this.cheatDesc = this.add(new FontMultiLabel(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4 + 18, this.cheatWidth * 18, 60, Font.SMALL, "Vorsicht: Schummeln\nwird mit Keule bestraft!!\n(Halte Strg beim Klick\nfür vollen Stapel)"));
this.cheatSearch = this.add(new Field(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4, this.cheatWidth * 18, 0, 128, null, ""));
this.cheatLast = "";
for(CheatTab tab : CheatTab.values()) {
this.add(new InventoryButton(this.cheatX + 18 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18));
this.add(new InventoryButton(this.cheatX + 18 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18, false));
}
this.setCurrentTab(selectedTab);
}
@ -882,7 +884,9 @@ public abstract class GuiContainer extends Gui
{
s = Color.RED + formatAmount(stack.getSize());
}
Drawing.drawTextRight(s, xPosition + scale * 16, yPosition + scale * 16 + 1 - Font.YGLYPH, 0xffffffff);
Font.set(scale > 1 ? Font.SMALL : Font.TINY);
Drawing.drawTextRight(s, xPosition + scale * 16, yPosition + scale * 16 + 1 - Font.HEIGHT, 0xffffffff);
Font.unset();
}
if (stack.isItemDamaged())

View file

@ -39,10 +39,10 @@ public class Area extends Textbox {
public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) {
if(scr_y != 0) {
int limit = Font.YGLYPH + this.textHeight - (this.size_y - (this.margin_y1 + this.margin_y2));
int limit = Font.HEIGHT + this.textHeight - (this.size_y - (this.margin_y1 + this.margin_y2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
int prev = this.text_y;
this.text_y += (scr_y < 0 ? -1 : 1) * (ctrl ? 1 : Font.YGLYPH) * this.gm.scrollLines * (shift ? 10 : 1);
this.text_y += (scr_y < 0 ? -1 : 1) * (ctrl ? 1 : Font.HEIGHT) * this.gm.scrollLines * (shift ? 10 : 1);
this.text_y = ExtMath.clampi(this.text_y, -limit, 0);
if(this.sel_start >= 0)
this.cursorY += (this.text_y - prev);
@ -101,7 +101,7 @@ public class Area extends Textbox {
}
protected void gui_text_clamp_scroll() {
int limit = Font.YGLYPH + this.textHeight - (this.size_y - (this.margin_y1 + this.margin_y2));
int limit = Font.HEIGHT + this.textHeight - (this.size_y - (this.margin_y1 + this.margin_y2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
this.text_y = ExtMath.clampi(this.text_y, -limit, 0);
}
@ -114,8 +114,8 @@ public class Area extends Textbox {
if(shift) {
if(this.cursorY < y1)
this.text_y += y1 - this.cursorY;
else if((this.cursorY + Font.YGLYPH) >= (y1 + y2))
this.text_y -= (this.cursorY + Font.YGLYPH) - (y1 + y2);
else if((this.cursorY + Font.HEIGHT) >= (y1 + y2))
this.text_y -= (this.cursorY + Font.HEIGHT) - (y1 + y2);
gui_text_update_cur(offset, false);
}
}

View file

@ -12,7 +12,7 @@ import common.util.Util;
public class Dropdown<T> extends Element {
public class Handle extends Element {
private Handle(boolean up) {
super(Dropdown.this.pos_x, Dropdown.this.pos_y + (up ? -(Font.YGLYPH * Dropdown.this.values.length + 2) : Dropdown.this.size_y), Dropdown.this.size_x, Font.YGLYPH * Dropdown.this.values.length + 2, null);
super(Dropdown.this.pos_x, Dropdown.this.pos_y + (up ? -(Font.HEIGHT * Dropdown.this.values.length + 2) : Dropdown.this.size_y), Dropdown.this.size_x, Font.HEIGHT * Dropdown.this.values.length + 2, null);
StringBuilder sb = new StringBuilder();
for(T value : Dropdown.this.values) {
if(sb.length() > 0)

View file

@ -15,7 +15,7 @@ public class Field extends Textbox {
private Field(int x, int y, int w, int h, int cap, boolean editable, FieldCallback callback, CharValidator validator, String text) {
super(x, y, w, h, cap, editable, callback, validator);
this.text_y = (this.size_y - (this.margin_y1 + this.margin_y2 + Font.YGLYPH)) / 2;
this.text_y = (this.size_y - (this.margin_y1 + this.margin_y2 + Font.HEIGHT)) / 2;
this.setText(text);
}
@ -69,10 +69,10 @@ public class Field extends Textbox {
public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) {
if(scr_y != 0 || scr_x != 0) {
int limit = Font.XGLYPH + this.textWidth - (this.size_x - (this.margin_x1 + this.margin_x2));
int limit = Font.WIDTH + this.textWidth - (this.size_x - (this.margin_x1 + this.margin_x2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
int prev = this.text_x;
this.text_x += ((scr_y != 0 ? scr_y : (-scr_x)) < 0 ? -1 : 1) * (ctrl ? 1 : Font.XGLYPH) * this.gm.scrollLines * (shift ? 10 : 1);
this.text_x += ((scr_y != 0 ? scr_y : (-scr_x)) < 0 ? -1 : 1) * (ctrl ? 1 : Font.WIDTH) * this.gm.scrollLines * (shift ? 10 : 1);
this.text_x = ExtMath.clampi(this.text_x, -limit, 0);
if(this.sel_start >= 0)
this.cursorPos += (this.text_x - prev);
@ -84,11 +84,11 @@ public class Field extends Textbox {
}
protected int getCursorY(int y1, int y2) {
return y1 + (y2 - Font.YGLYPH) / 2;
return y1 + (y2 - Font.HEIGHT) / 2;
}
protected void gui_text_clamp_scroll() {
int limit = Font.XGLYPH + this.textWidth - (this.size_x - (this.margin_x1 + this.margin_x2));
int limit = Font.WIDTH + this.textWidth - (this.size_x - (this.margin_x1 + this.margin_x2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
this.text_x = ExtMath.clampi(this.text_x, -limit, 0);
}
@ -100,8 +100,8 @@ public class Field extends Textbox {
if(shift) {
if(this.cursorPos < x1)
this.text_x += x1 - this.cursorPos;
else if((this.cursorPos + Font.XGLYPH) >= (x1 + x2))
this.text_x -= (this.cursorPos + Font.XGLYPH) - (x1 + x2);
else if((this.cursorPos + Font.WIDTH) >= (x1 + x2))
this.text_x -= (this.cursorPos + Font.WIDTH) - (x1 + x2);
gui_text_update_cur(offset, false);
}
}

View file

@ -0,0 +1,23 @@
package client.gui.element;
import client.gui.Font;
public class FontLabel extends Label {
private final Font font;
public FontLabel(int x, int y, int w, int h, Font font, String text, boolean left) {
super(x, y, w, h <= 0 ? font.getHeight() : h, text, left);
this.font = font;
}
public FontLabel(int x, int y, int w, Font font, String text, boolean left) {
super(x, y - font.getHeight(), w, font.getHeight(), text, left);
this.font = font;
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
Font.set(this.font);
super.drawForeground(x1, y1, x2, y2);
Font.unset();
}
}

View file

@ -0,0 +1,18 @@
package client.gui.element;
import client.gui.Font;
public class FontMultiLabel extends MultiLabel {
private final Font font;
public FontMultiLabel(int x, int y, int w, int h, Font font, String text) {
super(x, y, w, h, text);
this.font = font;
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
Font.set(this.font);
super.drawForeground(x1, y1, x2, y2);
Font.unset();
}
}

View file

@ -3,15 +3,24 @@ package client.gui.element;
import client.renderer.Drawing;
public class InventoryButton extends Element {
public InventoryButton(int x, int y, int w, int h) {
private final boolean bordered;
public InventoryButton(int x, int y, int w, int h, boolean bordered) {
super(x, y, w, h, null);
this.bordered = bordered;
}
protected void drawBackground() {
// Drawing.drawRect2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff6f6f6f, 0xffafafaf);
Drawing.drawRectBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff6f6f6f, 0xff000000, 0xffafafaf, 0xff4f4f4f);
drawButton(this.pos_x, this.pos_y, this.size_x, this.size_y, this.bordered);
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
}
public static void drawButton(int x, int y, int w, int h, boolean border) {
if(border)
Drawing.drawDoubleRect(x, y, w, h, 0xff6f6f6f, 0xffcfcfcf, 0xff2f2f2f);
else
Drawing.drawRect(x, y, w, h, 0xff6f6f6f, 0xffcfcfcf, 0xff2f2f2f);
}
}

View file

@ -26,7 +26,7 @@ public class MultiLabel extends Fill {
protected void drawForeground(int x1, int y1, int x2, int y2) {
int color = this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f);
for(int z = 0; z < this.lines.length; z++) {
Drawing.drawTextCentered(this.lines[z], x1 + x2 / 2, y1 + this.text_y + z * Font.YGLYPH, color);
Drawing.drawTextCentered(this.lines[z], x1 + x2 / 2, y1 + this.text_y + z * Font.HEIGHT, color);
}
}

View file

@ -243,7 +243,7 @@ abstract class Textbox extends Element {
int y2 = this.size_y - (this.margin_y1 + this.margin_y2);
this.gm.scissor(x1 < 0 ? 0 : x1, (this.gm.fbY - (y1 + y2)) < 0 ? 0 : (this.gm.fbY - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
Drawing.drawRect(this.getCursorX(x1, x2), this.getCursorY(y1, y2), 1, Font.YGLYPH, 0xff000000 | (~Util.mixColor(this.gm.style.field_top, this.gm.style.field_btm)));
Drawing.drawRect(this.getCursorX(x1, x2), this.getCursorY(y1, y2), 1, Font.HEIGHT, 0xff000000 | (~Util.mixColor(this.gm.style.field_top, this.gm.style.field_btm)));
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
}

View file

@ -34,7 +34,7 @@ public class GuiDisplay extends GuiOptions {
GuiDisplay.this.gm.full(value);
}
}, "Vollbild"));
int maxModes = ExtMath.clampi((height - ((3 * 20 + 2) * 2 + 18 + 4)) / Font.YGLYPH, 4, 28);
int maxModes = ExtMath.clampi((height - ((3 * 20 + 2) * 2 + 18 + 4)) / Font.HEIGHT, 4, 28);
DisplayMode[] dmodes = Window.getDisplayModes();
if(dmodes != null) {
List<DisplayMode> modes = Lists.newArrayList();

View file

@ -77,6 +77,7 @@ public class GuiStyle extends GuiOptions {
this.addSelector("gui_scale", 0, 3 * 34 + 20, 240, 0);
this.addSelector("gui_font", 242, 3 * 34 + 20, 240, 0);
this.addSelector("gui_scale_items", 0, 3 * 34 + 40, 240, 0);
this.addSelector("gui_scale_hotbar", 242, 3 * 34 + 40, 240, 0);
super.init(width, height);
}

View file

@ -39,7 +39,7 @@ public abstract class Drawing {
Font.bindTexture();
RenderBuffer rb = Tessellator.getBuffer();
rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
int h = Font.YGLYPH;
int h = Font.HEIGHT;
int tx, ty, u, v;
FontChar glyph;
char ch;
@ -75,7 +75,7 @@ public abstract class Drawing {
if(x < x1 || y < y1 || x > x2 || y > y2) {
break;
}
putGlyph(rb, Font.XGLYPH * 16, Font.YGLYPH * 16, x, y, (ch & 0x0f) * Font.XGLYPH + glyph.s, ((ch & 0xf0) >> 4) * Font.YGLYPH, glyph.u, h, ncolor, 0.0);
putGlyph(rb, Font.WIDTH * 16, Font.HEIGHT * 16, x, y, (ch & 0x0f) * Font.WIDTH + glyph.s, ((ch & 0xf0) >> 4) * Font.HEIGHT, glyph.u, h, ncolor, 0.0);
x += u;
}
Tessellator.draw();
@ -86,7 +86,7 @@ public abstract class Drawing {
}
public static void txt_overlay(int start, int end, int x, int y, int x1, int y1, int x2, int y2, int back, String str) {
int h = Font.YGLYPH;
int h = Font.HEIGHT;
int tx, ty, u, v;
FontChar glyph;
char ch;
@ -141,7 +141,7 @@ public abstract class Drawing {
}
public static Vec2i txt_size(int x, int y, int x1, int y1, int x2, int y2, String str) {
int h = Font.YGLYPH;
int h = Font.HEIGHT;
int ix = x;
int iy = y;
int tx, ty, u, v;
@ -179,7 +179,7 @@ public abstract class Drawing {
}
public static Vec2i txt_coord(int offset, int x, int y, int x1, int y1, int x2, int y2, String str) {
int h = Font.YGLYPH;
int h = Font.HEIGHT;
int tx, ty, u, v;
FontChar glyph;
char ch;
@ -223,7 +223,7 @@ public abstract class Drawing {
}
public static Offset txt_offset(int ox, int oy, int x, int y, int x1, int y1, int x2, int y2, String str) {
int h = Font.YGLYPH;
int h = Font.HEIGHT;
int tx, ty, u, v;
FontChar glyph;
char ch;
@ -311,7 +311,7 @@ public abstract class Drawing {
ch = str.charAt(z);
if(ch == Log.CHR_NLN) {
x = ox;
y += Font.YGLYPH;
y += Font.HEIGHT;
continue;
}
else if((ch >= Log.CHR_COLORS1 && ch <= Log.CHR_COLORE1) || (ch >= Log.CHR_COLORS2 && ch <= Log.CHR_COLORE2)) {
@ -329,7 +329,7 @@ public abstract class Drawing {
continue;
else if(glyph.u == 0)
glyph = Font.SIZES[Log.CHR_UNK];
putGlyph(rb, Font.XGLYPH * 16, Font.YGLYPH * 16, x + 1, y + 1, (ch & 0x0f) * Font.XGLYPH + glyph.s, ((ch & 0xf0) >> 4) * Font.YGLYPH, glyph.u, Font.YGLYPH, bcolor, -0.01);
putGlyph(rb, Font.WIDTH * 16, Font.HEIGHT * 16, x + 1, y + 1, (ch & 0x0f) * Font.WIDTH + glyph.s, ((ch & 0xf0) >> 4) * Font.HEIGHT, glyph.u, Font.HEIGHT, bcolor, -0.01);
x += glyph.u + 3 - glyph.s;
}
x = ox;
@ -339,7 +339,7 @@ public abstract class Drawing {
ch = str.charAt(z);
if(ch == Log.CHR_NLN) {
x = ox;
y += Font.YGLYPH;
y += Font.HEIGHT;
continue;
}
else if((ch >= Log.CHR_COLORS1 && ch <= Log.CHR_COLORE1) || (ch >= Log.CHR_COLORS2 && ch <= Log.CHR_COLORE2)) {
@ -357,7 +357,7 @@ public abstract class Drawing {
continue;
else if(glyph.u == 0)
glyph = Font.SIZES[Log.CHR_UNK];
putGlyph(rb, Font.XGLYPH * 16, Font.YGLYPH * 16, x, y, (ch & 0x0f) * Font.XGLYPH + glyph.s, ((ch & 0xf0) >> 4) * Font.YGLYPH, glyph.u, Font.YGLYPH, ncolor, -0.02);
putGlyph(rb, Font.WIDTH * 16, Font.HEIGHT * 16, x, y, (ch & 0x0f) * Font.WIDTH + glyph.s, ((ch & 0xf0) >> 4) * Font.HEIGHT, glyph.u, Font.HEIGHT, ncolor, -0.02);
x += glyph.u + 3 - glyph.s;
}
Tessellator.draw();
@ -378,7 +378,7 @@ public abstract class Drawing {
if(ch == Log.CHR_NLN) {
ix = x > ix ? x : ix;
x = 0;
y += Font.YGLYPH;
y += Font.HEIGHT;
continue;
}
else if(ch < Log.CHR_SPC) {
@ -394,7 +394,7 @@ public abstract class Drawing {
x += glyph.u + 3 - glyph.s;
ix = x > ix ? x : ix;
}
return new Vec2i(ix - 3, y + Font.YGLYPH);
return new Vec2i(ix - 3, y + Font.HEIGHT);
}
@ -495,6 +495,17 @@ public abstract class Drawing {
drawRect(x + 1, y + 1, w - 2, h - 2, color);
}
public static void drawDoubleRect(int x, int y, int w, int h, int color, int topleft, int btmright) {
int corner = Util.mixColor(topleft, btmright);
drawRect(x, y, w - 2, 2, topleft);
drawRect(x, y + 2, 2, h - 2, topleft);
drawRect(x + w - 2, y, 2, 2, corner);
drawRect(x, y + h - 2, 2, 2, corner);
drawRect(x + w - 2, y + 2, 2, h - 2, btmright);
drawRect(x + 2, y + h - 2, w - 4, 2, btmright);
drawRect(x + 2, y + 2, w - 4, h - 4, color);
}
public static void drawGradient(int x, int y, int w, int h, int top, int bottom, int topleft, int btmright) {
int corner = Util.mixColor(topleft, btmright);
drawRect(x, y, w - 1, 1, topleft);

View file

@ -4,7 +4,6 @@ import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.model.Model;