From 784231941661a3108549a1b5cd499bc5f7de2e46 Mon Sep 17 00:00:00 2001 From: nea Date: Fri, 25 Aug 2023 14:18:43 +0200 Subject: Add better key binding support --- .../kotlin/moe/nea/firmament/features/FeatureManager.kt | 2 +- .../moe/nea/firmament/features/inventory/SlotLocking.kt | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/main/kotlin/moe/nea/firmament/features') diff --git a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt index 0c8acb9..facb821 100644 --- a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt +++ b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt @@ -12,7 +12,6 @@ import moe.nea.firmament.Firmament import moe.nea.firmament.features.chat.ChatLinks import moe.nea.firmament.features.debug.DebugView import moe.nea.firmament.features.debug.DeveloperFeatures -import moe.nea.firmament.features.fishing.FishingWarning import moe.nea.firmament.features.fixes.Fixes import moe.nea.firmament.features.inventory.CraftingOverlay import moe.nea.firmament.features.inventory.SaveCursorPosition @@ -54,6 +53,7 @@ object FeatureManager : DataHolder(serializer(), "feature loadFeature(DeveloperFeatures) loadFeature(DebugView) } + allFeatures.forEach { it.config } hasAutoloaded = true } } diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt index f6a197c..ec86341 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt @@ -8,17 +8,17 @@ package moe.nea.firmament.features.inventory import kotlinx.serialization.Serializable import kotlinx.serialization.serializer -import net.minecraft.client.gui.DrawContext -import net.minecraft.entity.player.PlayerInventory import moe.nea.firmament.events.HandledScreenKeyPressedEvent import moe.nea.firmament.events.IsSlotProtectedEvent import moe.nea.firmament.events.SlotRenderEvents import moe.nea.firmament.features.FirmamentFeature -import moe.nea.firmament.keybindings.FirmamentKeyBindings +import moe.nea.firmament.gui.config.ManagedConfig import moe.nea.firmament.mixins.accessor.AccessorHandledScreen import moe.nea.firmament.util.CommonSoundEffects import moe.nea.firmament.util.MC import moe.nea.firmament.util.data.ProfileSpecificDataHolder +import net.minecraft.entity.player.PlayerInventory +import org.lwjgl.glfw.GLFW object SlotLocking : FirmamentFeature { override val identifier: String @@ -29,13 +29,19 @@ object SlotLocking : FirmamentFeature { val lockedSlots: MutableSet = mutableSetOf(), ) + object TConfig : ManagedConfig(identifier) { + val lock by keyBinding("lock") { GLFW.GLFW_KEY_L } + } + + override val config: TConfig + get() = TConfig + object DConfig : ProfileSpecificDataHolder(serializer(), "locked-slots", ::Data) - val keyBinding by FirmamentKeyBindings::SLOT_LOCKING val lockedSlots get() = DConfig.data?.lockedSlots override fun onLoad() { HandledScreenKeyPressedEvent.subscribe { - if (!it.matches(keyBinding)) return@subscribe + if (!it.matches(TConfig.lock)) return@subscribe val inventory = MC.handledScreen ?: return@subscribe inventory as AccessorHandledScreen -- cgit