1
0
Fork 0

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) {