fix: inventory cell quickslot indicator not readily updating

This commit is contained in:
minjaesong
2024-02-16 05:54:07 +09:00
parent 95f03c74c1
commit 902341bd78
3 changed files with 5 additions and 3 deletions

View File

@@ -97,7 +97,7 @@ internal class UIInventoryCells(
INVENTORY_CELLS_OFFSET_X(),
INVENTORY_CELLS_OFFSET_Y(),
CELLS_HOR, CELLS_VRT,
keyDownFun = createInvCellGenericKeyDownFun(),
keyDownFun = createInvCellGenericKeyDownFun { rebuildList() },
touchDownFun = createInvCellGenericTouchDownFun { rebuildList() },
wheelFun = { _, _, _, _, _, _ -> },
)

View File

@@ -54,7 +54,7 @@ class UIItemInventoryEquippedView(
amount = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
itemImage = null,
drawBackOnNull = true,
keyDownFun = createInvCellGenericKeyDownFun(),
keyDownFun = { _, _, _, _, _ -> },
touchDownFun = createInvCellGenericTouchDownFun(inventoryListRebuildFun), // to "unselect" the equipped item and main item grid would "untick" accordingly
wheelFun = { _, _, _, _, _, _ -> },
emptyCellIcon = equipPosIcon.get(cellToIcon[it], 1),

View File

@@ -114,7 +114,7 @@ open class UIItemInventoryItemGrid(
fun getEstimatedW(horizontalCells: Int) = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
fun getEstimatedH(verticalCells: Int) = verticalCells * UIItemInventoryElemSimple.height + (verticalCells - 1) * listGap
fun createInvCellGenericKeyDownFun(): (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit {
fun createInvCellGenericKeyDownFun(listRebuildFun: () -> Unit): (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit {
return { item: GameItem?, amount: Long, keycode: Int, _, _ ->
if (item != null && Terrarum.ingame != null && keycode in Input.Keys.NUM_0..Input.Keys.NUM_9) {
val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying
@@ -139,6 +139,8 @@ open class UIItemInventoryItemGrid(
inventory.setQuickslotItem(it, null)
}
}
listRebuildFun()
}
}
}