diff options
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/config')
4 files changed, 21 insertions, 14 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java b/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java index 435fb32..bd6c3f3 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java @@ -8,7 +8,7 @@ public class Mod { public final String creator; public final String version; public Config config; - public OptionPage defaultPage = new OptionPage(""); + public OptionPage defaultPage = new OptionPage("", this); /** * @param name Friendly name of the mod diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java index 021786d..8dcd9a1 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java @@ -1,5 +1,6 @@ package io.polyfrost.oneconfig.config.data; + import io.polyfrost.oneconfig.config.interfaces.BasicOption; import java.util.ArrayList; @@ -7,6 +8,7 @@ import java.util.HashMap; public class OptionPage { public final String name; + public final Mod mod; /** * Depth 1 = categories * Depth 2 = subcategories @@ -14,7 +16,8 @@ public class OptionPage { */ public final HashMap<String, HashMap<String, ArrayList<BasicOption>>> categories = new HashMap<>(); - public OptionPage(String name) { + public OptionPage(String name, Mod mod) { this.name = name; + this.mod = mod; } } diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java index 42c826e..5b6e2c0 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java @@ -1,12 +1,13 @@ package io.polyfrost.oneconfig.config.interfaces; +import io.polyfrost.oneconfig.gui.elements.BasicElement; + import java.lang.reflect.Field; @SuppressWarnings({"unused"}) public abstract class BasicOption { protected final Field field; protected final String name; - protected final String description; public final int size; /** @@ -14,13 +15,11 @@ public abstract class BasicOption { * * @param field variable attached to option (null for category) * @param name name of option - * @param description description of option * @param size size of option, 0 for single column, 1 for double. */ - public BasicOption(Field field, String name, String description, int size) { + public BasicOption(Field field, String name, int size) { this.field = field; this.name = name; - this.description = description; this.size = size; if (field != null) field.setAccessible(true); } @@ -52,10 +51,8 @@ public abstract class BasicOption { * @param vg NanoVG context * @param x x position * @param y y position - * @param mouseX x position of mouse - * @param mouseY y position of mouse */ - public abstract void draw(long vg, int x, int y, int mouseX, int mouseY); + public abstract void draw(long vg, int x, int y); /** * Function that gets called when mouse is clicked @@ -75,4 +72,11 @@ public abstract class BasicOption { */ protected void keyTyped(char typedChar, int keyCode) { } + + /** + * @return If the component has an option to render at half size + */ + public boolean hasHalfSize() { + return true; + } } diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java index 0539d5f..cbb7610 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java @@ -34,7 +34,7 @@ public class Config { if (Profiles.getProfileFile(configFile).exists()) load(); else save(); mod.config = this; - generateOptionList(this.getClass(), mod.defaultPage); + generateOptionList(this.getClass(), mod.defaultPage, mod); ConfigCore.oneConfigMods.add(mod); } @@ -66,7 +66,7 @@ public class Config { * @param clazz target class * @param page page to add options too */ - protected void generateOptionList(Class<?> clazz, OptionPage page) { + protected void generateOptionList(Class<?> clazz, OptionPage page, Mod mod) { for (Field field : clazz.getDeclaredFields()) { System.out.println(field); if (!field.isAnnotationPresent(Option.class)) { @@ -81,11 +81,11 @@ public class Config { ArrayList<BasicOption> options = page.categories.get(option.category()).get(option.subcategory()); switch (option.type()) { case PAGE: - OptionPage newPage = new OptionPage(option.name()); + OptionPage newPage = new OptionPage(option.name(), mod); try { field.setAccessible(true); Object object = field.get(clazz); - generateOptionList(object.getClass(), newPage); + generateOptionList(object.getClass(), newPage, mod); System.out.println(newPage.categories); options.add(new ConfigPage(field, option.name(), option.description(), option.size(), newPage)); } catch (IllegalAccessException e) { @@ -93,7 +93,7 @@ public class Config { } break; case SWITCH: - options.add(new ConfigSwitch(field, option.name(), option.description(), option.size())); + options.add(new ConfigSwitch(field, option.name(), option.size())); break; } } |