porting scroll behav to the storage chest

This commit is contained in:
minjaesong
2024-01-31 02:26:17 +09:00
parent e1935fb659
commit 3c6e7665fa

View File

@@ -114,6 +114,23 @@ internal class UIStorageChest : UICanvas(
itemListUpdate()
}
}
it.itemListWheelFun = { gameItem, amount, _, scrollY, _, _ ->
if (gameItem != null) {
val amount = scrollY.toLong().coerceIn(
-(getPlayerInventory().searchByID(gameItem.dynamicID)?.qty ?: 0L),
amount
)
// remove from the chest
if (amount >= 1f)
negotiator.refund(getFixtureInventory(), getPlayerInventory(), gameItem, amount)
// add to the chest
else if (amount <= -1f)
negotiator.accept(getPlayerInventory(), getFixtureInventory(), gameItem, -amount)
itemListUpdate()
}
}
}
// make grid mode buttons work together
itemListChest.itemList.navRemoCon.listButtonListener = { _,_ -> setCompact(false) }
@@ -137,6 +154,23 @@ internal class UIStorageChest : UICanvas(
itemListUpdate()
}
}
it.itemListWheelFun = { gameItem, amount, _, scrollY, _, _ ->
if (gameItem != null) {
val amount = scrollY.toLong().coerceIn(
-(getFixtureInventory().searchByID(gameItem.dynamicID)?.qty ?: 0L),
amount
)
// remove from the player
if (amount >= 1f)
negotiator.accept(getPlayerInventory(), getFixtureInventory(), gameItem, amount)
// add to the player
else if (amount <= -1f)
negotiator.refund(getFixtureInventory(), getPlayerInventory(), gameItem, -amount)
itemListUpdate()
}
}
}
itemListPlayer.itemList.navRemoCon.listButtonListener = { _,_ -> setCompact(false) }
itemListPlayer.itemList.navRemoCon.gridButtonListener = { _,_ -> setCompact(true) }