aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/config
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-04-27 18:36:51 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-04-27 18:36:51 +0200
commitee479dddc391a2cfb961ba1751e14884e933d3ff (patch)
treead88f551255b0069dfa46ec4aa4814d7f49e97c7 /src/main/java/io/polyfrost/oneconfig/config
parenta93ec306e83f51e121441cb00f04cd9bb36d6951 (diff)
downloadOneConfig-ee479dddc391a2cfb961ba1751e14884e933d3ff.tar.gz
OneConfig-ee479dddc391a2cfb961ba1751e14884e933d3ff.tar.bz2
OneConfig-ee479dddc391a2cfb961ba1751e14884e933d3ff.zip
Option page start
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/config')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/data/Mod.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java18
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java10
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;
}
}