Added ColorScheme to manage GUI colors; changed BG color slightly
This commit is contained in:
parent
e6e55a6c40
commit
0638794a80
@ -25,6 +25,7 @@ import ru.windcorp.progressia.client.graphics.backend.RenderTaskQueue;
|
|||||||
import ru.windcorp.progressia.client.graphics.flat.FlatRenderProgram;
|
import ru.windcorp.progressia.client.graphics.flat.FlatRenderProgram;
|
||||||
import ru.windcorp.progressia.client.graphics.font.GNUUnifontLoader;
|
import ru.windcorp.progressia.client.graphics.font.GNUUnifontLoader;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.ColorScheme;
|
||||||
import ru.windcorp.progressia.client.graphics.texture.Atlases;
|
import ru.windcorp.progressia.client.graphics.texture.Atlases;
|
||||||
import ru.windcorp.progressia.client.graphics.world.WorldRenderProgram;
|
import ru.windcorp.progressia.client.graphics.world.WorldRenderProgram;
|
||||||
import ru.windcorp.progressia.client.localization.Localizer;
|
import ru.windcorp.progressia.client.localization.Localizer;
|
||||||
@ -51,6 +52,7 @@ public class ClientProxy implements Proxy {
|
|||||||
throw CrashReports.report(e, "ClientProxy failed");
|
throw CrashReports.report(e, "ClientProxy failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorScheme.load(ResourceManager.getResource("assets/default.colorScheme"));
|
||||||
Localizer.getInstance().setLanguage("en-US");
|
Localizer.getInstance().setLanguage("en-US");
|
||||||
|
|
||||||
TestContent.registerContent();
|
TestContent.registerContent();
|
||||||
|
@ -34,13 +34,7 @@ public class Colors {
|
|||||||
DEBUG_BLUE = toVector(0xFF0000FF),
|
DEBUG_BLUE = toVector(0xFF0000FF),
|
||||||
DEBUG_CYAN = toVector(0xFF00FFFF),
|
DEBUG_CYAN = toVector(0xFF00FFFF),
|
||||||
DEBUG_MAGENTA = toVector(0xFFFF00FF),
|
DEBUG_MAGENTA = toVector(0xFFFF00FF),
|
||||||
DEBUG_YELLOW = toVector(0xFFFFFF00),
|
DEBUG_YELLOW = toVector(0xFFFFFF00);
|
||||||
|
|
||||||
LIGHT_GRAY = toVector(0xFFCBCBD0),
|
|
||||||
BLUE = toVector(0xFF37A2E6),
|
|
||||||
HOVER_BLUE = toVector(0xFFC3E4F7),
|
|
||||||
DISABLED_GRAY = toVector(0xFFE5E5E5),
|
|
||||||
DISABLED_BLUE = toVector(0xFFB2D8ED);
|
|
||||||
|
|
||||||
public static Vec4 toVector(int argb) {
|
public static Vec4 toVector(int argb) {
|
||||||
return toVector(argb, new Vec4());
|
return toVector(argb, new Vec4());
|
||||||
|
@ -18,10 +18,8 @@
|
|||||||
|
|
||||||
package ru.windcorp.progressia.client.graphics.gui;
|
package ru.windcorp.progressia.client.graphics.gui;
|
||||||
|
|
||||||
import glm.vec._4.Vec4;
|
|
||||||
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
|
||||||
|
|
||||||
public class Button extends BasicButton {
|
public class Button extends BasicButton {
|
||||||
|
|
||||||
@ -39,45 +37,26 @@ public class Button extends BasicButton {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assembleSelf(RenderTarget target) {
|
protected void assembleSelf(RenderTarget target) {
|
||||||
// Border
|
String state;
|
||||||
|
if (!isEnabled()) {
|
||||||
Vec4 borderColor;
|
state = "Disabled";
|
||||||
if (isPressed() || isHovered() || isFocused()) {
|
} else if (isPressed()) {
|
||||||
borderColor = Colors.BLUE;
|
state = "Pressed";
|
||||||
|
} else if (isHovered()) {
|
||||||
|
state = "Hovered";
|
||||||
|
} else if (isFocused()) {
|
||||||
|
state = "Focused";
|
||||||
} else {
|
} else {
|
||||||
borderColor = Colors.LIGHT_GRAY;
|
state = "Inactive";
|
||||||
}
|
}
|
||||||
target.fill(getX(), getY(), getWidth(), getHeight(), borderColor);
|
|
||||||
|
// Border
|
||||||
|
target.fill(getX(), getY(), getWidth(), getHeight(), ColorScheme.get("Core:ButtonBorder" + state));
|
||||||
|
|
||||||
// Inside area
|
// Inside area
|
||||||
|
target.fill(getX() + 2, getY() + 2, getWidth() - 4, getHeight() - 4, ColorScheme.get("Core:ButtonFill" + state));
|
||||||
if (isPressed()) {
|
|
||||||
// Do nothing
|
|
||||||
} else {
|
|
||||||
Vec4 backgroundColor;
|
|
||||||
if (isHovered() && isEnabled()) {
|
|
||||||
backgroundColor = Colors.HOVER_BLUE;
|
|
||||||
} else {
|
|
||||||
backgroundColor = Colors.WHITE;
|
|
||||||
}
|
|
||||||
target.fill(getX() + 2, getY() + 2, getWidth() - 4, getHeight() - 4, backgroundColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change label font color
|
// Change label font color
|
||||||
|
getLabel().setFont(getLabel().getFont().withColor(ColorScheme.get("Core:ButtonText" + state)));
|
||||||
if (isPressed()) {
|
|
||||||
getLabel().setFont(getLabel().getFont().withColor(Colors.WHITE));
|
|
||||||
} else {
|
|
||||||
getLabel().setFont(getLabel().getFont().withColor(Colors.BLACK));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void postAssembleSelf(RenderTarget target) {
|
|
||||||
// Apply disable tint
|
|
||||||
|
|
||||||
if (!isEnabled()) {
|
|
||||||
target.fill(getX(), getY(), getWidth(), getHeight(), Colors.toVector(0x88FFFFFF));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
package ru.windcorp.progressia.client.graphics.gui;
|
package ru.windcorp.progressia.client.graphics.gui;
|
||||||
|
|
||||||
import glm.vec._2.i.Vec2i;
|
import glm.vec._2.i.Vec2i;
|
||||||
import glm.vec._4.Vec4;
|
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
|
||||||
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
||||||
@ -43,34 +41,28 @@ public class Checkbox extends BasicButton {
|
|||||||
int x = getX();
|
int x = getX();
|
||||||
int y = getY() + (getHeight() - size) / 2;
|
int y = getY() + (getHeight() - size) / 2;
|
||||||
|
|
||||||
// Border
|
String state;
|
||||||
|
if (!Checkbox.this.isEnabled()) {
|
||||||
Vec4 borderColor;
|
state = "Disabled";
|
||||||
if (Checkbox.this.isPressed() || Checkbox.this.isHovered() || Checkbox.this.isFocused()) {
|
} else if (Checkbox.this.isPressed()) {
|
||||||
borderColor = Colors.BLUE;
|
state = "Pressed";
|
||||||
|
} else if (Checkbox.this.isHovered()) {
|
||||||
|
state = "Hovered";
|
||||||
|
} else if (Checkbox.this.isFocused()) {
|
||||||
|
state = "Focused";
|
||||||
} else {
|
} else {
|
||||||
borderColor = Colors.LIGHT_GRAY;
|
state = "Inactive";
|
||||||
}
|
}
|
||||||
target.fill(x, y, size, size, borderColor);
|
|
||||||
|
// Border
|
||||||
|
target.fill(x, y, size, size, ColorScheme.get("Core:CheckboxBorder" + state));
|
||||||
|
|
||||||
// Inside area
|
// Inside area
|
||||||
|
target.fill(x + 2, y + 2, size - 4, size - 4, ColorScheme.get("Core:CheckboxFill" + state));
|
||||||
if (Checkbox.this.isPressed()) {
|
|
||||||
// Do nothing
|
|
||||||
} else {
|
|
||||||
Vec4 backgroundColor;
|
|
||||||
if (Checkbox.this.isHovered() && Checkbox.this.isEnabled()) {
|
|
||||||
backgroundColor = Colors.HOVER_BLUE;
|
|
||||||
} else {
|
|
||||||
backgroundColor = Colors.WHITE;
|
|
||||||
}
|
|
||||||
target.fill(x + 2, y + 2, size - 4, size - 4, backgroundColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// "Tick"
|
// "Tick"
|
||||||
|
|
||||||
if (Checkbox.this.isChecked()) {
|
if (Checkbox.this.isChecked()) {
|
||||||
target.fill(x + 4, y + 4, size - 8, size - 8, Colors.BLUE);
|
target.fill(x + 4, y + 4, size - 8, size - 8, ColorScheme.get("Core:CheckboxCheck" + state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,22 +120,21 @@ public class Checkbox extends BasicButton {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assembleSelf(RenderTarget target) {
|
protected void assembleSelf(RenderTarget target) {
|
||||||
// Change label font color
|
String state;
|
||||||
|
if (!Checkbox.this.isEnabled()) {
|
||||||
if (isPressed()) {
|
state = "Disabled";
|
||||||
getLabel().setFont(getLabel().getFont().withColor(Colors.BLUE));
|
} else if (Checkbox.this.isPressed()) {
|
||||||
|
state = "Pressed";
|
||||||
|
} else if (Checkbox.this.isHovered()) {
|
||||||
|
state = "Hovered";
|
||||||
|
} else if (Checkbox.this.isFocused()) {
|
||||||
|
state = "Focused";
|
||||||
} else {
|
} else {
|
||||||
getLabel().setFont(getLabel().getFont().withColor(Colors.BLACK));
|
state = "Inactive";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// Change label font color
|
||||||
protected void postAssembleSelf(RenderTarget target) {
|
getLabel().setFont(getLabel().getFont().withColor(ColorScheme.get("Core:CheckboxText" + state)));
|
||||||
// Apply disable tint
|
|
||||||
|
|
||||||
if (!isEnabled()) {
|
|
||||||
target.fill(getX(), getY(), getWidth(), getHeight(), Colors.toVector(0x88FFFFFF));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* Progressia
|
||||||
|
* Copyright (C) 2020-2022 Wind Corporation and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package ru.windcorp.progressia.client.graphics.gui;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import glm.vec._4.Vec4;
|
||||||
|
import ru.windcorp.jputil.SyntaxException;
|
||||||
|
import ru.windcorp.jputil.chars.StringUtil;
|
||||||
|
import ru.windcorp.progressia.common.resource.Resource;
|
||||||
|
import ru.windcorp.progressia.common.util.crash.CrashReports;
|
||||||
|
import ru.windcorp.progressia.common.util.namespaces.IllegalIdException;
|
||||||
|
import ru.windcorp.progressia.common.util.namespaces.NamespacedUtil;
|
||||||
|
|
||||||
|
public class ColorScheme {
|
||||||
|
|
||||||
|
private static Map<String, Vec4> defaultScheme;
|
||||||
|
|
||||||
|
public static Vec4 get(String key) {
|
||||||
|
Vec4 color = defaultScheme.get(key);
|
||||||
|
if (color == null) {
|
||||||
|
throw CrashReports.report(null, "ColorScheme does not contain color %s", key);
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load(Resource resource) {
|
||||||
|
Map<String, Vec4> tmpMap = new HashMap<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String fullLine : StringUtil.split(resource.readAsString(), '\n')) {
|
||||||
|
String line = fullLine.trim();
|
||||||
|
if (line.isEmpty() || line.startsWith("#")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = StringUtil.split(line, '=', 2);
|
||||||
|
if (parts[1] == null) {
|
||||||
|
throw new SyntaxException("Could not parse \"" + line + "\": '=' not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = parts[0].trim();
|
||||||
|
checkKeyName(key);
|
||||||
|
if (tmpMap.containsKey(key)) {
|
||||||
|
throw new SyntaxException("Duplicate key " + key);
|
||||||
|
}
|
||||||
|
|
||||||
|
String value = parts[1].trim();
|
||||||
|
Vec4 color;
|
||||||
|
|
||||||
|
if (value.startsWith("#")) {
|
||||||
|
color = parseValueAsHex(value);
|
||||||
|
} else if (value.startsWith("$")) {
|
||||||
|
color = parseValueAsReference(value, tmpMap);
|
||||||
|
} else {
|
||||||
|
throw new SyntaxException("Unknown value format \"" + value + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpMap.put(key, color);
|
||||||
|
}
|
||||||
|
} catch (SyntaxException e) {
|
||||||
|
throw CrashReports.report(e, "Could not load ColorScheme from %s", resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultScheme = ImmutableMap.copyOf(tmpMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkKeyName(String key) throws SyntaxException {
|
||||||
|
try {
|
||||||
|
NamespacedUtil.checkId(key);
|
||||||
|
} catch (IllegalIdException e) {
|
||||||
|
throw new SyntaxException("Illegal key name \"" + key + "\"", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int parseHex(String from, int start, int length) {
|
||||||
|
return Integer.parseInt(from.substring(start, start + length), 0x10);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vec4 parseValueAsHex(String value) throws SyntaxException {
|
||||||
|
int a = 0xFF;
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
|
switch (value.length() - 1) {
|
||||||
|
case 3:
|
||||||
|
// #RGB
|
||||||
|
r = parseHex(value, 1, 1) * 0x11;
|
||||||
|
g = parseHex(value, 2, 1) * 0x11;
|
||||||
|
b = parseHex(value, 3, 1) * 0x11;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
// #ARGB
|
||||||
|
a = parseHex(value, 1, 1) * 0x11;
|
||||||
|
r = parseHex(value, 2, 1) * 0x11;
|
||||||
|
g = parseHex(value, 3, 1) * 0x11;
|
||||||
|
b = parseHex(value, 4, 1) * 0x11;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
// #RRGGBB
|
||||||
|
r = parseHex(value, 1, 2);
|
||||||
|
g = parseHex(value, 3, 2);
|
||||||
|
b = parseHex(value, 5, 2);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
// #AARRGGBB
|
||||||
|
a = parseHex(value, 1, 2);
|
||||||
|
r = parseHex(value, 3, 2);
|
||||||
|
g = parseHex(value, 5, 2);
|
||||||
|
b = parseHex(value, 7, 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new SyntaxException("Could not parse hex color \"" + value + "\": expecting #RGB, #ARGB, #RRGGBB or #AARRGGBB");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Vec4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vec4 parseValueAsReference(String value, Map<String, Vec4> map) throws SyntaxException {
|
||||||
|
String otherKey = value.substring(1);
|
||||||
|
checkKeyName(otherKey);
|
||||||
|
if (!map.containsKey(otherKey)) {
|
||||||
|
throw new SyntaxException("Key $" + otherKey + " not found");
|
||||||
|
}
|
||||||
|
return map.get(otherKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,6 @@ package ru.windcorp.progressia.client.graphics.gui;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import glm.vec._4.Vec4;
|
import glm.vec._4.Vec4;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
|
||||||
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
||||||
|
|
||||||
public class Panel extends Group {
|
public class Panel extends Group {
|
||||||
@ -36,7 +35,7 @@ public class Panel extends Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Panel(String name, Layout layout) {
|
public Panel(String name, Layout layout) {
|
||||||
this(name, layout, Colors.WHITE, Colors.LIGHT_GRAY);
|
this(name, layout, ColorScheme.get("Core:Background"), ColorScheme.get("Core:Border"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,6 @@ import org.lwjgl.glfw.GLFW;
|
|||||||
|
|
||||||
import glm.vec._2.i.Vec2i;
|
import glm.vec._2.i.Vec2i;
|
||||||
import glm.vec._4.Vec4;
|
import glm.vec._4.Vec4;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
|
||||||
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
||||||
@ -52,34 +51,28 @@ public class RadioButton extends BasicButton {
|
|||||||
int x = getX();
|
int x = getX();
|
||||||
int y = getY() + (getHeight() - size) / 2;
|
int y = getY() + (getHeight() - size) / 2;
|
||||||
|
|
||||||
// Border
|
String state;
|
||||||
|
if (!RadioButton.this.isEnabled()) {
|
||||||
Vec4 borderColor;
|
state = "Disabled";
|
||||||
if (RadioButton.this.isPressed() || RadioButton.this.isHovered() || RadioButton.this.isFocused()) {
|
} else if (RadioButton.this.isPressed()) {
|
||||||
borderColor = Colors.BLUE;
|
state = "Pressed";
|
||||||
|
} else if (RadioButton.this.isHovered()) {
|
||||||
|
state = "Hovered";
|
||||||
|
} else if (RadioButton.this.isFocused()) {
|
||||||
|
state = "Focused";
|
||||||
} else {
|
} else {
|
||||||
borderColor = Colors.LIGHT_GRAY;
|
state = "Inactive";
|
||||||
}
|
}
|
||||||
cross(target, x, y, size, borderColor);
|
|
||||||
|
// Border
|
||||||
|
cross(target, x, y, size, ColorScheme.get("Core:RadioButtonBorder" + state));
|
||||||
|
|
||||||
// Inside area
|
// Inside area
|
||||||
|
cross(target, x + 2, y + 2, size - 4, ColorScheme.get("Core:RadioButtonFill" + state));
|
||||||
if (RadioButton.this.isPressed()) {
|
|
||||||
// Do nothing
|
|
||||||
} else {
|
|
||||||
Vec4 backgroundColor;
|
|
||||||
if (RadioButton.this.isHovered() && RadioButton.this.isEnabled()) {
|
|
||||||
backgroundColor = Colors.HOVER_BLUE;
|
|
||||||
} else {
|
|
||||||
backgroundColor = Colors.WHITE;
|
|
||||||
}
|
|
||||||
cross(target, x + 2, y + 2, size - 4, backgroundColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// "Tick"
|
// "Tick"
|
||||||
|
|
||||||
if (RadioButton.this.isChecked()) {
|
if (RadioButton.this.isChecked()) {
|
||||||
cross(target, x + 4, y + 4, size - 8, Colors.BLUE);
|
cross(target, x + 4, y + 4, size - 8, ColorScheme.get("Core:RadioButtonCheck" + state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +139,8 @@ public class RadioButton extends BasicButton {
|
|||||||
group.selectNext();
|
group.selectNext();
|
||||||
removeAction(group.listener);
|
removeAction(group.listener);
|
||||||
group.buttons.remove(this);
|
group.buttons.remove(this);
|
||||||
group.getSelected(); // Clear reference if this was the only button
|
// Clear reference if this was the only button in the group
|
||||||
// in the group
|
group.getSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.group = group;
|
this.group = group;
|
||||||
@ -183,22 +176,21 @@ public class RadioButton extends BasicButton {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assembleSelf(RenderTarget target) {
|
protected void assembleSelf(RenderTarget target) {
|
||||||
// Change label font color
|
String state;
|
||||||
|
if (!RadioButton.this.isEnabled()) {
|
||||||
if (isPressed()) {
|
state = "Disabled";
|
||||||
getLabel().setFont(getLabel().getFont().withColor(Colors.BLUE));
|
} else if (RadioButton.this.isPressed()) {
|
||||||
|
state = "Pressed";
|
||||||
|
} else if (RadioButton.this.isHovered()) {
|
||||||
|
state = "Hovered";
|
||||||
|
} else if (RadioButton.this.isFocused()) {
|
||||||
|
state = "Focused";
|
||||||
} else {
|
} else {
|
||||||
getLabel().setFont(getLabel().getFont().withColor(Colors.BLACK));
|
state = "Inactive";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// Change label font color
|
||||||
protected void postAssembleSelf(RenderTarget target) {
|
getLabel().setFont(getLabel().getFont().withColor(ColorScheme.get("Core:RadioButtonText" + state)));
|
||||||
// Apply disable tint
|
|
||||||
|
|
||||||
if (!isEnabled()) {
|
|
||||||
target.fill(getX(), getY(), getWidth(), getHeight(), Colors.toVector(0x88FFFFFF));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ package ru.windcorp.progressia.client.graphics.gui.menu;
|
|||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import glm.vec._2.i.Vec2i;
|
import glm.vec._2.i.Vec2i;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
|
||||||
import ru.windcorp.progressia.client.graphics.GUI;
|
import ru.windcorp.progressia.client.graphics.GUI;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.ColorScheme;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Component;
|
import ru.windcorp.progressia.client.graphics.gui.Component;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.GUILayer;
|
import ru.windcorp.progressia.client.graphics.gui.GUILayer;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Label;
|
import ru.windcorp.progressia.client.graphics.gui.Label;
|
||||||
@ -50,7 +50,7 @@ public class MenuLayer extends GUILayer {
|
|||||||
|
|
||||||
setCursorPolicy(CursorPolicy.REQUIRE);
|
setCursorPolicy(CursorPolicy.REQUIRE);
|
||||||
|
|
||||||
this.background = new Panel(name + ".Background", new LayoutAlign(10), Colors.toVector(0x66000000), null);
|
this.background = new Panel(name + ".Background", new LayoutAlign(10), ColorScheme.get("Core:MenuLayerTint"), null);
|
||||||
this.content = content;
|
this.content = content;
|
||||||
|
|
||||||
background.addChild(content);
|
background.addChild(content);
|
||||||
@ -76,12 +76,12 @@ public class MenuLayer extends GUILayer {
|
|||||||
protected void addTitle() {
|
protected void addTitle() {
|
||||||
String translationKey = "Layer" + getName() + ".Title";
|
String translationKey = "Layer" + getName() + ".Title";
|
||||||
MutableString titleText = new MutableStringLocalized(translationKey);
|
MutableString titleText = new MutableStringLocalized(translationKey);
|
||||||
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
Font titleFont = new Font().deriveBold().withColor(ColorScheme.get("Core:Text")).withAlign(0.5f);
|
||||||
|
|
||||||
Label label = new Label(getName() + ".Title", titleFont, titleText);
|
Label label = new Label(getName() + ".Title", titleFont, titleText);
|
||||||
getContent().addChild(label);
|
getContent().addChild(label);
|
||||||
|
|
||||||
Panel panel = new Panel(getName() + ".Title.Underscore", null, Colors.BLUE, null);
|
Panel panel = new Panel(getName() + ".Title.Underscore", null, ColorScheme.get("Core:Accent"), null);
|
||||||
panel.setLayout(new LayoutFill() {
|
panel.setLayout(new LayoutFill() {
|
||||||
@Override
|
@Override
|
||||||
public Vec2i calculatePreferredSize(Component c) {
|
public Vec2i calculatePreferredSize(Component c) {
|
||||||
|
@ -22,6 +22,7 @@ import ru.windcorp.progressia.Progressia;
|
|||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
import ru.windcorp.progressia.client.graphics.Colors;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Typeface;
|
import ru.windcorp.progressia.client.graphics.font.Typeface;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.ColorScheme;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.GUILayer;
|
import ru.windcorp.progressia.client.graphics.gui.GUILayer;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Label;
|
import ru.windcorp.progressia.client.graphics.gui.Label;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Group;
|
import ru.windcorp.progressia.client.graphics.gui.Group;
|
||||||
@ -37,7 +38,7 @@ public class LayerAbout extends GUILayer {
|
|||||||
Group group = new Group("ControlDisplays", new LayoutVertical(5));
|
Group group = new Group("ControlDisplays", new LayoutVertical(5));
|
||||||
|
|
||||||
Font font = new Font().withColor(Colors.WHITE).deriveOutlined().withAlign(Typeface.ALIGN_RIGHT);
|
Font font = new Font().withColor(Colors.WHITE).deriveOutlined().withAlign(Typeface.ALIGN_RIGHT);
|
||||||
Font aboutFont = font.withColor(0xFF37A3E6).deriveBold();
|
Font aboutFont = font.withColor(ColorScheme.get("Core:Accent")).deriveBold();
|
||||||
|
|
||||||
group.addChild(
|
group.addChild(
|
||||||
new Label(
|
new Label(
|
||||||
|
@ -20,11 +20,11 @@ package ru.windcorp.progressia.test;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import ru.windcorp.progressia.client.ClientState;
|
import ru.windcorp.progressia.client.ClientState;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
|
||||||
import ru.windcorp.progressia.client.graphics.GUI;
|
import ru.windcorp.progressia.client.graphics.GUI;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Button;
|
import ru.windcorp.progressia.client.graphics.gui.Button;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Checkbox;
|
import ru.windcorp.progressia.client.graphics.gui.Checkbox;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.ColorScheme;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Label;
|
import ru.windcorp.progressia.client.graphics.gui.Label;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.RadioButton;
|
import ru.windcorp.progressia.client.graphics.gui.RadioButton;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.RadioButtonGroup;
|
import ru.windcorp.progressia.client.graphics.gui.RadioButtonGroup;
|
||||||
@ -65,7 +65,7 @@ public class LayerButtonTest extends MenuLayer {
|
|||||||
|
|
||||||
getContent().getChild(getContent().getChildren().size() - 1).setEnabled(false);
|
getContent().getChild(getContent().getChildren().size() - 1).setEnabled(false);
|
||||||
|
|
||||||
getContent().addChild(new Label("Hint", new Font().withColor(Colors.LIGHT_GRAY), "This is a MenuLayer"));
|
getContent().addChild(new Label("Hint", new Font().withColor(ColorScheme.get("Core:Border")), "This is a MenuLayer"));
|
||||||
|
|
||||||
getContent().addChild(new Button("Continue", "Continue").addAction(b -> {
|
getContent().addChild(new Button("Continue", "Continue").addAction(b -> {
|
||||||
getCloseAction().run();
|
getCloseAction().run();
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package ru.windcorp.progressia.test;
|
package ru.windcorp.progressia.test;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.ColorScheme;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.GUILayer;
|
import ru.windcorp.progressia.client.graphics.gui.GUILayer;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Label;
|
import ru.windcorp.progressia.client.graphics.gui.Label;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.Panel;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.layout.LayoutAlign;
|
import ru.windcorp.progressia.client.graphics.gui.layout.LayoutAlign;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.layout.LayoutFill;
|
||||||
import ru.windcorp.progressia.client.localization.MutableString;
|
import ru.windcorp.progressia.client.localization.MutableString;
|
||||||
|
|
||||||
public class LayerTestText extends GUILayer {
|
public class LayerTestText extends GUILayer {
|
||||||
@ -13,11 +15,13 @@ public class LayerTestText extends GUILayer {
|
|||||||
private final Consumer<LayerTestText> remover;
|
private final Consumer<LayerTestText> remover;
|
||||||
|
|
||||||
public LayerTestText(String name, MutableString value, Consumer<LayerTestText> remover) {
|
public LayerTestText(String name, MutableString value, Consumer<LayerTestText> remover) {
|
||||||
super(name, new LayoutAlign(15));
|
super(name, new LayoutFill());
|
||||||
this.remover = remover;
|
this.remover = remover;
|
||||||
|
|
||||||
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
Panel panel = new Panel(name + ".Background", new LayoutAlign(15), ColorScheme.get("Core:Background"), null);
|
||||||
getRoot().addChild(new Label(name + ".Text", titleFont, value));
|
Font titleFont = new Font().deriveBold().withColor(ColorScheme.get("Core:Text")).withAlign(0.5f);
|
||||||
|
panel.addChild(new Label(name + ".Text", titleFont, value));
|
||||||
|
getRoot().addChild(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
80
src/main/resources/assets/default.colorScheme
Normal file
80
src/main/resources/assets/default.colorScheme
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# Default color scheme for Progressia
|
||||||
|
#
|
||||||
|
# Line format:
|
||||||
|
# KEY = VALUE
|
||||||
|
# KEY must be a legal ID
|
||||||
|
# VALUE may be one of the following:
|
||||||
|
# #RGB
|
||||||
|
# #ARGB
|
||||||
|
# #RRGGBB
|
||||||
|
# #AARRGGBB
|
||||||
|
# $OTHER_KEY
|
||||||
|
|
||||||
|
Core:Background = #EFF0F1
|
||||||
|
Core:Border = #CBCBD0
|
||||||
|
Core:DisabledBackground = $Core:Background
|
||||||
|
Core:DisabledBorder = #DEDFE1
|
||||||
|
Core:Accent = #37A3E6
|
||||||
|
Core:AccentLighter = #C3E4F7
|
||||||
|
|
||||||
|
Core:Text = #31363B
|
||||||
|
|
||||||
|
Core:ButtonBorderDisabled = $Core:DisabledBorder
|
||||||
|
Core:ButtonBorderPressed = $Core:Accent
|
||||||
|
Core:ButtonBorderHovered = $Core:Accent
|
||||||
|
Core:ButtonBorderFocused = $Core:Accent
|
||||||
|
Core:ButtonBorderInactive = $Core:Border
|
||||||
|
Core:ButtonFillDisabled = $Core:DisabledBackground
|
||||||
|
Core:ButtonFillPressed = $Core:Accent
|
||||||
|
Core:ButtonFillHovered = $Core:AccentLighter
|
||||||
|
Core:ButtonFillFocused = $Core:Background
|
||||||
|
Core:ButtonFillInactive = $Core:Background
|
||||||
|
Core:ButtonTextDisabled = $Core:DisabledBorder
|
||||||
|
Core:ButtonTextPressed = $Core:Background
|
||||||
|
Core:ButtonTextHovered = $Core:Text
|
||||||
|
Core:ButtonTextFocused = $Core:Text
|
||||||
|
Core:ButtonTextInactive = $Core:Text
|
||||||
|
|
||||||
|
Core:CheckboxBorderDisabled = $Core:DisabledBorder
|
||||||
|
Core:CheckboxBorderPressed = $Core:Accent
|
||||||
|
Core:CheckboxBorderHovered = $Core:Accent
|
||||||
|
Core:CheckboxBorderFocused = $Core:Accent
|
||||||
|
Core:CheckboxBorderInactive = $Core:Border
|
||||||
|
Core:CheckboxFillDisabled = $Core:DisabledBackground
|
||||||
|
Core:CheckboxFillPressed = $Core:Accent
|
||||||
|
Core:CheckboxFillHovered = $Core:AccentLighter
|
||||||
|
Core:CheckboxFillFocused = $Core:Background
|
||||||
|
Core:CheckboxFillInactive = $Core:Background
|
||||||
|
Core:CheckboxTextDisabled = $Core:DisabledBorder
|
||||||
|
Core:CheckboxTextPressed = $Core:Accent
|
||||||
|
Core:CheckboxTextHovered = $Core:Text
|
||||||
|
Core:CheckboxTextFocused = $Core:Text
|
||||||
|
Core:CheckboxTextInactive = $Core:Text
|
||||||
|
Core:CheckboxCheckDisabled = $Core:DisabledBorder
|
||||||
|
Core:CheckboxCheckPressed = $Core:Accent
|
||||||
|
Core:CheckboxCheckHovered = $Core:Accent
|
||||||
|
Core:CheckboxCheckFocused = $Core:Accent
|
||||||
|
Core:CheckboxCheckInactive = $Core:Accent
|
||||||
|
|
||||||
|
Core:RadioButtonBorderDisabled = $Core:DisabledBorder
|
||||||
|
Core:RadioButtonBorderPressed = $Core:Accent
|
||||||
|
Core:RadioButtonBorderHovered = $Core:Accent
|
||||||
|
Core:RadioButtonBorderFocused = $Core:Accent
|
||||||
|
Core:RadioButtonBorderInactive = $Core:Border
|
||||||
|
Core:RadioButtonFillDisabled = $Core:DisabledBackground
|
||||||
|
Core:RadioButtonFillPressed = $Core:Accent
|
||||||
|
Core:RadioButtonFillHovered = $Core:AccentLighter
|
||||||
|
Core:RadioButtonFillFocused = $Core:Background
|
||||||
|
Core:RadioButtonFillInactive = $Core:Background
|
||||||
|
Core:RadioButtonTextDisabled = $Core:DisabledBorder
|
||||||
|
Core:RadioButtonTextPressed = $Core:Accent
|
||||||
|
Core:RadioButtonTextHovered = $Core:Text
|
||||||
|
Core:RadioButtonTextFocused = $Core:Text
|
||||||
|
Core:RadioButtonTextInactive = $Core:Text
|
||||||
|
Core:RadioButtonCheckDisabled = $Core:DisabledBorder
|
||||||
|
Core:RadioButtonCheckPressed = $Core:Accent
|
||||||
|
Core:RadioButtonCheckHovered = $Core:Accent
|
||||||
|
Core:RadioButtonCheckFocused = $Core:Accent
|
||||||
|
Core:RadioButtonCheckInactive = $Core:Accent
|
||||||
|
|
||||||
|
Core:MenuLayerTint = #6000
|
Reference in New Issue
Block a user