diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-27 18:36:51 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-27 18:36:51 +0200 |
commit | ee479dddc391a2cfb961ba1751e14884e933d3ff (patch) | |
tree | ad88f551255b0069dfa46ec4aa4814d7f49e97c7 /src/main/java/io/polyfrost/oneconfig/gui/pages | |
parent | a93ec306e83f51e121441cb00f04cd9bb36d6951 (diff) | |
download | OneConfig-ee479dddc391a2cfb961ba1751e14884e933d3ff.tar.gz OneConfig-ee479dddc391a2cfb961ba1751e14884e933d3ff.tar.bz2 OneConfig-ee479dddc391a2cfb961ba1751e14884e933d3ff.zip |
Option page start
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/pages')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java | 57 |
1 files changed, 48 insertions, 9 deletions
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 04b2ce7..9d93205 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -1,26 +1,65 @@ package io.polyfrost.oneconfig.gui.pages; +import io.polyfrost.oneconfig.config.OneConfigConfig; import io.polyfrost.oneconfig.config.data.Mod; +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; public class ModConfigPage extends Page { - private final Mod modData; + private final OptionPage page; - public ModConfigPage(Mod mod) { - super("Mod: " + mod.name); - this.modData = mod; + public ModConfigPage(OptionPage page) { + super("Mod: " + page.mod.name); + this.page = page; } @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 + 16; + 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; + int backgroundSize = 32; + for (int i = 0; i < page.categories.get(selectedCategory).get(subCategory).size(); i++) { + BasicOption option = page.categories.get(selectedCategory).get(subCategory).get(i); + if (i + 1 < page.categories.get(selectedCategory).get(subCategory).size()) { + BasicOption nextOption = page.categories.get(selectedCategory).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(); + } + RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20); + + optionY += 16; + for (int i = 0; i < page.categories.get(selectedCategory).get(subCategory).size(); i++) { + BasicOption option = page.categories.get(selectedCategory).get(subCategory).get(i); + option.draw(vg, optionX, optionY); + if (i + 1 < page.categories.get(selectedCategory).get(subCategory).size()) { + BasicOption nextOption = page.categories.get(selectedCategory).get(subCategory).get(i + 1); + if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) { + nextOption.draw(vg, optionX + 464, optionY); + optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16; + i++; + continue; + } + } + optionY += option.getHeight() + 16; + } + } } @Override public void finishUpAndClose() { - modData.config.save(); // TODO - } - - public Mod getModData() { - return modData; + page.mod.config.save(); // TODO } } |