fixed a bug where selected recipe does not highlight

This commit is contained in:
minjaesong
2022-07-02 15:57:58 +09:00
parent 5cd5e9a6bf
commit 60497e4201
4 changed files with 28 additions and 52 deletions

View File

@@ -210,6 +210,9 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
buttonCraft.touchDownListener = { _,_,_,_ ->
getPlayerInventory().let { player -> recipeClicked?.let { recipe ->
val mult = spinnerCraftCount.value.toLong()
// TODO check if player has enough amount of ingredients
itemListIngredients.getInventory().itemList.forEach { (itm, qty) ->
player.remove(itm, qty * mult)
}
@@ -252,6 +255,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
private fun highlightCraftingCandidateButton(button: UIItemInventoryCellBase?) { // a proxy function
itemListCraftable.highlightButton(button)
itemListCraftable.rebuild(catAll)
}
// reset whatever player has selected to null and bring UI to its initial state
@@ -292,22 +296,6 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
}
}
private fun setCompact(yes: Boolean) {
itemListCraftable.isCompactMode = yes
itemListCraftable.gridModeButtons[0].highlighted = !yes
itemListCraftable.gridModeButtons[1].highlighted = yes
itemListCraftable.itemPage = 0
itemListCraftable.rebuild(catAll)
itemListPlayer.isCompactMode = yes
itemListPlayer.gridModeButtons[0].highlighted = !yes
itemListPlayer.gridModeButtons[1].highlighted = yes
itemListPlayer.itemPage = 0
itemListPlayer.rebuild(catAll)
itemListUpdate()
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (!openingClickLatched) {
return super.touchDown(screenX, screenY, pointer, button)