diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-29 18:01:59 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-29 18:01:59 +0200 |
commit | ccec3f80c799b0127d7402201be63773916826bf (patch) | |
tree | b483204b16ac6b31da6555c242c6415d63b51951 /src/main/java/io/polyfrost | |
parent | 86f6f3e8c3ae91ddbc29985f73e1d4f29f0a4b17 (diff) | |
download | OneConfig-ccec3f80c799b0127d7402201be63773916826bf.tar.gz OneConfig-ccec3f80c799b0127d7402201be63773916826bf.tar.bz2 OneConfig-ccec3f80c799b0127d7402201be63773916826bf.zip |
fix a bunch of things
Diffstat (limited to 'src/main/java/io/polyfrost')
5 files changed, 32 insertions, 25 deletions
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 6f3c1b4..ef0b5a0 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java @@ -52,6 +52,10 @@ public class TextInputField extends BasicElement { this.password = password; } + public boolean getPassword() { + return password; + } + @Override public void draw(long vg, int x, int y) { this.x = x; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java index 5386fc9..65be59f 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java @@ -27,18 +27,18 @@ public class ConfigPage extends BasicOption { @Override public void draw(long vg, int x, int y) { int height = description.equals("") ? 64 : 96; - NanoVG.nvgScissor(vg, x - 2, y, 1024, height); + NanoVG.nvgScissor(vg, x - 16, y, 1024, height); boolean hovered = InputUtils.isAreaHovered(x - 2, y, 1024, height); boolean clicked = InputUtils.isAreaClicked(x - 2, y, 1024, height); backgroundColor = ColorUtils.smoothColor(backgroundColor, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, hovered, 100); if (clicked) NanoVG.nvgGlobalAlpha(vg, 0.8f); - RenderManager.drawRoundedRect(vg, x - 2, y, 1024, height, backgroundColor, 20); - RenderManager.drawString(vg, name, x + 24, y + 32, OneConfigConfig.WHITE, 24, Fonts.INTER_MEDIUM); + RenderManager.drawRoundedRect(vg, x - 16, y, 1024, height, backgroundColor, 20); + RenderManager.drawString(vg, name, x + 10, y + 32, OneConfigConfig.WHITE, 24, Fonts.INTER_MEDIUM); if (!description.equals("")) - RenderManager.drawString(vg, name, x + 24, y + 70, OneConfigConfig.WHITE, 14, Fonts.INTER_MEDIUM); - RenderManager.drawImage(vg, "/assets/oneconfig/textures/arrow.png", x + 995f, y + (description.equals("") ? 20f : 36f), 13, 22); + RenderManager.drawString(vg, name, x + 10, y + 70, OneConfigConfig.WHITE, 14, Fonts.INTER_MEDIUM); + RenderManager.drawImage(vg, "/assets/oneconfig/textures/arrow.png", x + 981f, y + (description.equals("") ? 20f : 36f), 13, 22); if (clicked) OneConfigGui.INSTANCE.openPage(new ModConfigPage(page)); NanoVG.nvgGlobalAlpha(vg, 1f); diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java index 8b96df1..4d44701 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java @@ -5,6 +5,7 @@ import io.polyfrost.oneconfig.config.interfaces.BasicOption; import io.polyfrost.oneconfig.gui.elements.TextInputField; import io.polyfrost.oneconfig.lwjgl.RenderManager; import io.polyfrost.oneconfig.lwjgl.font.Fonts; +import io.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.nanovg.NanoVG; import java.lang.reflect.Field; @@ -34,11 +35,18 @@ public class ConfigTextBox extends BasicOption { NanoVG.nvgResetScissor(vg); textField.draw(vg, x + (size == 1 && hasHalfSize() ? 224 : 352), y); + + if (secure) RenderManager.drawImage(vg, "/assets/oneconfig/textures/eye.png", x + 967, y + 7, 18, 18); + if (secure && InputUtils.isAreaClicked(x + 967, y + 7, 18, 18)) textField.setPassword(!textField.getPassword()); } @Override public void keyTyped(char key, int keyCode) { textField.keyTyped(key, keyCode); + try { + set(textField.getInput()); + } catch (IllegalAccessException ignored) { + } } @Override diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java index 3bae729..9d5dd6e 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -5,6 +5,7 @@ import io.polyfrost.oneconfig.config.data.OptionPage; import io.polyfrost.oneconfig.config.interfaces.BasicOption; import io.polyfrost.oneconfig.lwjgl.RenderManager; import io.polyfrost.oneconfig.lwjgl.font.Fonts; +import org.lwjgl.nanovg.NanoVG; public class ModConfigPage extends Page { private final OptionPage page; @@ -17,12 +18,13 @@ public class ModConfigPage extends Page { @Override public void draw(long vg, int x, int y) { if (page.categories.size() == 0) return; + NanoVG.nvgScissor(vg, x + 14, y, 1056, 800); String selectedCategory = page.categories.keySet().stream().findFirst().get(); int optionX = x + 30; int optionY = y + (page.categories.size() == 1 ? 32 : 72); for (String subCategory : page.categories.get(selectedCategory).keySet()) { RenderManager.drawString(vg, subCategory, x + 18, optionY, OneConfigConfig.WHITE, 24f, Fonts.INTER_MEDIUM); - optionY += 20; + optionY += 26; int backgroundSize = 32; for (int i = 0; i < page.categories.get(selectedCategory).get(subCategory).size(); i++) { @@ -35,9 +37,9 @@ public class ModConfigPage extends Page { continue; } } - backgroundSize += option.getHeight(); + backgroundSize += option.getHeight() + 16; } - RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20); + RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize - 16, OneConfigConfig.GRAY_900, 20); optionY += 16; for (int i = 0; i < page.categories.get(selectedCategory).get(subCategory).size(); i++) { @@ -54,8 +56,9 @@ public class ModConfigPage extends Page { } optionY += option.getHeight() + 16; } - optionY += 8; + optionY += 28; } + NanoVG.nvgResetScissor(vg); } @Override diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java index a7b7b90..fc8296d 100644 --- a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java @@ -9,35 +9,35 @@ import io.polyfrost.oneconfig.config.interfaces.Config; public class TestConfig extends Config { @Option( - name = "Test switch", + name = "Test checkbox", description = "Best description", subcategory = "Test", - type = OptionType.SWITCH + type = OptionType.CHECKBOX ) public static boolean switchTest; @Option( - name = "Test switch", + name = "Test checkbox", description = "Best description", subcategory = "Test", - type = OptionType.SWITCH + type = OptionType.CHECKBOX ) public static boolean switchTest1; @Option( - name = "Test switch", + name = "Test checkbox", description = "Best description", subcategory = "Test", - type = OptionType.SWITCH, + type = OptionType.CHECKBOX, size = 2 ) public static boolean switchTest2; @Option( - name = "Test switch", + name = "Test checkbox", description = "Best description", subcategory = "Test", - type = OptionType.SWITCH + type = OptionType.CHECKBOX ) public static boolean switchTest3; @@ -49,14 +49,6 @@ public class TestConfig extends Config { public static TestPage testPage = new TestPage(); @Option( - name = "Test Page But better", - type = OptionType.PAGE, - subcategory = "Test", - description = "The best page to have ever existed" - ) - public static TestPage testPage2 = new TestPage(); - - @Option( name = "Test switch", description = "Best description", subcategory = "Other subcategory", |