ui scale fix

This commit is contained in:
Sen 2025-06-13 00:02:32 +02:00
parent 17bb2e57ab
commit 58163db658
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
8 changed files with 75 additions and 48 deletions

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 + TextColor.GRAY + " Port " + TextColor.RESET + this.port + (this.enforceEncryption ? TextColor.GRAY + ", nur verschlüsselt" : ""),
x + 2, y + 18, 0xffb0b0b0);
x + 2, y + height - Font.YGLYPH * 2, 0xffb0b0b0);
if(!this.access.isEmpty())
Drawing.drawTextRight((this.keypair != null || !this.password.isEmpty() ? "+ " : "") + "Server-Passwort", x + width - 2, y + 18, 0xffb0b0b0);
Drawing.drawText("Zuletzt verbunden: " + (this.lastConnected == -1L ? "nie" : DATE_FORMAT.format(new Date(this.lastConnected))), x + 2, y + 18 + 16, 0xffb0b0b0);
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);
if(this.serverDigest != null)
Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + width - 2, y + 18 + 16, 0xffb0b0b0);
Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + width - 2, y + height - Font.YGLYPH, 0xffb0b0b0);
}
}
@ -264,12 +264,12 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
}
}
this.add(this.selectButton = new ActButton(width / 2 - 383, height - 28, 150, 0, this, "Verbinden"));
this.add(this.createButton = new ActButton(width - 204, 4, 200, 0, this, "Server hinzufügen ..."));
this.add(this.deleteButton = new ActButton(width / 2 - 75, height - 28, 150, 0, this, "Löschen"));
this.add(this.editButton = new ActButton(width / 2 + 79, height - 28, 150, 0, this, "Bearbeiten"));
this.add(this.copyButton = new ActButton(width / 2 - 229, height - 28, 150, 0, this, "Kopieren"));
this.add(new NavButton(width / 2 + 233, height - 28, 150, 0, GuiMenu.INSTANCE, "Abbrechen"));
this.add(this.selectButton = new ActButton(width / 2 - 379, height - 30, 150, 0, this, "Verbinden"));
this.add(this.createButton = new ActButton(width - 202, 12, 200, 0, this, "Server hinzufügen ..."));
this.add(this.deleteButton = new ActButton(width / 2 - 75, height - 30, 150, 0, this, "Löschen"));
this.add(this.editButton = new ActButton(width / 2 + 77, height - 30, 150, 0, this, "Bearbeiten"));
this.add(this.copyButton = new ActButton(width / 2 - 227, height - 30, 150, 0, this, "Kopieren"));
this.add(new NavButton(width / 2 + 229, height - 30, 150, 0, GuiMenu.INSTANCE, "Abbrechen"));
this.selectButton.enabled = false;
this.deleteButton.enabled = false;

View file

