mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
porting scroll behav to the storage chest
This commit is contained in:
@@ -114,6 +114,23 @@ internal class UIStorageChest : UICanvas(
|
|||||||
itemListUpdate()
|
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
|
// make grid mode buttons work together
|
||||||
itemListChest.itemList.navRemoCon.listButtonListener = { _,_ -> setCompact(false) }
|
itemListChest.itemList.navRemoCon.listButtonListener = { _,_ -> setCompact(false) }
|
||||||
@@ -137,6 +154,23 @@ internal class UIStorageChest : UICanvas(
|
|||||||
itemListUpdate()
|
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.listButtonListener = { _,_ -> setCompact(false) }
|
||||||
itemListPlayer.itemList.navRemoCon.gridButtonListener = { _,_ -> setCompact(true) }
|
itemListPlayer.itemList.navRemoCon.gridButtonListener = { _,_ -> setCompact(true) }
|
||||||
|
|||||||
Reference in New Issue
Block a user