add various ui improvements
This commit is contained in:
parent
6d9522c80d
commit
48918f0139
17 changed files with 192 additions and 274 deletions
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -151,19 +151,19 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> 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<GuiConnect.ServerInfo> implements Button
|
|||
public String getTitle() {
|
||||
return "Server auswählen";
|
||||
}
|
||||
|
||||
public int getListWidth() {
|
||||
return 660;
|
||||
}
|
||||
|
||||
public int getSlotHeight() {
|
||||
return 56;
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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<GuiChar.SkinEntry>
|
|||
}
|
||||
}
|
||||
|
||||
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<GuiChar.SkinEntry>
|
|||
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.SkinEntry>
|
|||
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<GuiChar.SkinEntry>
|
|||
|
||||
this.elements.clear();
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
|
|
|
@ -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<GuiCharacters.CharacterEntry> 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<GuiCharacters.CharacterEntry> 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<GuiCharacters.CharacterEntry> 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<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 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<GuiCharacters.CharacterEntry> impleme
|
|||
public String getTitle() {
|
||||
return "Charakter anpassen";
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 560;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
|
@ -115,7 +110,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> 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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class GuiClass extends GuiList<GuiClass.ClassEntry> 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<GuiClass.ClassEntry> 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<GuiClass.ClassEntry> implements ButtonCall
|
|||
public String getTitle() {
|
||||
return "Klasse wählen";
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> 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<GuiSpecies.SpeciesEntry> 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<GuiSpecies.SpeciesEntry> implements Butt
|
|||
public String getTitle() {
|
||||
return "Spezies wählen";
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
|
|
|
@ -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<T extends ListEntry> extends Gui
|
||||
{
|
||||
public static final int SCROLLBAR_WIDTH = 6;
|
||||
|
||||
protected final List<T> elements = Lists.newArrayList();
|
||||
|
||||
protected int width;
|
||||
|
@ -33,13 +29,11 @@ public abstract class GuiList<T extends ListEntry> 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<T extends ListEntry> 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<T extends ListEntry> 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<T extends ListEntry> 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<T extends ListEntry> 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<T extends ListEntry> 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<T extends ListEntry> 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<T extends ListEntry> 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<T extends ListEntry> 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)
|
||||
|
|
|
@ -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);
|
||||
}
|
40
client/src/main/java/client/gui/element/MultiLabel.java
Normal file
40
client/src/main/java/client/gui/element/MultiLabel.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 975 B After Width: | Height: | Size: 4.8 KiB |
Loading…
Add table
Add a link
Reference in a new issue