diff options
author | xander <xander@isxander.dev> | 2022-09-01 14:10:08 +0100 |
---|---|---|
committer | xander <xander@isxander.dev> | 2022-09-01 14:10:08 +0100 |
commit | 627c45bd6cfa7cce9e048d7681029c812a45f1cc (patch) | |
tree | 2c1931b9586b021c1e3d54db7bb1a01d6b644bff /src/main/java/dev/isxander/yacl/gui/YACLScreen.java | |
parent | 21728802a4ee2b65a32b626140ff01bf59a456c6 (diff) | |
download | YetAnotherConfigLib-627c45bd6cfa7cce9e048d7681029c812a45f1cc.tar.gz YetAnotherConfigLib-627c45bd6cfa7cce9e048d7681029c812a45f1cc.tar.bz2 YetAnotherConfigLib-627c45bd6cfa7cce9e048d7681029c812a45f1cc.zip |
category tooltips
fix slider scrolling
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/YACLScreen.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl/gui/YACLScreen.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java index aab047d..6ecbcc7 100644 --- a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java +++ b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java @@ -21,7 +21,7 @@ public class YACLScreen extends Screen { private final Screen parent; public OptionListWidget optionList; - public final List<ButtonWidget> categoryButtons; + public final List<CategoryWidget> categoryButtons; public ButtonWidget finishedSaveButton, cancelResetButton, undoButton; public YACLScreen(YetAnotherConfigLib config, Screen parent) { @@ -40,11 +40,11 @@ public class YACLScreen extends Screen { Dimension<Integer> categoryDim = Dimension.ofInt(padding, padding, columnWidth - padding * 2, 20); int idx = 0; for (ConfigCategory category : config.categories()) { - ButtonWidget categoryWidget = new ButtonWidget( + CategoryWidget categoryWidget = new CategoryWidget( + this, + category, categoryDim.x(), categoryDim.y(), - categoryDim.width(), categoryDim.height(), - category.name(), - (btn) -> changeCategory(categoryButtons.indexOf(btn)) + categoryDim.width(), categoryDim.height() ); if (idx == currentCategoryIdx) categoryWidget.active = false; @@ -96,6 +96,12 @@ public class YACLScreen extends Screen { super.render(matrices, mouseX, mouseY, delta); optionList.render(matrices, mouseX, mouseY, delta); + + for (CategoryWidget categoryWidget : categoryButtons) { + if (categoryWidget.hoveredTicks > 30) { + renderOrderedTooltip(matrices, categoryWidget.wrappedDescription, mouseX, mouseY); + } + } } @Override @@ -103,7 +109,7 @@ public class YACLScreen extends Screen { updateActionAvailability(); } - private void changeCategory(int idx) { + public void changeCategory(int idx) { int currentIndex = 0; for (ButtonWidget categoryWidget : categoryButtons) { categoryWidget.active = currentIndex != idx; |