aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-09-07 22:20:00 +0200
committerGitHub <noreply@github.com>2022-09-07 16:20:00 -0400
commit7c077e278b7266950a968a7e7f2f28b9a140ed96 (patch)
tree56b351874c48126f70e4ef6cbcf914ea832bdcd9 /src/main/java/cc/polyfrost/oneconfig/gui
parent17cfe96255f1ec3ab5609aa153d4abed2075c435 (diff)
downloadOneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.tar.gz
OneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.tar.bz2
OneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.zip
new: option descriptions (#127)
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java16
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java11
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java11
12 files changed, 46 insertions, 36 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
index fdd0c2f..681db60 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
@@ -42,20 +42,20 @@ import java.util.Arrays;
public class ConfigButton extends BasicOption {
private final BasicButton button;
- public ConfigButton(Runnable runnable, Object parent, String name, String category, String subcategory, int size, String text) {
- super(null, parent, name, category, subcategory, size);
+ public ConfigButton(Runnable runnable, Object parent, String name, String description, String category, String subcategory, int size, String text) {
+ super(null, parent, name, description, category, subcategory, size);
this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY);
this.button.setClickAction(runnable);
}
- public ConfigButton(Field field, Object parent, String name, String category, String subcategory, int size, String text) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigButton(Field field, Object parent, String name, String description, String category, String subcategory, int size, String text) {
+ super(field, parent, name, description, category, subcategory, size);
this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY);
this.button.setClickAction(getRunnableFromField(field, parent));
}
- public ConfigButton(Method method, Object parent, String name, String category, String subcategory, int size, String text) {
- super(null, parent, name, category, subcategory, size);
+ public ConfigButton(Method method, Object parent, String name, String description, String category, String subcategory, int size, String text) {
+ super(null, parent, name, description, category, subcategory, size);
this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY);
this.button.setClickAction(() -> {
try {
@@ -70,13 +70,13 @@ public class ConfigButton extends BasicOption {
public static ConfigButton create(Field field, Object parent) {
Button button = field.getAnnotation(Button.class);
- return new ConfigButton(field, parent, button.name(), button.category(), button.subcategory(), button.size(), button.text());
+ return new ConfigButton(field, parent, button.name(), button.description(), button.category(), button.subcategory(), button.size(), button.text());
}
public static ConfigButton create(Method method, Object parent) {
method.setAccessible(true);
Button button = method.getAnnotation(Button.class);
- return new ConfigButton(method, parent, button.name(), button.category(), button.subcategory(), button.size(), button.text());
+ return new ConfigButton(method, parent, button.name(), button.description(), button.category(), button.subcategory(), button.size(), button.text());
}
private static Runnable getRunnableFromField(Field field, Object parent) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
index 9cc60c9..6f3be32 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
@@ -48,13 +48,13 @@ public class ConfigCheckbox extends BasicOption {
private final ColorAnimation color = new ColorAnimation(ColorPalette.SECONDARY);
private Animation animation;
- public ConfigCheckbox(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigCheckbox(Field field, Object parent, String name, String description, String category, String subcategory, int size) {
+ super(field, parent, name, description, category, subcategory, size);
}
public static ConfigCheckbox create(Field field, Object parent) {
Checkbox checkbox = field.getAnnotation(Checkbox.class);
- return new ConfigCheckbox(field, parent, checkbox.name(), checkbox.category(), checkbox.subcategory(), checkbox.size());
+ return new ConfigCheckbox(field, parent, checkbox.name(), checkbox.description(), checkbox.category(), checkbox.subcategory(), checkbox.size());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
index 39780a1..5e92ddc 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
@@ -48,8 +48,8 @@ public class ConfigColorElement extends BasicOption {
private boolean open = false;
private final boolean allowAlpha;
- public ConfigColorElement(Field field, Object parent, String name, String category, String subcategory, int size, boolean allowAlpha) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigColorElement(Field field, Object parent, String name, String description, String category, String subcategory, int size, boolean allowAlpha) {
+ super(field, parent, name, description, category, subcategory, size);
hexField.setCentered(true);
alphaField.setCentered(true);
alphaField.onlyAcceptNumbers(true);
@@ -58,7 +58,7 @@ public class ConfigColorElement extends BasicOption {
public static ConfigColorElement create(Field field, Object parent) {
Color color = field.getAnnotation(Color.class);
- return new ConfigColorElement(field, parent, color.name(), color.category(), color.subcategory(), color.size(), color.allowAlpha());
+ return new ConfigColorElement(field, parent, color.name(), color.description(), color.category(), color.subcategory(), color.size(), color.allowAlpha());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
index 2660266..6dd463f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
@@ -49,14 +49,14 @@ public class ConfigDropdown extends BasicOption {
private boolean opened = false;
private Scissor inputScissor = null;
- public ConfigDropdown(Field field, Object parent, String name, String category, String subcategory, int size, String[] options) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigDropdown(Field field, Object parent, String name, String description, String category, String subcategory, int size, String[] options) {
+ super(field, parent, name, description, category, subcategory, size);
this.options = options;
}
public static ConfigDropdown create(Field field, Object parent) {
Dropdown dropdown = field.getAnnotation(Dropdown.class);
- return new ConfigDropdown(field, parent, dropdown.name(), dropdown.category(), dropdown.subcategory(), dropdown.size(), dropdown.options());
+ return new ConfigDropdown(field, parent, dropdown.name(), dropdown.description(), dropdown.category(), dropdown.subcategory(), dropdown.size(), dropdown.options());
}
@Override
@@ -189,4 +189,9 @@ public class ConfigDropdown extends BasicOption {
public int getHeight() {
return 32;
}
+
+ @Override
+ protected boolean shouldDrawDescription() {
+ return super.shouldDrawDescription() && !opened;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
index c8582d1..eb1dece 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
@@ -42,15 +42,15 @@ public class ConfigDualOption extends BasicOption {
private final String left, right;
private Animation posAnimation;
- public ConfigDualOption(Field field, Object parent, String name, String category, String subcategory, int size, String left, String right) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigDualOption(Field field, Object parent, String name, String description, String category, String subcategory, int size, String left, String right) {
+ super(field, parent, name, description, category, subcategory, size);
this.left = left;
this.right = right;
}
public static ConfigDualOption create(Field field, Object parent) {
DualOption dualOption = field.getAnnotation(DualOption.class);
- return new ConfigDualOption(field, parent, dualOption.name(), dualOption.category(), dualOption.subcategory(), dualOption.size(), dualOption.left(), dualOption.right());
+ return new ConfigDualOption(field, parent, dualOption.name(), dualOption.description(), dualOption.category(), dualOption.subcategory(), dualOption.size(), dualOption.left(), dualOption.right());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
index 45865fe..5e9f27f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
@@ -40,7 +40,7 @@ import java.lang.reflect.Field;
public class ConfigHeader extends BasicOption {
public ConfigHeader(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ super(field, parent, name, "", category, subcategory, size);
}
public static ConfigHeader create(Field field, Object parent) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
index c44c50d..94afaec 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
@@ -42,7 +42,7 @@ public class ConfigInfo extends BasicOption {
private final InfoType type;
public ConfigInfo(Field field, Object parent, String name, String category, String subcategory, int size, InfoType type) {
- super(field, parent, name, category, subcategory, size);
+ super(field, parent, name, "", category, subcategory, size);
this.type = type;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
index daa034f..491a99c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
@@ -45,15 +45,15 @@ public class ConfigKeyBind extends BasicOption {
private final BasicButton button;
private boolean clicked = false;
- public ConfigKeyBind(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigKeyBind(Field field, Object parent, String name, String description, String category, String subcategory, int size) {
+ super(field, parent, name, description, category, subcategory, size);
button = new BasicButton(256, 32, "", SVGs.KEYSTROKE, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY);
button.setToggleable(true);
}
public static ConfigKeyBind create(Field field, Object parent) {
KeyBind keyBind = field.getAnnotation(KeyBind.class);
- return new ConfigKeyBind(field, parent, keyBind.name(), keyBind.category(), keyBind.subcategory(), keyBind.size());
+ return new ConfigKeyBind(field, parent, keyBind.name(), keyBind.description(), keyBind.category(), keyBind.subcategory(), keyBind.size());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
index de10600..2d8c4f2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
@@ -48,13 +48,13 @@ public class ConfigPageButton extends BasicOption {
private final ColorAnimation backgroundColor = new ColorAnimation(ColorPalette.SECONDARY);
public ConfigPageButton(Field field, Object parent, String name, String description, String category, String subcategory, OptionPage page) {
- super(field, parent, name, category, subcategory, 2);
+ super(field, parent, name, "", category, subcategory, 2);
this.description = description;
this.page = new ModConfigPage(page);
}
public ConfigPageButton(Field field, Object parent, String name, String description, String category, String subcategory, Page page) {
- super(field, parent, name, category, subcategory, 2);
+ super(field, parent, name, "", category, subcategory, 2);
this.description = description;
this.page = page;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
index 4e2dda5..a4088d9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
@@ -46,8 +46,8 @@ public class ConfigSlider extends BasicOption {
private boolean dragging = false;
private boolean mouseWasDown = false;
- public ConfigSlider(Field field, Object parent, String name, String category, String subcategory, float min, float max, int step) {
- super(field, parent, name,category, subcategory, 2);
+ public ConfigSlider(Field field, Object parent, String name, String description, String category, String subcategory, float min, float max, int step) {
+ super(field, parent, name, description, category, subcategory, 2);
this.min = min;
this.max = max;
this.step = step;
@@ -56,7 +56,7 @@ public class ConfigSlider extends BasicOption {
public static ConfigSlider create(Field field, Object parent) {
Slider slider = field.getAnnotation(Slider.class);
- return new ConfigSlider(field, parent, slider.name(), slider.category(), slider.subcategory(), slider.min(), slider.max(), slider.step());
+ return new ConfigSlider(field, parent, slider.name(), slider.description(), slider.category(), slider.subcategory(), slider.min(), slider.max(), slider.step());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
index 9d13e3e..4ecc42b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
@@ -45,13 +45,13 @@ public class ConfigSwitch extends BasicOption {
private ColorAnimation color;
private Animation animation;
- public ConfigSwitch(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigSwitch(Field field, Object parent, String name, String description, String category, String subcategory, int size) {
+ super(field, parent, name, description, category, subcategory, size);
}
public static ConfigSwitch create(Field field, Object parent) {
Switch options = field.getAnnotation(Switch.class);
- return new ConfigSwitch(field, parent, options.name(), options.category(), options.subcategory(), options.size());
+ return new ConfigSwitch(field, parent, options.name(), options.description(), options.category(), options.subcategory(), options.size());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
index adb9131..4dc497b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
@@ -44,8 +44,8 @@ public class ConfigTextBox extends BasicOption {
private final boolean multiLine;
private final TextInputField textField;
- public ConfigTextBox(Field field, Object parent, String name, String category, String subcategory, int size, String placeholder, boolean secure, boolean multiLine) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigTextBox(Field field, Object parent, String name, String description, String category, String subcategory, int size, String placeholder, boolean secure, boolean multiLine) {
+ super(field, parent, name, category, description, subcategory, size);
this.secure = secure;
this.multiLine = multiLine;
this.textField = new TextInputField(size == 1 ? 256 : 640, multiLine ? 64 : 32, placeholder, multiLine, secure);
@@ -53,7 +53,7 @@ public class ConfigTextBox extends BasicOption {
public static ConfigTextBox create(Field field, Object parent) {
Text text = field.getAnnotation(Text.class);
- return new ConfigTextBox(field, parent, text.name(), text.category(), text.subcategory(), text.secure() || text.multiline() ? 2 : text.size(), text.placeholder(), text.secure(), text.multiline());
+ return new ConfigTextBox(field, parent, text.name(), text.description(), text.category(), text.subcategory(), text.secure() || text.multiline() ? 2 : text.size(), text.placeholder(), text.secure(), text.multiline());
}
@Override
@@ -97,4 +97,9 @@ public class ConfigTextBox extends BasicOption {
public int getHeight() {
return multiLine ? textField.getHeight() : 32;
}
+
+ @Override
+ protected boolean shouldDrawDescription() {
+ return super.shouldDrawDescription() && !textField.isToggled();
+ }
}