diff options
author | isXander <xander@isxander.dev> | 2023-05-27 21:32:41 +0100 |
---|---|---|
committer | isXander <xander@isxander.dev> | 2023-05-27 21:32:41 +0100 |
commit | 42cce53d6b5eccd1218c0fe0ea576417cb5e0119 (patch) | |
tree | a6cfad07f7f06f3c4a7b1e05d7888ab1b99cd596 /common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java | |
parent | d014d66e3aeda3399b86294119c13501cab5b8c1 (diff) | |
download | YetAnotherConfigLib-42cce53d6b5eccd1218c0fe0ea576417cb5e0119.tar.gz YetAnotherConfigLib-42cce53d6b5eccd1218c0fe0ea576417cb5e0119.tar.bz2 YetAnotherConfigLib-42cce53d6b5eccd1218c0fe0ea576417cb5e0119.zip |
reimplement category tooltips
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java')
-rw-r--r-- | common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java index d225d7e..1e52cde 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java +++ b/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java @@ -6,6 +6,9 @@ import dev.isxander.yacl.api.*; import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.api.utils.MutableDimension; import dev.isxander.yacl.api.utils.OptionUtils; +import dev.isxander.yacl.gui.tab.ScrollableNavigationBar; +import dev.isxander.yacl.gui.tab.ListHolderWidget; +import dev.isxander.yacl.gui.tab.TabExt; import dev.isxander.yacl.gui.utils.GuiUtils; import dev.isxander.yacl.impl.utils.YACLConstants; import net.minecraft.ChatFormatting; @@ -15,7 +18,6 @@ import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.components.tabs.Tab; import net.minecraft.client.gui.components.tabs.TabManager; import net.minecraft.client.gui.components.tabs.TabNavigationBar; @@ -25,13 +27,10 @@ import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Nullable; -import java.io.*; import java.util.HashSet; -import java.util.Optional; import java.util.Set; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; @@ -213,10 +212,11 @@ public class YACLScreen extends Screen { } } - private class CategoryTab implements Tab { + private class CategoryTab implements TabExt { private final ConfigCategory category; + private final Tooltip tooltip; - private TabListWidget<OptionListWidget> optionList; + private ListHolderWidget<OptionListWidget> optionList; private final Button saveFinishedButton; private final Button cancelResetButton; private final Button undoButton; @@ -225,6 +225,7 @@ public class YACLScreen extends Screen { public CategoryTab(ConfigCategory category) { this.category = category; + this.tooltip = Tooltip.create(category.tooltip()); int columnWidth = width / 3; int padding = columnWidth / 20; @@ -261,7 +262,7 @@ public class YACLScreen extends Screen { searchQuery -> optionList.getList().updateSearchQuery(searchQuery) ); - this.optionList = new TabListWidget<>( + this.optionList = new ListHolderWidget<>( () -> new ScreenRectangle(tabArea.position(), tabArea.width() / 3 * 2 + 1, tabArea.height()), new OptionListWidget(YACLScreen.this, category, minecraft, 0, 0, width / 3 * 2 + 1, height, desc -> { descriptionWidget.setOptionDescription(desc); @@ -308,6 +309,12 @@ public class YACLScreen extends Screen { descriptionWidget.tick(); } + @Nullable + @Override + public Tooltip getTooltip() { + return tooltip; + } + private void updateButtons() { boolean pendingChanges = pendingChanges(); @@ -319,11 +326,13 @@ public class YACLScreen extends Screen { } } - private class PlaceholderTab implements Tab { + private class PlaceholderTab implements TabExt { private final PlaceholderCategory category; + private final Tooltip tooltip; public PlaceholderTab(PlaceholderCategory category) { this.category = category; + this.tooltip = Tooltip.create(category.tooltip()); } @Override @@ -340,5 +349,10 @@ public class YACLScreen extends Screen { public void doLayout(ScreenRectangle screenRectangle) { minecraft.setScreen(category.screen().apply(minecraft, YACLScreen.this)); } + + @Override + public @Nullable Tooltip getTooltip() { + return this.tooltip; + } } } |