From 48918f01392f6c7a62db18e83610a3ea1b5180e1 Mon Sep 17 00:00:00 2001 From: Sen Date: Thu, 12 Jun 2025 19:27:41 +0200 Subject: [PATCH] add various ui improvements --- client/src/main/java/client/Client.java | 6 +- client/src/main/java/client/gui/Gui.java | 4 +- .../src/main/java/client/gui/GuiConfirm.java | 19 +- .../src/main/java/client/gui/GuiConnect.java | 12 +- client/src/main/java/client/gui/GuiInfo.java | 23 +- client/src/main/java/client/gui/GuiMenu.java | 22 +- .../src/main/java/client/gui/GuiServer.java | 2 +- .../java/client/gui/character/GuiChar.java | 12 +- .../client/gui/character/GuiCharacters.java | 17 +- .../java/client/gui/character/GuiClass.java | 9 +- .../java/client/gui/character/GuiSpecies.java | 9 +- .../main/java/client/gui/element/GuiList.java | 232 +++++------------- .../java/client/gui/element/ListEntry.java | 2 +- .../java/client/gui/element/MultiLabel.java | 40 +++ .../client/network/ClientLoginHandler.java | 13 +- .../main/java/client/renderer/Drawing.java | 44 +++- .../main/resources/textures/background.png | Bin 975 -> 4881 bytes 17 files changed, 192 insertions(+), 274 deletions(-) create mode 100644 client/src/main/java/client/gui/element/MultiLabel.java diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index efafa55..d42f3cc 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1115,7 +1115,7 @@ public class Client implements IThreadListener { if(this.open != null) this.open.render(); else if(this.world == null || this.charEditor) - Drawing.drawScaled(this, Gui.DIRT_BACKGROUND); + Drawing.drawScaled(this, Gui.BACKGROUND); if(Bind.INFO.isDown() && (this.open == null || !(this.open.selected instanceof client.gui.element.Field || this.open.selected instanceof Area))) this.drawInfo(); if(this.hudOverlay && !(this.open instanceof GuiConsole)) { @@ -2351,7 +2351,7 @@ public class Client implements IThreadListener { public void disconnected(String msg) { Log.NETWORK.info("Getrennt: %s", msg); this.unload(true); - this.displayGuiScreen(new GuiInfo("Von Server getrennt", TextColor.RED + "Verbindung zum Server wurde getrennt\n\n" + TextColor.RESET + msg)); + this.displayGuiScreen(new GuiInfo("Von Server getrennt", TextColor.RED + "Verbindung zum Server wurde getrennt\n\n" + TextColor.RESET + msg, true)); } @@ -2560,7 +2560,7 @@ public class Client implements IThreadListener { public String apply(DebugFunction func) { return TextColor.CYAN + bind + TextColor.RED + "+" + TextColor.GREEN + func.key.getDisplay() + TextColor.GRAY + " - " + TextColor.YELLOW + func.help; } - }, Client.this.debug.values()))); + }, Client.this.debug.values()), true)); } }); this.registerDebug(Keysym.N, "NoClip umschalten", new DebugRunner() { diff --git a/client/src/main/java/client/gui/Gui.java b/client/src/main/java/client/gui/Gui.java index 871b64f..b8e4fbf 100644 --- a/client/src/main/java/client/gui/Gui.java +++ b/client/src/main/java/client/gui/Gui.java @@ -16,7 +16,7 @@ import client.window.Keysym; import common.collect.Lists; public abstract class Gui { - public static final String DIRT_BACKGROUND = "textures/background.png"; + public static final String BACKGROUND = "textures/background.png"; public static final int HOVER_COLOR = 0x288080ff; public static final int PRESS_COLOR = 0x30afafff; @@ -307,7 +307,7 @@ public abstract class Gui { Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010); } else { - Drawing.drawScaled(this.gm, DIRT_BACKGROUND); + Drawing.drawScaled(this.gm, BACKGROUND); } } diff --git a/client/src/main/java/client/gui/GuiConfirm.java b/client/src/main/java/client/gui/GuiConfirm.java index 8ab9cd5..1a266f2 100755 --- a/client/src/main/java/client/gui/GuiConfirm.java +++ b/client/src/main/java/client/gui/GuiConfirm.java @@ -3,19 +3,20 @@ package client.gui; import client.gui.element.ActButton; import client.gui.element.ButtonCallback; import client.gui.element.Label; +import client.gui.element.MultiLabel; import client.gui.element.PressType; -import client.gui.element.TransparentArea; public class GuiConfirm extends Gui implements ButtonCallback { public static interface Callback { void confirm(boolean confirmed); } - protected Callback callback; - protected String messageLine1; - private String messageLine2; - protected String confirmButtonText; - protected String cancelButtonText; + private final Callback callback; + private final String messageLine1; + private final String messageLine2; + private final String confirmButtonText; + private final String cancelButtonText; + private ActButton confirmBtn; private ActButton cancelBtn; @@ -29,9 +30,9 @@ public class GuiConfirm extends Gui implements ButtonCallback { public void init(int width, int height) { this.add(new Label(0, 0, 700, 0, this.messageLine1)); - this.add(new TransparentArea(0, 80, 700, 300, this.messageLine2, this.gm.world != null && !this.gm.charEditor)); - this.confirmBtn = this.add(new ActButton(100, 500, 245, 0, this, this.confirmButtonText)); - this.cancelBtn = this.add(new ActButton(355, 500, 245, 0, this, this.cancelButtonText)); + this.add(new MultiLabel(0, 80, 700, 300, this.messageLine2, true)); + this.confirmBtn = this.add(new ActButton(100, 450, 245, 0, this, this.confirmButtonText)); + this.cancelBtn = this.add(new ActButton(355, 450, 245, 0, this, this.cancelButtonText)); this.shift(); } diff --git a/client/src/main/java/client/gui/GuiConnect.java b/client/src/main/java/client/gui/GuiConnect.java index cd468b7..7b90b09 100644 --- a/client/src/main/java/client/gui/GuiConnect.java +++ b/client/src/main/java/client/gui/GuiConnect.java @@ -151,19 +151,19 @@ public class GuiConnect extends GuiList implements Button } } - public void draw(int x, int y, int mouseXIn, int mouseYIn, boolean hover) { + public void draw(int x, int y, int width, int height, int mouseXIn, int mouseYIn, boolean hover) { Drawing.drawText(this.name + TextColor.GRAY + " - " + TextColor.RESET + this.user, x + 2, y, 0xffffffff); if(this.keypair != null || !this.password.isEmpty()) Drawing.drawTextRight( (this.keypair != null ? "Pubkey " + this.keyDigest : "") + (this.keypair != null && !this.password.isEmpty() ? " + " : "") + (!this.password.isEmpty() ? "Passwort" : ""), - x + 660 - 4 - 2, y, 0xffffffff); + 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, 0xff808080); if(!this.access.isEmpty()) - Drawing.drawTextRight((this.keypair != null || !this.password.isEmpty() ? "+ " : "") + "Server-Passwort", x + 660 - 4 - 2, y + 18, 0xff808080); + Drawing.drawTextRight((this.keypair != null || !this.password.isEmpty() ? "+ " : "") + "Server-Passwort", x + width - 2, y + 18, 0xff808080); Drawing.drawText("Zuletzt verbunden: " + (this.lastConnected == -1L ? "nie" : DATE_FORMAT.format(new Date(this.lastConnected))), x + 2, y + 18 + 16, 0xff808080); if(this.serverDigest != null) - Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + 660 - 4 - 2, y + 18 + 16, 0xff808080); + Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + width - 2, y + 18 + 16, 0xff808080); } } @@ -340,10 +340,6 @@ public class GuiConnect extends GuiList implements Button public String getTitle() { return "Server auswählen"; } - - public int getListWidth() { - return 660; - } public int getSlotHeight() { return 56; diff --git a/client/src/main/java/client/gui/GuiInfo.java b/client/src/main/java/client/gui/GuiInfo.java index 402783c..f61d76c 100644 --- a/client/src/main/java/client/gui/GuiInfo.java +++ b/client/src/main/java/client/gui/GuiInfo.java @@ -2,6 +2,7 @@ package client.gui; import client.Client; import client.gui.element.Element; +import client.gui.element.MultiLabel; import client.gui.element.NavButton; import client.gui.element.TransparentArea; import common.Version; @@ -16,7 +17,7 @@ public class GuiInfo extends Gui { private static final String INFO = "Ein Spiel zur Simulation, zum Testen, für Rollenspiele, Mehrspieler und vieles mehr." + "\n" + "Optimiert für Geschwindigkeit, Stabilität und" + TextColor.UNKNOWN + "" + TextColor.UNKNOWN + " [Speicherzugriffsfehler]"; - private static final String HACKED = "Ein weiterer Release von WAAAAAAAAAAAAAAAAAAAAAAAAAAAAGHDRIVE!!!1!!!ONEoneOnetyone!1!!!" + "\n" + + private static final String HACKED = "Ein weiterer Release von WAAAAAAAAAAAAGHDRIVE!!!1!!!ONEoneOnetyone!1!!!" + "\n" + "Update 0.2 - Läuft jetzt auch mit nur 512KB Fast-RAM!"; private static final String[] LIBRARIES = { @@ -33,11 +34,12 @@ public class GuiInfo extends Gui { "JOrbis 20101023 (JCraft) - jogg, jorbis, CodecJOrbis" }; - public static final GuiInfo INSTANCE = new GuiInfo("Über dieses Programm", getFormat(false)); - public static final GuiInfo HAX = new GuiInfo("Üb3r d1es3n Cr4ck", getFormat(true)); + public static final GuiInfo INSTANCE = new GuiInfo("Über dieses Programm", getFormat(false), true); + public static final GuiInfo HAX = new GuiInfo("Üb3r d1es3n Cr4ck", getFormat(true), true); private final String header; private final String info; + private final boolean center; private static String getFormat(boolean hax) { return getInfo(hax) + "\n\n" + getCredits(hax) + "\n\n" + getLibraries(hax) + "\n\n" + getCode(hax) + "\n\n" + getColors(); @@ -65,7 +67,7 @@ public class GuiInfo extends Gui { private static String getLibraries(boolean hax) { StringBuilder sb = new StringBuilder(getHeader(hax, "Verwendete Programmbibliotheken", "U$3d 3xpl0its")); for(String lib : LIBRARIES) { - sb.append("\n" + TextColor.LGRAY + "-> " + TextColor.NEON + lib); + sb.append("\n" + TextColor.NEON + lib); } return sb.toString(); } @@ -73,7 +75,7 @@ public class GuiInfo extends Gui { private static String getCode(boolean hax) { StringBuilder sb = new StringBuilder(getHeader(hax, "Zusätzlicher Quellcode", "M0ar 3xpl01ts")); for(String lib : CODE) { - sb.append("\n" + TextColor.LGRAY + "-> " + TextColor.NEON + lib); + sb.append("\n" + TextColor.NEON + lib); } return sb.toString(); } @@ -82,10 +84,10 @@ public class GuiInfo extends Gui { StringBuilder sb = new StringBuilder(); int num = 0; for(TextColor color : TextColor.values()) { - if(num > 0) - sb.append(' '); + if(num == 14) + sb.append('\n'); if((color.code >= Log.CHR_COLORS1 && color.code <= Log.CHR_COLORE1) || (color.code >= Log.CHR_COLORS2 && color.code <= Log.CHR_COLORE2)) { - sb.append(color + "#" + (char)(num < 10 ? ('0' + num) : ('A' + (num - 10)))); + sb.append(color + "#" + (char)(num < 10 ? ('0' + num) : ('A' + (num - 10))) + ' '); num++; } } @@ -102,13 +104,14 @@ public class GuiInfo extends Gui { return sb.toString(); } - public GuiInfo(String header, String info) { + public GuiInfo(String header, String info, boolean center) { this.header = header; this.info = info; + this.center = center; } public void init(int width, int height) { - this.add(new TransparentArea(10, 10, width - 20, height - 44, this.info, this.gm.world != null && !this.gm.charEditor)); + this.add(this.center ? new MultiLabel(10, 10, width - 20, height - 44, this.info, false) : new TransparentArea(10, 10, width - 20, height - 44, this.info, this.gm.world != null && !this.gm.charEditor)); this.add(new NavButton(0, height - Element.BASE_HEIGHT, width, 0, GuiMenu.INSTANCE, "Zurück")); } diff --git a/client/src/main/java/client/gui/GuiMenu.java b/client/src/main/java/client/gui/GuiMenu.java index 662e945..68c77f5 100644 --- a/client/src/main/java/client/gui/GuiMenu.java +++ b/client/src/main/java/client/gui/GuiMenu.java @@ -51,7 +51,7 @@ public class GuiMenu extends Gui { this.ticks = 0; this.hacked = 0; this.resetAnimation(); - this.add(new ActButton(0, 0, 170, 0, new ButtonCallback() { + this.add(new ActButton(0, 0, 180, 0, new ButtonCallback() { public void use(ActButton elem, PressType action) { if(action == PressType.SECONDARY) { GuiMenu.this.gm.joinDebugWorld(); @@ -66,16 +66,16 @@ public class GuiMenu extends Gui { } } }, "Server beitreten")); - this.add(new NavButton(0, 20, 170, 0, GuiServer.INSTANCE, "Schnellverbindung")); - this.add(new ActButton(0, 40, 170, 0, new ButtonCallback() { + this.add(new ActButton(0, 20, 180, 0, new ButtonCallback() { public void use(ActButton elem, PressType action) { if(GuiMenu.this.hacked == 8) GuiMenu.this.hacked++; else - GuiMenu.this.gm.displayGuiScreen(GuiOptions.getPage()); + GuiMenu.this.gm.displayGuiScreen(GuiServer.INSTANCE); } - }, "Einstellungen")); - this.infoButton = this.add(new ActButton(0, 60, 170, 0, new ButtonCallback() { + }, "Schnellverbindung")); + this.add(new NavButton(0, 40, 180, 0, GuiOptions.getPage(), "Einstellungen")); + this.infoButton = this.add(new ActButton(0, 60, 180, 0, new ButtonCallback() { public void use(ActButton elem, PressType action) { GuiMenu.this.gm.displayGuiScreen(GuiMenu.this.hacked == 10 ? GuiInfo.HAX : GuiInfo.INSTANCE); } @@ -98,7 +98,7 @@ public class GuiMenu extends Gui { } } }); - this.add(new ActButton(0, 90, 170, 0, new ButtonCallback() { + this.add(new ActButton(0, 90, 180, 0, new ButtonCallback() { public void use(ActButton elem, PressType action) { GuiMenu.this.gm.interrupted = true; } @@ -109,11 +109,11 @@ public class GuiMenu extends Gui { this.pickSplash(); } else { - this.add(new NavButton(0, 0, 170, 0, this.gm.charEditor ? GuiChar.INSTANCE : null, this.gm.charEditor ? "Zurück zum Editor" : "Zurück zum Spiel")); - this.add(new NavButton(0, 20, 170, 0, GuiOptions.getPage(), "Einstellungen")); + this.add(new NavButton(0, 0, 180, 0, this.gm.charEditor ? GuiChar.INSTANCE : null, this.gm.charEditor ? "Zurück zum Editor" : "Zurück zum Spiel")); + this.add(new NavButton(0, 20, 180, 0, GuiOptions.getPage(), "Einstellungen")); if(!this.gm.charEditor) - this.add(new NavButton(0, 40, 170, 0, GuiCharacters.INSTANCE, "Charakter")); - this.add(new ActButton(0, this.gm.charEditor ? 50 : 70, 170, 0, new ButtonCallback() { + this.add(new NavButton(0, 40, 180, 0, GuiCharacters.INSTANCE, "Charakter")); + this.add(new ActButton(0, this.gm.charEditor ? 50 : 70, 180, 0, new ButtonCallback() { public void use(ActButton elem, PressType action) { GuiMenu.this.gm.unload(true); // GuiMenu.this.gm.displayGuiScreen(INSTANCE); diff --git a/client/src/main/java/client/gui/GuiServer.java b/client/src/main/java/client/gui/GuiServer.java index 70f9273..d5c8b67 100644 --- a/client/src/main/java/client/gui/GuiServer.java +++ b/client/src/main/java/client/gui/GuiServer.java @@ -144,7 +144,7 @@ public class GuiServer extends Gui implements FieldCallback { GuiServer.this.passLabel.setText("Ersatz-Passwort (mind. 8 Zeichen)"); } } - }, "Schlüsselpaar wirklich entfernen?", "Wenn das Schlüsselpaar gelöscht wird, ist es nicht mehr möglich, sich damit auf dem Server zu identifizieren und sich anzumelden.\nDamit könnte der Zugriff auf den Server unmöglich werden.", "Schlüsselpaar löschen", "Abbrechen")); + }, "Schlüsselpaar wirklich entfernen?", "Wenn das Schlüsselpaar gelöscht wird, ist es nicht mehr möglich, sich damit\nauf dem Server zu identifizieren und sich anzumelden.\nDamit könnte der Zugriff auf den Server unmöglich werden.", "Schlüsselpaar löschen", "Abbrechen")); } } }, this.keypair == null ? "Neues Schlüsselpaar generieren" : "Schlüsselpaar entfernen")); diff --git a/client/src/main/java/client/gui/character/GuiChar.java b/client/src/main/java/client/gui/character/GuiChar.java index 7feb01b..fcfee42 100755 --- a/client/src/main/java/client/gui/character/GuiChar.java +++ b/client/src/main/java/client/gui/character/GuiChar.java @@ -23,6 +23,7 @@ import client.gui.element.Element; import client.gui.element.GuiList; import client.gui.element.Label; import client.gui.element.ListEntry; +import client.gui.element.MultiLabel; import client.gui.element.NavButton; import client.gui.element.PressType; import client.gui.element.Slider; @@ -101,7 +102,7 @@ public class GuiChar extends GuiList } } - public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) + public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered) { String str = (this.skinFile != null ? this.skinFile.getName() : ( @@ -252,7 +253,7 @@ public class GuiChar extends GuiList private ActButton templateButton; private DragAdjust adjust; private ActButton dimButton; - private TransparentArea descLines; + private MultiLabel descLines; private float yaw = -15.0f; private float pitch = -15.0f; private boolean waiting = true; @@ -427,7 +428,7 @@ public class GuiChar extends GuiList GuiChar.this.setDimButton(); } }, "")); - this.descLines = this.add(new TransparentArea(width - 396, height - 220 + Element.BASE_HEIGHT, 392, 66, "", false)); + this.descLines = this.add(new MultiLabel(width - 396, height - 220 + Element.BASE_HEIGHT, 392, 66, "", true)); this.setDimButton(); } @@ -537,11 +538,6 @@ public class GuiChar extends GuiList this.elements.clear(); } - - public int getListWidth() - { - return 400 - 20; - } public int getSlotHeight() { diff --git a/client/src/main/java/client/gui/character/GuiCharacters.java b/client/src/main/java/client/gui/character/GuiCharacters.java index e80c593..bcf4d1b 100644 --- a/client/src/main/java/client/gui/character/GuiCharacters.java +++ b/client/src/main/java/client/gui/character/GuiCharacters.java @@ -3,12 +3,12 @@ package client.gui.character; import client.gui.GuiConfirm; import client.gui.GuiMenu; import client.gui.element.ActButton; +import client.gui.element.Area; import client.gui.element.ButtonCallback; import client.gui.element.GuiList; import client.gui.element.ListEntry; import client.gui.element.NavButton; import client.gui.element.PressType; -import client.gui.element.TransparentArea; import client.renderer.Drawing; import common.color.TextColor; import common.entity.npc.PlayerCharacter; @@ -28,7 +28,7 @@ public class GuiCharacters extends GuiList impleme this.initial = initial; } - public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) + public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered) { if(this.initial) Drawing.drawRect(x, y, 1, 36, 0xffaf0000); @@ -52,7 +52,7 @@ public class GuiCharacters extends GuiList impleme public static final GuiCharacters INSTANCE = new GuiCharacters(); - private TransparentArea descField; + private Area descField; private ActButton actionButtom; private ActButton deleteButtom; @@ -70,7 +70,7 @@ public class GuiCharacters extends GuiList impleme public void init(int width, int height) { super.init(width, height); - this.setDimensions(600, height, 32, height - 32); + this.setDimensions(width - 300, height, 32, height - 32); this.elements.clear(); int selected = this.gm.selectedCharacter; for(PlayerCharacter character : this.gm.characterList) { @@ -78,7 +78,7 @@ public class GuiCharacters extends GuiList impleme } this.elements.add(new CharacterEntry(null, false)); this.setSelected(ExtMath.clampi(selected, -1, this.elements.size() - 1)); - this.descField = this.add(new TransparentArea(width - 390, 62, 380, height - 124, "", false)); + 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")); @@ -88,11 +88,6 @@ public class GuiCharacters extends GuiList impleme public String getTitle() { return "Charakter anpassen"; } - - public int getListWidth() - { - return 560; - } public int getSlotHeight() { @@ -115,7 +110,7 @@ public class GuiCharacters extends GuiList impleme GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement)); GuiCharacters.this.gm.displayGuiScreen(GuiCharacters.this); } - }, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie von \"" + entry.character.name() + "\" werden für imer verloren sein!", "Löschen", "Abbrechen")); + }, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie\nvon \"" + entry.character.name() + "\" werden für immer verloren sein!", "Löschen", "Abbrechen")); } } } diff --git a/client/src/main/java/client/gui/character/GuiClass.java b/client/src/main/java/client/gui/character/GuiClass.java index 97cde18..f031a68 100644 --- a/client/src/main/java/client/gui/character/GuiClass.java +++ b/client/src/main/java/client/gui/character/GuiClass.java @@ -20,7 +20,7 @@ public class GuiClass extends GuiList implements ButtonCall this.clazz = clazz; } - public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) + public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered) { if(GuiClass.this.gm.player != null && this.clazz == GuiClass.this.gm.player.getNpcClass()) Drawing.drawRect(x, y, 1, 44, 0xffaf0000); @@ -44,7 +44,7 @@ public class GuiClass extends GuiList implements ButtonCall public void init(int width, int height) { super.init(width, height); - this.setDimensions(400, height, 32, height - 32); + this.setDimensions(width, height, 32, height - 32); this.elements.clear(); if(this.gm.player != null && this.gm.player.getSpecies().classEnum != null) for(Enum clazz : this.gm.player.getSpecies().classEnum.getEnumConstants()) { @@ -57,11 +57,6 @@ public class GuiClass extends GuiList implements ButtonCall public String getTitle() { return "Klasse wählen"; } - - public int getListWidth() - { - return 400 - 20; - } public int getSlotHeight() { diff --git a/client/src/main/java/client/gui/character/GuiSpecies.java b/client/src/main/java/client/gui/character/GuiSpecies.java index 1619b3d..3bc15f9 100644 --- a/client/src/main/java/client/gui/character/GuiSpecies.java +++ b/client/src/main/java/client/gui/character/GuiSpecies.java @@ -23,7 +23,7 @@ public class GuiSpecies extends GuiList implements Butt this.species = species; } - public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) + public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered) { if(GuiSpecies.this.gm.player != null && this.species == GuiSpecies.this.gm.player.getSpecies()) Drawing.drawRect(x, y, 1, 44, 0xffaf0000); @@ -49,7 +49,7 @@ public class GuiSpecies extends GuiList implements Butt public void init(int width, int height) { super.init(width, height); - this.setDimensions(400, height, 32, height - 32); + this.setDimensions(width, height, 32, height - 32); this.elements.clear(); for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { this.elements.add(new SpeciesEntry(species)); @@ -61,11 +61,6 @@ public class GuiSpecies extends GuiList implements Butt public String getTitle() { return "Spezies wählen"; } - - public int getListWidth() - { - return 400 - 20; - } public int getSlotHeight() { diff --git a/client/src/main/java/client/gui/element/GuiList.java b/client/src/main/java/client/gui/element/GuiList.java index 1f4ac01..e6208bd 100755 --- a/client/src/main/java/client/gui/element/GuiList.java +++ b/client/src/main/java/client/gui/element/GuiList.java @@ -2,20 +2,16 @@ package client.gui.element; import java.util.List; -import org.lwjgl.opengl.GL11; - import client.gui.Gui; -import client.renderer.DefaultVertexFormats; import client.renderer.Drawing; -import client.renderer.GlState; -import client.renderer.RenderBuffer; -import client.renderer.Tessellator; import client.window.Button; import common.collect.Lists; import common.util.ExtMath; public abstract class GuiList extends Gui { + public static final int SCROLLBAR_WIDTH = 6; + protected final List elements = Lists.newArrayList(); protected int width; @@ -33,13 +29,11 @@ public abstract class GuiList extends Gui protected int selectedElement = -1; protected long lastClicked; - public abstract int getListWidth(); // 220 - public abstract int getSlotHeight(); - protected int getScrollBarX() + protected boolean isScrollbarRight() { - return 0; + return false; } public void setDimensions(int widthIn, int heightIn, int topIn, int bottomIn) @@ -86,16 +80,16 @@ public abstract class GuiList extends Gui public int getSlotIndexFromScreenCoords(int x, int y) { - int i = this.left + this.width / 2 - this.getListWidth() / 2; - int j = this.left + this.width / 2 + this.getListWidth() / 2; - int k = y - this.top + (int)this.amountScrolled - 4; - int l = k / this.getSlotHeight(); - return this.isInList(x, y) && x >= i && x <= j && l >= 0 && k >= 0 && l < this.getSize() ? l : -1; + int x1 = this.left + (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH); + int x2 = this.left + (this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : this.width); + int y1 = y - this.top + (int)this.amountScrolled - 4; + int idx = y1 / this.getSlotHeight(); + return this.isInList(x, y) && x >= x1 && x <= x2 && idx >= 0 && y1 >= 0 && idx < this.getSize() ? idx : -1; } protected boolean isInList(int x, int y) { - return x >= this.getScrollBarX() + 6; // x < this.getScrollBarX(); + return this.isScrollbarRight() ? x < this.width - SCROLLBAR_WIDTH : x >= SCROLLBAR_WIDTH; } protected final boolean isSelected(int slotIndex) @@ -118,9 +112,9 @@ public abstract class GuiList extends Gui return (int)this.amountScrolled; } - public boolean isMouseYWithinSlotBounds(int p_148141_1_) + public boolean isMouseYWithinSlotBounds(int y) { - return p_148141_1_ >= this.top && p_148141_1_ <= this.bottom && this.mouseX >= this.left && this.mouseX <= this.right; + return y >= this.top && y <= this.bottom && this.mouseX >= this.left && this.mouseX <= this.right; } public void scrollBy(int amount) @@ -130,25 +124,6 @@ public abstract class GuiList extends Gui this.initialClickY = -2; } -// public void actionPerformed(Button button) -// { -// if (button.enabled) -// { -// if (button.id == this.scrollUpButtonID) -// { -// this.amountScrolled -= (float)(this.slotHeight * 2 / 3); -// this.initialClickY = -2; -// this.bindAmountScrolled(); -// } -// else if (button.id == this.scrollDownButtonID) -// { -// this.amountScrolled += (float)(this.slotHeight * 2 / 3); -// this.initialClickY = -2; -// this.bindAmountScrolled(); -// } -// } -// } - public void draw() { int mouseXIn = this.gm.mouse_x; @@ -156,90 +131,50 @@ public abstract class GuiList extends Gui this.mouseX = mouseXIn; this.mouseY = mouseYIn; this.drawBackground(); - int i = this.getScrollBarX(); - int j = i + 6; this.bindAmountScrolled(); - GlState.disableLighting(); - GlState.disableFog(); - GlState.enableTexture2D(); - RenderBuffer worldrenderer = Tessellator.getBuffer(); - this.gm.getTextureManager().bindTexture(Gui.DIRT_BACKGROUND); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); + + Drawing.drawScaled(this.gm, Gui.BACKGROUND, 0, this.top, this.gm.fb_x, this.bottom - this.top, 0xff7f7f7f); - float f = 32.0F; - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos((double)0, (double)this.bottom, 0.0D).tex((double)((float)0 / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex(); - worldrenderer.pos((double)this.gm.fb_x, (double)this.bottom, 0.0D).tex((double)((float)this.gm.fb_x / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex(); - worldrenderer.pos((double)this.gm.fb_x, (double)this.top, 0.0D).tex((double)((float)this.gm.fb_x / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex(); - worldrenderer.pos((double)0, (double)this.top, 0.0D).tex((double)((float)0 / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex(); - Tessellator.draw(); - - int x = this.left + this.width / 2 - this.getListWidth() / 2 + 2; + int x = this.left + (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH); int y = this.top + 4 - (int)this.amountScrolled; - this.drawSelectionBox(x, y, mouseXIn, mouseYIn); - GlState.disableDepth(); - - this.overlayBackground(0, this.top, 255, 255); - this.overlayBackground(this.bottom, this.height, 255, 255); - - GlState.enableBlend(); - GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE); - GlState.disableAlpha(); - GlState.shadeModel(GL11.GL_SMOOTH); - GlState.disableTexture2D(); - - int i1 = 4; - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos((double)0, (double)(this.top + i1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 0).endVertex(); - worldrenderer.pos((double)this.gm.fb_x, (double)(this.top + i1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 0).endVertex(); - worldrenderer.pos((double)this.gm.fb_x, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex(); - worldrenderer.pos((double)0, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex(); - Tessellator.draw(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos((double)0, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex(); - worldrenderer.pos((double)this.gm.fb_x, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); - worldrenderer.pos((double)this.gm.fb_x, (double)(this.bottom - i1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 0).endVertex(); - worldrenderer.pos((double)0, (double)(this.bottom - i1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 0).endVertex(); - Tessellator.draw(); - - int j1 = this.getMaxScroll(); + int size = this.getSize(); - if (j1 > 0) + for (int z = 0; z < size; z++) { - int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); - k1 = ExtMath.clampi(k1, 32, this.bottom - this.top - 8); - int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top; + int y1 = y + z * this.getSlotHeight(); + int h = this.getSlotHeight() - 4; - if (l1 < this.top) - { - l1 = this.top; - } + 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); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex(); - worldrenderer.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); - worldrenderer.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex(); - worldrenderer.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex(); - Tessellator.draw(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos((double)i, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex(); - worldrenderer.pos((double)j, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex(); - worldrenderer.pos((double)j, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex(); - worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex(); - Tessellator.draw(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos((double)i, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex(); - worldrenderer.pos((double)(j - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex(); - worldrenderer.pos((double)(j - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex(); - worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex(); - Tessellator.draw(); + 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); + if(hover) + Drawing.drawRect(x, y1 - 2, this.width - SCROLLBAR_WIDTH, this.getSlotHeight(), Gui.HOVER_COLOR); } + + Drawing.drawScaled(this.gm, Gui.BACKGROUND, 0, 0, this.gm.fb_x, this.top, 0xffffffff); + Drawing.drawScaled(this.gm, Gui.BACKGROUND, 0, this.bottom, this.gm.fb_x, this.height - this.bottom, 0xffffffff); + Drawing.drawRect(-1, -1, this.gm.fb_x + 2, this.top + 1, 0, this.gm.style.brdr_top, this.gm.style.brdr_btm); + Drawing.drawRect(-1, this.bottom, this.gm.fb_x + 2, this.height - this.bottom + 1, 0, this.gm.style.brdr_top, this.gm.style.brdr_btm); + + int edge = 2; + Drawing.drawGradient(0, this.top, this.gm.fb_x, edge, 0xff000000, 0x00000000); + Drawing.drawGradient(0, this.bottom - edge, this.gm.fb_x, edge, 0x00000000, 0xff000000); + + int max = this.getMaxScroll(); - GlState.enableTexture2D(); - GlState.shadeModel(GL11.GL_FLAT); - GlState.enableAlpha(); - GlState.disableBlend(); + if (max > 0) + { + int barHeight = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); + barHeight = ExtMath.clampi(barHeight, 32, this.bottom - this.top - 8); + int scrollX = this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : 0; + int scrollY = (int)this.amountScrolled * (this.bottom - this.top - barHeight) / max + this.top; + if(scrollY < this.top) + scrollY = this.top; + Drawing.drawRect(scrollX, this.top, SCROLLBAR_WIDTH, this.bottom - this.top, 0xff000000); + Drawing.drawGradient(scrollX, scrollY, SCROLLBAR_WIDTH, barHeight, this.gm.style.fill_top, this.gm.style.fill_btm, this.gm.style.brdr_top, this.gm.style.brdr_btm); + } super.draw(); } @@ -248,16 +183,14 @@ public abstract class GuiList extends Gui { if (this.isMouseYWithinSlotBounds(this.mouseY)) { -// if (Button.MOUSE_LEFT.isDown() && this.getEnabled()) -// { if (this.initialClickY == -1) { boolean flag1 = true; if (this.mouseY >= this.top && this.mouseY <= this.bottom) { - int j2 = (this.width - this.getListWidth()) / 2; - int k2 = (this.width + this.getListWidth()) / 2; + int j2 = (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH); + int k2 = (this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : this.width); int l2 = this.mouseY - this.top + (int)this.amountScrolled - 4; int i1 = l2 / this.getSlotHeight(); @@ -269,8 +202,8 @@ public abstract class GuiList extends Gui flag1 = false; } - int i3 = this.getScrollBarX(); - int j1 = i3 + 6; + int i3 = this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : 0; + int j1 = i3 + SCROLLBAR_WIDTH; if (this.mouseX >= i3 && this.mouseX <= j1) { @@ -310,63 +243,8 @@ public abstract class GuiList extends Gui this.amountScrolled -= (float)(this.mouseY - this.initialClickY) * this.scrollMultiplier; this.initialClickY = this.mouseY; } -// } -// else -// { -// this.initialClickY = -1; -// } } } - - protected void drawSelectionBox(int x, int y, int mouseXIn, int mouseYIn) - { - int size = this.getSize(); - RenderBuffer rb = Tessellator.getBuffer(); - - for (int z = 0; z < size; z++) - { - int y1 = y + z * this.getSlotHeight(); - int h = this.getSlotHeight() - 4; - - if (this.isSelected(z)) - { - int x1 = this.left + (this.width / 2 - this.getListWidth() / 2); - int x2 = this.left + this.width / 2 + this.getListWidth() / 2; - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - GlState.disableTexture2D(); - rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - rb.pos((double)x1, (double)(y1 + h + 2), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex(); - rb.pos((double)x2, (double)(y1 + h + 2), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex(); - rb.pos((double)x2, (double)(y1 - 2), 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex(); - rb.pos((double)x1, (double)(y1 - 2), 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex(); - rb.pos((double)(x1 + 1), (double)(y1 + h + 1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex(); - rb.pos((double)(x2 - 1), (double)(y1 + h + 1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); - rb.pos((double)(x2 - 1), (double)(y1 - 1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex(); - rb.pos((double)(x1 + 1), (double)(y1 - 1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex(); - Tessellator.draw(); - GlState.enableTexture2D(); - } - - boolean hover = this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == z; - this.getListEntry(z).draw(x, y1, mouseXIn - x, mouseYIn - y1, hover); - if(hover) - Drawing.drawRect(x - 2, y1 - 2, this.getListWidth(), this.getSlotHeight(), Gui.HOVER_COLOR); - } - } - - protected void overlayBackground(int startY, int endY, int startAlpha, int endAlpha) - { - RenderBuffer rb = Tessellator.getBuffer(); - this.gm.getTextureManager().bindTexture(Gui.DIRT_BACKGROUND); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - float f = 32.0F; - rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - rb.pos((double)0, (double)endY, 0.0D).tex(0.0D, (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex(); - rb.pos((double)this.gm.fb_x, (double)endY, 0.0D).tex((double)((float)this.gm.fb_x / 32.0F), (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex(); - rb.pos((double)this.gm.fb_x, (double)startY, 0.0D).tex((double)((float)this.gm.fb_x / 32.0F), (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex(); - rb.pos((double)0, (double)startY, 0.0D).tex(0.0D, (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex(); - Tessellator.draw(); - } public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) { @@ -377,16 +255,16 @@ public abstract class GuiList extends Gui if (i >= 0) { - int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2; - int k = this.top + 4 - this.getAmountScrolled() + i * this.getSlotHeight(); - int l = x - j; - int i1 = y - k; + int x1 = this.left + (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH) + 2; + int y1 = this.top + 4 - this.getAmountScrolled() + i * this.getSlotHeight(); + int mx = x - x1; + int my = y - y1; boolean flag = i == this.selectedElement && System.currentTimeMillis() - this.lastClicked < (long)this.gm.dclickDelay; this.selectedElement = i; this.lastClicked = System.currentTimeMillis(); - this.getListEntry(i).select(flag, l, i1); + this.getListEntry(i).select(flag, mx, my); } } if(btn == Button.MOUSE_LEFT && this.clicked(x, y) == null) diff --git a/client/src/main/java/client/gui/element/ListEntry.java b/client/src/main/java/client/gui/element/ListEntry.java index 76236d1..1360285 100644 --- a/client/src/main/java/client/gui/element/ListEntry.java +++ b/client/src/main/java/client/gui/element/ListEntry.java @@ -2,6 +2,6 @@ package client.gui.element; public interface ListEntry { - void draw(int x, int y, int mouseX, int mouseY, boolean hovered); + void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered); void select(boolean dclick, int mx, int my); } \ No newline at end of file diff --git a/client/src/main/java/client/gui/element/MultiLabel.java b/client/src/main/java/client/gui/element/MultiLabel.java new file mode 100644 index 0000000..3eb64a8 --- /dev/null +++ b/client/src/main/java/client/gui/element/MultiLabel.java @@ -0,0 +1,40 @@ +package client.gui.element; + +import client.gui.Font; +import client.renderer.Drawing; +import common.util.Util; + +public class MultiLabel extends Fill { + private String[] lines; + + public MultiLabel(int x, int y, int w, int h, String text, boolean top) { + super(x, y, w, h, text, top, true); + } + + public MultiLabel(int x, int y, int w, int h, String text) { + super(x, y, w, h, text, false, true); + } + + public void setText(String str) { + super.setText(str); + this.lines = str.split("\n", -1); + } + + protected void drawBackground() { + } + + 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); + } + } + + protected int getMarginX() { + return 0; + } + + protected int getMarginY() { + return 0; + } +} diff --git a/client/src/main/java/client/network/ClientLoginHandler.java b/client/src/main/java/client/network/ClientLoginHandler.java index 5dced68..b4379e4 100755 --- a/client/src/main/java/client/network/ClientLoginHandler.java +++ b/client/src/main/java/client/network/ClientLoginHandler.java @@ -29,6 +29,7 @@ import common.packet.RPacketRequestEncrypt; import common.packet.RPacketResponse; import common.packet.RPacketServerConfig; import common.util.EncryptUtil; +import common.util.Util; public class ClientLoginHandler implements IClientLoginHandler { private static enum LoginState { @@ -85,14 +86,14 @@ public class ClientLoginHandler implements IClientLoginHandler { ClientLoginHandler.this.connection.closeChannel("Verbindung wurde abgebrochen"); } } - }, "Die Identität des Servers ist unbekannt", "Es wurde noch nie mit diesem Server verbunden.\nSoll die Verbindung wirklich fortgesetzt werden?\n\nDie Pubkey-ID des Servers lautet:\nRSA-4096 " + EncryptUtil.getXorSha512Hash(pubkey.getEncoded()) + "\n\nDer öffentliche Schlüssel des Servers lautet:\n" + Base64.getEncoder().encodeToString(pubkey.getEncoded()), "Verbindung herstellen", "Abbrechen und trennen")); + }, "Die Identität des Servers ist unbekannt", "Es wurde noch nie mit diesem Server verbunden.\nSoll die Verbindung wirklich fortgesetzt werden?\n\nDie Pubkey-ID des Servers lautet:\nRSA-4096 " + EncryptUtil.getXorSha512Hash(pubkey.getEncoded()) + "\n\nDer öffentliche Schlüssel des Servers lautet:\n" + Util.breakString(Base64.getEncoder().encodeToString(pubkey.getEncoded()), 64), "Verbindung herstellen", "Abbrechen und trennen")); } }); return; } else if(!this.server.getServerKey().equals(pubkey)) { - this.connection.closeChannel("Die Identität des Servers hat sich geändert\n\nDer Server hat einen anderen öffentlichen Schlüssel als vorher bekannt war, dies kann bedeuten dass der Inhaber jetzt einen anderen Schlüssel verwendet oder sich ein anderer Server als dieser ausgibt (\"Man-in-the-middle-attack\").\n\nDie Pubkey-ID des Servers lautet:\nRSA-4096 " + EncryptUtil.getXorSha512Hash(pubkey.getEncoded()) + "\n\nDer öffentliche Schlüssel des Servers lautet:\n" + Base64.getEncoder().encodeToString(pubkey.getEncoded()) + "\n\nDie vertrauenswürdige Pubkey-ID lautet:\nRSA-4096 " + EncryptUtil.getXorSha512Hash(this.server.getServerKey().getEncoded()) + "\n\nDer vertrauenswürdige Schlüssel lautet:\n" + Base64.getEncoder().encodeToString(this.server.getServerKey().getEncoded()) + - "\n\nFalls der Server trotzdem vertrauenswürdig wirkt, kann die Server-Identifizierung im den Einstellungen von '" + this.server.getName() + "' zurückgesetzt werden."); + this.connection.closeChannel("Die Identität des Servers hat sich geändert\n\nDer Server hat einen anderen öffentlichen Schlüssel als vorher bekannt war,\ndies kann bedeuten dass der Inhaber jetzt einen anderen Schlüssel verwendet\noder sich ein anderer Server als dieser ausgibt (\"Man-in-the-middle-attack\").\n\nDie Pubkey-ID des Servers lautet: RSA-4096 " + EncryptUtil.getXorSha512Hash(pubkey.getEncoded()) + "\n\nDer öffentliche Schlüssel des Servers lautet:\n" + Util.breakString(Base64.getEncoder().encodeToString(pubkey.getEncoded()), 96) + "\n\nDie vertrauenswürdige Pubkey-ID lautet: RSA-4096 " + EncryptUtil.getXorSha512Hash(this.server.getServerKey().getEncoded()) + "\n\nDer vertrauenswürdige Schlüssel lautet:\n" + Util.breakString(Base64.getEncoder().encodeToString(this.server.getServerKey().getEncoded()), 96) + + "\n\nFalls der Server trotzdem vertrauenswürdig wirkt, kann die Server-Identifizierung\nin den Einstellungen von '" + this.server.getName() + "' zurückgesetzt werden."); return; } this.startEncryption(secret, pubkey, token); @@ -126,8 +127,8 @@ public class ClientLoginHandler implements IClientLoginHandler { if(this.state == LoginState.HANDSHAKE) { this.connection.setConnectionState(PacketRegistry.LOGIN); if(this.server.requiresEncryption()) { - this.connection.closeChannel("Der Server unterstützt keine verschlüsselte Verbindung, dies ist in den Servereinstellungen von '" - + this.server.getName() + "' als erforderlich eingestellt, stelle keine ungesicherte Verbindung her."); + this.connection.closeChannel("Der Server unterstützt keine verschlüsselte Verbindung, dies ist\nin den Servereinstellungen von '" + + this.server.getName() + "' als erforderlich\neingestellt, stelle keine ungesicherte Verbindung her."); return; } if(this.server.getServerKey() != null) { @@ -147,7 +148,7 @@ public class ClientLoginHandler implements IClientLoginHandler { ClientLoginHandler.this.connection.closeChannel("Verbindung wurde abgebrochen"); } } - }, "Der Server hat die Verschlüsselung deaktiviert", "Es wurde bereits verschlüsselt mit diesem Server kommuniziert.\n\nSoll die Verbindung wirklich fortgesetzt werden?\n\nDie Pubkey-Authentifizierung wird nicht verfügbar sein und die Server-ID wird ignoriert und zurückgesetzt.", "Unverschlüsselt verbinden", "Abbrechen und trennen")); + }, "Der Server hat die Verschlüsselung deaktiviert", "Es wurde bereits verschlüsselt mit diesem Server kommuniziert.\n\nSoll die Verbindung wirklich fortgesetzt werden?\n\nDie Pubkey-Authentifizierung wird nicht verfügbar sein\nund die Server-ID wird ignoriert und zurückgesetzt.", "Unverschlüsselt verbinden", "Abbrechen und trennen")); } }); return; diff --git a/client/src/main/java/client/renderer/Drawing.java b/client/src/main/java/client/renderer/Drawing.java index 1ce4933..1337d9b 100644 --- a/client/src/main/java/client/renderer/Drawing.java +++ b/client/src/main/java/client/renderer/Drawing.java @@ -497,6 +497,28 @@ public abstract class Drawing { drawGradient(x + 2, y + 2, w - 4, h - 4, top, bottom); } + public static void drawRect(int x, int y, int w, int h, int color, int topleft, int btmright) { + int corner = Util.mixColor(topleft, btmright); + drawRect(x, y, w - 1, 1, topleft); + drawRect(x, y + 1, 1, h - 1, topleft); + drawRect(x + w - 1, y + 1, 1, 1, corner); + drawRect(x, y + h - 1, 1, 1, corner); + drawRect(x + w - 1, y + 1, 1, h - 1, btmright); + drawRect(x + 1, y + h - 1, w - 2, 1, btmright); + drawRect(x + 1, y + 1, w - 2, h - 2, 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); + drawRect(x, y + 1, 1, h - 1, topleft); + drawRect(x + w - 1, y + 1, 1, 1, corner); + drawRect(x, y + h - 1, 1, 1, corner); + drawRect(x + w - 1, y + 1, 1, h - 1, btmright); + drawRect(x + 1, y + h - 1, w - 2, 1, btmright); + drawGradient(x + 1, y + 1, w - 2, h - 2, top, bottom); + } + public static int getWidth(String str) { return getSize(str).xpos; } @@ -544,28 +566,24 @@ public abstract class Drawing { } public static void drawScaled(Client gm, String texture) { - drawScaled(gm, texture, 0, 0, gm.fb_x, gm.fb_y); + drawScaled(gm, texture, 0, 0, gm.fb_x, gm.fb_y, 0xffffffff); } - public static void drawScaled(Client gm, String texture, double x, double y, double width, double height) { + public static void drawScaled(Client gm, String texture, int x, int y, int width, int height, int color) { GlState.enableTexture2D(); GlState.disableLighting(); GlState.disableFog(); RenderBuffer buf = Tessellator.getBuffer(); gm.getTextureManager().bindTexture(texture); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); + GlState.color(color); double scale = 32.0; - buf.begin(GL11.GL_QUADS, 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(); + buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buf.pos((double)x, (double)y + (double)height, 0.0D).tex(0.0D, (double)height / scale).endVertex(); + buf.pos((double)x + (double)width, (double)y + (double)height, 0.0D).tex((double)width / scale, (double)height / scale).endVertex(); + buf.pos((double)x + (double)width, (double)y, 0.0D).tex((double)width / scale, 0.0).endVertex(); + buf.pos((double)x, (double)y, 0.0D).tex(0.0D, 0.0).endVertex(); Tessellator.draw(); GlState.disableTexture2D(); + GlState.color(1.0F, 1.0F, 1.0F, 1.0F); } } diff --git a/client/src/main/resources/textures/background.png b/client/src/main/resources/textures/background.png index cae55280556d473ca2b7aa5e3a643f61092fe553..d2ac167f6cc168c4936ee4016c7f1bf422e1ebe0 100755 GIT binary patch literal 4881 zcmeHKX;2f{7LJIBY$}S%bI{oCV3R!|Eny7=&>$iz45QfT?m&brCY=RPaRK*HM#gc& z1qDG=Lt|KafB5pW1fHL~Vof%miHhnh%5o@OEl~r&4nW|3up8K8ep7Y&vPvx!+ z2^QH}{mY6%q1Xln2t&c|Amd|c2EJ3ji{Vlz=2H^F!pTrnPgSXvQdt~9CF4~Dl`zPp z6pEobYi@+@R+lNJ&x_>b|^$1@an=)_2Yr3b0Gb-rSA*p%-V_h4;?SeMDo1l8RbJC zTWouJV2F1VxoVS7%60waT_JbJ24$SAv@I6hn6m89qKDT~M$TwN-dGM_Ienak4?fhB zmBuS&wrz}h%HuKiENLD<-DLf8zAnnZ-B}ZGyvV$4%NS=HVp4KlUDJcUN1Ep>(8($s zI_#g7t{Um|F>acgCq zcJ{KN7YZ*rws=u;GF;pWSc5TtXb8nwHE(fhAItpQFt^DU+AZTYlegU@?(5fC-8c7G z<(L{mruW(T()zrW_e{@W_6u`zs`lp26sJky$}597mt&3%ERocjZU35m9RE4!&E#=n zMnur$?9Jm7ZN%3Zk-_}mLKhtO(p-3Ewmj6rv15=$))+f(=9qzmuyq4^hp~}+fUzkn zsM(=$|K)|8yWf;u8WJS4N()|8Fj*Y$Y@2n@z366Pi4-pS<=Vz-s~1n+^;>v)-vn0Z zyqmf^=Q$6;RHG+WGx{#@S-!kjYuSds*!JV4F#)1H>^}v2UBVt_>dKw0w}THW!A zJt_Ac&+Z;Ed_e8E82A3V(i=aVI6u(7F=(`nr*?}MTo#o1?O0mu%Z%%;Ew^?=j8BSw z8=p0@N}JGkL0x_}lHgunOQzjFRdn0`=e_Ob>qZ6Tr!U$VS$liQ#b^C*K4xK6TlBAn zy!z8gpn4^0?$EAS8d9-I+ZjMx+RfY?oxg0TFtnwvdWC00k zVpc+M7?u!=@o~u0!^+)&00KEdqEv%CPN6{z0?5RRfOn&r22o8AGFAYEi$kcsN;N@c zyRu#Bu%AJuV?rKQRChHlMM8!C-4tLXfMQ5eh0thvz1~&Na#gCMX$(G}PopzwOePEv zuqIwXq6S!@8Ed5I;t&!VOf6H9GNpoQ3{?GTc+xcBgWg8q=Z2@FtT zF(OoAT4Q*DLIGr4AHkKF3`b0_1RG~z7@GsLaE=sayGh(&l+K{TOg9#Xg|WC&z8k9- zRiHvcq6&;KQUP*T8Q|gY+?afVfx!eJh{i(-aa2C5Q` z>m8Mm3I|kdf{F8aJQmEuIDm>t=fV;eLjq%T9*aOZ7{Nx_CMq05{FQ1s3bs=wN23Xv zN)c_EFba-%hXe{BrYrrUB_s|drNBV|O_wROhL00rGC47eM2%`Pcx*n8#bz==%uFW7 z?IUOoq1J#(G;%WNuB@&QjN5{MWPq@!u}%Sj$phqq_^Jt%RI0<2$~XaJ42f#=?3osW zqImEvC*bOu!eUTGGy%Ftce#GB%l@VmcpRMT z#>N@28=pX7Hi6?XpCw_!Y!oLjE?t5%IOwPB8l{xfqiVuC8t4eL0_ADaiaN=(QIkJK z>thJxE&#z`P#S*~jMkkn&Db+OWb97+izeuHAFni<>9Klth1 zi+^whK>cNr&(imcTwmn+ECoIb{H40S$n{wYd=~gib^YJuvif+PA{5|XkRDu?Qr}OT z0xntuQ~?nh3dMSe@##a^kv;+#`;&oUzy8lGY-|VjZR<158km{_h2CM4D&~bwUDuCc zbK8FTdM~@i*GbMRt$l4GpJv!jEusH$zpcb`Pet~rhBFjO`34UNf++ZeWkvUDM^b9U zp-wfn4{HydjGUdFO6KHlkBD8HocSE8q(=#yub1<)b6=ks#Wg?Go{srb?DOC1{ATDY zY>tR5=A%0fJMX9L?PwKmeq5egTn_H@ZECk&*Z{}1x9;HT^w!~9 zauYUfFI{tWx;OIYn*67UN1q3^(&i|W6<*a%hjP=IQTbJeHeW4YGiYU4Wh5S{q{JS1 zeXlv`(dps$CIoB4U!B^2NAg^Esl`Gm4D9S@R@*YPx@H*(@}~s)1q<_h7OeO$R8T~y literal 975 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstPBjy3;{kN zu93Eym7!K85iU77In#2ycDBZ}x3>cokAl$<7zrWZVDv@;=+7!o7sn8dVAcLkK?X$* z=EI!d;y=Az)F+_$@MKB&TF!lHR~z;zcK91DsZe2D@I}(ID=O?mvtflvOmW6`EmzHG zaR=rtOIXZuXI{0?nf`4-xZ~DOS9Jqzqv~pNyV>Q9Y93f|PAoqbyUI@6is5g{#shp$ hr?JUA{x*BjCuRpJrg+|iwTht7_H^}gS?83{1OQi0Oius+