aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/hud
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-07 17:56:57 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-07 17:56:57 +0200
commit813f3193c6d017701948d32caa9c5b7ed07d083d (patch)
tree1a735f41ddb03a9fe501ac9f2b032e6a91cbadcc /src/main/java/cc/polyfrost/oneconfig/hud
parent48d30c844ecbd132eee3a3c53597c9853d7cd4a3 (diff)
downloadOneConfig-813f3193c6d017701948d32caa9c5b7ed07d083d.tar.gz
OneConfig-813f3193c6d017701948d32caa9c5b7ed07d083d.tar.bz2
OneConfig-813f3193c6d017701948d32caa9c5b7ed07d083d.zip
finish config system rewrite
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/hud')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java
new file mode 100644
index 0000000..758249a
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java
@@ -0,0 +1,45 @@
+package cc.polyfrost.oneconfig.hud;
+
+import cc.polyfrost.oneconfig.config.annotations.HUD;
+import cc.polyfrost.oneconfig.config.core.ConfigUtils;
+import cc.polyfrost.oneconfig.config.elements.BasicOption;
+import cc.polyfrost.oneconfig.config.elements.OptionPage;
+import cc.polyfrost.oneconfig.gui.elements.config.*;
+import cc.polyfrost.oneconfig.internal.hud.HudCore;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class HUDUtils {
+ public static void addHudOptions(OptionPage page, Field field, Object instance) {
+ HUD hudAnnotation = field.getAnnotation(HUD.class);
+ BasicHud hud = (BasicHud) ConfigUtils.getField(field, instance);
+ if (hud == null) return;
+ HudCore.huds.add(hud);
+ String category = hudAnnotation.category();
+ String subcategory = hudAnnotation.subcategory();
+ ArrayList<BasicOption> options = ConfigUtils.getSubCategory(page, hudAnnotation.category(), hudAnnotation.subcategory()).options;
+ try {
+ options.add(new ConfigHeader(field, hud, hudAnnotation.name(), category, subcategory, 2));
+ options.add(new ConfigSwitch(hud.getClass().getField("enabled"), hud, "Enabled", category, subcategory, 2));
+ options.addAll(ConfigUtils.getClassOptions(hud));
+ options.add(new ConfigCheckbox(hud.getClass().getField("rounded"), hud, "Rounded corners", category, subcategory, 1));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled);
+ options.add(new ConfigCheckbox(hud.getClass().getField("border"), hud, "Outline/border", category, subcategory, 1));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled);
+ options.add(new ConfigColorElement(hud.getClass().getField("bgColor"), hud, "Background color:", category, subcategory, 1));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled);
+ options.add(new ConfigColorElement(hud.getClass().getField("borderColor"), hud, "Border color:", category, subcategory, 1));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled && hud.border);
+ options.add(new ConfigSlider(hud.getClass().getField("cornerRadius"), hud, "Corner radius:", category, subcategory, 2, 0, 10, 0));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled && hud.rounded);
+ options.add(new ConfigSlider(hud.getClass().getField("borderSize"), hud, "Border thickness:", category, subcategory, 2, 0, 10, 0));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled && hud.border);
+ options.add(new ConfigSlider(hud.getClass().getField("paddingX"), hud, "X-Padding", category, subcategory, 2, 0, 50, 0));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled);
+ options.add(new ConfigSlider(hud.getClass().getField("paddingY"), hud, "Y-Padding", category, subcategory, 2, 0, 50, 0));
+ options.get(options.size() - 1).addDependency(() -> hud.enabled);
+ } catch (NoSuchFieldException ignored) {
+ }
+ }
+}