aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/gui
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-01 11:32:02 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-01 11:32:02 +0200
commitd0d1de91a163d69976ce113cad0fe49556112e36 (patch)
tree52c46b126127ab94adf0f008068aea78d3a5415b /src/main/java/io/polyfrost/oneconfig/gui
parentfe8261cf7c10af90c0154633a6a8f18b3e5bfb12 (diff)
downloadOneConfig-d0d1de91a163d69976ce113cad0fe49556112e36.tar.gz
OneConfig-d0d1de91a163d69976ce113cad0fe49556112e36.tar.bz2
OneConfig-d0d1de91a163d69976ce113cad0fe49556112e36.zip
fix ordering issues
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java97
1 files changed, 53 insertions, 44 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 6bdf9d9..4839c61 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -19,7 +19,10 @@ public class ModConfigPage extends Page {
super("Mod: " + page.mod.name);
this.page = page;
if (page.categories.size() == 0) return;
- selectedCategory = page.categories.keySet().stream().findFirst().get();
+ 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));
@@ -50,46 +53,50 @@ public class ModConfigPage extends Page {
}
// Background
- 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;
+ 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 = optionY;
- 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) {
@@ -98,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;
}
}
}