From 8d684679e1f874b288c90a7c781893567e3f869a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 24 Feb 2024 20:11:00 +0100 Subject: Compact Tab List now has toggle tab support. --- .../misc/compacttablist/CompactTabListConfig.java | 9 +++++++ .../misc/compacttablist/TabListRenderer.kt | 31 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java index 4d5530ea3..92db866a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/CompactTabListConfig.java @@ -15,6 +15,15 @@ public class CompactTabListConfig { @FeatureToggle public boolean enabled = false; + @Expose + @ConfigOption( + name = "Toggle Tab", + desc = "Use the tab key to toggle the tab list, not show tab list while the key is pressed. " + + "Similar to patcher's feature." + ) + @ConfigEditorBoolean + public boolean toggleTab = false; + @Expose @ConfigOption(name = "Hide Hypixel Adverts", desc = "Hides text from advertising the Hypixel server or store in the tablist.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt index bff4f3a42..bb5193074 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc.compacttablist import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SkipTabListLineEvent import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiPlayerTabOverlay import at.hannibal2.skyhanni.utils.CollectionUtils.filterToMutable @@ -31,6 +32,36 @@ object TabListRenderer { if (!config.enabled) return event.isCanceled = true + if (config.toggleTab) return + + drawTabList() + } + + private var isPressed = false + private var isTabToggled = false + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.enabled) return + if (!config.toggleTab) return + if (Minecraft.getMinecraft().currentScreen != null) return + + if (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isPressed) { + isPressed = true + } else { + if (isPressed) { + isPressed = false + isTabToggled = !isTabToggled + } + } + + if (isTabToggled) { + drawTabList() + } + } + + private fun drawTabList() { val columns = TabListReader.renderColumns if (columns.isEmpty()) return -- cgit