@ -17,6 +17,7 @@ import org.lwjgl.opengl.GL13;
import client.Client;
import client.Client.FileMode;
import client.gui.FileCallback;
import client.gui.Font;
import client.gui.GuiLoading;
import client.gui.element.ActButton;
import client.gui.element.Element;
@ -113,7 +114,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.drawText(this.charinfo.skin, x + 64 + 3, y + 18, 0xffc0c0c0);
Drawing.drawTextRight(this.charinfo.skin, x + width - 2, y + height - Font.YGLYPH, 0xffc0c0c0);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
@ -253,6 +254,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
private DragAdjust adjust;
private ActButton dimButton;
private MultiLabel descLines;
private ActButton cancelButton;
private float yaw = -15.0f;
private float pitch = -15.0f;
private boolean waiting = true;
@ -269,7 +271,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
{
super.init(width, height);
this.waiting = true;
this.setDimensions(400, height, 32, height - 32);
this.setDimensions(390, height, 32, height - 32);
if(this.gm.getRenderManager().gm == null) {
this.unload();
this.adjust = null;
@ -277,7 +279,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}
this.currentSkin = this.gm.player != null && !EntityTexManager.hasCustomSkin(this.gm.player.getId()) ? this.gm.player.getChar() : null;
this.load(this.gm.player == null ? ModelType.HUMANOID : this.gm.player.getModel(), this.gm.player != null ? this.gm.player.getSpecies() : SpeciesRegistry.CLASSES.get(EntityHuman.class));
this.add(new ActButton(4, 4, 194, 0, new ButtonCallback() {
this.add(new ActButton(2, 12, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() {
public void selected(File file) {
@ -287,7 +289,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
});
}
}, "Importieren: Standard"));
this.add(new ActButton(202, 4, 194, 0, new ButtonCallback() {
this.add(new ActButton(197, 12, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() {
public void selected(File file) {
@ -297,13 +299,13 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
});
}
}, "Importieren: Schlank"));
this.addSelector("char_filter_species", 400, 4, 300, 0);
this.add(new ActButton(4, height - 28, 194, 0, new ButtonCallback() {
this.addSelector("char_filter_species", 392, 12, 250, 0);
this.add(new ActButton(2, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
}
}, "Neu laden"));
this.templateButton = this.add(new ActButton(202, height - 28, 194, 0, new ButtonCallback() {
this.templateButton = this.add(new ActButton(197, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
SkinEntry skin = GuiChar.this.getSelected();
if(skin != null && skin.getLocation() != null) {
@ -337,20 +339,23 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}
}
}, "Vorlage kopieren"));
if(width >= 784 + 460 && height >= 128 + 640)
this.adjust = this.add(new DragAdjust(width / 2 - 230, height - 64 - 640, 460, 640));
else
this.adjust = this.add(new DragAdjust(390 - 115 - 4, height - 32 - 160 - 4, 115, 160));
this.add(new Label(width - 396, 56, 392, "Spezies: " + (this.gm.player == null ? "<?>" : this.gm.player.getSpecies().name), true));
this.add(new NavButton(width - 396, 56, 392, 0, GuiSpecies.INSTANCE, "Spezies ändern"));
this.add(new Label(width - 396, 56 + 92, 392, "Klasse: " + (this.gm.player == null || this.gm.player.getSpecies().classEnum == null || this.gm.player.getNpcClass() == null || this.gm.player.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.player.getNpcClass().toString()), true))
this.add(new Label(width - 390, 48, 388, "Spezies: " + (this.gm.player == null ? "<?>" : this.gm.player.getSpecies().name), true));
this.add(new NavButton(width - 390, 48, 388, 0, GuiSpecies.INSTANCE, "Spezies ändern"));
this.add(new Label(width - 390, 82, 388, "Klasse: " + (this.gm.player == null || this.gm.player.getSpecies().classEnum == null || this.gm.player.getNpcClass() == null || this.gm.player.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.player.getNpcClass().toString()), true))
.enabled = this.gm.player != null && this.gm.player.getSpecies().classEnum != null;
this.add(new NavButton(width - 396, 56 + 92, 392, 0, GuiClass.INSTANCE, "Klasse ändern"))
this.add(new NavButton(width - 390, 82, 388, 0, GuiClass.INSTANCE, "Klasse ändern"))
.enabled = this.gm.player != null && this.gm.player.getSpecies().classEnum != null;
final ActButton[] alignBtns = new ActButton[Alignment.values().length];
for (int z = 0; z < Alignment.values().length; z++)
{
final Alignment align = Alignment.values()[z];
alignBtns[z] = this.add(new ActButton(width - 396 + (z % 3) * 132, height - 32 - 28 * 3 + 28 * (z / 3), 128, 0, new ButtonCallback() {
alignBtns[z] = this.add(new ActButton(width - 390 + (z % 3) * 130, height - 32 - 20 * 3 + 20 * (z / 3), 128, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false;
@ -363,7 +368,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}, align.color + align.display));
alignBtns[z].enabled = this.gm.player == null || this.gm.player.getAlignment() != align;
}
this.add(new Slider(width / 2 - 200, height - 28, 400, 0, 1, this.gm.player == null ? 120 : this.gm.player.getMinSize(), this.gm.player == null ? 320 : this.gm.player.getMaxSize(), this.gm.player == null ? 180 : this.gm.player.getDefaultSize(), this.gm.player == null ? 180 : this.gm.player.getCurrentSize(), new SliderCallback() {
this.add(new Slider(width - 390, 136, 388, 0, 1, this.gm.player == null ? 120 : this.gm.player.getMinSize(), this.gm.player == null ? 320 : this.gm.player.getMaxSize(), this.gm.player == null ? 180 : this.gm.player.getDefaultSize(), this.gm.player == null ? 180 : this.gm.player.getCurrentSize(), new SliderCallback() {
public void use(Slider elem, int value) {
if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false;
@ -371,10 +376,10 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}
}
}, "Spieler-Größe", "cm")).enabled = this.gm.player == null || this.gm.player.getMinSize() != this.gm.player.getMaxSize();
this.add(new Label(width / 2 - 200, 36 + 20, 400, "Name", true));
this.add(new Label(width - 396, height - 364, 392, "Beschreibung", true));
final Area descField = this.add(new Area(width - 396, height - 364, 392, 130, IPlayer.MAX_INFO_LENGTH, ""));
this.add(new ActButton(width - 198, height - 28, 194, 0, new ButtonCallback() {
this.add(new Label(width - 390, 116, 388, "Name", true));
this.add(new Label(width - 390, 170, 388, "Beschreibung", true));
final Area descField = this.add(new Area(width - 390, 170, 388, height - 328, IPlayer.MAX_INFO_LENGTH, ""));
this.add(new ActButton(width - 195, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiChar.this.gm.player != null) {
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ..."));
@ -384,7 +389,16 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}
}
}, "Charakter erstellen"));
this.add(new Field(width / 2 - 200, 36 + 20, 400, 0, IPlayer.MAX_NICK_LENGTH, new FieldCallback() {
this.cancelButton = this.add(new ActButton(width - 390, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiChar.this.gm.player != null) {
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ..."));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CANCEL_EDITOR));
}
}
}, "Abbrechen"));
this.setCharsAvailable();
this.add(new Field(width - 390, 116, 388, 0, IPlayer.MAX_NICK_LENGTH, new FieldCallback() {
public void use(Field elem, FieldAction value) {
if(value == FieldAction.SEND || value == FieldAction.UNFOCUS) {
String name = elem.getText();
@ -411,7 +425,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}
}
}
this.dimButton = this.add(new ActButton(width - 396, height - 220, 392, 0, new ButtonCallback() {
this.dimButton = this.add(new ActButton(width - 390, height - 156, 388, 0, new ButtonCallback() {
public void use(ActButton elem, PressType mode) {
if(mode == PressType.TERTIARY) {
GuiChar.this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
@ -427,7 +441,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
GuiChar.this.setDimButton();
}
}, ""));
this.descLines = this.add(new MultiLabel(width - 396, height - 220 + Element.BASE_HEIGHT, 392, 66, "", true));
this.descLines = this.add(new MultiLabel(width - 390, height - 156 + Element.BASE_HEIGHT, 388, 42, "", true));
this.setDimButton();
}
@ -449,8 +463,10 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
if(this.adjust != null) {
float factor = this.gm.player.width > 2.15f ? 2.15f / this.gm.player.width : 1.0f;
factor = this.gm.player.height > 3.0f && 3.0f / this.gm.player.height < factor ? 3.0f / this.gm.player.height : factor;
drawEntity(400 + (this.gm.fb_x - 400 - 400) / 2, this.gm.fb_y - 160, 160.0f * factor
, this.yaw, this.pitch, this.gm.player);
if(this.gm.fb_x >= 784 + 460 && this.gm.fb_y >= 128 + 640)
drawEntity(400 + (this.gm.fb_x - 400 - 400) / 2, this.gm.fb_y - 160, 160.0f * factor, this.yaw, this.pitch, this.gm.player);
else
drawEntity(390 - 4 - 115 / 2, this.gm.fb_y - 60, 40.0f * factor, this.yaw, this.pitch, this.gm.player);
}
}
@ -470,6 +486,11 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
return "Charakter anpassen";
}
public void setCharsAvailable() {
if(this.cancelButton != null)
this.cancelButton.enabled = !this.gm.characterList.isEmpty();
}
public static BufferedImage loadSkin(File file)
{
BufferedImage img = null;

View file

@ -1,5 +1,6 @@
package client.gui.character;
import client.gui.Font;
import client.gui.GuiConfirm;
import client.gui.GuiMenu;
import client.gui.element.ActButton;
@ -33,13 +34,13 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
if(this.initial)
Drawing.drawRect(x, y, 1, 36, 0xffaf0000);
String str = this.character == null ? TextColor.BLUE + "[" + TextColor.CYAN + "+" + TextColor.BLUE + "]" :
String.format(TextColor.GREEN + "Level " + TextColor.DGREEN + "%d " + TextColor.YELLOW + "%s " + TextColor.VIOLET + "%s" + TextColor.GRAY + " [%s%s" + TextColor.GRAY + "]",
character.level(), character.type(), character.name(), character.align().color, character.align().display);
String.format(TextColor.GREEN + "Level " + TextColor.DGREEN + "%d " + TextColor.YELLOW + "%s " + TextColor.VIOLET + "%s",
character.level(), character.type(), character.name());
String pos = this.character == null ? TextColor.BROWN + "Neuen Charakter erstellen" :
String.format(TextColor.NEON + "%s " + TextColor.GRAY + "bei " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.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 + 16, 0xffffffff);
Drawing.drawText(pos, x + 3, y + height - Font.YGLYPH, 0xffffffff);
}
public void select(boolean dclick, int mx, int my)
@ -61,7 +62,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
private void updateButtons() {
CharacterEntry entry = this.getSelected();
this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : (entry.character.info() == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info())));
this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : String.format(TextColor.GRAY + "[%s%s" + TextColor.GRAY + "]\n" + TextColor.RESET + "%s", entry.character.align().color, entry.character.align().display, entry.character.info() == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info())));
this.actionButtom.setText(entry != null && entry.character == null ? "Charakter erstellen" : "Charakter spielen");
this.actionButtom.enabled = entry != null && !entry.initial;
this.deleteButtom.enabled = entry != null && entry.character != null && !entry.initial;
@ -79,9 +80,9 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
this.elements.add(new CharacterEntry(null, false));
this.setSelected(ExtMath.clampi(selected, -1, this.elements.size() - 1));
this.descField = this.add(new Area(width - 300, 32, 300, height - 64, ""));
this.deleteButtom = this.add(new ActButton(width / 2 - 304, height - 28, 200, 0, this, "Charakter löschen"));
this.actionButtom = this.add(new ActButton(width / 2 - 100, height - 28, 200, 0, this, ""));
this.add(new NavButton(width / 2 + 104, height - 28, 200, 0, GuiMenu.INSTANCE, "Abbrechen"));
this.deleteButtom = this.add(new ActButton(width / 2 - 302, height - 30, 200, 0, this, "Charakter löschen"));
this.actionButtom = this.add(new ActButton(width / 2 - 100, height - 30, 200, 0, this, ""));
this.add(new NavButton(width / 2 + 102, height - 30, 200, 0, GuiMenu.INSTANCE, "Abbrechen"));
this.updateButtons();
}

View file

@ -50,8 +50,8 @@ public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ButtonCall
for(Enum clazz : this.gm.player.getSpecies().classEnum.getEnumConstants()) {
this.elements.add(new ClassEntry(clazz));
}
this.add(new NavButton(width - 198 * 2, height - 28, 194, 0, GuiChar.INSTANCE, "Zurück"));
this.selectButton = this.add(new ActButton(width - 198, height - 28, 194, 0, this, "Klasse ändern"));
this.add(new NavButton(width / 2 - 195, height - 30, 194, 0, GuiChar.INSTANCE, "Zurück"));
this.selectButton = this.add(new ActButton(width / 2 + 1, height - 30, 194, 0, this, "Klasse ändern"));
}
public String getTitle() {

View file

@ -54,8 +54,8 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements Butt
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
this.elements.add(new SpeciesEntry(species));
}
this.add(new NavButton(width - 198 * 2, height - 28, 194, 0, GuiChar.INSTANCE, "Zurück"));
this.selectButton = this.add(new ActButton(width - 198, height - 28, 194, 0, this, "Spezies ändern"));
this.add(new NavButton(width / 2 - 195, height - 30, 194, 0, GuiChar.INSTANCE, "Zurück"));
this.selectButton = this.add(new ActButton(width / 2 + 1, height - 30, 194, 0, this, "Spezies ändern"));
}
public String getTitle() {

View file

@ -139,6 +139,7 @@ public abstract class GuiList<T extends ListEntry> extends Gui
int y = this.top + 4 - (int)this.amountScrolled;
int size = this.getSize();
boolean canHover = this.clicked(mouseXIn, mouseYIn) == null;
for (int z = 0; z < size; z++)
{
@ -147,8 +148,8 @@ public abstract class GuiList<T extends ListEntry> extends Gui
Drawing.drawRectBorder(x, y1 - 2, this.width - SCROLLBAR_WIDTH, this.getSlotHeight(), this.isSelected(z) ? this.gm.style.fill_btm : this.gm.style.fill_top, this.isSelected(z) ? 0xffffffff : 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm);
boolean hover = this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == z;
this.getListEntry(z).draw(x + 2, y1, this.width - SCROLLBAR_WIDTH - 4, this.getSlotHeight(), mouseXIn - x - 2, mouseYIn - y1, hover);
boolean hover = canHover && this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == z;
this.getListEntry(z).draw(x + 2, y1, this.width - SCROLLBAR_WIDTH - 4, this.getSlotHeight() - 4, mouseXIn - x - 2, mouseYIn - y1, hover);
if(hover)
Drawing.drawRect(x, y1 - 2, this.width - SCROLLBAR_WIDTH, this.getSlotHeight(), Gui.HOVER_COLOR);
}
@ -249,7 +250,7 @@ public abstract class GuiList<T extends ListEntry> extends Gui
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift)
{
super.mouse(btn, x, y, ctrl, shift);
if (this.isMouseYWithinSlotBounds(y))
if (this.isMouseYWithinSlotBounds(y) && this.clicked(x, y) == null)
{
int i = this.getSlotIndexFromScreenCoords(x, y);
@ -285,7 +286,7 @@ public abstract class GuiList<T extends ListEntry> extends Gui
public void drag(int x, int y) {
super.drag(x, y);
if(this.selected == null && Button.MOUSE_LEFT.isDown())
if(this.selected == null && Button.MOUSE_LEFT.isDown() && (this.initialClickY != -1 || this.clicked(x, y) == null))
this.handleMouseInput();
}
}

View file

@ -1634,6 +1634,9 @@ public class ClientPlayer implements IClientPlayer
else if(this.gm.open instanceof GuiCharacters) {
this.gm.displayGuiScreen(this.gm.open);
}
else if(this.gm.open instanceof GuiChar guichar) {
guichar.setCharsAvailable();
}
}
public void handleKeepAlive(SPacketKeepAlive packetIn)

View file

@ -57,6 +57,7 @@ public class CPacketAction implements Packet<IPlayer>
{
OPEN_EDITOR,
CLOSE_EDITOR,
CANCEL_EDITOR,
SELECT_CHARACTER,
DELETE_CHARACTER,
SWING_ARM,