aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/gui/elements/config
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-30 11:54:24 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-30 11:54:24 +0100
commit026aebb4748747f08d5088947056a75740550b17 (patch)
tree23583932e47825a91250ff60807d8a201b9557c3 /src/main/java/io/polyfrost/oneconfig/gui/elements/config
parent78fab84df48759e8968c477924b4bcc3b81e6cee (diff)
downloadOneConfig-026aebb4748747f08d5088947056a75740550b17.tar.gz
OneConfig-026aebb4748747f08d5088947056a75740550b17.tar.bz2
OneConfig-026aebb4748747f08d5088947056a75740550b17.zip
config elements
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/elements/config')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java53
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java34
2 files changed, 87 insertions, 0 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
new file mode 100644
index 0000000..705ab1a
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
@@ -0,0 +1,53 @@
+package io.polyfrost.oneconfig.gui.elements.config;
+
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.config.interfaces.BasicOption;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import io.polyfrost.oneconfig.utils.InputUtils;
+import io.polyfrost.oneconfig.utils.MathUtils;
+
+import java.lang.reflect.Field;
+
+public class ConfigDualOption extends BasicOption {
+ private float percentMove = 0f;
+ private final String left, right;
+
+ public ConfigDualOption(Field field, String name, int size, String left, String right) {
+ super(field, name, size);
+ this.left = left;
+ this.right = right;
+
+ }
+
+ @Override
+ public int getHeight() {
+ return 32;
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ boolean toggled = false;
+ try {
+ toggled = (boolean) get();
+ } catch (IllegalAccessException ignored) {
+ }
+ RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM);
+ RenderManager.drawRoundedRect(vg, x + 226, y, 256, 32, OneConfigConfig.GRAY_500, 12f);
+ int x1 = (int) (x + 228 + (percentMove * 128));
+ RenderManager.drawRoundedRect(vg, x1, y + 2, 124, 28, OneConfigConfig.BLUE_600, 10f);
+ RenderManager.drawString(vg, left, x + 290 - RenderManager.getTextWidth(vg, left, 14f, Fonts.INTER_MEDIUM) / 2, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, right, x + 418 - RenderManager.getTextWidth(vg, right, 14f, Fonts.INTER_MEDIUM) / 2, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM);
+
+ if (InputUtils.isAreaClicked(x + 226, y, 256, 32)) {
+ toggled = !toggled;
+ try {
+ set(toggled);
+ } catch (IllegalAccessException e) {
+ System.err.println("failed to write config value: class=" + this + " fieldWatching=" + field + " valueWrite=" + toggled);
+ e.printStackTrace();
+ }
+ }
+ percentMove = MathUtils.clamp(MathUtils.easeOut(percentMove, toggled ? 1f : 0f, 10));
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
new file mode 100644
index 0000000..39f8cf9
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
@@ -0,0 +1,34 @@
+package io.polyfrost.oneconfig.gui.elements.config;
+
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.config.interfaces.BasicOption;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+import java.lang.reflect.Field;
+
+public class ConfigUniSelector extends BasicOption {
+ String[] options;
+
+ public ConfigUniSelector(Field field, String name, int size, String[] options) {
+ super(field, name, size);
+ this.options = options;
+ }
+
+ @Override
+ public int getHeight() {
+ return 0;
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ int selected = 0;
+ try {
+ selected = (int) get();
+ } catch (IllegalAccessException ignored) {
+ }
+ RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, options[selected], x + 16, y + 16, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM);
+ RenderManager.drawImage(vg, "/assets/oneconfig/textures/arrow.png", x + 230, y + 7, 13, 22, OneConfigConfig.BLUE_400); // TODO
+ }
+}