feat: page button in waydrobe keybinds
This commit is contained in:
@@ -2,14 +2,12 @@ package moe.nea.firmament.features.inventory
|
||||
|
||||
import org.lwjgl.glfw.GLFW
|
||||
import net.minecraft.item.Items
|
||||
import net.minecraft.screen.slot.SlotActionType
|
||||
import moe.nea.firmament.annotations.Subscribe
|
||||
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
|
||||
import moe.nea.firmament.features.FirmamentFeature
|
||||
import moe.nea.firmament.gui.config.ManagedConfig
|
||||
import moe.nea.firmament.util.MC
|
||||
import moe.nea.firmament.util.mc.SlotUtils.clickLeftMouseButton
|
||||
import moe.nea.firmament.util.mc.SlotUtils.clickMiddleMouseButton
|
||||
|
||||
object WardrobeKeybinds : FirmamentFeature {
|
||||
override val identifier: String
|
||||
@@ -17,6 +15,9 @@ object WardrobeKeybinds : FirmamentFeature {
|
||||
|
||||
object TConfig : ManagedConfig(identifier, Category.INVENTORY) {
|
||||
val wardrobeKeybinds by toggle("wardrobe-keybinds") { false }
|
||||
val changePageKeybind by keyBinding("change-page") { GLFW.GLFW_KEY_ENTER }
|
||||
val nextPage by keyBinding("next-page") { GLFW.GLFW_KEY_D }
|
||||
val previousPage by keyBinding("previous-page") { GLFW.GLFW_KEY_A }
|
||||
val slotKeybinds = (1..9).map {
|
||||
keyBinding("slot-$it") { GLFW.GLFW_KEY_0 + it }
|
||||
}
|
||||
@@ -37,6 +38,26 @@ object WardrobeKeybinds : FirmamentFeature {
|
||||
if (!regex.matches(event.screen.title.string)) return
|
||||
if (!TConfig.wardrobeKeybinds) return
|
||||
|
||||
if (
|
||||
event.matches(TConfig.changePageKeybind) ||
|
||||
event.matches(TConfig.previousPage) ||
|
||||
event.matches(TConfig.nextPage)
|
||||
) {
|
||||
event.cancel()
|
||||
|
||||
val handler = event.screen.screenHandler
|
||||
val previousSlot = handler.getSlot(45)
|
||||
val nextSlot = handler.getSlot(53)
|
||||
|
||||
val backPressed = event.matches(TConfig.changePageKeybind) || event.matches(TConfig.previousPage)
|
||||
val nextPressed = event.matches(TConfig.changePageKeybind) || event.matches(TConfig.nextPage)
|
||||
|
||||
if (backPressed && previousSlot.stack.item == Items.ARROW) previousSlot.clickLeftMouseButton(handler)
|
||||
if (nextPressed && nextSlot.stack.item == Items.ARROW) nextSlot.clickLeftMouseButton(handler)
|
||||
}
|
||||
|
||||
|
||||
|
||||
val slot =
|
||||
slotKeybindsWithSlot
|
||||
.find { event.matches(it.second.get()) }
|
||||
|
||||
@@ -355,6 +355,12 @@
|
||||
"firmament.config.storage-overlay.scroll-speed": "Scroll Speed",
|
||||
"firmament.config.storage-overlay.scroll-speed.description": "Scroll speed inside of the storage overlay and overview.",
|
||||
"firmament.config.wardrobe-keybinds": "Wardrobe Keybinds",
|
||||
"firmament.config.wardrobe-keybinds.change-page": "Change Page",
|
||||
"firmament.config.wardrobe-keybinds.change-page.description": "Changes the active page",
|
||||
"firmament.config.wardrobe-keybinds.next-page": "Next Page",
|
||||
"firmament.config.wardrobe-keybinds.next-page.description": "Goes to the next page",
|
||||
"firmament.config.wardrobe-keybinds.previous-page": "Previous Page",
|
||||
"firmament.config.wardrobe-keybinds.previous-page.description": "Goes to the previous page",
|
||||
"firmament.config.wardrobe-keybinds.slot-1": "Slot 1",
|
||||
"firmament.config.wardrobe-keybinds.slot-1.description": "Keybind to toggle the first set in your wardrobe",
|
||||
"firmament.config.wardrobe-keybinds.slot-2": "Slot 2",
|
||||
|
||||
Reference in New Issue
Block a user