aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/OneConfig.java10
-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
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/HudGui.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java28
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/SideBar.java10
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java11
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java69
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java98
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java20
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigHud.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java52
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java74
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java8
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java42
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/image/Image.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/test/TestConfig.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java17
-rw-r--r--src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java4
46 files changed, 439 insertions, 159 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/OneConfig.java b/src/main/java/io/polyfrost/oneconfig/OneConfig.java
index 0f8fed9..f3668d8 100644
--- a/src/main/java/io/polyfrost/oneconfig/OneConfig.java
+++ b/src/main/java/io/polyfrost/oneconfig/OneConfig.java
@@ -52,17 +52,21 @@ public class OneConfig {
@Mod.EventHandler
public void onPostFMLInit(FMLPostInitializationEvent event) {
+ reloadModsList();
+ }
+
+ public static void reloadModsList() {
loadedMods.addAll(ConfigCore.settings.keySet());
LinkedHashSet<ModData> modData = new LinkedHashSet<>(ConfigCore.settings.keySet());
- for(ModContainer mod : Loader.instance().getActiveModList()) {
+ for (ModContainer mod : Loader.instance().getActiveModList()) {
ModMetadata metadata = mod.getMetadata();
loadedOtherMods.add(metadata);
String author = metadata.authorList.size() > 0 ? metadata.authorList.get(0) : "";
ModData newMod = new ModData(metadata.name, ModType.OTHER, author, metadata.version);
- if(newMod.name.equals("OneConfig") || newMod.name.equals("Minecraft Coder Pack") || newMod.name.equals("Forge Mod Loader") || newMod.name.equals("Minecraft Forge")) {
+ if (newMod.name.equals("Minecraft Coder Pack") || newMod.name.equals("Forge Mod Loader") || newMod.name.equals("Minecraft Forge")) { // TODO add oneconfig
continue;
}
- if(modData.add(newMod)) loadedMods.add(newMod); // anti duplicate fix
+ if (modData.add(newMod)) loadedMods.add(newMod); // anti duplicate fix
}
}
}
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
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java
index 12b9755..32e401b 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java
@@ -3,7 +3,6 @@ package io.polyfrost.oneconfig.gui;
import io.polyfrost.oneconfig.hud.HudCore;
import io.polyfrost.oneconfig.hud.interfaces.BasicHud;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
-import io.polyfrost.oneconfig.test.TestHud;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Keyboard;
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
index 6f8aeea..fd0ef47 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -12,7 +12,8 @@ import net.minecraft.client.gui.GuiScreen;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Keyboard;
-import static org.lwjgl.nanovg.NanoVG.*;
+import static org.lwjgl.nanovg.NanoVG.nvgResetScissor;
+import static org.lwjgl.nanovg.NanoVG.nvgScissor;
public class OneConfigGui extends GuiScreen {
public static OneConfigGui INSTANCE;
@@ -33,13 +34,15 @@ public class OneConfigGui extends GuiScreen {
public OneConfigGui() {
INSTANCE = this;
}
+
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
+ long start = System.nanoTime();
RenderManager.setupAndDraw((vg) -> {
- if(currentPage == null) currentPage = new HomePage();
+ if (currentPage == null) currentPage = new HomePage();
//nvgScale(vg, 0.5f, 0.5f);
- if(OneConfigConfig.ROUNDED_CORNERS) {
+ if (OneConfigConfig.ROUNDED_CORNERS) {
RenderManager.drawRoundedRect(vg, 544, 140, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN);
RenderManager.drawRoundedRect(vg, 320, 140, 244, 800, OneConfigConfig.GRAY_900_80, OneConfigConfig.CORNER_RADIUS_WIN);
RenderManager.drawRect(vg, 544, 140, 20, 800, OneConfigConfig.GRAY_800);
@@ -48,21 +51,22 @@ public class OneConfigGui extends GuiScreen {
// L;
}
- RenderManager.drawLine(vg, 544, 212, 1600, 212, 1, OneConfigConfig.GRAY_700);
+ RenderManager.drawLine(vg, 544, 212, 1600, 212, 1, OneConfigConfig.GRAY_700);
RenderManager.drawLine(vg, 544, 140, 544, 940, 1, OneConfigConfig.GRAY_700);
RenderManager.drawImage(vg, "/assets/oneconfig/textures/icon.png", x + 19, y + 19, 42, 42);
RenderManager.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.INTER_BOLD); // added half line height to center text
RenderManager.drawString(vg, "By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR);
+ textInputField.draw(vg, x + 400, y + 200);
//element.setColorPalette(0);
sideBar.draw(vg, x, y);
nvgScissor(vg, x + 224, y + 72, 1056, 728);
- if(prevPage != null) {
+ if (prevPage != null) {
pageProgress = MathUtils.easeInOutCirc(50, pageProgress, 832 - pageProgress, 220);
prevPage.draw(vg, (int) (x - pageProgress), y + 72);
RenderManager.drawLine(vg, (int) (x - pageProgress + 1055), y + 72, (int) (x - pageProgress + 1057), y + 800, 2, OneConfigConfig.GRAY_700); // TODO might remove this
currentPage.draw(vg, (int) (x - pageProgress + 1056), y + 72);
- if(pageProgress > 828f) {
+ if (pageProgress > 828f) {
prevPage = null;
pageProgress = -224f;
}
@@ -70,14 +74,19 @@ public class OneConfigGui extends GuiScreen {
currentPage.draw(vg, (int) (x - pageProgress), y + 72);
}
nvgResetScissor(vg);
+ long end = System.nanoTime() - start;
+ String s = (" draw: " + end / 1000000f + "ms");
RenderManager.drawString(vg, currentPage.getTitle(), x + 336, y + 36, OneConfigConfig.WHITE_90, 32f, Fonts.INTER_SEMIBOLD);
+ RenderManager.drawString(vg, s, x + 1170, y + 790, OneConfigConfig.GRAY_300, 10f, Fonts.INTER_MEDIUM);
+
- //textInputField.draw(vg, 792, 548);
- //btn.draw(vg, 976, 870);
+ //textInputField.draw(vg, 792, 548);
+ //btn.draw(vg, 976, 870);
//RenderManager.drawGradientRoundedRect(vg, 100, 100, 500, 100, OneConfigConfig.BLUE_600, OneConfigConfig.BLUE_500, OneConfigConfig.CORNER_RADIUS_WIN);
});
+
}
protected void keyTyped(char key, int keyCode) {
@@ -91,7 +100,8 @@ public class OneConfigGui extends GuiScreen {
}
public void openPage(@NotNull Page page) {
- if(prevPage == null) {
+ currentPage.finishUpAndClose();
+ if (prevPage == null) {
prevPage = currentPage;
}
currentPage = page;
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
index fd8f92e..f6ec15f 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
@@ -4,12 +4,11 @@ import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.gui.elements.BasicButton;
import io.polyfrost.oneconfig.gui.pages.HomePage;
import io.polyfrost.oneconfig.gui.pages.ModsPage;
+import io.polyfrost.oneconfig.gui.pages.PerformanceModsPage;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.MathUtils;
-import io.polyfrost.oneconfig.utils.TickDelay;
import net.minecraft.client.Minecraft;
-import scala.collection.parallel.ParIterableLike;
import java.util.ArrayList;
import java.util.List;
@@ -23,7 +22,7 @@ public class SideBar {
btnList.add(new BasicButton(192, 36, "Dashboard", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage()));
btnList.add(new BasicButton(192, 36, "Global Search", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Mods", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage()));
- btnList.add(new BasicButton(192, 36, "Performance", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Performance Mods", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new PerformanceModsPage()));
btnList.add(new BasicButton(192, 36, "Profiles", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Updates", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Screenshots", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
@@ -60,13 +59,10 @@ public class SideBar {
}
if (btn.isClicked()) {
- if(i < 520) targetY = btn.y;
+ if (i < 520) targetY = btn.y;
}
}
-
-
-
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
index c0d4cec..3ded1b1 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -9,9 +9,6 @@ import io.polyfrost.oneconfig.utils.ColorUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
public class BasicButton extends BasicElement {
protected String text;
@@ -135,4 +132,12 @@ public class BasicButton extends BasicElement {
runnable.run();
}
}
+
+ public void setToggled(boolean state) {
+ this.toggled = state;
+ }
+
+ public String getText() {
+ return text;
+ }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
index 38304e4..071a311 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -1,12 +1,18 @@
package io.polyfrost.oneconfig.gui.elements;
+import io.polyfrost.oneconfig.OneConfig;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.config.data.ModData;
+import io.polyfrost.oneconfig.config.data.ModType;
+import io.polyfrost.oneconfig.gui.OneConfigGui;
+import io.polyfrost.oneconfig.gui.pages.ModConfigPage;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.ColorUtils;
import io.polyfrost.oneconfig.utils.InputUtils;
import net.minecraft.client.Minecraft;
+import net.minecraftforge.client.ClientCommandHandler;
+import net.minecraftforge.fml.common.ModMetadata;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.nanovg.NanoVG;
@@ -32,23 +38,21 @@ public class ModCard extends BasicElement {
@Override
public void draw(long vg, int x, int y) {
- if(disabled) NanoVG.nvgGlobalAlpha(vg, 0.5f);
+ if (disabled) NanoVG.nvgGlobalAlpha(vg, 0.5f);
RenderManager.drawRoundedRectVaried(vg, x, y, width, 87, colorGray, 12f, 12f, 0f, 0f);
RenderManager.drawRoundedRectVaried(vg, x, y + 87, width, 32, colorPrimary, 0f, 0f, 12f, 12f);
- RenderManager.drawLine(vg, x, y + 86, x + width, y + 86, 2,OneConfigConfig.GRAY_300);
- //RenderManager.drawRect(vg, x, y + 87, width, 12, colorPrimary);
- if(iconPath != null) {
+ RenderManager.drawLine(vg, x, y + 86, x + width, y + 86, 2, OneConfigConfig.GRAY_300);
+ if (iconPath != null) {
RenderManager.drawImage(vg, iconPath, x, y, width, 87);
} else {
RenderManager.drawImage(vg, "/assets/oneconfig/textures/box.png", x + 98, y + 19, 48, 48);
}
- //favoriteHitbox.draw(vg, x + 212, y + 87);
favoriteHitbox.update(x + 212, y + 87);
favoriteHitbox.currentColor = ColorUtils.getColor(favoriteHitbox.currentColor, favoriteHitbox.colorPalette, favoriteHitbox.hovered, favoriteHitbox.clicked);
RenderManager.drawRoundedRectVaried(vg, x + 212, y + 87, 32, 32, favoriteHitbox.currentColor, 0f, 0f, 12f, 0f);
favorite = favoriteHitbox.isToggled();
- RenderManager.drawString(vg, modData.name, x + 12, y + 102, OneConfigConfig.WHITE, 14f, Fonts.INTER_MEDIUM);
- if(favorite) {
+ RenderManager.drawString(vg, modData.name, x + 12, y + 103, OneConfigConfig.WHITE, 14f, Fonts.INTER_MEDIUM);
+ if (favorite) {
RenderManager.drawImage(vg, "/assets/oneconfig/textures/love.png", x + 220, y + 95, 16, 16);
} else {
RenderManager.drawImage(vg, "/assets/oneconfig/textures/love_empty.png", x + 220, y + 95, 16, 16);
@@ -57,19 +61,20 @@ public class ModCard extends BasicElement {
isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87);
boolean isHoveredSecondary = InputUtils.isAreaHovered(x, y + 87, width - 32, 32) && !disabled;
colorGray = ColorUtils.getColor(colorGray, 0, isHoveredMain, clicked && isHoveredMain);
- if(active && !disabled) {
+ if (active && !disabled) {
colorPrimary = ColorUtils.getColor(colorPrimary, 1, isHoveredSecondary, clicked && isHoveredSecondary);
- } else colorPrimary = ColorUtils.smoothColor(colorPrimary, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, isHoveredSecondary, 20f);
+ } else
+ colorPrimary = ColorUtils.smoothColor(colorPrimary, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, isHoveredSecondary, 20f);
- if(clicked && isHoveredMain) {
- if(!active) toggled = false;
+ if (clicked && isHoveredMain) {
+ if (!active) toggled = false;
}
- if(clicked && favoriteHitbox.hovered) toggled = false;
- if(clicked && !isHoveredSecondary && active) toggled = true;
- if(!active & disabled) toggled = false;
- //RenderManager.drawString(vg, "active=" + active, x + 300, y + 12, OneConfigConfig.WHITE, 12f, Fonts.INTER_MEDIUM); // TODO remove debug stuff
- //RenderManager.drawString(vg, "disabled=" + disabled, x + 300, y + 24, OneConfigConfig.WHITE, 12f, Fonts.INTER_MEDIUM);
- //RenderManager.drawString(vg, "favorite=" + favorite, x + 300, y + 36, OneConfigConfig.WHITE, 12f, Fonts.INTER_MEDIUM);
+ if (clicked && favoriteHitbox.hovered) toggled = false;
+ if (clicked && !isHoveredSecondary && active) toggled = true;
+ if (!active & disabled) toggled = false;
+ //RenderManager.drawString(vg, "active=" + active, x + 150, y + 92, OneConfigConfig.WHITE, 10f, Fonts.INTER_MEDIUM); // debug stuff
+ //RenderManager.drawString(vg, "disabled=" + disabled, x + 150, y + 103, OneConfigConfig.WHITE, 10f, Fonts.INTER_MEDIUM);
+ //RenderManager.drawString(vg, "favorite=" + favorite, x + 150, y + 114, OneConfigConfig.WHITE, 10f, Fonts.INTER_MEDIUM);
active = toggled;
@@ -77,8 +82,34 @@ public class ModCard extends BasicElement {
}
public void onClick() {
- if(isHoveredMain) {
- Minecraft.getMinecraft().thePlayer.sendChatMessage("you thought you opened the config for " + modData.name + " but actually it doesnt exist");
+ if (isHoveredMain) {
+ for (ModData data : OneConfig.loadedMods) {
+ if (data.modType != ModType.OTHER) {
+ if (data.name.equalsIgnoreCase(modData.name)) {
+ OneConfigGui.INSTANCE.openPage(new ModConfigPage(data));
+ }
+ }
+ }
+ for (ModMetadata mod : OneConfig.loadedOtherMods) {
+ if (mod.name.equalsIgnoreCase(modData.name)) {
+ System.out.println("Attempting to run command for a mod that isn't OneConfig: " + mod.name);
+ for (String commands : ClientCommandHandler.instance.getCommands().keySet()) {
+ if (commands.equalsIgnoreCase(mod.name)) {
+ System.out.println("Found command for mod: /" + commands);
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands);
+ //Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + mod.name.toLowerCase());
+ break;
+ }
+ if (commands.equalsIgnoreCase(mod.modId)) {
+ System.out.println("Found command for mod: /" + commands);
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands);
+ break;
+ }
+ }
+ return;
+ }
+
+ }
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java
index 93df1b4..641f5fd 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java
@@ -1,6 +1,6 @@
package io.polyfrost.oneconfig.gui.elements;
-public class SearchField extends TextInputField{
+public class SearchField extends TextInputField {
public SearchField(int width, int height, String defaultText, boolean multiLine, boolean password) {
super(width, height, defaultText, multiLine, password);
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java
index e2c7602..c7756fb 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java
@@ -1,14 +1,16 @@
package io.polyfrost.oneconfig.gui.elements;
-import com.google.common.base.Strings;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import net.minecraft.client.gui.GuiScreen;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.nanovg.NanoVG;
-import static org.lwjgl.nanovg.NanoVG.*;
+import static org.lwjgl.nanovg.NanoVG.nvgResetScissor;
+import static org.lwjgl.nanovg.NanoVG.nvgScissor;
public class TextInputField extends BasicElement {
@@ -18,6 +20,10 @@ public class TextInputField extends BasicElement {
protected boolean password;
protected int caretPos;
+ protected int x, y;
+ protected long vg;
+ protected int deltaX;
+ protected int prevCaret = 0;
public TextInputField(int width, int height, String defaultText, boolean multiLine, boolean password) {
super(width, height, false);
@@ -41,42 +47,68 @@ public class TextInputField extends BasicElement {
@Override
public void draw(long vg, int x, int y) {
+ this.x = x;
+ this.y = y;
+ this.vg = vg;
RenderManager.drawHollowRoundRect(vg, x, y, width, height, OneConfigConfig.GRAY_700, 12f, 2f);
super.update(x, y);
int color = toggled ? OneConfigConfig.WHITE : OneConfigConfig.WHITE_60;
float width;
StringBuilder s = new StringBuilder();
int offset = 12;
- if(!password) {
+ if (!password) {
width = RenderManager.getTextWidth(vg, input.substring(0, caretPos), 14f);
} else {
- for(int i = 0; i < input.length(); i++) {
+ for (int i = 0; i < input.length(); i++) {
s.append("*");
}
width = RenderManager.getTextWidth(vg, s.substring(0, caretPos), 14f);
}
+ nvgScissor(vg, x, y, this.width, height);
+ if (clicked) {
+ NanoVG.nvgGlobalAlpha(vg, 0.3f);
+ int point = (Mouse.getX() - x) - deltaX;
+ if (Mouse.getX() - x - 12 < 0) {
+ RenderManager.drawRect(vg, x + offset + width, y + 2, -width, height - 4, OneConfigConfig.BLUE_600);
+ } else if (!(Mouse.getX() - x > RenderManager.getTextWidth(vg, input, 14f) + 12)) {
+ RenderManager.drawRect(vg, x + offset + width, y + 2, point, height - 4, OneConfigConfig.BLUE_600);
+ } else {
+ RenderManager.drawRect(vg, x + offset + width, y + 2, RenderManager.getTextWidth(vg, input, 14f) - width, height - 4, OneConfigConfig.BLUE_600);
+ }
+ //System.out.println(offset + width);
+ //System.out.println(point);
+ prevCaret = calculatePos((int) (offset + width));
+ NanoVG.nvgGlobalAlpha(vg, 1f);
+ }
+ try {
+ //System.out.println("prevCaret: " + prevCaret + " caretPos: " + caretPos);
+ //RenderManager.drawRect(vg, (int) x + RenderManager.getTextWidth(vg, input.substring(0, caretPos), 14f), y, (int) RenderManager.getTextWidth(vg, input.substring(caretPos, prevCaret), 14f), height, OneConfigConfig.GRAY_300);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
- if(toggled) {
- RenderManager.drawLine(vg, x + width + 12, (float) y + 7, x + width + 13, (float) y + height - 7, 1, OneConfigConfig.WHITE);
+ if (toggled) {
+ RenderManager.drawLine(vg, x + width + 12, (float) y + 7, x + width + 12, (float) y + height - 7, 1, OneConfigConfig.WHITE);
}
- if(input.equals("")){
+
+ if (input.equals("")) {
RenderManager.drawString(vg, defaultText, x + 12, y + 17, color, 14f, Fonts.INTER_REGULAR);
}
- nvgScissor(vg, x, y, this.width, height);
- if(!password) {
+
+ if (!password) {
RenderManager.drawString(vg, input, x + offset, y + 17, color, 14f, Fonts.INTER_REGULAR);
- nvgResetScissor(vg);
} else {
-
RenderManager.drawString(vg, s.toString(), x + offset, y + 17, color, 14f, Fonts.INTER_REGULAR);
}
+ nvgResetScissor(vg);
}
public void keyTyped(char c, int key) {
if (toggled) {
- if(GuiScreen.isCtrlKeyDown()) {
- if(key == Keyboard.KEY_BACK) {
+ if (GuiScreen.isCtrlKeyDown()) {
+ if (key == Keyboard.KEY_BACK) {
try {
input = input.substring(0, input.lastIndexOf(" "));
caretPos = input.length();
@@ -89,7 +121,7 @@ public class TextInputField extends BasicElement {
}
if (key == Keyboard.KEY_BACK) {
if (input.length() > 0) {
- if(caretPos == input.length()) {
+ if (caretPos == input.length()) {
input = input.substring(0, input.length() - 1);
} else {
input = input.substring(0, caretPos - 1) + input.substring(caretPos);
@@ -98,7 +130,7 @@ public class TextInputField extends BasicElement {
}
return;
}
- if(key == Keyboard.KEY_TAB) {
+ if (key == Keyboard.KEY_TAB) {
input += " ";
caretPos += 4;
return;
@@ -106,26 +138,25 @@ public class TextInputField extends BasicElement {
if (key == Keyboard.KEY_RIGHT) {
caretPos++;
- if(caretPos > input.length()) {
+ if (caretPos > input.length()) {
caretPos = input.length();
}
return;
}
if (key == Keyboard.KEY_LEFT) {
caretPos--;
- if(caretPos < 0) {
+ if (caretPos < 0) {
caretPos = 0;
}
return;
}
-
- if(key == Keyboard.KEY_RETURN) {
+ if (key == Keyboard.KEY_RETURN) {
toggled = false;
}
- if(key == Keyboard.KEY_LCONTROL || key == Keyboard.KEY_RCONTROL || key == Keyboard.KEY_LMENU || key == Keyboard.KEY_RMENU || key == Keyboard.KEY_LMETA || key == Keyboard.KEY_RMETA || key == Keyboard.KEY_LSHIFT || key == Keyboard.KEY_RSHIFT || key == Keyboard.KEY_RETURN || key == Keyboard.KEY_CAPITAL || key == 221) {
+ if (key == Keyboard.KEY_LCONTROL || key == Keyboard.KEY_RCONTROL || key == Keyboard.KEY_LMENU || key == Keyboard.KEY_RMENU || key == Keyboard.KEY_LMETA || key == Keyboard.KEY_RMETA || key == Keyboard.KEY_LSHIFT || key == Keyboard.KEY_RSHIFT || key == Keyboard.KEY_RETURN || key == Keyboard.KEY_CAPITAL || key == 221) {
return;
}
input = addCharAtPoint(caretPos, c);
@@ -136,4 +167,31 @@ public class TextInputField extends BasicElement {
private @NotNull String addCharAtPoint(int index, char c) {
return input.substring(0, index) + c + input.substring(index);
}
+
+ @Override
+ public void onClick() {
+ deltaX = Mouse.getX() - x;
+ toggled = true;
+ caretPos = calculatePos(Mouse.getX());
+ }
+
+ private int calculatePos(int pos) {
+ String s1 = "";
+ int i;
+ for (char c : input.toCharArray()) {
+ if (pos - x - 12 < 0) {
+ return 0;
+ }
+ if (pos - x - 12 > RenderManager.getTextWidth(vg, input, 14f)) {
+ deltaX = (int) RenderManager.getTextWidth(vg, input, 14f) + 12;
+ return input.length();
+ }
+ s1 += c;
+ i = (int) RenderManager.getTextWidth(vg, s1, 14f);
+ if (i >= pos - x - 16) {
+ return s1.length();
+ }
+ }
+ return 0;
+ }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java
index 1cf0ab8..a19cb55 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java
@@ -1,15 +1,21 @@
package io.polyfrost.oneconfig.gui.elements.config;
+import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.config.interfaces.Option;
+import io.polyfrost.oneconfig.gui.elements.BasicElement;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import java.lang.reflect.Field;
public class OConfigButton extends Option {
private final String text;
+ private final BasicElement element;
- public OConfigButton(Field field, String name, String description, String text) {
- super(field, name, description);
+ public OConfigButton(Field field, String name, String description, String text, int size) {
+ super(field, name, description, size);
this.text = text;
+ element = new BasicElement(128, 32, 1, true);
}
@Override
@@ -18,7 +24,13 @@ public class OConfigButton extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
-
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
+ if (size == 0) {
+ RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM);
+ element.setWidth((int) RenderManager.getTextWidth(vg, text, 12f) + 80);
+ element.draw(vg, x + 480 - element.getWidth(), y);
+ RenderManager.drawString(vg, text, x + element.getWidth() / 2f, y + 16, OneConfigConfig.WHITE, 12f, Fonts.INTER_MEDIUM);
+ // ???
+ }
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java
index e57f130..aa763ef 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java
@@ -7,8 +7,8 @@ import java.util.List;
public class OConfigCategory extends Option {
public final List<Option> options;
- public OConfigCategory(String name, String description, List<Option> options) {
- super(null, name, description);
+ public OConfigCategory(String name, String description, List<Option> options, int size) {
+ super(null, name, description, size);
this.options = options;
}
@@ -18,7 +18,7 @@ public class OConfigCategory extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java
index fcad08f..ed98bd4 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java
@@ -7,8 +7,8 @@ import java.lang.reflect.Field;
public class OConfigColor extends Option {
private final boolean allowAlpha;
- public OConfigColor(Field field, String name, String description, boolean allowAlpha) {
- super(field, name, description);
+ public OConfigColor(Field field, String name, String description, boolean allowAlpha, int size) {
+ super(field, name, description, size);
this.allowAlpha = allowAlpha;
}
@@ -18,7 +18,7 @@ public class OConfigColor extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigHud.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigHud.java
index 2d6141a..8e36fe9 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigHud.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigHud.java
@@ -6,8 +6,8 @@ import java.lang.reflect.Field;
public class OConfigHud extends Option {
- public OConfigHud(Field field, String name, String description) {
- super(field, name, description);
+ public OConfigHud(Field field, String name, String description, int size) {
+ super(field, name, description, size);
}
@Override
@@ -16,7 +16,7 @@ public class OConfigHud extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java
index 3e0e208..30bb709 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java
@@ -8,8 +8,8 @@ public class OConfigSelector extends Option {
private final String[] options;
private final int defaultSelection;
- public OConfigSelector(Field field, String name, String description, String[] options, int defaultSelection) {
- super(field, name, description);
+ public OConfigSelector(Field field, String name, String description, String[] options, int defaultSelection, int size) {
+ super(field, name, description, size);
this.options = options;
this.defaultSelection = defaultSelection;
}
@@ -20,7 +20,7 @@ public class OConfigSelector extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java
index 0427b35..bb3a485 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java
@@ -9,8 +9,8 @@ public class OConfigSlider extends Option {
private final float max;
private final float precision;
- public OConfigSlider(Field field, String name, String description, float min, float max, float precision) {
- super(field, name, description);
+ public OConfigSlider(Field field, String name, String description, float min, float max, float precision, int size) {
+ super(field, name, description, size);
this.min = min;
this.max = max;
this.precision = precision;
@@ -22,7 +22,7 @@ public class OConfigSlider extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java
index 08c315f..753d8f6 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java
@@ -6,8 +6,8 @@ import java.lang.reflect.Field;
public class OConfigSwitch extends Option {
- public OConfigSwitch(Field field, String name, String description) {
- super(field, name, description);
+ public OConfigSwitch(Field field, String name, String description, int size) {
+ super(field, name, description, size);
}
@Override
@@ -16,7 +16,7 @@ public class OConfigSwitch extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java
index 407f733..606d493 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java
@@ -8,8 +8,8 @@ public class OConfigText extends Option {
private final String placeholder;
private final boolean hideText;
- public OConfigText(Field field, String name, String description, String placeholder, boolean hideText) {
- super(field, name, description);
+ public OConfigText(Field field, String name, String description, String placeholder, boolean hideText, int size) {
+ super(field, name, description, size);
this.placeholder = placeholder;
this.hideText = hideText;
}
@@ -20,7 +20,7 @@ public class OConfigText extends Option {
}
@Override
- public void draw(int x, int y, int width, int mouseX, int mouseY) {
+ public void draw(long vg, int x, int y, int mouseX, int mouseY) {
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
index d38f565..667b02e 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -7,6 +7,7 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts;
public class HomePage extends Page {
private final BasicButton btn = new BasicButton(184, 36, "Socials", "/assets/oneconfig/textures/share.png", "/assets/oneconfig/textures/share2.png", 1, BasicButton.ALIGNMENT_CENTER);
+
public HomePage() {
super("Home Dashboard");
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
new file mode 100644
index 0000000..357d684
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -0,0 +1,52 @@
+package io.polyfrost.oneconfig.gui.pages;
+
+import io.polyfrost.oneconfig.config.core.ConfigCore;
+import io.polyfrost.oneconfig.config.data.ModData;
+import io.polyfrost.oneconfig.config.interfaces.Option;
+import io.polyfrost.oneconfig.gui.elements.config.OConfigCategory;
+import org.lwjgl.input.Mouse;
+
+import java.util.ArrayList;
+
+public class ModConfigPage extends Page {
+ private final ModData modData;
+ private final ArrayList<Option> options;
+
+ public ModConfigPage(ModData mod) {
+ super("Mod: " + mod.name);
+ this.modData = mod;
+ options = ConfigCore.settings.get(mod);
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ for (Option option : options) {
+ if (option instanceof OConfigCategory) {
+ OConfigCategory category = (OConfigCategory) option;
+ for (Option subOption : category.options) {
+ if (subOption.size == 0) {
+ subOption.draw(vg, x, y, Mouse.getX(), Mouse.getY());
+ }
+ }
+ for (Option subOption : category.options) {
+ if (subOption.size == 1) {
+ subOption.draw(vg, x, y, Mouse.getX(), Mouse.getY());
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void finishUpAndClose() {
+ modData.config.save(); // TODO
+ }
+
+ public ModData getModData() {
+ return modData;
+ }
+
+ protected ArrayList<Option> getOptions() {
+ return options;
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
index 856b2f3..9fc14f7 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -1,52 +1,80 @@
package io.polyfrost.oneconfig.gui.pages;
import io.polyfrost.oneconfig.OneConfig;
+import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.config.data.ModData;
+import io.polyfrost.oneconfig.config.data.ModType;
import io.polyfrost.oneconfig.gui.elements.BasicButton;
import io.polyfrost.oneconfig.gui.elements.ModCard;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import java.util.ArrayList;
import java.util.List;
public class ModsPage extends Page {
- private final BasicButton allBtn = new BasicButton(49, 40, "All", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton newBtn = new BasicButton(64, 40, "New", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton combatBtn = new BasicButton(104, 40, "Combat", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton hudBtn = new BasicButton(104, 40, "HUD & QoL", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton hypixelBtn = new BasicButton(104, 40, "Hypixel", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton skyblockBtn = new BasicButton(104, 40, "Skyblock", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton utilBtn = new BasicButton(104, 40, "Utility", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton customBtn = new BasicButton(104, 40, "Custom", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
private final List<ModCard> modCards = new ArrayList<>();
+ private final List<BasicButton> modCategories = new ArrayList<>();
public ModsPage() {
super("Mods");
- for(ModData modData : OneConfig.loadedMods) {
+ for (ModData modData : OneConfig.loadedMods) {
modCards.add(new ModCard(modData, null, true, false, false));
}
+ for (ModCard card : modCards) {
+ if (card.isFavorite()) {
+ modCards.remove(card);
+ modCards.add(0, card);
+ }
+ }
+ modCategories.add(new BasicButton(64, 32, "All", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(80, 32, "Combat", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(64, 32, "HUD", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(104, 32, "Utility & QoL", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(80, 32, "Hypixel", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(80, 32, "Skyblock", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(88, 32, "3rd Party", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.get(0).setToggled(true);
}
public void draw(long vg, int x, int y) {
- allBtn.draw(vg, x + 16, y + 16);
- newBtn.draw(vg, x + 92, y + 16);
- combatBtn.draw(vg, x + 168, y + 16);
- hudBtn.draw(vg, x + 284, y + 16);
- hypixelBtn.draw(vg, x + 400, y + 16);
- skyblockBtn.draw(vg, x + 516, y + 16);
- utilBtn.draw(vg, x + 632, y + 16);
- customBtn.draw(vg, x + 748, y + 16);
+ int iXCat = x + 16;
+ for (BasicButton btn : modCategories) {
+ btn.draw(vg, iXCat, y + 16);
+ iXCat += btn.getWidth() + 8;
+ }
+ if ((modCategories.get(1).isClicked() || modCategories.get(2).isClicked() || modCategories.get(3).isClicked() || modCategories.get(4).isClicked() || modCategories.get(5).isClicked() || modCategories.get(6).isClicked()) && modCategories.get(0).isToggled()) {
+ modCategories.get(0).setToggled(false);
+ }
+ if (!modCategories.get(0).isToggled() && !modCategories.get(1).isToggled() && !modCategories.get(2).isToggled() && !modCategories.get(3).isToggled() && !modCategories.get(4).isToggled() && !modCategories.get(5).isToggled() && !modCategories.get(6).isToggled()) {
+ modCategories.get(0).setToggled(true);
+ }
+ if (modCategories.get(0).isToggled()) {
+ for (BasicButton btn : modCategories) {
+ if (!btn.getText().equals("All")) {
+ btn.setToggled(false);
+ }
+ }
+ }
+
int iX = x + 16;
int iY = y + 72;
- for(ModCard modCard : modCards) {
- modCard.draw(vg, iX, iY);
- iX += 260;
- if(iX > x + 796) {
- iX = x + 16;
- iY += 135;
+ for (ModCard modCard : modCards) {
+ if (modCategories.get(0).isToggled() || (modCategories.get(1).isToggled() && modCard.getModData().modType == ModType.PVP) || (modCategories.get(2).isToggled() && modCard.getModData().modType == ModType.HUD) || (modCategories.get(3).isToggled() && modCard.getModData().modType == ModType.UTIL_QOL) || (modCategories.get(4).isToggled() && modCard.getModData().modType == ModType.HYPIXEL) || (modCategories.get(5).isToggled() && modCard.getModData().modType == ModType.SKYBLOCK) || (modCategories.get(6).isToggled() && modCard.getModData().modType == ModType.OTHER)) {
+ modCard.draw(vg, iX, iY);
+ iX += 260;
+ if (iX > x + 796) {
+ iX = x + 16;
+ iY += 135;
+ }
}
}
+ if (iX == x + 16 && iY == y + 72) {
+ RenderManager.drawString(vg, "Looks like there is nothing here. Try another category?", x + 16, y + 72, OneConfigConfig.WHITE_60, 14f, Fonts.INTER_MEDIUM);
+ }
}
+
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
index 492a1f9..58c181f 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
@@ -6,7 +6,7 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts;
/**
* A page is a 1056x728 rectangle of the GUI. It is the main content of the gui, and can be switched back and forwards easily. All the content of OneConfig is in a page.
*/
-public class Page {
+public abstract class Page {
protected final String title;
Page(String title) {
@@ -14,7 +14,11 @@ public class Page {
}
public void draw(long vg, int x, int y) {
- RenderManager.drawString(vg, "If you are seeing this, something went quite wrong.", x + 12, y + 12, -1, 24f, Fonts.INTER_BOLD);
+ RenderManager.drawString(vg, "Doesn't appear there is any content to this page :(", x + 12, y + 18, -1, 24f, Fonts.INTER_BOLD);
+ }
+
+ public void finishUpAndClose() {
+
}
public String getTitle() {
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java
new file mode 100644
index 0000000..8dbdea9
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java
@@ -0,0 +1,42 @@
+package io.polyfrost.oneconfig.gui.pages;
+
+import io.polyfrost.oneconfig.OneConfig;
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.config.data.ModData;
+import io.polyfrost.oneconfig.config.data.ModType;
+import io.polyfrost.oneconfig.gui.elements.ModCard;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PerformanceModsPage extends Page {
+ List<ModCard> modCards = new ArrayList<>();
+
+ public PerformanceModsPage() {
+ super("Performance Mods");
+ for (ModData mod : OneConfig.loadedMods) {
+ if (mod.modType == ModType.PERFORMANCE) {
+ modCards.add(new ModCard(mod, null, true, false, false));
+ }
+ }
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ int iX = x + 16;
+ int iY = y + 16;
+ for (ModCard card : modCards) {
+ card.draw(vg, iX, iY);
+ iX += 260;
+ if (iX > x + 796) {
+ iX = x + 16;
+ iY += 135;
+ }
+ }
+ if (iX == x + 16 && iY == y + 16) {
+ RenderManager.drawString(vg, "Looks like there is nothing here. Try getting some more mods!", x + 16, y + 16, OneConfigConfig.WHITE_60, 14f, Fonts.INTER_MEDIUM);
+ }
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java
index f5105fb..2127251 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java
@@ -7,6 +7,7 @@ import java.net.URL;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.nio.file.Files;
public final class IOUtil {
@@ -15,7 +16,7 @@ public final class IOUtil {
/**
* Taken from legui under MIT License
- * https://github.com/SpinyOwl/legui/blob/develop/LICENSE
+ * <a href="https://github.com/SpinyOwl/legui/blob/develop/LICENSE">https://github.com/SpinyOwl/legui/blob/develop/LICENSE</a>
*/
@SuppressWarnings("RedundantCast")
public static ByteBuffer resourceToByteBuffer(String path) throws IOException {
@@ -27,7 +28,7 @@ public final class IOUtil {
InputStream stream;
File file = new File(path);
if (file.exists() && file.isFile()) {
- stream = new FileInputStream(file);
+ stream = Files.newInputStream(file.toPath());
} else {
stream = IOUtil.class.getResourceAsStream(path);
}
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java
index ea1a44b..6c77108 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java
@@ -8,7 +8,7 @@ import java.nio.ByteBuffer;
/**
* Taken from LWJGLTwoPointFive under The Unlicense
- * https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/
+ * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a>
*/
public class Lwjgl2FunctionProvider implements FunctionProvider {
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
index 3855162..87e3d03 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -88,8 +88,7 @@ public final class RenderManager {
nvgRoundedRect(vg, x, y, width, height, radius);
NVGColor nvgColor = color(vg, color);
NVGColor nvgColor2 = color(vg, color2);
- nvgFillPaint(vg, nvgLinearGradient(vg, x, y + height, x + width, y, nvgColor, nvgColor2, bg)); // like the gradient is blocky
- nvgFillPaint(vg, bg);
+ nvgFillPaint(vg, nvgLinearGradient(vg, x, y + height, x + width, y, nvgColor, nvgColor2, bg));
nvgFill(vg);
nvgColor.free();
nvgColor2.free();
@@ -101,7 +100,7 @@ public final class RenderManager {
nvgRect(vg, x, y, width, height);
NVGColor nvgColor = color(vg, color);
NVGColor nvgColor2 = color(vg, color2);
- nvgFillPaint(vg, nvgLinearGradient(vg, x, y + height, x + width, y, nvgColor, nvgColor2, bg)); // like the gradient is blocky
+ nvgFillPaint(vg, nvgLinearGradient(vg, x, y + height, x + width, y, nvgColor, nvgColor2, bg));
nvgFillPaint(vg, bg);
nvgFill(vg);
nvgColor.free();
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/Image.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/Image.java
index 2ed7276..b304624 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/Image.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/Image.java
@@ -5,6 +5,7 @@ import java.nio.ByteBuffer;
public class Image {
private final int reference;
private final ByteBuffer buffer;
+
public Image(int reference, ByteBuffer buffer) {
this.reference = reference;
this.buffer = buffer;
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
index 4a35959..3415ea9 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
@@ -7,14 +7,11 @@ import org.lwjgl.nanovg.NSVGImage;
import org.lwjgl.nanovg.NanoSVG;
import org.lwjgl.nanovg.NanoVG;
import org.lwjgl.stb.STBImage;
-import org.lwjgl.system.MemoryStack;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.StandardCharsets;
import java.util.HashMap;
public class ImageLoader {
@@ -45,7 +42,7 @@ public class ImageLoader {
}
public boolean loadSVGImage(String fileName) {
- if(!NSVGImageHashMap.containsKey(fileName)) {
+ if (!NSVGImageHashMap.containsKey(fileName)) {
try {
InputStream inputStream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("oneconfig", fileName)).getInputStream();
StringBuilder resultStringBuilder = new StringBuilder();
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
index 066677b..7dc0d49 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
@@ -8,7 +8,7 @@ import org.objectweb.asm.tree.*;
/**
* Taken from LWJGLTwoPointFive under The Unlicense
- * https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/
+ * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a>
*/
public class ClassTransformer implements IClassTransformer {
@Override
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java
index 1f48135..b269a2a 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java
@@ -10,7 +10,7 @@ import java.util.Set;
/**
* Taken from LWJGLTwoPointFive under The Unlicense
- * https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/
+ * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a>
*/
public class LoadingPlugin implements IFMLLoadingPlugin {
diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java
index b0282ae..940d9c0 100644
--- a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java
+++ b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java
@@ -25,6 +25,6 @@ public class TestConfig extends Config {
public static TestHud testTextHud2 = new TestHud();
public TestConfig() {
- super(new ModData("hacks", ModType.QOL, "ShadyDev", "1.0"), "hacksConfig.json");
+ super(new ModData("hacks", ModType.UTIL_QOL, "ShadyDev", "1.0"), "hacksConfig.json");
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
index 88ec1ee..8d62cbf 100644
--- a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
@@ -1,7 +1,6 @@
package io.polyfrost.oneconfig.test;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
-import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import net.minecraft.client.gui.GuiScreen;
import java.awt.*;
@@ -18,7 +17,6 @@ public class TestNanoVGGui extends GuiScreen {
//RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8);
//RenderManager.drawString(vg, "Hello!", 80, 20, Color.WHITE.getRGB(), 50, Fonts.MC_REGULAR);
//RenderManager.drawString(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.INTER_BOLD);
- //RenderManager.drawImage(vg, "/assets/oneconfig/textures/hudsettings.png", 10, 10, 400, 400);
RenderManager.drawSVGImage(vg, "icons/TestIcon.svg", 10, 10, 100, 100);
//RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB());
//RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB());
diff --git a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java
index dd9a78e..abc36a5 100644
--- a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java
+++ b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java
@@ -10,10 +10,10 @@ public class ColorUtils {
public static int getColor(int currentColor, int colorPalette, boolean hover, boolean click) {
float[] color = splitColor(currentColor);
- if(click) {
+ if (click) {
switch (colorPalette) {
case -2:
- return new Color(0.9f,0.9f,0.9f,0.2f).getRGB();
+ return new Color(0.9f, 0.9f, 0.9f, 0.2f).getRGB();
case -1:
return OneConfigConfig.GRAY_500_80;
default:
@@ -26,7 +26,7 @@ public class ColorUtils {
switch (colorPalette) {
case -2:
- return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), new float[]{0.9f,0.9f,0.9f,0.3f}, hover, 20f);
+ return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), new float[]{0.9f, 0.9f, 0.9f, 0.3f}, hover, 20f);
case -1:
return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover, 10f);
default:
@@ -41,9 +41,10 @@ public class ColorUtils {
/**
* Smooths the transition of a color between two colors.
+ *
* @param currentColor the current color (also the one you want to change)
- * @param direction false to move towards initColor, true to move towards finalColor
- * @param speed speed of the transition
+ * @param direction false to move towards initColor, true to move towards finalColor
+ * @param speed speed of the transition
* @return currentColor but with the new color
*/
public static int smoothColor(int currentColor, int initColor, int finalColor, boolean direction, float speed) {
@@ -55,7 +56,7 @@ public class ColorUtils {
@Contract(value = "_ -> new", pure = true)
private static float @NotNull [] splitColor(int color) {
- return new float[] { (color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) /255f };
+ return new float[]{(color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) / 255f};
}
private static int getColorComponents(float[] currentColor, float[] initColor, float[] finalColor, boolean hover, float speed) {
@@ -70,11 +71,11 @@ public class ColorUtils {
private static float smooth(float current, float min, float max, boolean moveToFinal, float speed) {
current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f, speed);
- if(current <= min) {
+ if (current <= min) {
current = min;
}
- if(current >= max) {
+ if (current >= max) {
current = max;
}
return current;
diff --git a/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java
index d5ad44b..1ce1a30 100644
--- a/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java
+++ b/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java
@@ -6,6 +6,7 @@ import org.lwjgl.input.Mouse;
public class InputUtils {
/**
* function to determine weather the mouse is currently over a specific region. Uses the current nvgScale to fix to any scale.
+ *
* @return true if mouse is over region, false if not.
*/
public static boolean isAreaHovered(int x, int y, int width, int height) {
diff --git a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java
index dc70eea..1e4857f 100644
--- a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java
+++ b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java
@@ -18,7 +18,9 @@ public class MathUtils {
return current * current;
}
- /** taken from <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a> */
+ /**
+ * taken from <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a>
+ */
public static float easeInOutCirc(float t, float b, float c, float d) {
if ((t /= d / 2) < 1) return -c / 2 * ((float) Math.sqrt(1 - t * t) - 1) + b;
return c / 2 * ((float) Math.sqrt(1 - (t -= 2) * t) + 1) + b;