diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-10 17:20:24 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-10 17:20:24 +0200 |
commit | f0aac9cac78fc14e2991741061c67b622c039f37 (patch) | |
tree | b957cfafb51656efdaa1cd92ce99281ef27328e9 /src/main/java/cc/polyfrost/oneconfig/gui | |
parent | 20cf8146e88f3ca06399fdf163badef759f01d2c (diff) | |
download | OneConfig-f0aac9cac78fc14e2991741061c67b622c039f37.tar.gz OneConfig-f0aac9cac78fc14e2991741061c67b622c039f37.tar.bz2 OneConfig-f0aac9cac78fc14e2991741061c67b622c039f37.zip |
new category system
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java | 32 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java | 16 |
2 files changed, 44 insertions, 4 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java new file mode 100644 index 0000000..9daa965 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java @@ -0,0 +1,32 @@ +package cc.polyfrost.oneconfig.gui.elements.config; + +import cc.polyfrost.oneconfig.config.OneConfigConfig; +import cc.polyfrost.oneconfig.config.interfaces.BasicOption; +import cc.polyfrost.oneconfig.lwjgl.RenderManager; +import cc.polyfrost.oneconfig.lwjgl.font.Fonts; +import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; +import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.relauncher.FMLLaunchHandler; + +import java.lang.reflect.Field; + +public class ConfigHeader extends BasicOption { + + public ConfigHeader(Field field, String name, int size) { + super(field, name, size); + } + + @Override + public void draw(long vg, int x, int y) { + Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 480 : 992, 32); + RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); + ScissorManager.resetScissor(vg, scissor); + } + + + @Override + public int getHeight() { + return 32; + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java index 790d0e4..bdc7242 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -2,6 +2,7 @@ package cc.polyfrost.oneconfig.gui.pages; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.data.OptionPage; +import cc.polyfrost.oneconfig.config.data.OptionSubcategory; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.elements.BasicButton; @@ -38,7 +39,7 @@ public class ModConfigPage extends Page { @Override public void draw(long vg, int x, int y) { - if (page.categories.size() == 0) return; + /* String filter = OneConfigGui.INSTANCE == null ? "" : OneConfigGui.INSTANCE.getSearchValue().toLowerCase().trim(); LinkedHashMap<String, ArrayList<BasicOption>> filteredSubcategories = new LinkedHashMap<>(page.categories.get(selectedCategory).subcategories); if (!filter.equals("")) { @@ -141,7 +142,14 @@ public class ModConfigPage extends Page { optionLastY += option.getHeight() + 16; } } + }*/ + + if (page.categories.size() == 0) return; + int optionY = y + (page.categories.size() == 1 ? 16 : 64); + for (OptionSubcategory subCategory : page.categories.get(selectedCategory).subcategories) { + optionY += subCategory.draw(vg, x + 30, optionY); } + totalSize = optionY - y; } @Override @@ -166,9 +174,9 @@ public class ModConfigPage extends Page { @Override public void keyTyped(char key, int keyCode) { if (page.categories.size() == 0) return; - for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) { - for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) { - page.categories.get(selectedCategory).subcategories.get(subCategory).get(i).keyTyped(key, keyCode); + for (OptionSubcategory subCategory : page.categories.get(selectedCategory).subcategories) { + for (BasicOption option : subCategory.options) { + option.keyTyped(key, keyCode); } } } |