aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
diff options
context:
space:
mode:
authorisXander <isxander@users.noreply.github.com>2022-09-18 19:14:58 +0100
committerisXander <isxander@users.noreply.github.com>2022-09-18 19:15:09 +0100
commit33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd (patch)
treea964082d62c3b13f5628c036fe49f9ea19d32315 /src/main/java/dev/isxander/yacl/gui/YACLScreen.java
parent564a028eed25cfce0e0486f1a1a21affb499a311 (diff)
downloadYetAnotherConfigLib-33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd.tar.gz
YetAnotherConfigLib-33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd.tar.bz2
YetAnotherConfigLib-33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd.zip
1.3.0
option tooltips now consume the pending value PlaceholderCategory: a category that when selected, just opens a screen
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/YACLScreen.java')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/YACLScreen.java36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
index 26f4ad5..80ffb0e 100644
--- a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
+++ b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
@@ -1,10 +1,7 @@
package dev.isxander.yacl.gui;
import com.mojang.blaze3d.systems.RenderSystem;
-import dev.isxander.yacl.api.ConfigCategory;
-import dev.isxander.yacl.api.Option;
-import dev.isxander.yacl.api.OptionFlag;
-import dev.isxander.yacl.api.YetAnotherConfigLib;
+import dev.isxander.yacl.api.*;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.api.utils.OptionUtils;
import dev.isxander.yacl.impl.YACLConstants;
@@ -32,13 +29,11 @@ public class YACLScreen extends Screen {
private final Screen parent;
public OptionListWidget optionList;
-// public final List<CategoryWidget> categoryButtons;
public CategoryListWidget categoryList;
public TooltipButtonWidget finishedSaveButton, cancelResetButton, undoButton;
public SearchFieldWidget searchFieldWidget;
- public Text saveButtonMessage;
- public Text saveButtonTooltipMessage;
+ public Text saveButtonMessage, saveButtonTooltipMessage;
private int saveButtonMessageTime;
@@ -46,34 +41,15 @@ public class YACLScreen extends Screen {
super(config.title());
this.config = config;
this.parent = parent;
-// this.categoryButtons = new ArrayList<>();
this.currentCategoryIdx = 0;
}
@Override
protected void init() {
-// categoryButtons.clear();
int columnWidth = width / 3;
int padding = columnWidth / 20;
columnWidth = Math.min(columnWidth, 400);
int paddedWidth = columnWidth - padding * 2;
-// Dimension<Integer> categoryDim = Dimension.ofInt(width / 3 / 2, padding, paddedWidth, 20);
-// int idx = 0;
-// for (ConfigCategory category : config.categories()) {
-// CategoryWidget categoryWidget = new CategoryWidget(
-// this,
-// category,
-// idx,
-// categoryDim.x() - categoryDim.width() / 2, categoryDim.y(),
-// categoryDim.width(), categoryDim.height()
-// );
-//
-// categoryButtons.add(categoryWidget);
-// addDrawableChild(categoryWidget);
-//
-// idx++;
-// categoryDim.move(0, 21);
-// }
Dimension<Integer> actionDim = Dimension.ofInt(width / 3 / 2, height - padding - 20, paddedWidth, 20);
finishedSaveButton = new TooltipButtonWidget(this, actionDim.x() - actionDim.width() / 2, actionDim.y(), actionDim.width(), actionDim.height(), Text.empty(), Text.empty(), (btn) -> {
@@ -167,8 +143,12 @@ public class YACLScreen extends Screen {
}
public void changeCategory(int idx) {
- currentCategoryIdx = idx;
- optionList.refreshOptions();
+ if (currentCategoryIdx != -1 && config.categories().get(idx) instanceof PlaceholderCategory placeholderCategory) {
+ client.setScreen(placeholderCategory.screen().apply(client, this));
+ } else {
+ currentCategoryIdx = idx;
+ optionList.refreshOptions();
+ }
}
private void updateActionAvailability() {