gui disabled colors
This commit is contained in:
parent
6a6a820963
commit
3316c42ed8
10 changed files with 64 additions and 19 deletions
|
@ -112,7 +112,7 @@ public class GuiMenu extends Gui {
|
||||||
if(!this.gm.charEditor)
|
if(!this.gm.charEditor)
|
||||||
this.add(new NavButton(202, 28, 198, 24, GuiCharacters.INSTANCE, "Charakter"));
|
this.add(new NavButton(202, 28, 198, 24, GuiCharacters.INSTANCE, "Charakter"));
|
||||||
if(!this.gm.isRemote() && !this.gm.debugWorld) {
|
if(!this.gm.isRemote() && !this.gm.debugWorld) {
|
||||||
this.add(new Textbox(0, 56, 96, 24, 5, true, new Textbox.Callback() {
|
final Textbox portBox = this.add(new Textbox(0, 56, 96, 24, 5, true, new Textbox.Callback() {
|
||||||
public void use(Textbox elem, Action value) {
|
public void use(Textbox elem, Action value) {
|
||||||
if(value == Action.SEND || value == Action.UNFOCUS) {
|
if(value == Action.SEND || value == Action.UNFOCUS) {
|
||||||
int port = -1;
|
int port = -1;
|
||||||
|
@ -128,10 +128,12 @@ public class GuiMenu extends Gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "" + this.gm.port)); // "srv_port"
|
}, "" + this.gm.port)); // "srv_port"
|
||||||
|
portBox.enabled = this.gm.bind == -1;
|
||||||
this.add(new ActButton(100, 56, 300, 24, new ActButton.Callback() {
|
this.add(new ActButton(100, 56, 300, 24, new ActButton.Callback() {
|
||||||
public void use(ActButton elem, ActButton.Mode action) {
|
public void use(ActButton elem, ActButton.Mode action) {
|
||||||
GuiMenu.this.gm.bind(GuiMenu.this.gm.bind = (GuiMenu.this.gm.bind != -1 ? -1 : GuiMenu.this.gm.port));
|
GuiMenu.this.gm.bind(GuiMenu.this.gm.bind = (GuiMenu.this.gm.bind != -1 ? -1 : GuiMenu.this.gm.port));
|
||||||
elem.setText(GuiMenu.this.gm.bind != -1 ? "LAN-Welt schließen" : "LAN-Welt öffnen");
|
elem.setText(GuiMenu.this.gm.bind != -1 ? "LAN-Welt schließen" : "LAN-Welt öffnen");
|
||||||
|
portBox.enabled = GuiMenu.this.gm.bind == -1;
|
||||||
}
|
}
|
||||||
}, this.gm.bind != -1 ? "LAN-Welt schließen" : "LAN-Welt öffnen"));
|
}, this.gm.bind != -1 ? "LAN-Welt schließen" : "LAN-Welt öffnen"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,20 @@ public class Bar extends Fill {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBackground() {
|
protected void drawBackground() {
|
||||||
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.enabled)
|
||||||
if(this.progress > 0)
|
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.drawGradient(this.pos_x + 2, this.pos_y + 2, this.progress, this.size_y - 4, this.color | 0xff000000, Util.mixColor(this.color | 0xff000000, 0xff000000));
|
else
|
||||||
|
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_btm, 0.5f), Util.mulColor(this.gm.style.fill_top, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
|
if(this.progress > 0) {
|
||||||
|
if(this.enabled)
|
||||||
|
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));
|
||||||
|
else
|
||||||
|
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.progress, this.size_y - 4, Util.mulColor(this.color | 0xff000000, 0.5f), Util.mulColor(Util.mixColor(this.color | 0xff000000, 0xff000000), 0.5f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||||
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.gm.style.text_label);
|
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getMarginX() {
|
protected int getMarginX() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import game.init.SoundEvent;
|
||||||
import game.renderer.Drawing;
|
import game.renderer.Drawing;
|
||||||
import game.renderer.Drawing.Vec2i;
|
import game.renderer.Drawing.Vec2i;
|
||||||
import game.util.Formatter;
|
import game.util.Formatter;
|
||||||
|
import game.util.Util;
|
||||||
import game.window.Button;
|
import game.window.Button;
|
||||||
import game.window.Keysym;
|
import game.window.Keysym;
|
||||||
|
|
||||||
|
@ -192,13 +193,16 @@ public abstract class Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBackground() {
|
protected void drawBackground() {
|
||||||
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);
|
if(this.enabled)
|
||||||
|
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);
|
||||||
|
else
|
||||||
|
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_top, 0.5f), Util.mulColor(this.gm.style.fill_btm, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||||
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.gm.style.text_base);
|
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.enabled ? this.gm.style.text_base : Util.mulColor(this.gm.style.text_base, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw() {
|
public void draw() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package game.gui.element;
|
package game.gui.element;
|
||||||
|
|
||||||
import game.renderer.Drawing;
|
import game.renderer.Drawing;
|
||||||
|
import game.util.Util;
|
||||||
|
|
||||||
public class Label extends Fill {
|
public class Label extends Fill {
|
||||||
public Label(int x, int y, int w, int h, String text, boolean top, boolean left) {
|
public Label(int x, int y, int w, int h, String text, boolean top, boolean left) {
|
||||||
|
@ -19,7 +20,7 @@ public class Label extends Fill {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||||
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.gm.style.text_label);
|
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getMarginX() {
|
protected int getMarginX() {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package game.gui.element;
|
||||||
import game.Game;
|
import game.Game;
|
||||||
import game.gui.Gui;
|
import game.gui.Gui;
|
||||||
import game.renderer.Drawing;
|
import game.renderer.Drawing;
|
||||||
|
import game.util.Util;
|
||||||
|
|
||||||
public class NavButton extends ActButton {
|
public class NavButton extends ActButton {
|
||||||
private final Gui navGui;
|
private final Gui navGui;
|
||||||
|
@ -17,8 +18,12 @@ public class NavButton extends ActButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBackground() {
|
protected void drawBackground() {
|
||||||
if(this.gm.open == this.navGui)
|
if(this.gm.open == this.navGui) {
|
||||||
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.enabled)
|
||||||
|
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
|
||||||
|
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_btm, 0.5f), Util.mulColor(this.gm.style.fill_top, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
super.drawBackground();
|
super.drawBackground();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package game.gui.element;
|
package game.gui.element;
|
||||||
|
|
||||||
import game.renderer.Drawing;
|
import game.renderer.Drawing;
|
||||||
|
import game.util.Util;
|
||||||
|
|
||||||
public class SelectableButton extends ActButton {
|
public class SelectableButton extends ActButton {
|
||||||
private boolean selected;
|
private boolean selected;
|
||||||
|
@ -11,8 +12,12 @@ public class SelectableButton extends ActButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBackground() {
|
protected void drawBackground() {
|
||||||
if(this.selected)
|
if(this.selected) {
|
||||||
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.enabled)
|
||||||
|
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
|
||||||
|
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_btm, 0.5f), Util.mulColor(this.gm.style.fill_top, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
super.drawBackground();
|
super.drawBackground();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package game.gui.element;
|
||||||
import game.renderer.Drawing;
|
import game.renderer.Drawing;
|
||||||
import game.util.ExtMath;
|
import game.util.ExtMath;
|
||||||
import game.util.Formatter;
|
import game.util.Formatter;
|
||||||
|
import game.util.Util;
|
||||||
import game.window.Button;
|
import game.window.Button;
|
||||||
|
|
||||||
public class Slider extends Element {
|
public class Slider extends Element {
|
||||||
|
@ -161,7 +162,13 @@ public class Slider extends Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBackground() {
|
protected void drawBackground() {
|
||||||
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.enabled) {
|
||||||
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);
|
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);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_btm, 0.5f), Util.mulColor(this.gm.style.fill_top, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
|
Drawing.drawGradientBorder(this.pos_x + this.position - (this.handle / 2), this.pos_y, this.handle, this.size_y, Util.mulColor(this.gm.style.fill_top, 0.5f), Util.mulColor(this.gm.style.fill_btm, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,17 +430,20 @@ public class Textbox extends Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBackground() {
|
protected void drawBackground() {
|
||||||
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);
|
if(this.enabled)
|
||||||
|
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);
|
||||||
|
else
|
||||||
|
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.field_top, 0.5f), Util.mulColor(this.gm.style.field_btm, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||||
Drawing.txt_draw(x1 + (this.xbreak ? 0 : this.text_x), y1 + this.text_y,
|
Drawing.txt_draw(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.text_field, this.text);
|
this.xbreak ? (this.pos_x + x2) : Integer.MAX_VALUE, Integer.MAX_VALUE, this.enabled ? this.gm.style.text_field : Util.mulColor(this.gm.style.text_field, 0.5f), this.text);
|
||||||
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, 0x808080ff, this.text);
|
this.xbreak ? (this.pos_x + x2) : Integer.MAX_VALUE, Integer.MAX_VALUE, this.enabled ? 0x808080ff : 0x80404040, this.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawOverlay() {
|
public void drawOverlay() {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package game.gui.element;
|
||||||
|
|
||||||
import game.renderer.Drawing;
|
import game.renderer.Drawing;
|
||||||
import game.util.Formatter;
|
import game.util.Formatter;
|
||||||
|
import game.util.Util;
|
||||||
import game.window.Button;
|
import game.window.Button;
|
||||||
|
|
||||||
public class Toggle extends Element {
|
public class Toggle extends Element {
|
||||||
|
@ -44,8 +45,12 @@ public class Toggle extends Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBackground() {
|
protected void drawBackground() {
|
||||||
if(this.value)
|
if(this.value) {
|
||||||
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.enabled)
|
||||||
|
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
|
||||||
|
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_btm, 0.5f), Util.mulColor(this.gm.style.fill_top, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
super.drawBackground();
|
super.drawBackground();
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,4 +287,10 @@ int utf_len(const char *str) {
|
||||||
return ((((c1 >> 24 & 255) + (c2 >> 24 & 255)) / 2) << 24) | ((((c1 >> 16 & 255) + (c2 >> 16 & 255)) / 2) << 16) | ((((c1 >> 8 & 255) + (c2 >> 8 & 255)) / 2) << 8) |
|
return ((((c1 >> 24 & 255) + (c2 >> 24 & 255)) / 2) << 24) | ((((c1 >> 16 & 255) + (c2 >> 16 & 255)) / 2) << 16) | ((((c1 >> 8 & 255) + (c2 >> 8 & 255)) / 2) << 8) |
|
||||||
(((c1 & 255) + (c2 & 255)) / 2);
|
(((c1 & 255) + (c2 & 255)) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int mulColor(int color, float brightness) {
|
||||||
|
int mul = ExtMath.clampi((int)(brightness * 255.0f), 0, 255);
|
||||||
|
return (color & 0xff000000) | ((((color >> 16 & 255) * mul) / 255) << 16) | ((((color >> 8 & 255) * mul) / 255) << 8) |
|
||||||
|
(((color & 255) * mul) / 255);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue