diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-10-09 13:28:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-09 13:28:21 +0200 |
commit | 6b01ce6c00663b929893e091646971e71becc3be (patch) | |
tree | 61cff8709f359804ae5b5264f7457be8344bdd1a | |
parent | 4c7409ca07be69d2708f22db6bba229a18557ce7 (diff) | |
download | skyhanni-6b01ce6c00663b929893e091646971e71becc3be.tar.gz skyhanni-6b01ce6c00663b929893e091646971e71becc3be.tar.bz2 skyhanni-6b01ce6c00663b929893e091646971e71becc3be.zip |
Feature: Inventory Focus Mode (#2694)
Co-authored-by: jani270 <69345714+jani270@users.noreply.github.com>
4 files changed, 64 insertions, 0 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 new file mode 100644 index 000000000..3211354fe --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.config.features.inventory; + +import at.hannibal2.skyhanni.config.FeatureToggle; +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 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.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @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; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 6e064ced6..71ab7c792 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -85,6 +85,11 @@ public class InventoryConfig { public PersonalCompactorConfig personalCompactor = new PersonalCompactorConfig(); @Expose + @ConfigOption(name = "Focus Mode", desc="") + @Accordion + public FocusModeConfig focusMode = new FocusModeConfig(); + + @Expose @ConfigOption(name = "RNG Meter", desc = "") @Accordion public RngMeterConfig rngMeter = new RngMeterConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt new file mode 100644 index 000000000..c02f29933 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt @@ -0,0 +1,35 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +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.isKeyClicked +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object FocusMode { + + private val config get() = SkyHanniMod.feature.inventory.focusMode + + private var toggle = true + + @SubscribeEvent(priority = EventPriority.LOWEST) + fun onLorenzToolTip(event: LorenzToolTipEvent) { + if (!isEnabled() || !toggle) return + if(event.toolTip.isEmpty()) return + event.toolTip = mutableListOf(event.toolTip.first()) + } + + @SubscribeEvent + fun onLorenzTick(event: LorenzTickEvent) { + if (!isEnabled()) return + if (!config.toggleKey.isKeyClicked()) return + toggle = !toggle + } + + fun isEnabled() = LorenzUtils.inSkyBlock && InventoryUtils.inContainer() && config.enabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index 7ff17f965..0f025e50b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -41,6 +41,8 @@ object InventoryUtils { fun inInventory() = Minecraft.getMinecraft().currentScreen is GuiChest + fun inContainer() = Minecraft.getMinecraft().currentScreen is GuiContainer + fun ContainerChest.getInventoryName() = this.lowerChestInventory.displayName.unformattedText.trim() fun getWindowId(): Int? = (Minecraft.getMinecraft().currentScreen as? GuiChest)?.inventorySlots?.windowId |