diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-10-27 23:28:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-27 23:28:03 +0100 |
| commit | 50ee0e0c4e8daad88a225a84b675277229e516c6 (patch) | |
| tree | 5bd00a3e0b846d6f505aef69f9bd7401338c06f0 | |
| parent | 45d20d1b77e0f5c5cdcab0687dc590b726fa913d (diff) | |
| download | SkyHanni-50ee0e0c4e8daad88a225a84b675277229e516c6.tar.gz SkyHanni-50ee0e0c4e8daad88a225a84b675277229e516c6.tar.bz2 SkyHanni-50ee0e0c4e8daad88a225a84b675277229e516c6.zip | |
Improvement: Focus Mode Options (#2844)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java | 14 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt | 25 |
2 files changed, 34 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java index 3211354fe..7cf4e6016 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java @@ -5,12 +5,14 @@ import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.annotations.SearchTag; import org.lwjgl.input.Keyboard; public class FocusModeConfig { @Expose - @ConfigOption(name = "Enabled", desc = "In focus mode you only see the name of the item instead of the whole description.") + @ConfigOption(name = "Enabled", desc = "In focus mode you only see the name of the item instead of the whole description. §eSet a Toggle key below to use.") + @SearchTag("compact hide") @ConfigEditorBoolean @FeatureToggle public boolean enabled = false; @@ -19,4 +21,14 @@ public class FocusModeConfig { @ConfigOption(name = "Toggle Key", desc = "Key to toggle the focus mode on and off.") @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE) public int toggleKey = Keyboard.KEY_NONE; + + @Expose + @ConfigOption(name = "Disable Hint", desc = "Disable the line in item tooltips that show how to enable or disable this feature via key press.") + @ConfigEditorBoolean + public boolean disableHint = false; + + @Expose + @ConfigOption(name = "Always Enabled", desc = "Ignore the keybind and enable this feature all the time.") + @ConfigEditorBoolean + public boolean alwaysEnabled = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt index ad2ae077e..427608d0b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -15,20 +16,36 @@ object FocusMode { private val config get() = SkyHanniMod.feature.inventory.focusMode - private var toggle = true + private var active = false @SubscribeEvent(priority = EventPriority.LOWEST) fun onLorenzToolTip(event: LorenzToolTipEvent) { - if (!isEnabled() || !toggle) return + if (!isEnabled()) return if (event.toolTip.isEmpty()) return - event.toolTip = mutableListOf(event.toolTip.first()) + val keyName = KeyboardManager.getKeyName(config.toggleKey) + + val hint = !config.disableHint && !config.alwaysEnabled && keyName != "NONE" + if (active || config.alwaysEnabled) { + event.toolTip = buildList { + add(event.toolTip.first()) + if (hint) { + add("§7Focus Mode from SkyHanni active!") + add("Press $keyName to disable!") + } + }.toMutableList() + } else { + if (hint) { + event.toolTip.add(1, "§7Press $keyName to enable Focus Mode from SkyHanni!") + } + } } @SubscribeEvent fun onLorenzTick(event: LorenzTickEvent) { if (!isEnabled()) return + if (config.alwaysEnabled) return if (!config.toggleKey.isKeyClicked()) return - toggle = !toggle + active = !active } fun isEnabled() = LorenzUtils.inSkyBlock && InventoryUtils.inContainer() && config.enabled |
