diff options
Diffstat (limited to 'src/main/java/io')
5 files changed, 86 insertions, 6 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java index 8376786..9145790 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java @@ -24,6 +24,9 @@ public enum OptionType { TEXT, SLIDER, COLOR, + /** + * Type: int + */ DROPDOWN, MULTI_DROPDOWN, INFO 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 211c2ce..8ed51f8 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java @@ -120,6 +120,9 @@ public class Config { case UNI_SELECTOR: options.add(new ConfigUniSelector(field, option.name(), option.size(), option.options())); break; + case DROPDOWN: + options.add(new ConfigDropdown(field, option.name(), option.size(), option.options())); + break; } } } diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java new file mode 100644 index 0000000..8dea265 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java @@ -0,0 +1,55 @@ +package io.polyfrost.oneconfig.gui.elements.config; + +import io.polyfrost.oneconfig.config.OneConfigConfig; +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; + +import java.lang.reflect.Field; + +public class ConfigDropdown extends BasicOption { + private final String[] options; + public ConfigDropdown(Field field, String name, int size, String[] options) { + super(field, name, size); + this.options = options; + } + + @Override + public void draw(long vg, int x, int y) { + + } + + @Override + public void drawLast(long vg, int x, int y) { + int selected = 0; + try { + selected = (int) get(); + } catch (IllegalAccessException ignored) { + } + + RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM); + + if (size == 1) { + RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, OneConfigConfig.GRAY_500, 12); + RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.INTER_MEDIUM); + RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); + RenderManager.drawImage(vg, "/assets/oneconfig/textures/dropdown_arrow.png", x + 459, y + 8, 10, 6); + NanoVG.nvgTranslate(vg, x + 469, y + 24); + } else { + RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, OneConfigConfig.GRAY_500, 12); + RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.INTER_MEDIUM); + RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); + RenderManager.drawImage(vg, "/assets/oneconfig/textures/dropdown_arrow.png", x + 971, y + 8, 10, 6); + NanoVG.nvgTranslate(vg, x + 981, y + 24); + } + NanoVG.nvgRotate(vg, (float) Math.toRadians(180)); + RenderManager.drawImage(vg, "/assets/oneconfig/textures/dropdown_arrow.png", 0, 0, 10, 6); + NanoVG.nvgResetTransform(vg); + } + + @Override + public int getHeight() { + return 32; + } +} 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 b3f689c..b999137 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 @@ -32,7 +32,6 @@ public class ConfigTextBox extends BasicOption { } catch (IllegalAccessException ignored) { } - 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, new Color(196,196,196).getRGB()); diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java index bd1fb58..f49d958 100644 --- a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java @@ -71,12 +71,32 @@ public class TestConfig extends Config { public static boolean switchTest5; @Option( - name = "Test check", - subcategory = "Other subcategory", - type = OptionType.CHECKBOX, - category = "Test category" + name = "Favorite food", + subcategory = "Dropdowns", + type = OptionType.DROPDOWN, + category = "Dropdowns", + options = {"Taco", "Pizza", "Hamburger", "Paimon"} + ) + public static int dropdown1; + + @Option( + name = "Favorite food", + subcategory = "Dropdowns", + type = OptionType.DROPDOWN, + category = "Dropdowns", + options = {"Taco", "Pizza", "Hamburger", "Paimon"} + ) + public static int dropdown2; + + @Option( + name = "Favorite food", + subcategory = "Dropdowns", + type = OptionType.DROPDOWN, + category = "Dropdowns", + size = 2, + options = {"Taco", "Pizza", "Hamburger", "Paimon"} ) - public static boolean switchTest6; + public static int dropdown3; public TestConfig() { super(new Mod("hacks", ModType.UTIL_QOL, "ShadyDev", "1.0"), "hacksConfig.json"); |