Allow to scroll exopack inventory when hovering over slots in non OTM guis through config option

Fixes #208
This commit is contained in:
DBotThePony 2022-11-25 14:14:02 +07:00
parent c98ef2b877
commit 5c1aaaa352
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 19 additions and 2 deletions

View File

@ -13,7 +13,7 @@ object ClientConfig {
specBuilder.comment("Clientside Config").push("client")
}
var EXOSUIT_INVENTORY_ROWS: Int by specBuilder
var EXOPACK_INVENTORY_ROWS: Int by specBuilder
.comment("Amount of inventory rows to show when wearing Exosuit")
.defineInRange("exosuitInventoryRows", 3, 3, 6)
@ -21,6 +21,10 @@ object ClientConfig {
.comment("If looking below this angle (actually, looking 'above' as you see in game, but not as you expect it, check with debug screen), Crouch + Jump will trigger jump boost android ability")
.defineInRange("jumpBoostTriggerAngle", 30.0, -180.0, 180.0)
var EXOPACK_FREE_SCROLL: Boolean by specBuilder
.comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar")
.define("exopackFreeScroll", true)
init {
specBuilder.pop()
spec = specBuilder.build()

View File

@ -12,6 +12,7 @@ import net.minecraftforge.client.event.MovementInputUpdateEvent
import net.minecraftforge.client.event.ScreenEvent
import net.minecraftforge.client.event.ScreenEvent.MouseDragged
import net.minecraftforge.client.event.ScreenEvent.MouseScrolled
import ru.dbotthepony.mc.otm.ClientConfig
import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer
@ -220,6 +221,18 @@ fun onMouseScrolled(event: MouseScrolled.Pre) {
event.isCanceled = true
return
}
if (ClientConfig.EXOPACK_FREE_SCROLL && widget.panel is InventoryScrollbarPanel) {
val slot = screen.slotUnderMouse
if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exoPackContainer)) {
widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.scrollDelta)
event.isCanceled = true
return
}
}
return
}
}
}

View File

@ -585,6 +585,6 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
const val MAX_ROWS = 6
var lastScroll = 0
var lastRows by ClientConfig::EXOSUIT_INVENTORY_ROWS
var lastRows by ClientConfig::EXOPACK_INVENTORY_ROWS
}
}