diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-01 12:36:56 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-01 12:36:56 +0100 |
commit | 9694fd2bf0aa538652b9c65472c5f2017efce195 (patch) | |
tree | a8c9dba6e4dd5359dd01942cba47fd54c84d452b | |
parent | 60f1c29872465a25be4f2c4ca8c5eb1abf69f988 (diff) | |
parent | fb9d2f2633c185faba162d85e4ae71c2a347fbb5 (diff) | |
download | OneConfig-9694fd2bf0aa538652b9c65472c5f2017efce195.tar.gz OneConfig-9694fd2bf0aa538652b9c65472c5f2017efce195.tar.bz2 OneConfig-9694fd2bf0aa538652b9c65472c5f2017efce195.zip |
Merge remote-tracking branch 'origin/master'
26 files changed, 161 insertions, 84 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java index fecd438..c0a4169 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java @@ -28,5 +28,5 @@ public @interface ConfigPage { /** * The category of the page */ - String category() default "general"; + String category() default "General"; } 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 05505a9..a4f4a67 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java @@ -24,7 +24,7 @@ public @interface Option { /** * The category of the component */ - String category() default "general"; + String category() default "General"; /** * The subcategory of the component (displayed as header) diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java index 15c073c..a3752bb 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java @@ -4,10 +4,10 @@ import io.polyfrost.oneconfig.config.interfaces.BasicOption; import io.polyfrost.oneconfig.gui.elements.config.ConfigPageButton; import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedHashMap; public class OptionCategory { - public final HashMap<String, ArrayList<BasicOption>> subcategories = new HashMap<>(); + public final LinkedHashMap<String, ArrayList<BasicOption>> subcategories = new LinkedHashMap<>(); public final ArrayList<ConfigPageButton> topPages = new ArrayList<>(); public final ArrayList<ConfigPageButton> bottomPages = new ArrayList<>(); } diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java index 12aef6a..8103404 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java @@ -1,7 +1,6 @@ package io.polyfrost.oneconfig.config.data; - -import java.util.HashMap; +import java.util.LinkedHashMap; public class OptionPage { public final String name; @@ -11,7 +10,7 @@ public class OptionPage { * Depth 2 = subcategories * Depth 3 = list of options */ - public final HashMap<String, OptionCategory> categories = new HashMap<>(); + public final LinkedHashMap<String, OptionCategory> categories = new LinkedHashMap<>(); public OptionPage(String name, Mod mod) { this.name = name; 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 7e106f4..8376786 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java @@ -9,7 +9,13 @@ public enum OptionType { * Type: boolean */ CHECKBOX, + /** + * Type: boolean + */ DUAL_OPTION, + /** + * Type: int + */ UNI_SELECTOR, /** * Type: String 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 35b299b..2af4357 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java @@ -8,7 +8,10 @@ import io.polyfrost.oneconfig.config.data.Mod; import io.polyfrost.oneconfig.config.data.OptionCategory; import io.polyfrost.oneconfig.config.data.OptionPage; import io.polyfrost.oneconfig.config.profiles.Profiles; +import io.polyfrost.oneconfig.gui.OneConfigGui; import io.polyfrost.oneconfig.gui.elements.config.*; +import io.polyfrost.oneconfig.gui.pages.ModConfigPage; +import net.minecraft.client.Minecraft; import java.io.*; import java.lang.reflect.Field; @@ -20,6 +23,7 @@ import java.util.*; public class Config { protected final String configFile; protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().registerTypeAdapterFactory(OneConfigTypeAdapterFactory.getStaticTypeAdapterFactory()).create(); + private static Mod mod; /** * @param modData information about the mod @@ -36,6 +40,7 @@ public class Config { mod.config = this; generateOptionList(this.getClass(), mod.defaultPage, mod); ConfigCore.oneConfigMods.add(mod); + this.mod = mod; } /** @@ -157,4 +162,12 @@ public class Config { } } } + + /** + * Function to open the gui of this mod + */ + public void openGui() { + if (mod == null) return; + Minecraft.getMinecraft().displayGuiScreen(new OneConfigGui(new ModConfigPage(mod.defaultPage))); + } } diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java index 77d30bd..130df7f 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java @@ -1,7 +1,6 @@ package io.polyfrost.oneconfig.gui; import io.polyfrost.oneconfig.config.OneConfigConfig; -import io.polyfrost.oneconfig.gui.elements.BasicElement; import io.polyfrost.oneconfig.gui.elements.TextInputField; import io.polyfrost.oneconfig.gui.pages.HomePage; import io.polyfrost.oneconfig.gui.pages.Page; @@ -36,6 +35,11 @@ public class OneConfigGui extends GuiScreen { INSTANCE = this; } + public OneConfigGui(Page page) { + INSTANCE = this; + currentPage = page; + } + @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); diff --git a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java index 60f2a93..dc136a7 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java @@ -3,7 +3,9 @@ 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.utils.MathUtils; @@ -18,18 +20,19 @@ public class SideBar { private float targetY = 0, currentY = 0; public SideBar() { - btnList.add(new BasicButton(192, 36, "Dashboard", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage())); - btnList.add(new BasicButton(192, 36, "Global Search", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Mods", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage())); - btnList.add(new BasicButton(192, 36, "Performance", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Profiles", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Updates", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Screenshots", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "HUD Settings", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "General", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Close", "/assets/oneconfig/textures/share.png", null, -1, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(null))); - btnList.add(new BasicButton(192, 36, "Minimize", "/assets/oneconfig/textures/share.png", null, -1, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Edit HUD", "/assets/oneconfig/textures/share.png", null, 0, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(new HudGui()))); + 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()))); } public void draw(long vg, int x, int y) { @@ -53,8 +56,8 @@ public class SideBar { RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 420, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_SEMIBOLD); i = 342; } - if (i == 474) { - i = 518; + if (i == 518) { + i = 562; } if (btn.isClicked() && btn.getPage() != null) { 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 444094e..1587a93 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java @@ -11,6 +11,7 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts; 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; @@ -19,6 +20,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lwjgl.nanovg.NanoVG; +import java.util.ArrayList; + public class ModCard extends BasicElement { private final String iconPath; private final Mod modData; @@ -94,11 +97,21 @@ public class ModCard extends BasicElement { } for (ModMetadata mod : OneConfig.loadedOtherMods) { if (mod.name.equalsIgnoreCase(modData.name)) { - System.out.println("Attempting to run command for a mod that isn't OneConfig: " + mod.name); - for (String commands : ClientCommandHandler.instance.getCommands().keySet()) { - if (commands.equalsIgnoreCase(mod.name) || commands.equalsIgnoreCase(mod.modId)) { + ArrayList<String> possibleCommands = new ArrayList<>(); + possibleCommands.add(mod.name.toLowerCase().replace(" ", "")); + possibleCommands.add(mod.modId.toLowerCase().replaceAll("[ -_]", "")); + if (mod.name.split(" ").length > 1) { + StringBuilder result = new StringBuilder(); + for (String word : mod.name.split(" ")) { + if (word.length() == 0) continue; + result.append(word.charAt(0)); + } + possibleCommands.add(result.toString().toLowerCase()); + } + for (String command : ClientCommandHandler.instance.getCommands().keySet()) { + if (possibleCommands.contains(command)) { try { - ClientCommandHandler.instance.getCommands().get(commands).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{}); + ClientCommandHandler.instance.getCommands().get(command).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{}); } catch (CommandException e) { throw new RuntimeException(e); } diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java index 6832236..93f4378 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java @@ -26,10 +26,10 @@ public class ConfigCheckbox extends BasicOption { toggled = (boolean) get(); } catch (IllegalAccessException ignored) { } - boolean hover = InputUtils.isAreaHovered(x, y, 24, 24); + boolean hover = InputUtils.isAreaHovered(x, y + 4, 24, 24); boolean clicked = InputUtils.isClicked() && hover; - if(clicked) { + if (clicked) { toggled = !toggled; try { set(toggled); @@ -38,18 +38,18 @@ public class ConfigCheckbox extends BasicOption { e.printStackTrace(); } } - if(percentOn != 1f) { // performance - RenderManager.drawRoundedRect(vg, x, y, 24, 24, color, 6f); - RenderManager.drawHollowRoundRect(vg, x, y, 23.5f, 23.5f, OneConfigConfig.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok + if (percentOn != 1f) { // performance + RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, color, 6f); + RenderManager.drawHollowRoundRect(vg, x, y + 4, 23.5f, 23.5f, OneConfigConfig.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok } color = ColorUtils.smoothColor(color, OneConfigConfig.GRAY_600, OneConfigConfig.GRAY_400, hover, 40f); - RenderManager.drawString(vg, name, x + 32, y + 14, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM); + RenderManager.drawString(vg, name, x + 32, y + 17, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM); percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 5f)); - if(percentOn == 0f) return; - if(percentOn != 1f) { - RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB()); + if (percentOn == 0f) return; + if (percentOn != 1f) { + RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y + 4, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB()); } else { // performance, that color could cause havoc am I right definitely - RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y, 24, 24); + RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y + 4, 24, 24); } } 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 f3224b5..4839c61 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -3,25 +3,49 @@ package io.polyfrost.oneconfig.gui.pages; import io.polyfrost.oneconfig.config.OneConfigConfig; import io.polyfrost.oneconfig.config.data.OptionPage; import io.polyfrost.oneconfig.config.interfaces.BasicOption; +import io.polyfrost.oneconfig.gui.elements.BasicButton; import io.polyfrost.oneconfig.gui.elements.config.ConfigPageButton; import io.polyfrost.oneconfig.lwjgl.RenderManager; import io.polyfrost.oneconfig.lwjgl.font.Fonts; +import java.util.ArrayList; + public class ModConfigPage extends Page { private final OptionPage page; + private final ArrayList<BasicButton> categories = new ArrayList<>(); + private String selectedCategory; public ModConfigPage(OptionPage page) { super("Mod: " + page.mod.name); this.page = page; + if (page.categories.size() == 0) return; + for (String category : page.categories.keySet()) { + selectedCategory = category; + break; + } + if (page.categories.size() < 2) return; + for (String category : page.categories.keySet()) { + BasicButton button = new BasicButton(0, 32, category, null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> switchCategory(category)); + if (category.equals(selectedCategory)) button.setToggled(true); + categories.add(button); + } } @Override public void draw(long vg, int x, int y) { if (page.categories.size() == 0) return; - String selectedCategory = page.categories.keySet().stream().findFirst().get(); int optionX = x + 30; int optionY = y + (page.categories.size() == 1 ? 16 : 64); + // Category buttons + int buttonX = x + 16; + for (BasicButton button : categories) { + if (button.getWidth() == 0) + button.setWidth((int) (Math.ceil(RenderManager.getTextWidth(vg, button.getText(), 14f, Fonts.INTER_MEDIUM) / 8f) * 8 + 16)); + button.draw(vg, buttonX, y + 16); + buttonX += button.getWidth() + 16; + } + // Top page buttons for (ConfigPageButton page : page.categories.get(selectedCategory).topPages) { page.draw(vg, optionX, optionY); @@ -29,46 +53,50 @@ public class ModConfigPage extends Page { } // Background - int backgroundSize = 48; - for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) { - backgroundSize += 32; - for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) { - BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i); - if (i + 1 < page.categories.get(selectedCategory).subcategories.get(subCategory).size()) { - BasicOption nextOption = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i + 1); - if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) { - backgroundSize += Math.max(option.getHeight(), nextOption.getHeight()) + 16; - i++; - continue; + if (page.categories.get(selectedCategory).subcategories.keySet().size() > 0) { + int backgroundSize = 16; + for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) { + backgroundSize += 48; + for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) { + BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i); + if (i + 1 < page.categories.get(selectedCategory).subcategories.get(subCategory).size()) { + BasicOption nextOption = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i + 1); + if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) { + backgroundSize += Math.max(option.getHeight(), nextOption.getHeight()) + 16; + i++; + continue; + } } + backgroundSize += option.getHeight() + 16; } - backgroundSize += option.getHeight() + 16; } + RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20); } - RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20); // draw options - optionY += 16; - int optionLastY = optionX; - for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) { - RenderManager.drawString(vg, subCategory, optionX, optionY + 16, OneConfigConfig.WHITE_90, 24f, Fonts.INTER_MEDIUM); - optionY += 48; - for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) { - BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i); - option.draw(vg, optionX, optionY); - if (i + 1 < page.categories.get(selectedCategory).subcategories.get(subCategory).size()) { - BasicOption nextOption = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i + 1); - if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) { - nextOption.draw(vg, optionX + 512, optionY); - optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16; - i++; - continue; + int optionLastY = optionY + 16; + if (page.categories.get(selectedCategory).subcategories.keySet().size() > 0) { + optionY += 16; + for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) { + RenderManager.drawString(vg, subCategory, optionX, optionY + 16, OneConfigConfig.WHITE_90, 24f, Fonts.INTER_MEDIUM); + optionY += 48; + for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) { + BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i); + option.draw(vg, optionX, optionY); + if (i + 1 < page.categories.get(selectedCategory).subcategories.get(subCategory).size()) { + BasicOption nextOption = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i + 1); + if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) { + nextOption.draw(vg, optionX + 512, optionY); + optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16; + i++; + continue; + } } + optionY += option.getHeight() + 16; } - optionY += option.getHeight() + 16; } + optionY += 16; } - optionY += 16; // Bottom page buttons for (ConfigPageButton page : page.categories.get(selectedCategory).bottomPages) { @@ -77,21 +105,23 @@ public class ModConfigPage extends Page { } // Draw last options - for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) { - optionLastY += 48; - for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) { - BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i); - option.drawLast(vg, optionX, optionLastY); - if (i + 1 < page.categories.get(selectedCategory).subcategories.get(subCategory).size()) { - BasicOption nextOption = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i + 1); - if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) { - nextOption.drawLast(vg, optionX + 512, optionLastY); - optionLastY += Math.max(option.getHeight(), nextOption.getHeight()) + 16; - i++; - continue; + if (page.categories.get(selectedCategory).subcategories.keySet().size() > 0) { + for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) { + optionLastY += 48; + for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) { + BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i); + option.drawLast(vg, optionX, optionLastY); + if (i + 1 < page.categories.get(selectedCategory).subcategories.get(subCategory).size()) { + BasicOption nextOption = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i + 1); + if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) { + nextOption.drawLast(vg, optionX + 512, optionLastY); + optionLastY += Math.max(option.getHeight(), nextOption.getHeight()) + 16; + i++; + continue; + } } + optionLastY += option.getHeight() + 16; } - optionLastY += option.getHeight() + 16; } } } @@ -104,11 +134,19 @@ public class ModConfigPage extends Page { @Override public void keyTyped(char key, int keyCode) { if (page.categories.size() == 0) return; - String selectedCategory = page.categories.keySet().stream().findFirst().get(); 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); } } } + + public void switchCategory(String newCategory) { + if (!page.categories.containsKey(newCategory)) return; + selectedCategory = newCategory; + for (BasicButton button : categories) { + if (button.getText().equals(newCategory)) continue; + button.setToggled(false); + } + } } diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java index 3ac04bf..e482e37 100644 --- a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java @@ -73,7 +73,8 @@ public class TestConfig extends Config { @Option( name = "Test check", subcategory = "Other subcategory", - type = OptionType.CHECKBOX + type = OptionType.CHECKBOX, + category = "Test category" ) public static boolean switchTest6; diff --git a/src/main/resources/assets/oneconfig/font/OneConfig Designs (Copy)/Theme.png b/src/main/resources/assets/oneconfig/font/OneConfig Designs (Copy)/Theme.png Binary files differnew file mode 100644 index 0000000..df8e3de --- /dev/null +++ b/src/main/resources/assets/oneconfig/font/OneConfig Designs (Copy)/Theme.png diff --git a/src/main/resources/assets/oneconfig/textures/Dashboard.png b/src/main/resources/assets/oneconfig/textures/Dashboard.png Binary files differnew file mode 100644 index 0000000..179a57d --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Dashboard.png diff --git a/src/main/resources/assets/oneconfig/textures/HUD.png b/src/main/resources/assets/oneconfig/textures/HUD.png Binary files differnew file mode 100644 index 0000000..98c052c --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/HUD.png diff --git a/src/main/resources/assets/oneconfig/textures/HUDSettings.png b/src/main/resources/assets/oneconfig/textures/HUDSettings.png Binary files differnew file mode 100644 index 0000000..9dd5b5d --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/HUDSettings.png diff --git a/src/main/resources/assets/oneconfig/textures/Image.png b/src/main/resources/assets/oneconfig/textures/Image.png Binary files differnew file mode 100644 index 0000000..f9a4d25 --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Image.png diff --git a/src/main/resources/assets/oneconfig/textures/Minimise.png b/src/main/resources/assets/oneconfig/textures/Minimise.png Binary files differnew file mode 100644 index 0000000..dbe5a56 --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Minimise.png diff --git a/src/main/resources/assets/oneconfig/textures/Mods.png b/src/main/resources/assets/oneconfig/textures/Mods.png Binary files differnew file mode 100644 index 0000000..07ebd26 --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Mods.png diff --git a/src/main/resources/assets/oneconfig/textures/Performance.png b/src/main/resources/assets/oneconfig/textures/Performance.png Binary files differnew file mode 100644 index 0000000..fe64b1d --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Performance.png diff --git a/src/main/resources/assets/oneconfig/textures/Profiles.png b/src/main/resources/assets/oneconfig/textures/Profiles.png Binary files differnew file mode 100644 index 0000000..f0574e6 --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Profiles.png diff --git a/src/main/resources/assets/oneconfig/textures/Settings.png b/src/main/resources/assets/oneconfig/textures/Settings.png Binary files differnew file mode 100644 index 0000000..c8c9888 --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Settings.png diff --git a/src/main/resources/assets/oneconfig/textures/Theme.png b/src/main/resources/assets/oneconfig/textures/Theme.png Binary files differnew file mode 100644 index 0000000..df8e3de --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Theme.png diff --git a/src/main/resources/assets/oneconfig/textures/Update.png b/src/main/resources/assets/oneconfig/textures/Update.png Binary files differnew file mode 100644 index 0000000..d44220b --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/Update.png diff --git a/src/main/resources/assets/oneconfig/textures/XCircle.png b/src/main/resources/assets/oneconfig/textures/XCircle.png Binary files differnew file mode 100644 index 0000000..85c82f2 --- /dev/null +++ b/src/main/resources/assets/oneconfig/textures/XCircle.png diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 3c1921e..246a086 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -10,8 +10,8 @@ "authorList": [ "MoonTidez", "DeDiamondPro", - "nxtdaydelivery" - "Wyvest" + "nxtdaydelivery", + "Wyvest" ], "credits": "", "logoFile": "", |