diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-03 20:32:12 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-03 20:32:12 +0100 |
commit | 1618ea0aeb9118c4e12dc0837c8d77226fa7d8a9 (patch) | |
tree | 35548314de237745528d2ab7854ed3dc2a1bd2dd /src/main | |
parent | 3d1b6f71080f2cfc48a36db8880da64073f023bb (diff) | |
download | skyhanni-1618ea0aeb9118c4e12dc0837c8d77226fa7d8a9.tar.gz skyhanni-1618ea0aeb9118c4e12dc0837c8d77226fa7d8a9.tar.bz2 skyhanni-1618ea0aeb9118c4e12dc0837c8d77226fa7d8a9.zip |
Show the custom hotkey name in the harp inventory.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt index f2b17d79d..f210f857c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.utils.InventoryUtils.openInventoryName +import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -25,17 +26,7 @@ object HarpFeatures { override fun hasNext() = currentIndex < 7 - override fun next() = when (currentIndex++) { - 0 -> config.harpKeybinds.key1 - 1 -> config.harpKeybinds.key2 - 2 -> config.harpKeybinds.key3 - 3 -> config.harpKeybinds.key4 - 4 -> config.harpKeybinds.key5 - 5 -> config.harpKeybinds.key6 - 6 -> config.harpKeybinds.key7 - - else -> throw NoSuchElementException("currentIndex: $currentIndex") - } + override fun next() = getKey(currentIndex++) ?: throw NoSuchElementException("currentIndex: $currentIndex") } } @@ -64,6 +55,18 @@ object HarpFeatures { } } + fun getKey(index: Int) = when (index) { + 0 -> config.harpKeybinds.key1 + 1 -> config.harpKeybinds.key2 + 2 -> config.harpKeybinds.key3 + 3 -> config.harpKeybinds.key4 + 4 -> config.harpKeybinds.key5 + 5 -> config.harpKeybinds.key6 + 6 -> config.harpKeybinds.key7 + + else -> null + } + @SubscribeEvent fun onRenderItemTip(event: RenderItemTipEvent) { if (!LorenzUtils.inSkyBlock) return @@ -75,7 +78,8 @@ object HarpFeatures { val index = buttonColors.indexOfFirst { it == event.stack.displayName[1] } if (index == -1) return // this should never happen unless there's an update - event.stackTip = (index + 1).toString() + val keyCode = getKey(index) ?: return + event.stackTip = KeyboardManager.getKeyName(keyCode) } @SubscribeEvent |