diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-26 20:35:35 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-26 20:35:35 +0200 |
commit | aad5111d45a66d943f0bcbe885ccb28249441d11 (patch) | |
tree | 94bcedd85c1725a7a813185b0a931ffc3eb215fd /src/main/java/io/polyfrost/oneconfig/gui | |
parent | 5eb52cdd6ce2e65be7eefecfea7cfdb63404f481 (diff) | |
download | OneConfig-aad5111d45a66d943f0bcbe885ccb28249441d11.tar.gz OneConfig-aad5111d45a66d943f0bcbe885ccb28249441d11.tar.bz2 OneConfig-aad5111d45a66d943f0bcbe885ccb28249441d11.zip |
config system rewrite
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui')
13 files changed, 51 insertions, 226 deletions
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 071a311..09c6aa0 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java @@ -2,7 +2,7 @@ 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.Mod; import io.polyfrost.oneconfig.config.data.ModType; import io.polyfrost.oneconfig.gui.OneConfigGui; import io.polyfrost.oneconfig.gui.pages.ModConfigPage; @@ -19,14 +19,14 @@ import org.lwjgl.nanovg.NanoVG; public class ModCard extends BasicElement { private final String iconPath; - private final ModData modData; + private final Mod modData; private final BasicElement favoriteHitbox = new BasicElement(32, 32, -2, true); private boolean active, disabled, favorite; private int colorGray = OneConfigConfig.GRAY_600; private int colorPrimary = OneConfigConfig.BLUE_600; private boolean isHoveredMain = false; - public ModCard(@NotNull ModData mod, @Nullable String iconPath, boolean active, boolean disabled, boolean favorite) { + public ModCard(@NotNull Mod mod, @Nullable String iconPath, boolean active, boolean disabled, boolean favorite) { super(244, 119, false); this.modData = mod; this.iconPath = iconPath; @@ -83,7 +83,7 @@ public class ModCard extends BasicElement { public void onClick() { if (isHoveredMain) { - for (ModData data : OneConfig.loadedMods) { + for (Mod data : OneConfig.loadedMods) { if (data.modType != ModType.OTHER) { if (data.name.equalsIgnoreCase(modData.name)) { OneConfigGui.INSTANCE.openPage(new ModConfigPage(data)); @@ -113,7 +113,7 @@ public class ModCard extends BasicElement { } } - public ModData getModData() { + public Mod getModData() { return modData; } 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 new file mode 100644 index 0000000..c761cd7 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java @@ -0,0 +1,26 @@ +package io.polyfrost.oneconfig.gui.elements.config; + +import io.polyfrost.oneconfig.config.data.OptionPage; +import io.polyfrost.oneconfig.config.interfaces.BasicOption; + +import java.lang.reflect.Field; + +public class ConfigPage extends BasicOption { + public final OptionPage page; + + public ConfigPage(Field field, String name, String description, int size, OptionPage page) { + super(field, name, description, size); + this.page = page; + } + + + @Override + public void draw(long vg, int x, int y, int mouseX, int mouseY) { + + } + + @Override + public int getHeight() { + return 0; + } +} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java index 753d8f6..3da2480 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java @@ -1,22 +1,23 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.config.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.BasicOption; import java.lang.reflect.Field; -public class OConfigSwitch extends Option { +public class ConfigSwitch extends BasicOption { - public OConfigSwitch(Field field, String name, String description, int size) { + public ConfigSwitch(Field field, String name, String description, int size) { super(field, name, description, size); } - @Override - public int getHeight() { - return 0; - } @Override public void draw(long vg, int x, int y, int mouseX, int mouseY) { } + + @Override + public int getHeight() { + 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 deleted file mode 100644 index a19cb55..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java +++ /dev/null @@ -1,36 +0,0 @@ -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, int size) { - super(field, name, description, size); - this.text = text; - element = new BasicElement(128, 32, 1, true); - } - - @Override - public int getHeight() { - return 0; - } - - @Override - 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 deleted file mode 100644 index aa763ef..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements.config; - -import io.polyfrost.oneconfig.config.interfaces.Option; - -import java.util.List; - -public class OConfigCategory extends Option { - public final List<Option> options; - - public OConfigCategory(String name, String description, List<Option> options, int size) { - super(null, name, description, size); - this.options = options; - } - - @Override - public int getHeight() { - return 0; - } - - @Override - 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 deleted file mode 100644 index ed98bd4..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements.config; - -import io.polyfrost.oneconfig.config.interfaces.Option; - -import java.lang.reflect.Field; - -public class OConfigColor extends Option { - private final boolean allowAlpha; - - public OConfigColor(Field field, String name, String description, boolean allowAlpha, int size) { - super(field, name, description, size); - this.allowAlpha = allowAlpha; - } - - @Override - public int getHeight() { - return 0; - } - - @Override - 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 deleted file mode 100644 index 8e36fe9..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigHud.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements.config; - -import io.polyfrost.oneconfig.config.interfaces.Option; - -import java.lang.reflect.Field; - -public class OConfigHud extends Option { - - public OConfigHud(Field field, String name, String description, int size) { - super(field, name, description, size); - } - - @Override - public int getHeight() { - return 0; - } - - @Override - 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 deleted file mode 100644 index 30bb709..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements.config; - -import io.polyfrost.oneconfig.config.interfaces.Option; - -import java.lang.reflect.Field; - -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, int size) { - super(field, name, description, size); - this.options = options; - this.defaultSelection = defaultSelection; - } - - @Override - public int getHeight() { - return 0; - } - - @Override - 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 deleted file mode 100644 index bb3a485..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements.config; - -import io.polyfrost.oneconfig.config.interfaces.Option; - -import java.lang.reflect.Field; - -public class OConfigSlider extends Option { - private final float min; - private final float max; - private final float precision; - - 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; - } - - @Override - public int getHeight() { - return 0; - } - - @Override - 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 deleted file mode 100644 index 606d493..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements.config; - -import io.polyfrost.oneconfig.config.interfaces.Option; - -import java.lang.reflect.Field; - -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, int size) { - super(field, name, description, size); - this.placeholder = placeholder; - this.hideText = hideText; - } - - @Override - public int getHeight() { - return 0; - } - - @Override - public void draw(long vg, int x, int y, int mouseX, int mouseY) { - - } -} 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 357d684..6d24f4a 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -1,18 +1,16 @@ 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 io.polyfrost.oneconfig.config.data.Mod; +import io.polyfrost.oneconfig.config.interfaces.BasicOption; import java.util.ArrayList; public class ModConfigPage extends Page { - private final ModData modData; - private final ArrayList<Option> options; + private final Mod modData; + private final ArrayList<BasicOption> options; - public ModConfigPage(ModData mod) { + public ModConfigPage(Mod mod) { super("Mod: " + mod.name); this.modData = mod; options = ConfigCore.settings.get(mod); @@ -20,21 +18,7 @@ public class ModConfigPage extends Page { @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 @@ -42,11 +26,11 @@ public class ModConfigPage extends Page { modData.config.save(); // TODO } - public ModData getModData() { + public Mod getModData() { return modData; } - protected ArrayList<Option> getOptions() { + protected ArrayList<BasicOption> 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 9fc14f7..b45facb 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -2,7 +2,7 @@ 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.Mod; import io.polyfrost.oneconfig.config.data.ModType; import io.polyfrost.oneconfig.gui.elements.BasicButton; import io.polyfrost.oneconfig.gui.elements.ModCard; @@ -19,7 +19,7 @@ public class ModsPage extends Page { public ModsPage() { super("Mods"); - for (ModData modData : OneConfig.loadedMods) { + for (Mod modData : OneConfig.loadedMods) { modCards.add(new ModCard(modData, null, true, false, false)); } for (ModCard card : modCards) { diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java index 8dbdea9..43cc423 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java @@ -2,7 +2,7 @@ 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.Mod; import io.polyfrost.oneconfig.config.data.ModType; import io.polyfrost.oneconfig.gui.elements.ModCard; import io.polyfrost.oneconfig.lwjgl.RenderManager; @@ -16,7 +16,7 @@ public class PerformanceModsPage extends Page { public PerformanceModsPage() { super("Performance Mods"); - for (ModData mod : OneConfig.loadedMods) { + for (Mod mod : OneConfig.loadedMods) { if (mod.modType == ModType.PERFORMANCE) { modCards.add(new ModCard(mod, null, true, false, false)); } |