aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/config')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java8
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java4
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java3
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java4
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java3
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java3
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/data/ModType.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java21
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java9
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java6
13 files changed, 60 insertions, 22 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
index 3ebc876..bfb123a 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
@@ -14,7 +14,7 @@ public class OneConfigConfig extends Config {
public static String currentProfile = "Default Profile";
// TODO i dont know how this works so this is just gonna be here for now
- public static final int TRANSPARENT = new Color(0,0,0,0).getRGB(); // Transparent // button sidebar normal
+ public static final int TRANSPARENT = new Color(0, 0, 0, 0).getRGB(); // Transparent // button sidebar normal
public static final int GRAY_900 = new Color(13, 14, 15, 255).getRGB(); // Gray 900
public static final int GRAY_900_80 = new Color(13, 14, 15, 204).getRGB(); // Gray 900 80%
@@ -43,12 +43,6 @@ public class OneConfigConfig extends Config {
public static float CORNER_RADIUS = 12f;
-
-
-
-
-
-
public OneConfigConfig() {
super(null, "OneConfig.json");
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java
index 449d297..3ba1078 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java
@@ -9,6 +9,10 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface Button {
String name();
+
String description() default "";
+
String text() default "Button";
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java
index 05b5277..83b7af4 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java
@@ -9,5 +9,8 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
public @interface Category {
String name();
+
String description() default "";
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java
index feee4b4..6854bc2 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java
@@ -9,6 +9,10 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface ColorPicker {
String name();
+
String description() default "";
+
boolean allowAlpha() default true;
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java
index 5e1cd62..00a2e74 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java
@@ -9,5 +9,8 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface HudComponent {
String name();
+
String description() default "";
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java
index 8b476ab..00d88d8 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java
@@ -9,7 +9,12 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface Selector {
String name();
+
String description() default "";
+
String[] options();
+
int defaultSelection() default 0;
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java
index cf8bfcd..ea19da5 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java
@@ -9,8 +9,14 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface Slider {
String name();
+
String description() default "";
+
float min();
+
float max();
+
float precision();
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java
index 19ec1db..8ff2f11 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java
@@ -9,5 +9,8 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface Switch {
String name();
+
String description() default "";
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java
index 7b5837c..0df1426 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java
@@ -9,7 +9,12 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface TextField {
String name();
+
String description() default "";
+
String placeholder() default "";
+
boolean hideText() default false;
+
+ int size() default 1;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java b/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java
index 8b6e7de..d2c5549 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java
@@ -1,10 +1,11 @@
package io.polyfrost.oneconfig.config.data;
public enum ModType {
- PVP,
PERFORMANCE,
+ PVP,
HUD,
- QOL,
+ UTIL_QOL,
HYPIXEL,
+ SKYBLOCK,
OTHER
}
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 049ad3e..f0efcb0 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
@@ -13,6 +13,7 @@ import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
@@ -42,7 +43,7 @@ public class Config {
* Save current config to file
*/
public void save() {
- try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(Profiles.getProfileFile(configFile)), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(Profiles.getProfileFile(configFile).toPath()), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(this.getClass()));
} catch (IOException e) {
e.printStackTrace();
@@ -53,7 +54,7 @@ public class Config {
* Load file and overwrite current values
*/
public void load() {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(Profiles.getProfileFile(configFile)), StandardCharsets.UTF_8))) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(Profiles.getProfileFile(configFile).toPath()), StandardCharsets.UTF_8))) {
deserializePart(new JsonParser().parse(reader).getAsJsonObject(), this.getClass());
} catch (IOException e) {
e.printStackTrace();
@@ -71,31 +72,31 @@ public class Config {
for (Class<?> innerClass : clazz.getClasses()) {
if (innerClass.isAnnotationPresent(Category.class)) {
Category category = innerClass.getAnnotation(Category.class);
- options.add(new OConfigCategory(category.name(), category.description(), generateOptionList(innerClass)));
+ options.add(new OConfigCategory(category.name(), category.description(), generateOptionList(innerClass), category.size()));
}
}
for (Field field : clazz.getFields()) {
if (field.isAnnotationPresent(Button.class)) {
Button button = field.getAnnotation(Button.class);
- options.add(new OConfigButton(field, button.name(), button.description(), button.text()));
+ options.add(new OConfigButton(field, button.name(), button.description(), button.text(), button.size()));
} else if (field.isAnnotationPresent(ColorPicker.class)) {
ColorPicker colorPicker = field.getAnnotation(ColorPicker.class);
- options.add(new OConfigColor(field, colorPicker.name(), colorPicker.description(), colorPicker.allowAlpha()));
+ options.add(new OConfigColor(field, colorPicker.name(), colorPicker.description(), colorPicker.allowAlpha(), colorPicker.size()));
} else if (field.isAnnotationPresent(Selector.class)) {
Selector selector = field.getAnnotation(Selector.class);
- options.add(new OConfigSelector(field, selector.name(), selector.description(), selector.options(), selector.defaultSelection()));
+ options.add(new OConfigSelector(field, selector.name(), selector.description(), selector.options(), selector.defaultSelection(), selector.size()));
} else if (field.isAnnotationPresent(Slider.class)) {
Slider slider = field.getAnnotation(Slider.class);
- options.add(new OConfigSlider(field, slider.name(), slider.description(), slider.min(), slider.max(), slider.precision()));
+ options.add(new OConfigSlider(field, slider.name(), slider.description(), slider.min(), slider.max(), slider.precision(), slider.size()));
} else if (field.isAnnotationPresent(Switch.class)) {
Switch aSwitch = field.getAnnotation(Switch.class);
- options.add(new OConfigSwitch(field, aSwitch.name(), aSwitch.description()));
+ options.add(new OConfigSwitch(field, aSwitch.name(), aSwitch.description(), aSwitch.size()));
} else if (field.isAnnotationPresent(TextField.class)) {
TextField textField = field.getAnnotation(TextField.class);
- options.add(new OConfigText(field, textField.name(), textField.description(), textField.placeholder(), textField.hideText()));
+ options.add(new OConfigText(field, textField.name(), textField.description(), textField.placeholder(), textField.hideText(), textField.size()));
} else if (field.isAnnotationPresent(HudComponent.class)) {
HudComponent hudComponent = field.getAnnotation(HudComponent.class);
- options.add(new OConfigHud(field, hudComponent.name(), hudComponent.description()));
+ options.add(new OConfigHud(field, hudComponent.name(), hudComponent.description(), hudComponent.size()));
try {
Object hud = field.get(BasicHud.class);
HudCore.huds.add((BasicHud) hud);
diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java
index 99cf656..bd9c034 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java
@@ -7,6 +7,7 @@ public abstract class Option {
protected final Field field;
protected final String name;
protected final String description;
+ public final int size;
/**
* Initialize option
@@ -14,11 +15,13 @@ public abstract class Option {
* @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 Option(Field field, String name, String description) {
+ public Option(Field field, String name, String description, int size) {
this.field = field;
this.name = name;
this.description = description;
+ this.size = size;
if (field != null) field.setAccessible(true);
}
@@ -46,13 +49,13 @@ public abstract class Option {
/**
* Function that gets called when drawing option
*
+ * @param vg NanoVG context
* @param x x position
* @param y y position
- * @param width width of menu
* @param mouseX x position of mouse
* @param mouseY y position of mouse
*/
- public abstract void draw(int x, int y, int width, int mouseX, int mouseY);
+ public abstract void draw(long vg, int x, int y, int mouseX, int mouseY);
/**
* Function that gets called when mouse is clicked
diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java
new file mode 100644
index 0000000..4802ec5
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java
@@ -0,0 +1,6 @@
+package io.polyfrost.oneconfig.config.interfaces;
+
+public enum Size {
+ SINGLE_COLUMN, // A single column, 480x32
+ DOUBLE_COLUMN // A double column, 992x32
+}