From 5300c9e4fc5d6da4fe56d7dfcf944b5741fe3a4a Mon Sep 17 00:00:00 2001 From: Sen Date: Thu, 20 Mar 2025 15:33:08 +0100 Subject: [PATCH] ui border, fixes --- java/src/game/Game.java | 12 +-- java/src/game/gui/Gui.java | 15 +--- java/src/game/gui/GuiMenu.java | 2 +- java/src/game/gui/GuiStyle.java | 66 ++++++++------ java/src/game/gui/Style.java | 72 ++++++---------- java/src/game/gui/container/GuiContainer.java | 2 +- java/src/game/gui/element/Bar.java | 2 +- java/src/game/gui/element/Dropdown.java | 3 +- java/src/game/gui/element/Element.java | 6 +- java/src/game/gui/element/GuiList.java | 2 +- .../src/game/gui/element/InventoryButton.java | 2 +- java/src/game/gui/element/SelectedButton.java | 2 +- java/src/game/gui/element/Slider.java | 4 +- java/src/game/gui/element/Textbox.java | 10 ++- java/src/game/gui/element/Toggle.java | 2 +- java/src/game/gui/world/GuiWorlds.java | 2 +- java/src/game/renderer/Drawing.java | 85 ++++++++++--------- java/src/game/vars/ColorVar.java | 10 +++ 18 files changed, 150 insertions(+), 149 deletions(-) diff --git a/java/src/game/Game.java b/java/src/game/Game.java index 54a8f42..3bf3e92 100755 --- a/java/src/game/Game.java +++ b/java/src/game/Game.java @@ -734,7 +734,7 @@ public class Game implements IThreadListener { Drawing.drawTextboxRight(name, x + 250, y, 0x3f000000); Drawing.drawTextbox(String.format(TextColor.GREEN + "%d " + TextColor.GRAY + "/ " + TextColor.NEON + "%d", value, max), x, y, 0x3f000000); // Drawing.drawRectColor(x, y + 20, 250, 10, 0xff000000); - Drawing.drawRect2GradBorder(x, y + 20, 250, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f); + Drawing.drawRectBorder(x, y + 20, 250, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f); Drawing.drawGradient(x + 2 + 246 - w, y + 20 + 2, w, 6, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000)); return y + 40; } @@ -743,7 +743,7 @@ public class Game implements IThreadListener { Drawing.drawTextbox(name, x, y, 0x3f000000); // Drawing.drawRectColor(x, y + 20, 250, 10, 0xff000000); // Drawing.drawRectColor(x, y + 20, (int)(250.0f * fill), 10, color | 0xff000000); - Drawing.drawRect2GradBorder(x, y + 20, 250, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f); + Drawing.drawRectBorder(x, y + 20, 250, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f); Drawing.drawGradient(x + 2, y + 20 + 2, (int)(246.0f * fill), 6, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000)); return y + 40; } @@ -767,7 +767,7 @@ public class Game implements IThreadListener { int x = this.fb_x / 2 - 180 + n * 40 + 4; int y = this.fb_y - 40; // Drawing.drawRect2Border(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xffafafaf); - Drawing.drawRect2GradBorder(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xff000000, 0xffafafaf, 0xff7f7f7f, 0xff7f7f7f, 0xff4f4f4f); + Drawing.drawRectBorder(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xff000000, 0xffafafaf, 0xff4f4f4f); } ItemStack itemstack = this.thePlayer != null ? this.thePlayer.inventory.getCurrentItem() : null; @@ -790,7 +790,7 @@ public class Game implements IThreadListener { entity.getHealth() + TextColor.GRAY + " / " + EntityLiving.getMaxHpColor(entity.getMaxHealth()) + entity.getMaxHealth() + TextColor.GRAY + "]"; Drawing.drawTextboxCentered(s, x, y, 0x3f000000); - Drawing.drawRect2GradBorder(x - 200, y + 20, 400, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f); + Drawing.drawRectBorder(x - 200, y + 20, 400, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f); Drawing.drawGradient(x - 200 + 2, y + 20 + 2, (int)(396.0f * ((float)entity.getHealth() / (float)entity.getMaxHealth())), 6, entity.getColor() | 0xff000000, Util.mixColor(entity.getColor() | 0xff000000, 0xff000000)); // Drawing.drawRectColor(x - 200, y + 20, 400, 10, 0xff000000); // Drawing.drawRectColor(x - 200, y + 20, , 0xff000000 | ); @@ -810,7 +810,7 @@ public class Game implements IThreadListener { String name = (potion.isBadEffect() ? TextColor.ORANGE : TextColor.ACID) + potion.getDisplay() + PotionHelper.getPotionPotency(effect.getAmplifier()); String desc = TextColor.NEON + Potion.getDurationString(effect); // Drawing.drawRectColor(x, y, 250, Font.DEFAULT.yglyph + 2, color | 0xff000000); - Drawing.drawGradient2GradBorder(x, y, 250, Font.YGLYPH + 4, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000), 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f); + Drawing.drawGradientBorder(x, y, 250, Font.YGLYPH + 4, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000), 0xff202020, 0xffcfcfcf, 0xff6f6f6f); Drawing.drawText(name, x + 4, y + 2, 0xffffffff); Drawing.drawTextRight(desc, x + 250 - 4, y + 2, 0xffffffff); y += 24; @@ -937,7 +937,7 @@ public class Game implements IThreadListener { if(this.open != null) this.open.render(); else if(this.theWorld == null || this.theWorld.hasNoChunks()) - Drawing.drawScaledBackground(this, Gui.DIRT_BACKGROUND); + Drawing.drawScaled(this, Gui.DIRT_BACKGROUND); if(Bind.INFO.isDown() && (this.open == null || !(this.open.selected instanceof Textbox))) this.drawInfo(); if(this.hudOverlay && !(this.open instanceof GuiConsole)) diff --git a/java/src/game/gui/Gui.java b/java/src/game/gui/Gui.java index c3b612f..4c702e5 100644 --- a/java/src/game/gui/Gui.java +++ b/java/src/game/gui/Gui.java @@ -12,14 +12,14 @@ import game.gui.element.Dropdown.Handle; import game.gui.element.Element; import game.renderer.Drawing; import game.renderer.GlState; -import game.vars.CVar; -import game.vars.ColorVar; import game.window.Bind; import game.window.Button; import game.window.Keysym; public abstract class Gui { public static final String DIRT_BACKGROUND = "textures/background.png"; + public static final int HOVER_COLOR = 0x288080ff; + public static final int PRESS_COLOR = 0x30afafff; protected final Game gm = Game.getGame(); @@ -183,14 +183,7 @@ public abstract class Gui { } protected Element addSelector(String cvar, int x, int y, int w, int h) { - CVar cv = this.gm.getVar(cvar); - if(cv instanceof ColorVar) { - ColorVar color = (ColorVar)cv; - if(!color.getDisplay().isEmpty()) - this.add(color.label(x, y - 20, w, 20)); - return this.add(color.editor(x, y, w, h)); - } - return this.add(cv.selector(x, y, w, h)); + return this.add(this.gm.getVar(cvar).selector(x, y, w, h)); } public void draw() { @@ -315,7 +308,7 @@ public abstract class Gui { Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010); } else { - Drawing.drawScaledBackground(this.gm, DIRT_BACKGROUND); + Drawing.drawScaled(this.gm, DIRT_BACKGROUND); } } diff --git a/java/src/game/gui/GuiMenu.java b/java/src/game/gui/GuiMenu.java index b551652..3a16edd 100644 --- a/java/src/game/gui/GuiMenu.java +++ b/java/src/game/gui/GuiMenu.java @@ -77,7 +77,7 @@ public class GuiMenu extends Gui { }, "Info / Über / Mitwirkende") { public void drawHover() { if(GuiMenu.this.hacked == 10) { - Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, (this.gm.style.hover & 0xff000000) | 0x7f00ff); + Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x287f00ff); GuiMenu.this.rand.setSeed(((long)this.gm.mouse_x * 7652657L) ^ ((long)this.gm.mouse_y * 87262826276L)); int width = Drawing.getWidth("Hax!"); for(int z = 0; z < 64; z++) { diff --git a/java/src/game/gui/GuiStyle.java b/java/src/game/gui/GuiStyle.java index f6f1c30..931f0d7 100644 --- a/java/src/game/gui/GuiStyle.java +++ b/java/src/game/gui/GuiStyle.java @@ -3,41 +3,52 @@ package game.gui; import game.gui.element.ActButton; import game.gui.element.ActButton.Mode; import game.gui.element.Dropdown; +import game.gui.element.Element; import game.gui.element.SelectedButton; import game.gui.element.Slider; import game.gui.element.Switch; import game.gui.element.Textbox; import game.gui.element.Textbox.Action; import game.gui.element.Toggle; +import game.vars.CVar; +import game.vars.ColorVar; public class GuiStyle extends GuiOptions implements Dropdown.Callback, ActButton.Callback, Toggle.Callback, Switch.Callback, Slider.Callback, Textbox.Callback { private static final String[] STYLE_CVARS = { - "color_hover", - "color_background_t", "color_button_top", "color_textbox_top", "color_border_top", - "color_press", - "color_background_b", "color_button_btm", "color_textbox_btm", "color_border_btm", - - "color_select", - "color_label_text", + "color_button_text", "color_textbox_text", - "color_cursor" + "color_label_text" }; protected GuiStyle() { } + protected Element addSelector(String cvar, int x, int y, int w, int h) { + CVar cv = this.gm.getVar(cvar); + if(cv instanceof ColorVar) { + ColorVar color = (ColorVar)cv; + if(!color.getDisplay().isEmpty()) + this.add(color.label(x, y - 20, w, 20)); + if(this.gm.style != Style.CUSTOM) + return this.add(new Textbox(x, y, w, h, true, color.getFieldValue(this.gm.style))); + else + return this.add(color.editor(x, y, w, h)); + } + return super.addSelector(cvar, x, y, w, h); + } + public void init(int width, int height) { int z; for(z = 0; z < STYLE_CVARS.length; z++) { - this.addSelector(STYLE_CVARS[z], 10 + (z % 5) * 190, 100 + z / 5 * 50, 180, 24); + this.addSelector(STYLE_CVARS[z], 10 + ((z % 3) + 1) * 190, 100 + z / 3 * 50, 180, 24); } z = 0; for(Style theme : Style.values()) { @@ -65,25 +76,30 @@ public class GuiStyle extends GuiOptions implements Dropdown.Callback, A this.add(new Slider(330, height - 34, 300, 24, 0, -20, 827, 60, 120, this, "SLIDER")); this.add(new Textbox(650, height - 34, 300, 24, 128, true, this, "FIELD")); - this.add(new ActButton(200, 100 + 3 * 50, 560, 24, new ActButton.Callback() { - public void use(ActButton elem, Mode action) { - if(GuiStyle.this.gm.style != Style.CUSTOM) { + if(this.gm.style != Style.CUSTOM) { + this.add(new ActButton(200, 100 + 3 * 50, 560, 24, new ActButton.Callback() { + public void use(ActButton elem, Mode action) { + if(GuiStyle.this.gm.style != Style.CUSTOM) { + GuiStyle.this.gm.style.copyToCustom(); + GuiStyle.this.gm.style = Style.CUSTOM; + GuiStyle.this.gm.setDirty(); + GuiStyle.this.gm.displayGuiScreen(GuiStyle.this); + } + } + }, "In angepassten Stil kopieren")); + } + else { + this.add(new ActButton(200, 100 + 3 * 50, 560, 24, new ActButton.Callback() { + public void use(ActButton elem, Mode action) { GuiStyle.this.gm.style = Style.CUSTOM; + for(String cvar : STYLE_CVARS) { + GuiStyle.this.gm.getVar(cvar).setDefault(); + } GuiStyle.this.gm.setDirty(); + GuiStyle.this.gm.displayGuiScreen(GuiStyle.this); } - GuiStyle.this.gm.displayGuiScreen(GuiStyle.this); - } - }, "Übernehmen")); - this.add(new ActButton(200, 140 + 3 * 50, 560, 24, new ActButton.Callback() { - public void use(ActButton elem, Mode action) { - GuiStyle.this.gm.style = Style.CUSTOM; - for(String cvar : STYLE_CVARS) { - GuiStyle.this.gm.getVar(cvar).setDefault(); - } - GuiStyle.this.gm.setDirty(); - GuiStyle.this.gm.displayGuiScreen(GuiStyle.this); - } - }, "Zurücksetzen")); + }, "Angepassten Stil zurücksetzen")); + } super.init(width, height); } diff --git a/java/src/game/gui/Style.java b/java/src/game/gui/Style.java index 4c2ada5..79e328c 100644 --- a/java/src/game/gui/Style.java +++ b/java/src/game/gui/Style.java @@ -7,7 +7,7 @@ import game.vars.Variable; import game.vars.Variable.IntType; public enum Style implements IStringSerializable, Displayable { - DEFAULT("default", "Glänzend (Standard)"), GRAY("gray", "Grau"), BLUE("blue", "Blau"), CUSTOM("custom", "Angepasst"); + DEFAULT("default", "Standard"), SHINY("shiny", "Glänzend"), GRAY("gray", "Grau"), BLUE("blue", "Blau"), CUSTOM("custom", "Angepasst"); public final String id; public final String name; @@ -17,69 +17,52 @@ public enum Style implements IStringSerializable, Displayable { this.name = name; } - @Variable(type = IntType.COLOR, name = "color_border_top", category = CVarCategory.STYLE, display = "Umrahmung") + @Variable(type = IntType.COLOR, name = "color_border_top", category = CVarCategory.STYLE, display = "Umrahmung oben / l.") public int brdr_top; - @Variable(type = IntType.COLOR, name = "color_border_btm", category = CVarCategory.STYLE) + @Variable(type = IntType.COLOR, name = "color_border_btm", category = CVarCategory.STYLE, display = "Umrahmung unten / r.") public int brdr_btm; - @Variable(type = IntType.COLOR, name = "color_button_top", category = CVarCategory.STYLE, display = "Knopf") + @Variable(type = IntType.COLOR, name = "color_button_top", category = CVarCategory.STYLE, display = "Knopf oben") public int fill_top; - @Variable(type = IntType.COLOR, name = "color_button_btm", category = CVarCategory.STYLE) + @Variable(type = IntType.COLOR, name = "color_button_btm", category = CVarCategory.STYLE, display = "Knopf unten") public int fill_btm; - @Variable(type = IntType.COLOR, name = "color_textbox_top", category = CVarCategory.STYLE, display = "Textfeld") + @Variable(type = IntType.COLOR, name = "color_textbox_top", category = CVarCategory.STYLE, display = "Textfeld oben") public int field_top; - @Variable(type = IntType.COLOR, name = "color_textbox_btm", category = CVarCategory.STYLE) + @Variable(type = IntType.COLOR, name = "color_textbox_btm", category = CVarCategory.STYLE, display = "Textfeld unten") public int field_btm; @Variable(type = IntType.COLOR, name = "color_label_text", category = CVarCategory.STYLE, display = "Beschriftung") public int text_label; - @Variable(type = IntType.COLOR, name = "color_button_text", category = CVarCategory.STYLE, display = "Text Knopf") + @Variable(type = IntType.COLOR, name = "color_button_text", category = CVarCategory.STYLE, display = "Knopf Text") public int text_base; @Variable(type = IntType.COLOR, name = "color_textbox_text", category = CVarCategory.STYLE, display = "Textfeld Text") public int text_field; - - @Variable(type = IntType.COLOR, name = "color_background_t", category = CVarCategory.STYLE, display = "Hintergrund") - public int bg_top; - @Variable(type = IntType.COLOR, name = "color_background_b", category = CVarCategory.STYLE) - public int bg_btm; - - @Variable(type = IntType.ALPHA, name = "color_press", category = CVarCategory.STYLE, display = "Gedrückt") - public int press; - @Variable(type = IntType.ALPHA, name = "color_hover", category = CVarCategory.STYLE, display = "Gewählt") - public int hover; - @Variable(type = IntType.ALPHA, name = "color_select", category = CVarCategory.STYLE, display = "Textauswahl") - public int select; - @Variable(type = IntType.ALPHA, name = "color_cursor", category = CVarCategory.STYLE, display = "Textmarke") - public int cursor; static { DEFAULT + .border(0xa0a0a0, 0x202020) + .base(0x606060, 0x404040, 0xffffff, 0xefefef) + .field(0x000000, 0x101010, 0xffffff); + + SHINY .border(0xffffff, 0x3f3f3f) - .background(0x000000, 0x000000) .base(0x404040, 0x000000, 0xffffff, 0xefefef) - .field(0x000000, 0x202020, 0xdfdfdf) - .select(0x30ffffff, 0x28ffffff, 0x60dfdfdf, 0xffffffff); + .field(0x000000, 0x202020, 0xdfdfdf); GRAY .border(0x000000, 0x202020) - .background(0x404040, 0x0a0a0a) .base(0x808080, 0x000000, 0xffffff, 0xffffff) - .field(0x404040, 0x808080, 0xffffff) - .select(0x18ffffff, 0x288080ff, 0x808080ff, 0xff000000); + .field(0x404040, 0x808080, 0xffffff); BLUE .border(0x0000df, 0x300020) - .background(0x20208f, 0x0a0a2d) .base(0x2020a0, 0x000020, 0x8fffaf, 0x00cfaf) - .field(0x505090, 0x406060, 0xcfdfff) - .select(0x288f00ff, 0x28c080ff, 0x604020ff, 0xff2fff6f); + .field(0x505090, 0x406060, 0xcfdfff); CUSTOM .border(0x000000, 0x000000) - .background(0x404040, 0x404040) .base(0x808080, 0x808080, 0xffffff, 0xffffff) - .field(0x808080, 0x808080, 0xffffff) - .select(0x18ffffff, 0x288080ff, 0x808080ff, 0xff000000); + .field(0x808080, 0x808080, 0xffffff); } private Style border(int top, int btm) { @@ -88,12 +71,6 @@ public enum Style implements IStringSerializable, Displayable { return this; } - private Style background(int top, int btm) { - this.bg_top = top | 0xff000000; - this.bg_btm = btm | 0xff000000; - return this; - } - private Style base(int top, int btm, int text, int label) { this.fill_top = top | 0xff000000; this.fill_btm = btm | 0xff000000; @@ -109,14 +86,6 @@ public enum Style implements IStringSerializable, Displayable { return this; } - private Style select(int prs, int hov, int sel, int cur) { - this.press = prs; - this.hover = hov; - this.select = sel; - this.cursor = cur; - return this; - } - public String getName() { return this.id; } @@ -124,4 +93,11 @@ public enum Style implements IStringSerializable, Displayable { public String getDisplay() { return this.name; } + + public void copyToCustom() { + CUSTOM + .border(this.brdr_top, this.brdr_btm) + .base(this.fill_top, this.fill_btm, this.text_base, this.text_label) + .field(this.field_top, this.field_btm, this.text_field); + } } diff --git a/java/src/game/gui/container/GuiContainer.java b/java/src/game/gui/container/GuiContainer.java index 5ac44bf..ce2a976 100755 --- a/java/src/game/gui/container/GuiContainer.java +++ b/java/src/game/gui/container/GuiContainer.java @@ -1111,7 +1111,7 @@ public abstract class GuiContainer extends Gui } public void drawBackground() { - Drawing.drawRect2GradBorder(this.container_x, this.container_y, this.container_w, this.container_h, 0xff3f3f3f, 0xff000000, 0xff7f7f7f, 0xff4f4f4f, 0xff4f4f4f, 0xff1f1f1f); + Drawing.drawRectBorder(this.container_x, this.container_y, this.container_w, this.container_h, 0xff3f3f3f, 0xff000000, 0xff7f7f7f, 0xff1f1f1f); } diff --git a/java/src/game/gui/element/Bar.java b/java/src/game/gui/element/Bar.java index b96c9aa..50546f9 100644 --- a/java/src/game/gui/element/Bar.java +++ b/java/src/game/gui/element/Bar.java @@ -24,7 +24,7 @@ public class Bar extends Fill { } protected void drawBackground() { - Drawing.drawGradient2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, this.gm.style.brdr_top, this.gm.style.brdr_btm); + Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm); if(this.progress > 0) Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.progress, this.size_y - 4, this.color | 0xff000000, Util.mixColor(this.color | 0xff000000, 0xff000000)); } diff --git a/java/src/game/gui/element/Dropdown.java b/java/src/game/gui/element/Dropdown.java index 716e2b3..33280de 100644 --- a/java/src/game/gui/element/Dropdown.java +++ b/java/src/game/gui/element/Dropdown.java @@ -1,6 +1,7 @@ package game.gui.element; import game.gui.Font; +import game.gui.Gui; import game.renderer.Drawing; import game.util.Displayable; import game.util.ExtMath; @@ -59,7 +60,7 @@ public class Dropdown extends Element { public void drawHover() { int m = ((this.gm.mouse_y - (this.pos_y + this.margin_y1)) * Dropdown.this.values.length / (this.size_y - (this.margin_y1 + this.margin_y2))); // if((sys.mouse_y - this.pos_y) < (this.size_y - this.margin_y2)) - Drawing.drawRect(this.pos_x + this.margin_x1, this.pos_y + this.margin_y1 + ExtMath.clampi(m, 0, Dropdown.this.values.length - 1) * ((this.size_y - (this.margin_y1 + this.margin_y2)) / Dropdown.this.values.length), this.size_x - (this.margin_x1 + this.margin_x2), (this.size_y - (this.margin_y1 + this.margin_y2)) / Dropdown.this.values.length, this.gm.style.hover); + Drawing.drawRect(this.pos_x + this.margin_x1, this.pos_y + this.margin_y1 + ExtMath.clampi(m, 0, Dropdown.this.values.length - 1) * ((this.size_y - (this.margin_y1 + this.margin_y2)) / Dropdown.this.values.length), this.size_x - (this.margin_x1 + this.margin_x2), (this.size_y - (this.margin_y1 + this.margin_y2)) / Dropdown.this.values.length, Gui.HOVER_COLOR); } } diff --git a/java/src/game/gui/element/Element.java b/java/src/game/gui/element/Element.java index dcad5f9..c063994 100644 --- a/java/src/game/gui/element/Element.java +++ b/java/src/game/gui/element/Element.java @@ -192,7 +192,7 @@ public abstract class Element { } protected void drawBackground() { - Drawing.drawGradient2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_top, this.gm.style.fill_btm, this.gm.style.brdr_top, this.gm.style.brdr_btm); + Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_top, this.gm.style.fill_btm, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm); // Drawing.drawGradient2GradBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_top, this.gm.style.fill_btm, 0xff000000, // this.gm.style.brdr_top, Drawing.mixColor(this.gm.style.brdr_top, this.gm.style.brdr_btm), Drawing.mixColor(this.gm.style.brdr_top, this.gm.style.brdr_btm), this.gm.style.brdr_btm); } @@ -254,11 +254,11 @@ public abstract class Element { } public void drawHover() { - Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.hover); + Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, Gui.HOVER_COLOR); } public void drawPress() { - Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.press); + Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, Gui.PRESS_COLOR); } public void playSound() { diff --git a/java/src/game/gui/element/GuiList.java b/java/src/game/gui/element/GuiList.java index cd1ff3d..0c3ceb3 100755 --- a/java/src/game/gui/element/GuiList.java +++ b/java/src/game/gui/element/GuiList.java @@ -351,7 +351,7 @@ public abstract class GuiList extends Gui 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(), this.gm.style.hover); + Drawing.drawRect(x - 2, y1 - 2, this.getListWidth(), this.getSlotHeight(), Gui.HOVER_COLOR); } } diff --git a/java/src/game/gui/element/InventoryButton.java b/java/src/game/gui/element/InventoryButton.java index 0e4a219..6027422 100644 --- a/java/src/game/gui/element/InventoryButton.java +++ b/java/src/game/gui/element/InventoryButton.java @@ -9,7 +9,7 @@ public class InventoryButton extends Element { protected void drawBackground() { // Drawing.drawRect2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff6f6f6f, 0xffafafaf); - Drawing.drawRect2GradBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff6f6f6f, 0xff000000, 0xffafafaf, 0xff7f7f7f, 0xff7f7f7f, 0xff4f4f4f); + Drawing.drawRectBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff6f6f6f, 0xff000000, 0xffafafaf, 0xff4f4f4f); } protected void drawForeground(int x1, int y1, int x2, int y2) { diff --git a/java/src/game/gui/element/SelectedButton.java b/java/src/game/gui/element/SelectedButton.java index 930a348..2c25a52 100644 --- a/java/src/game/gui/element/SelectedButton.java +++ b/java/src/game/gui/element/SelectedButton.java @@ -13,6 +13,6 @@ public class SelectedButton extends ActButton { } protected void drawBackground() { - Drawing.drawGradient2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, this.gm.style.brdr_top, this.gm.style.brdr_btm); + Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm); } } diff --git a/java/src/game/gui/element/Slider.java b/java/src/game/gui/element/Slider.java index 932936c..4e58fac 100644 --- a/java/src/game/gui/element/Slider.java +++ b/java/src/game/gui/element/Slider.java @@ -161,7 +161,7 @@ public class Slider extends Element { } protected void drawBackground() { - Drawing.drawGradient2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, this.gm.style.brdr_top, this.gm.style.brdr_btm); - Drawing.drawGradient2Border(this.pos_x + this.position - (this.handle / 2), this.pos_y, this.handle, this.size_y, this.gm.style.fill_top, this.gm.style.fill_btm, this.gm.style.brdr_btm, this.gm.style.brdr_top); + Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm); + Drawing.drawGradientBorder(this.pos_x + this.position - (this.handle / 2), this.pos_y, this.handle, this.size_y, this.gm.style.fill_top, this.gm.style.fill_btm, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm); } } diff --git a/java/src/game/gui/element/Textbox.java b/java/src/game/gui/element/Textbox.java index 4710bdf..825438c 100644 --- a/java/src/game/gui/element/Textbox.java +++ b/java/src/game/gui/element/Textbox.java @@ -68,6 +68,10 @@ public class Textbox extends Element { public Textbox(int x, int y, int w, int h, String text) { this(x, y, w, h, Integer.MAX_VALUE, false, false, null, null, text); } + + public Textbox(int x, int y, int w, int h, boolean line, String text) { + this(x, y, w, h, Integer.MAX_VALUE, line, false, null, null, text); + } // public void setEditable(boolean editable) { // this.editable = editable; @@ -426,7 +430,7 @@ public class Textbox extends Element { } protected void drawBackground() { - Drawing.drawGradient2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.field_top, this.gm.style.field_btm, this.gm.style.brdr_top, this.gm.style.brdr_btm); + Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.field_top, this.gm.style.field_btm, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm); } protected void drawForeground(int x1, int y1, int x2, int y2) { @@ -436,7 +440,7 @@ public class Textbox extends Element { if(this.sel_start >= 0 && this.sel_end != this.sel_start) Drawing.txt_overlay(this.sel_start, this.sel_end, x1 + (this.xbreak ? 0 : this.text_x), y1 + this.text_y, x1 + this.text_x, y1 + this.text_y, - this.xbreak ? (this.pos_x + x2) : Integer.MAX_VALUE, Integer.MAX_VALUE, this.gm.style.select, this.text); + this.xbreak ? (this.pos_x + x2) : Integer.MAX_VALUE, Integer.MAX_VALUE, 0x808080ff, this.text); } public void drawOverlay() { @@ -447,7 +451,7 @@ public class Textbox extends Element { int y2 = this.size_y - (this.margin_y1 + this.margin_y2); GL11.glScissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2); GL11.glEnable(GL11.GL_SCISSOR_TEST); - Drawing.drawRect(this.cursorX, this.cursorY, 1, Font.YGLYPH, this.gm.style.cursor); + Drawing.drawRect(this.cursorX, this.cursorY, 1, Font.YGLYPH, 0xff000000 | (~Util.mixColor(this.gm.style.field_top, this.gm.style.field_btm))); GL11.glDisable(GL11.GL_SCISSOR_TEST); } } diff --git a/java/src/game/gui/element/Toggle.java b/java/src/game/gui/element/Toggle.java index f2acdf3..0079768 100644 --- a/java/src/game/gui/element/Toggle.java +++ b/java/src/game/gui/element/Toggle.java @@ -45,7 +45,7 @@ public class Toggle extends Element { protected void drawBackground() { if(this.value) - Drawing.drawGradient2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, this.gm.style.brdr_top, this.gm.style.brdr_btm); + Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm); else super.drawBackground(); } diff --git a/java/src/game/gui/world/GuiWorlds.java b/java/src/game/gui/world/GuiWorlds.java index 788f673..cef6363 100755 --- a/java/src/game/gui/world/GuiWorlds.java +++ b/java/src/game/gui/world/GuiWorlds.java @@ -608,7 +608,7 @@ public class GuiWorlds extends GuiList implements ActButton. { super.drawOverlays(); if(this.warningMessage != null) { - Drawing.drawBordered(this.gm.fb_x / 2 - 200, this.gm.fb_y - 84, 400, 18, 0xff000000, 0xff808080); + Drawing.drawRectBorder(this.gm.fb_x / 2 - 200, this.gm.fb_y - 85, 400, 20, 0xff000000, 0xff202020, 0xffffffff, 0xffa0a0a0); // drawRect(this.gm.fb_x / 2 - 191, this.gm.fb_y - 82, this.gm.fb_x / 2 + 191, this.gm.fb_y - 66, 0xff808080); // drawRect(this.gm.fb_x / 2 - 190, this.gm.fb_y - 81, this.gm.fb_x / 2 + 190, this.gm.fb_y - 67, 0xff000000); Drawing.drawTextCentered(this.warningMessage, this.gm.fb_x / 2, this.gm.fb_y - 84, 0xffff0000); diff --git a/java/src/game/renderer/Drawing.java b/java/src/game/renderer/Drawing.java index f5ed13b..934f5af 100644 --- a/java/src/game/renderer/Drawing.java +++ b/java/src/game/renderer/Drawing.java @@ -411,7 +411,7 @@ public abstract class Drawing { } - public static void drawGradient(int x, int y, int w, int h, int ctop, int cbottom) + public static void drawGradient(int x, int y, int w, int h, int top, int bottom) { GlState.disableTexture2D(); GlState.enableBlend(); @@ -420,10 +420,10 @@ public abstract class Drawing { GlState.shadeModel(GL11.GL_SMOOTH); RenderBuffer buf = Tessellator.getBuffer(); buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - buf.pos((double)(x + w), (double)y, 0.0).color(ctop).endVertex(); - buf.pos((double)x, (double)y, 0.0).color(ctop).endVertex(); - buf.pos((double)x, (double)(y + h), 0.0).color(cbottom).endVertex(); - buf.pos((double)(x + w), (double)(y + h), 0.0).color(cbottom).endVertex(); + buf.pos((double)(x + w), (double)y, 0.0).color(top).endVertex(); + buf.pos((double)x, (double)y, 0.0).color(top).endVertex(); + buf.pos((double)x, (double)(y + h), 0.0).color(bottom).endVertex(); + buf.pos((double)(x + w), (double)(y + h), 0.0).color(bottom).endVertex(); Tessellator.draw(); GlState.shadeModel(GL11.GL_FLAT); GlState.disableBlend(); @@ -431,25 +431,25 @@ public abstract class Drawing { GlState.enableTexture2D(); } - public static void draw4Gradient(int x, int y, int w, int h, int lopleft, int topright, int btmleft, int btmright) - { - GlState.disableTexture2D(); - GlState.enableBlend(); - GlState.disableAlpha(); - GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); - GlState.shadeModel(GL11.GL_SMOOTH); - RenderBuffer buf = Tessellator.getBuffer(); - buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - buf.pos((double)(x + w), (double)y, 0.0).color(topright).endVertex(); - buf.pos((double)x, (double)y, 0.0).color(lopleft).endVertex(); - buf.pos((double)x, (double)(y + h), 0.0).color(btmleft).endVertex(); - buf.pos((double)(x + w), (double)(y + h), 0.0).color(btmright).endVertex(); - Tessellator.draw(); - GlState.shadeModel(GL11.GL_FLAT); - GlState.disableBlend(); - GlState.enableAlpha(); - GlState.enableTexture2D(); - } +// public static void draw4Gradient(int x, int y, int w, int h, int topleft, int topright, int btmleft, int btmright) +// { +// GlState.disableTexture2D(); +// GlState.enableBlend(); +// GlState.disableAlpha(); +// GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); +// GlState.shadeModel(GL11.GL_SMOOTH); +// RenderBuffer buf = Tessellator.getBuffer(); +// buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); +// buf.pos((double)(x + w), (double)y, 0.0).color(topright).endVertex(); +// buf.pos((double)x, (double)y, 0.0).color(topleft).endVertex(); +// buf.pos((double)x, (double)(y + h), 0.0).color(btmleft).endVertex(); +// buf.pos((double)(x + w), (double)(y + h), 0.0).color(btmright).endVertex(); +// Tessellator.draw(); +// GlState.shadeModel(GL11.GL_FLAT); +// GlState.disableBlend(); +// GlState.enableAlpha(); +// GlState.enableTexture2D(); +// } public static void drawRect(int x, int y, int w, int h, int color) { @@ -473,29 +473,30 @@ public abstract class Drawing { GlState.color(1.0f, 1.0f, 1.0f, 1.0f); } - public static void drawBordered(int x, int y, int w, int h, int color, int border) { + public static void drawRectBorder(int x, int y, int w, int h, int color, int border, int topleft, int btmright) { + int corner = Util.mixColor(topleft, btmright); drawRect(x, y, w, h, border); - drawRect(x + 1, y + 1, w - 2, h - 2, color); - } - - public static void drawRect2GradBorder(int x, int y, int w, int h, int color, int border, int lopleft, int topright, int btmleft, int btmright) { - drawRect(x, y, w, h, border); - draw4Gradient(x + 1, y + 1, w - 2, h - 2, lopleft, topright, btmleft, btmright); + drawRect(x + 1, y + 1, w - 3, 1, topleft); + drawRect(x + 1, y + 2, 1, h - 3, topleft); + drawRect(x + w - 2, y + 1, 1, 1, corner); + drawRect(x + 1, y + h - 2, 1, 1, corner); + drawRect(x + w - 2, y + 2, 1, h - 3, btmright); + drawRect(x + 2, y + h - 2, w - 4, 1, btmright); drawRect(x + 2, y + 2, w - 4, h - 4, color); } - public static void drawGradient2GradBorder(int x, int y, int w, int h, int top, int bottom, int border, int lopleft, int topright, int btmleft, int btmright) { + public static void drawGradientBorder(int x, int y, int w, int h, int top, int bottom, int border, int topleft, int btmright) { + int corner = Util.mixColor(topleft, btmright); drawRect(x, y, w, h, border); - draw4Gradient(x + 1, y + 1, w - 2, h - 2, lopleft, topright, btmleft, btmright); + drawRect(x + 1, y + 1, w - 3, 1, topleft); + drawRect(x + 1, y + 2, 1, h - 3, topleft); + drawRect(x + w - 2, y + 1, 1, 1, corner); + drawRect(x + 1, y + h - 2, 1, 1, corner); + drawRect(x + w - 2, y + 2, 1, h - 3, btmright); + drawRect(x + 2, y + h - 2, w - 4, 1, btmright); drawGradient(x + 2, y + 2, w - 4, h - 4, top, bottom); } - public static void drawGradient2Border(int x, int y, int w, int h, int top, int bottom, int b_top, int b_bottom) { - drawGradient(x, y, w, h, b_top, b_bottom); - drawGradient(x + 1, y + 1, w - 2, h - 2, top, bottom); - } - - public static int getWidth(String str) { return getSize(str).xpos; } @@ -542,11 +543,11 @@ public abstract class Drawing { drawText(str, x - size.xpos / 2, y - size.ypos, color); } - public static void drawScaledBackground(Game gm, String texture) { - drawScaledBackground(gm, texture, 0, 0, gm.fb_x, gm.fb_y); + public static void drawScaled(Game gm, String texture) { + drawScaled(gm, texture, 0, 0, gm.fb_x, gm.fb_y); } - public static void drawScaledBackground(Game gm, String texture, double x, double y, double width, double height) { + public static void drawScaled(Game gm, String texture, double x, double y, double width, double height) { GlState.enableTexture2D(); GlState.disableLighting(); GlState.disableFog(); diff --git a/java/src/game/vars/ColorVar.java b/java/src/game/vars/ColorVar.java index 4a98027..0651922 100644 --- a/java/src/game/vars/ColorVar.java +++ b/java/src/game/vars/ColorVar.java @@ -3,6 +3,7 @@ package game.vars; import java.lang.reflect.Field; import game.color.TextColor; +import game.gui.Style; import game.gui.element.Label; import game.gui.element.Slider; import game.gui.element.Textbox; @@ -48,4 +49,13 @@ public class ColorVar extends IntVar { } }, this.format()); } + + public String getFieldValue(Style style) { + try { + return this.formatValue(this.field.getInt(style)); + } + catch(IllegalArgumentException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } }