ui border, fixes

This commit is contained in:
Sen 2025-03-20 15:33:08 +01:00
parent a378c69d26
commit 5300c9e4fc
18 changed files with 150 additions and 149 deletions

View file

@ -734,7 +734,7 @@ public class Game implements IThreadListener {
Drawing.drawTextboxRight(name, x + 250, y, 0x3f000000); 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.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.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)); Drawing.drawGradient(x + 2 + 246 - w, y + 20 + 2, w, 6, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
return y + 40; return y + 40;
} }
@ -743,7 +743,7 @@ public class Game implements IThreadListener {
Drawing.drawTextbox(name, x, y, 0x3f000000); Drawing.drawTextbox(name, x, y, 0x3f000000);
// Drawing.drawRectColor(x, y + 20, 250, 10, 0xff000000); // Drawing.drawRectColor(x, y + 20, 250, 10, 0xff000000);
// Drawing.drawRectColor(x, y + 20, (int)(250.0f * fill), 10, color | 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)); Drawing.drawGradient(x + 2, y + 20 + 2, (int)(246.0f * fill), 6, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
return y + 40; return y + 40;
} }
@ -767,7 +767,7 @@ public class Game implements IThreadListener {
int x = this.fb_x / 2 - 180 + n * 40 + 4; int x = this.fb_x / 2 - 180 + n * 40 + 4;
int y = this.fb_y - 40; int y = this.fb_y - 40;
// Drawing.drawRect2Border(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xffafafaf); // 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; 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.getHealth() + TextColor.GRAY + " / " + EntityLiving.getMaxHpColor(entity.getMaxHealth()) +
entity.getMaxHealth() + TextColor.GRAY + "]"; entity.getMaxHealth() + TextColor.GRAY + "]";
Drawing.drawTextboxCentered(s, x, y, 0x3f000000); 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.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, 400, 10, 0xff000000);
// Drawing.drawRectColor(x - 200, y + 20, , 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 name = (potion.isBadEffect() ? TextColor.ORANGE : TextColor.ACID) + potion.getDisplay() + PotionHelper.getPotionPotency(effect.getAmplifier());
String desc = TextColor.NEON + Potion.getDurationString(effect); String desc = TextColor.NEON + Potion.getDurationString(effect);
// Drawing.drawRectColor(x, y, 250, Font.DEFAULT.yglyph + 2, color | 0xff000000); // 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.drawText(name, x + 4, y + 2, 0xffffffff);
Drawing.drawTextRight(desc, x + 250 - 4, y + 2, 0xffffffff); Drawing.drawTextRight(desc, x + 250 - 4, y + 2, 0xffffffff);
y += 24; y += 24;
@ -937,7 +937,7 @@ public class Game implements IThreadListener {
if(this.open != null) if(this.open != null)
this.open.render(); this.open.render();
else if(this.theWorld == null || this.theWorld.hasNoChunks()) 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))) if(Bind.INFO.isDown() && (this.open == null || !(this.open.selected instanceof Textbox)))
this.drawInfo(); this.drawInfo();
if(this.hudOverlay && !(this.open instanceof GuiConsole)) if(this.hudOverlay && !(this.open instanceof GuiConsole))

View file

@ -12,14 +12,14 @@ import game.gui.element.Dropdown.Handle;
import game.gui.element.Element; import game.gui.element.Element;
import game.renderer.Drawing; import game.renderer.Drawing;
import game.renderer.GlState; import game.renderer.GlState;
import game.vars.CVar;
import game.vars.ColorVar;
import game.window.Bind; import game.window.Bind;
import game.window.Button; import game.window.Button;
import game.window.Keysym; import game.window.Keysym;
public abstract class Gui { public abstract class Gui {
public static final String DIRT_BACKGROUND = "textures/background.png"; 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(); 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) { protected Element addSelector(String cvar, int x, int y, int w, int h) {
CVar cv = this.gm.getVar(cvar); return this.add(this.gm.getVar(cvar).selector(x, y, w, h));
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));
} }
public void draw() { 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); Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010);
} }
else { else {
Drawing.drawScaledBackground(this.gm, DIRT_BACKGROUND); Drawing.drawScaled(this.gm, DIRT_BACKGROUND);
} }
} }

View file

@ -77,7 +77,7 @@ public class GuiMenu extends Gui {
}, "Info / Über / Mitwirkende") { }, "Info / Über / Mitwirkende") {
public void drawHover() { public void drawHover() {
if(GuiMenu.this.hacked == 10) { 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)); GuiMenu.this.rand.setSeed(((long)this.gm.mouse_x * 7652657L) ^ ((long)this.gm.mouse_y * 87262826276L));
int width = Drawing.getWidth("Hax!"); int width = Drawing.getWidth("Hax!");
for(int z = 0; z < 64; z++) { for(int z = 0; z < 64; z++) {

View file

@ -3,41 +3,52 @@ package game.gui;
import game.gui.element.ActButton; import game.gui.element.ActButton;
import game.gui.element.ActButton.Mode; import game.gui.element.ActButton.Mode;
import game.gui.element.Dropdown; import game.gui.element.Dropdown;
import game.gui.element.Element;
import game.gui.element.SelectedButton; import game.gui.element.SelectedButton;
import game.gui.element.Slider; import game.gui.element.Slider;
import game.gui.element.Switch; import game.gui.element.Switch;
import game.gui.element.Textbox; import game.gui.element.Textbox;
import game.gui.element.Textbox.Action; import game.gui.element.Textbox.Action;
import game.gui.element.Toggle; import game.gui.element.Toggle;
import game.vars.CVar;
import game.vars.ColorVar;
public class GuiStyle extends GuiOptions implements Dropdown.Callback<String>, ActButton.Callback, Toggle.Callback, Switch.Callback<String>, Slider.Callback, Textbox.Callback { public class GuiStyle extends GuiOptions implements Dropdown.Callback<String>, ActButton.Callback, Toggle.Callback, Switch.Callback<String>, Slider.Callback, Textbox.Callback {
private static final String[] STYLE_CVARS = { private static final String[] STYLE_CVARS = {
"color_hover",
"color_background_t",
"color_button_top", "color_button_top",
"color_textbox_top", "color_textbox_top",
"color_border_top", "color_border_top",
"color_press",
"color_background_b",
"color_button_btm", "color_button_btm",
"color_textbox_btm", "color_textbox_btm",
"color_border_btm", "color_border_btm",
"color_select",
"color_label_text",
"color_button_text", "color_button_text",
"color_textbox_text", "color_textbox_text",
"color_cursor" "color_label_text"
}; };
protected GuiStyle() { 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) { public void init(int width, int height) {
int z; int z;
for(z = 0; z < STYLE_CVARS.length; 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; z = 0;
for(Style theme : Style.values()) { for(Style theme : Style.values()) {
@ -65,25 +76,30 @@ public class GuiStyle extends GuiOptions implements Dropdown.Callback<String>, A
this.add(new Slider(330, height - 34, 300, 24, 0, -20, 827, 60, 120, this, "SLIDER")); 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 Textbox(650, height - 34, 300, 24, 128, true, this, "FIELD"));
this.add(new ActButton(200, 100 + 3 * 50, 560, 24, new ActButton.Callback() { if(this.gm.style != Style.CUSTOM) {
public void use(ActButton elem, Mode action) { this.add(new ActButton(200, 100 + 3 * 50, 560, 24, new ActButton.Callback() {
if(GuiStyle.this.gm.style != Style.CUSTOM) { 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; GuiStyle.this.gm.style = Style.CUSTOM;
for(String cvar : STYLE_CVARS) {
GuiStyle.this.gm.getVar(cvar).setDefault();
}
GuiStyle.this.gm.setDirty(); GuiStyle.this.gm.setDirty();
GuiStyle.this.gm.displayGuiScreen(GuiStyle.this);
} }
GuiStyle.this.gm.displayGuiScreen(GuiStyle.this); }, "Angepassten Stil zurücksetzen"));
} }
}, "Ü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"));
super.init(width, height); super.init(width, height);
} }

View file

@ -7,7 +7,7 @@ import game.vars.Variable;
import game.vars.Variable.IntType; import game.vars.Variable.IntType;
public enum Style implements IStringSerializable, Displayable { 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 id;
public final String name; public final String name;
@ -17,69 +17,52 @@ public enum Style implements IStringSerializable, Displayable {
this.name = name; 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; 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; 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; 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; 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; 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; public int field_btm;
@Variable(type = IntType.COLOR, name = "color_label_text", category = CVarCategory.STYLE, display = "Beschriftung") @Variable(type = IntType.COLOR, name = "color_label_text", category = CVarCategory.STYLE, display = "Beschriftung")
public int text_label; 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; public int text_base;
@Variable(type = IntType.COLOR, name = "color_textbox_text", category = CVarCategory.STYLE, display = "Textfeld Text") @Variable(type = IntType.COLOR, name = "color_textbox_text", category = CVarCategory.STYLE, display = "Textfeld Text")
public int text_field; 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 { static {
DEFAULT DEFAULT
.border(0xa0a0a0, 0x202020)
.base(0x606060, 0x404040, 0xffffff, 0xefefef)
.field(0x000000, 0x101010, 0xffffff);
SHINY
.border(0xffffff, 0x3f3f3f) .border(0xffffff, 0x3f3f3f)
.background(0x000000, 0x000000)
.base(0x404040, 0x000000, 0xffffff, 0xefefef) .base(0x404040, 0x000000, 0xffffff, 0xefefef)
.field(0x000000, 0x202020, 0xdfdfdf) .field(0x000000, 0x202020, 0xdfdfdf);
.select(0x30ffffff, 0x28ffffff, 0x60dfdfdf, 0xffffffff);
GRAY GRAY
.border(0x000000, 0x202020) .border(0x000000, 0x202020)
.background(0x404040, 0x0a0a0a)
.base(0x808080, 0x000000, 0xffffff, 0xffffff) .base(0x808080, 0x000000, 0xffffff, 0xffffff)
.field(0x404040, 0x808080, 0xffffff) .field(0x404040, 0x808080, 0xffffff);
.select(0x18ffffff, 0x288080ff, 0x808080ff, 0xff000000);
BLUE BLUE
.border(0x0000df, 0x300020) .border(0x0000df, 0x300020)
.background(0x20208f, 0x0a0a2d)
.base(0x2020a0, 0x000020, 0x8fffaf, 0x00cfaf) .base(0x2020a0, 0x000020, 0x8fffaf, 0x00cfaf)
.field(0x505090, 0x406060, 0xcfdfff) .field(0x505090, 0x406060, 0xcfdfff);
.select(0x288f00ff, 0x28c080ff, 0x604020ff, 0xff2fff6f);
CUSTOM CUSTOM
.border(0x000000, 0x000000) .border(0x000000, 0x000000)
.background(0x404040, 0x404040)
.base(0x808080, 0x808080, 0xffffff, 0xffffff) .base(0x808080, 0x808080, 0xffffff, 0xffffff)
.field(0x808080, 0x808080, 0xffffff) .field(0x808080, 0x808080, 0xffffff);
.select(0x18ffffff, 0x288080ff, 0x808080ff, 0xff000000);
} }
private Style border(int top, int btm) { private Style border(int top, int btm) {
@ -88,12 +71,6 @@ public enum Style implements IStringSerializable, Displayable {
return this; 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) { private Style base(int top, int btm, int text, int label) {
this.fill_top = top | 0xff000000; this.fill_top = top | 0xff000000;
this.fill_btm = btm | 0xff000000; this.fill_btm = btm | 0xff000000;
@ -109,14 +86,6 @@ public enum Style implements IStringSerializable, Displayable {
return this; 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() { public String getName() {
return this.id; return this.id;
} }
@ -124,4 +93,11 @@ public enum Style implements IStringSerializable, Displayable {
public String getDisplay() { public String getDisplay() {
return this.name; 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);
}
} }

View file

@ -1111,7 +1111,7 @@ public abstract class GuiContainer extends Gui
} }
public void drawBackground() { 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);
} }

View file

@ -24,7 +24,7 @@ public class Bar extends Fill {
} }
protected void drawBackground() { 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) 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)); 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));
} }

View file

@ -1,6 +1,7 @@
package game.gui.element; package game.gui.element;
import game.gui.Font; import game.gui.Font;
import game.gui.Gui;
import game.renderer.Drawing; import game.renderer.Drawing;
import game.util.Displayable; import game.util.Displayable;
import game.util.ExtMath; import game.util.ExtMath;
@ -59,7 +60,7 @@ public class Dropdown<T> extends Element {
public void drawHover() { 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))); 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)) // 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);
} }
} }

View file

@ -192,7 +192,7 @@ public abstract class Element {
} }
protected void drawBackground() { 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, // 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); // 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() { 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() { 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() { public void playSound() {

View file

@ -351,7 +351,7 @@ public abstract class GuiList<T extends ListEntry> extends Gui
boolean hover = this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == z; boolean hover = this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == z;
this.getListEntry(z).draw(x, y1, mouseXIn - x, mouseYIn - y1, hover); this.getListEntry(z).draw(x, y1, mouseXIn - x, mouseYIn - y1, hover);
if(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);
} }
} }

View file

@ -9,7 +9,7 @@ public class InventoryButton extends Element {
protected void drawBackground() { protected void drawBackground() {
// Drawing.drawRect2Border(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff6f6f6f, 0xffafafaf); // 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) { protected void drawForeground(int x1, int y1, int x2, int y2) {

View file

@ -13,6 +13,6 @@ public class SelectedButton extends ActButton {
} }
protected void drawBackground() { 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);
} }
} }

View file

@ -161,7 +161,7 @@ public class Slider extends Element {
} }
protected void drawBackground() { 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);
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.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);
} }
} }

View file

@ -68,6 +68,10 @@ public class Textbox extends Element {
public Textbox(int x, int y, int w, int h, String text) { 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); 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) { // public void setEditable(boolean editable) {
// this.editable = editable; // this.editable = editable;
@ -426,7 +430,7 @@ public class Textbox extends Element {
} }
protected void drawBackground() { 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) { 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) 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, 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, 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() { public void drawOverlay() {
@ -447,7 +451,7 @@ public class Textbox extends Element {
int y2 = this.size_y - (this.margin_y1 + this.margin_y2); 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.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); 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); GL11.glDisable(GL11.GL_SCISSOR_TEST);
} }
} }

View file

@ -45,7 +45,7 @@ public class Toggle extends Element {
protected void drawBackground() { protected void drawBackground() {
if(this.value) 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 else
super.drawBackground(); super.drawBackground();
} }

View file

@ -608,7 +608,7 @@ public class GuiWorlds extends GuiList<GuiWorlds.SaveInfo> implements ActButton.
{ {
super.drawOverlays(); super.drawOverlays();
if(this.warningMessage != null) { 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 - 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); // 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); Drawing.drawTextCentered(this.warningMessage, this.gm.fb_x / 2, this.gm.fb_y - 84, 0xffff0000);

View file

@ -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.disableTexture2D();
GlState.enableBlend(); GlState.enableBlend();
@ -420,10 +420,10 @@ public abstract class Drawing {
GlState.shadeModel(GL11.GL_SMOOTH); GlState.shadeModel(GL11.GL_SMOOTH);
RenderBuffer buf = Tessellator.getBuffer(); RenderBuffer buf = Tessellator.getBuffer();
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
buf.pos((double)(x + w), (double)y, 0.0).color(ctop).endVertex(); buf.pos((double)(x + w), (double)y, 0.0).color(top).endVertex();
buf.pos((double)x, (double)y, 0.0).color(ctop).endVertex(); buf.pos((double)x, (double)y, 0.0).color(top).endVertex();
buf.pos((double)x, (double)(y + h), 0.0).color(cbottom).endVertex(); buf.pos((double)x, (double)(y + h), 0.0).color(bottom).endVertex();
buf.pos((double)(x + w), (double)(y + h), 0.0).color(cbottom).endVertex(); buf.pos((double)(x + w), (double)(y + h), 0.0).color(bottom).endVertex();
Tessellator.draw(); Tessellator.draw();
GlState.shadeModel(GL11.GL_FLAT); GlState.shadeModel(GL11.GL_FLAT);
GlState.disableBlend(); GlState.disableBlend();
@ -431,25 +431,25 @@ public abstract class Drawing {
GlState.enableTexture2D(); GlState.enableTexture2D();
} }
public static void draw4Gradient(int x, int y, int w, int h, int lopleft, int topright, int btmleft, int btmright) // public static void draw4Gradient(int x, int y, int w, int h, int topleft, int topright, int btmleft, int btmright)
{ // {
GlState.disableTexture2D(); // GlState.disableTexture2D();
GlState.enableBlend(); // GlState.enableBlend();
GlState.disableAlpha(); // GlState.disableAlpha();
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); // GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
GlState.shadeModel(GL11.GL_SMOOTH); // GlState.shadeModel(GL11.GL_SMOOTH);
RenderBuffer buf = Tessellator.getBuffer(); // RenderBuffer buf = Tessellator.getBuffer();
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); // buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
buf.pos((double)(x + w), (double)y, 0.0).color(topright).endVertex(); // 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, 0.0).color(topleft).endVertex();
buf.pos((double)x, (double)(y + h), 0.0).color(btmleft).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(); // buf.pos((double)(x + w), (double)(y + h), 0.0).color(btmright).endVertex();
Tessellator.draw(); // Tessellator.draw();
GlState.shadeModel(GL11.GL_FLAT); // GlState.shadeModel(GL11.GL_FLAT);
GlState.disableBlend(); // GlState.disableBlend();
GlState.enableAlpha(); // GlState.enableAlpha();
GlState.enableTexture2D(); // GlState.enableTexture2D();
} // }
public static void drawRect(int x, int y, int w, int h, int color) 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); 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, y, w, h, border);
drawRect(x + 1, y + 1, w - 2, h - 2, color); 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);
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 + 1, y + h - 2, 1, 1, corner);
drawRect(x, y, w, h, border); drawRect(x + w - 2, y + 2, 1, h - 3, btmright);
draw4Gradient(x + 1, y + 1, w - 2, h - 2, lopleft, topright, btmleft, btmright); drawRect(x + 2, y + h - 2, w - 4, 1, btmright);
drawRect(x + 2, y + 2, w - 4, h - 4, color); 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); 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); 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) { public static int getWidth(String str) {
return getSize(str).xpos; return getSize(str).xpos;
} }
@ -542,11 +543,11 @@ public abstract class Drawing {
drawText(str, x - size.xpos / 2, y - size.ypos, color); drawText(str, x - size.xpos / 2, y - size.ypos, color);
} }
public static void drawScaledBackground(Game gm, String texture) { public static void drawScaled(Game gm, String texture) {
drawScaledBackground(gm, texture, 0, 0, gm.fb_x, gm.fb_y); 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.enableTexture2D();
GlState.disableLighting(); GlState.disableLighting();
GlState.disableFog(); GlState.disableFog();

View file

@ -3,6 +3,7 @@ package game.vars;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import game.color.TextColor; import game.color.TextColor;
import game.gui.Style;
import game.gui.element.Label; import game.gui.element.Label;
import game.gui.element.Slider; import game.gui.element.Slider;
import game.gui.element.Textbox; import game.gui.element.Textbox;
@ -48,4 +49,13 @@ public class ColorVar extends IntVar {
} }
}, this.format()); }, this.format());
} }
public String getFieldValue(Style style) {
try {
return this.formatValue(this.field.getInt(style));
}
catch(IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
} }