aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/io/polyfrost/oneconfig/OneConfig.java3
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java7
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java24
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java4
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/SideBar.java29
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java17
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java9
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java61
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java14
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java3
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java7
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java3
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java92
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java37
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/image/Images.java43
-rw-r--r--src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java1
-rw-r--r--src/main/resources/assets/oneconfig/icons/TestIcon.svg0
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/arrows/chevron.png (renamed from src/main/resources/assets/oneconfig/textures/arrow.png)bin190 -> 190 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/arrows/dropdown_arrow.png (renamed from src/main/resources/assets/oneconfig/textures/dropdown_arrow.png)bin164 -> 164 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/arrows/up_arrow.png (renamed from src/main/resources/assets/oneconfig/textures/smallUpArrow.png)bin162 -> 162 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/color/colorspectrum.png (renamed from src/main/resources/assets/oneconfig/textures/colorspectrum.png)bin39089 -> 39089 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/color/colorwheel.png (renamed from src/main/resources/assets/oneconfig/textures/colorwheel.png)bin193805 -> 193805 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/color/huegradient.png (renamed from src/main/resources/assets/oneconfig/textures/huegradient.png)bin3290 -> 3290 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/configs/checkmark.png (renamed from src/main/resources/assets/oneconfig/textures/check.png)bin1714 -> 1714 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/configs/favorite_active.png (renamed from src/main/resources/assets/oneconfig/textures/love.png)bin323 -> 323 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/configs/favorite_inactive.png (renamed from src/main/resources/assets/oneconfig/textures/love_empty.png)bin426 -> 426 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/configs/hide_eye.png (renamed from src/main/resources/assets/oneconfig/textures/eye.png)bin338 -> 338 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/logo.png (renamed from src/main/resources/assets/oneconfig/textures/icon.png)bin1819 -> 1819 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/nav/close.png (renamed from src/main/resources/assets/oneconfig/textures/XCircle.png)bin383 -> 383 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/nav/launch.png (renamed from src/main/resources/assets/oneconfig/textures/share2.png)bin430 -> 430 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/nav/minimize.png (renamed from src/main/resources/assets/oneconfig/textures/Minimise.png)bin302 -> 302 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/nav/search.png (renamed from src/main/resources/assets/oneconfig/textures/search.png)bin555 -> 555 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/general/nav/share.png (renamed from src/main/resources/assets/oneconfig/textures/share.png)bin480 -> 480 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/dashboard.png (renamed from src/main/resources/assets/oneconfig/textures/Dashboard.png)bin405 -> 405 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/hud/hud.png (renamed from src/main/resources/assets/oneconfig/textures/HUD.png)bin379 -> 379 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/hud/settings.png (renamed from src/main/resources/assets/oneconfig/textures/HUDSettings.png)bin399 -> 399 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/mod/mod_box.png (renamed from src/main/resources/assets/oneconfig/textures/box.png)bin1472 -> 1472 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/mod/mods.png (renamed from src/main/resources/assets/oneconfig/textures/Mods.png)bin285 -> 285 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/mod/performance.png (renamed from src/main/resources/assets/oneconfig/textures/Performance.png)bin381 -> 381 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/preferences.png (renamed from src/main/resources/assets/oneconfig/textures/Settings.png)bin425 -> 425 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/profiles.png (renamed from src/main/resources/assets/oneconfig/textures/Profiles.png)bin437 -> 437 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/screenshot.png (renamed from src/main/resources/assets/oneconfig/textures/Image.png)bin369 -> 369 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/themes.png (renamed from src/main/resources/assets/oneconfig/textures/Theme.png)bin304 -> 304 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/gui/icons/updates.png (renamed from src/main/resources/assets/oneconfig/textures/Update.png)bin343 -> 343 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/hudsettings.pngbin7226 -> 0 bytes
50 files changed, 181 insertions, 199 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/OneConfig.java b/src/main/java/io/polyfrost/oneconfig/OneConfig.java
index 5e25ee0..3c867b9 100644
--- a/src/main/java/io/polyfrost/oneconfig/OneConfig.java
+++ b/src/main/java/io/polyfrost/oneconfig/OneConfig.java
@@ -8,6 +8,7 @@ import io.polyfrost.oneconfig.config.data.ModType;
import io.polyfrost.oneconfig.hud.HudCore;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import io.polyfrost.oneconfig.lwjgl.image.Images;
import io.polyfrost.oneconfig.test.TestConfig;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.ClientCommandHandler;
@@ -52,7 +53,7 @@ public class OneConfig {
RenderManager.setupAndDraw((vg) -> {
RenderManager.drawRoundedRect(vg, -100, -100, 50, 50, -1, 12f);
RenderManager.drawString(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.INTER_MEDIUM);
- RenderManager.drawImage(vg, "/assets/oneconfig/textures/icon.png", -100, -100, 50, 50);
+ RenderManager.drawImage(vg, Images.LOGO, -100, -100, 50, 50);
});
}
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java
index a4f4a67..77831db 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java
@@ -32,10 +32,11 @@ public @interface Option {
String subcategory();
- /** A String array of all the possible values for the UniSelector, dropdownList, and ComboBox.
+ /**
+ * A String array of all the possible values for the UniSelector, dropdownList, and ComboBox.
* Also used in the DualOption slider, index 0 is the left, index 1 is the right; for example:
* {"Option 1", "Option 2"}
- * */
+ */
String[] options() default {};
/**
@@ -62,10 +63,12 @@ public @interface Option {
* Steps of slider (0 for no steps)
*/
int step() default 0;
+
/**
* Minimum value of slider
*/
float min() default 0;
+
/**
* The maximum value of the slider
*/
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 8d19b55..3c02b69 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java
@@ -1,7 +1,5 @@
package io.polyfrost.oneconfig.config.interfaces;
-import io.polyfrost.oneconfig.gui.elements.BasicElement;
-
import java.lang.reflect.Field;
@SuppressWarnings({"unused"})
@@ -13,9 +11,9 @@ public abstract class BasicOption {
/**
* Initialize option
*
- * @param field variable attached to option (null for category)
- * @param name name of option
- * @param size size of option, 0 for single column, 1 for double.
+ * @param field variable attached to option (null for category)
+ * @param name name of option
+ * @param size size of option, 0 for single column, 1 for double.
*/
public BasicOption(Field field, String name, int size) {
this.field = field;
@@ -48,9 +46,9 @@ public abstract class BasicOption {
/**
* Function that gets called when drawing option
*
- * @param vg NanoVG context
- * @param x x position
- * @param y y position
+ * @param vg NanoVG context
+ * @param x x position
+ * @param y y position
*/
public abstract void draw(long vg, int x, int y);
@@ -58,9 +56,9 @@ public abstract class BasicOption {
* Function that gets called last drawing option,
* should be used for things that draw above other options
*
- * @param vg NanoVG context
- * @param x x position
- * @param y y position
+ * @param vg NanoVG context
+ * @param x x position
+ * @param y y position
*/
public void drawLast(long vg, int x, int y) {
@@ -69,8 +67,8 @@ public abstract class BasicOption {
/**
* Function that gets called when a key is typed
*
- * @param key char that has been typed
- * @param keyCode code of key
+ * @param key char that has been typed
+ * @param keyCode code of key
*/
public void keyTyped(char key, int keyCode) {
}
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 ca151db..b3c8c75 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
@@ -18,7 +18,10 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
public class Config {
protected final String configFile;
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
index 130df7f..f34abe5 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -57,7 +57,7 @@ public class OneConfigGui extends GuiScreen {
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.drawImage(vg, "/assets/oneconfig/textures/gui/general/logo.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 + 1020, y + 16);
@@ -97,7 +97,7 @@ public class OneConfigGui extends GuiScreen {
}
public void openPage(@NotNull Page page) {
- if(page == currentPage) return;
+ if (page == currentPage) return;
currentPage.finishUpAndClose();
if (prevPage == null) {
prevPage = currentPage;
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
index dc136a7..195e398 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
@@ -3,11 +3,10 @@ package io.polyfrost.oneconfig.gui;
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.ModConfigPage;
import io.polyfrost.oneconfig.gui.pages.ModsPage;
-import io.polyfrost.oneconfig.gui.pages.Page;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import io.polyfrost.oneconfig.lwjgl.image.Images;
import io.polyfrost.oneconfig.utils.MathUtils;
import net.minecraft.client.Minecraft;
@@ -20,19 +19,19 @@ public class SideBar {
private float targetY = 0, currentY = 0;
public SideBar() {
- btnList.add(new BasicButton(192, 36, "Dashboard", "/assets/oneconfig/textures/Dashboard.png", null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage()));
- btnList.add(new BasicButton(192, 36, "Global Search", "/assets/oneconfig/textures/search.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Mods", "/assets/oneconfig/textures/Mods.png", null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage()));
- btnList.add(new BasicButton(192, 36, "Performance", "/assets/oneconfig/textures/Performance.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Profiles", "/assets/oneconfig/textures/Profiles.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Updates", "/assets/oneconfig/textures/Update.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Theme", "/assets/oneconfig/textures/Theme.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Screenshots", "/assets/oneconfig/textures/Image.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "HUD Settings", "/assets/oneconfig/textures/HUDSettings.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Preferences", "/assets/oneconfig/textures/Settings.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Close", "/assets/oneconfig/textures/XCircle.png", null, -1, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(null)));
- btnList.add(new BasicButton(192, 36, "Minimize", "/assets/oneconfig/textures/Minimise.png", null, -1, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Edit HUD", "/assets/oneconfig/textures/HUD.png", null, 0, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(new HudGui())));
+ btnList.add(new BasicButton(192, 36, "Dashboard", Images.DASHBOARD, null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage()));
+ btnList.add(new BasicButton(192, 36, "Global Search", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Mods", Images.MODS, null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage()));
+ btnList.add(new BasicButton(192, 36, "Performance", Images.PERFORMANCE, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Profiles", Images.PROFILES, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Updates", Images.UPDATES, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Theme", Images.THEMES, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Screenshots", Images.SCREENSHOT, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "HUD Settings", Images.HUD_SETTINGS, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Preferences", Images.PREFERENCES, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Close", Images.CLOSE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(null)));
+ btnList.add(new BasicButton(192, 36, "Minimize", Images.MINIMIZE, null, -1, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Edit HUD", Images.HUD, null, 0, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(new HudGui())));
}
public void draw(long vg, int x, int 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 1a1dcf7..716ef1e 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -5,6 +5,7 @@ import io.polyfrost.oneconfig.gui.OneConfigGui;
import io.polyfrost.oneconfig.gui.pages.Page;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import io.polyfrost.oneconfig.lwjgl.image.Images;
import io.polyfrost.oneconfig.utils.ColorUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -12,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
public class BasicButton extends BasicElement {
protected String text;
- protected String fileNameLeftIco, fileNameRightIco;
+ protected Images fileNameLeftIco, fileNameRightIco;
private final int thisAlignment;
private final float fontSize;
private final int colorPalette;
@@ -33,11 +34,11 @@ public class BasicButton extends BasicElement {
* @param colorPalette color palette to use. see {@link io.polyfrost.oneconfig.utils.ColorUtils} for more info. Can support color palette of -2, which is larger font and icons. Also supports -3, which is just the text changing color.
* @param alignment alignment of the button. ALIGNMENT_LEFT or ALIGNMENT_CENTER.
*/
- public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment) {
+ public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment) {
super(width, height, colorPalette, true);
this.text = text;
- this.fileNameLeftIco = fileNameLeftIco;
- this.fileNameRightIco = fileNameRightIco;
+ if (fileNameLeftIco != null) this.fileNameLeftIco = fileNameLeftIco;
+ if (fileNameRightIco != null) this.fileNameRightIco = fileNameRightIco;
this.thisAlignment = alignment;
if (colorPalette == -2) {
fontSize = 24f;
@@ -48,22 +49,22 @@ public class BasicButton extends BasicElement {
}
}
- public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, Page page) {
+ public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, Page page) {
this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment);
this.page = page;
}
- public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, boolean toggleable) {
+ public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, boolean toggleable) {
this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment);
this.toggleable = toggleable;
}
- public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, Runnable runnable) {
+ public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, Runnable runnable) {
this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment);
this.runnable = runnable;
}
- public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, boolean toggleable, Runnable runnable) {
+ public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, boolean toggleable, Runnable runnable) {
this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment, runnable);
this.toggleable = toggleable;
}
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 1587a93..90a3910 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -8,12 +8,11 @@ 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.lwjgl.image.Images;
import io.polyfrost.oneconfig.utils.ColorUtils;
import io.polyfrost.oneconfig.utils.InputUtils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.resources.I18n;
import net.minecraft.command.CommandException;
-import net.minecraft.command.ICommandSender;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.ModMetadata;
import org.jetbrains.annotations.NotNull;
@@ -50,7 +49,7 @@ public class ModCard extends BasicElement {
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);
+ RenderManager.drawImage(vg, Images.MOD_BOX, x + 98, y + 19, 48, 48);
}
favoriteHitbox.update(x + 212, y + 87);
favoriteHitbox.currentColor = ColorUtils.getColor(favoriteHitbox.currentColor, favoriteHitbox.colorPalette, favoriteHitbox.hovered, favoriteHitbox.clicked);
@@ -58,9 +57,9 @@ public class ModCard extends BasicElement {
favorite = favoriteHitbox.isToggled();
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);
+ RenderManager.drawImage(vg, Images.FAVORITE, x + 220, y + 95, 16, 16);
} else {
- RenderManager.drawImage(vg, "/assets/oneconfig/textures/love_empty.png", x + 220, y + 95, 16, 16);
+ RenderManager.drawImage(vg, Images.FAVORITE_OFF, x + 220, y + 95, 16, 16);
}
super.update(x, y);
isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87);
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 081c99b..b254a22 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java
@@ -85,7 +85,7 @@ public class TextInputField extends BasicElement {
toggled = false;
}
int color = toggled ? OneConfigConfig.WHITE : OneConfigConfig.WHITE_60;
- if(!toggled) caretPos = input.length();
+ if (!toggled) caretPos = input.length();
float width;
StringBuilder s = new StringBuilder();
if (!password) {
@@ -96,7 +96,7 @@ public class TextInputField extends BasicElement {
}
width = RenderManager.getTextWidth(vg, s.substring(0, caretPos), 14f, Fonts.INTER_REGULAR);
}
- if(hovered) {
+ if (hovered) {
while (Mouse.next()) {
if (Mouse.getEventButtonState()) {
if (Mouse.getEventButton() == 0) {
@@ -127,17 +127,19 @@ public class TextInputField extends BasicElement {
if (start != 0f && end != 0f && toggled) {
RenderManager.drawRect(vg, start, y + height / 2f - 10, end, 20, OneConfigConfig.GRAY_300);
}
- if(hovered) {
+ if (hovered) {
if (Mouse.isButtonDown(0) && !isDoubleClick) {
caretPos = calculatePos(Mouse.getX());
if (caretPos > prevCaret) {
- if(!centered) start = x + 12 + this.getTextWidth(vg, input.substring(0, prevCaret));
- else start = x + this.width / 2f - halfTextWidth + this.getTextWidth(vg, input.substring(0, prevCaret));
+ if (!centered) start = x + 12 + this.getTextWidth(vg, input.substring(0, prevCaret));
+ else
+ start = x + this.width / 2f - halfTextWidth + this.getTextWidth(vg, input.substring(0, prevCaret));
end = this.getTextWidth(vg, input.substring(prevCaret, caretPos));
selectedText = input.substring(prevCaret, caretPos);
} else {
- if(!centered) start = x + 12 + this.getTextWidth(vg, input.substring(0, prevCaret));
- else start = x + this.width / 2f - halfTextWidth + this.getTextWidth(vg, input.substring(0, prevCaret));
+ if (!centered) start = x + 12 + this.getTextWidth(vg, input.substring(0, prevCaret));
+ else
+ start = x + this.width / 2f - halfTextWidth + this.getTextWidth(vg, input.substring(0, prevCaret));
end = -this.getTextWidth(vg, input.substring(caretPos, prevCaret));
selectedText = input.substring(caretPos, prevCaret);
}
@@ -146,7 +148,7 @@ public class TextInputField extends BasicElement {
if (toggled) {
- if(!centered) {
+ if (!centered) {
RenderManager.drawLine(vg, x + width + 12, (float) y + height / 2f - 10, x + width + 12, (float) y + height / 2f + 10, 1, OneConfigConfig.WHITE);
} else {
RenderManager.drawLine(vg, x + this.width / 2f - halfTextWidth + width, (float) y + height / 2f - 10, x + this.width / 2f - halfTextWidth + width, (float) y + height / 2f + 10, 1, OneConfigConfig.WHITE);
@@ -155,7 +157,7 @@ public class TextInputField extends BasicElement {
if (input.equals("")) {
- if(!centered) {
+ if (!centered) {
RenderManager.drawString(vg, defaultText, x + 12, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
} else {
RenderManager.drawString(vg, defaultText, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
@@ -163,7 +165,7 @@ public class TextInputField extends BasicElement {
}
if (!password) {
- if(!centered) {
+ if (!centered) {
RenderManager.drawString(vg, input, x + 12, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
} else {
RenderManager.drawString(vg, input, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
@@ -195,7 +197,7 @@ public class TextInputField extends BasicElement {
e.printStackTrace();
}
}
- if(key == Keyboard.KEY_DELETE) {
+ if (key == Keyboard.KEY_DELETE) {
input = "";
}
@@ -258,7 +260,7 @@ public class TextInputField extends BasicElement {
return;
}
if (key == Keyboard.KEY_TAB) {
- if(onlyNums) return;
+ if (onlyNums) return;
input += " ";
caretPos += 4;
return;
@@ -311,7 +313,7 @@ public class TextInputField extends BasicElement {
end = 0f;
}
}
- if(key == Keyboard.KEY_END) {
+ if (key == Keyboard.KEY_END) {
toggled = false;
}
@@ -319,24 +321,24 @@ public class TextInputField extends BasicElement {
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 || key == Keyboard.KEY_HOME) {
return;
}
- if(onlyNums) {
- if(!Character.isDigit(c) && key != 52) return;
+ if (onlyNums) {
+ if (!Character.isDigit(c) && key != 52) return;
}
if (!Character.isDefined(key)) return;
if (!Character.isDefined(c)) return;
- if(GuiScreen.isCtrlKeyDown()) return;
- if(ChatAllowedCharacters.isAllowedCharacter(c)) {
- if(getTextWidth(vg, input) + 22 > width) { // over typing is banned
+ if (GuiScreen.isCtrlKeyDown()) return;
+ if (ChatAllowedCharacters.isAllowedCharacter(c)) {
+ if (getTextWidth(vg, input) + 22 > width) { // over typing is banned
return;
}
-