storage chest compact mode buttons now work together

This commit is contained in:
minjaesong
2021-03-16 16:22:16 +09:00
parent 953e44c8d7
commit 5f7db4cf19
2 changed files with 21 additions and 1 deletions

View File

@@ -93,6 +93,20 @@ internal class UIStorageChest : UICanvas(), HasInventory {
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
}
private fun setCompact(yes: Boolean) {
itemListChest.isCompactMode = yes
itemListChest.gridModeButtons[0].highlighted = !yes
itemListChest.gridModeButtons[1].highlighted = yes
itemListChest.itemPage = 0
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
itemListPlayer.isCompactMode = yes
itemListPlayer.gridModeButtons[0].highlighted = !yes
itemListPlayer.gridModeButtons[1].highlighted = yes
itemListPlayer.itemPage = 0
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
}
override fun updateUI(delta: Float) {
if (!initialised) {
initialised = true
@@ -143,6 +157,12 @@ internal class UIStorageChest : UICanvas(), HasInventory {
handler.allowESCtoClose = true
// make grid mode buttons work together
itemListChest.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
itemListChest.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
itemListPlayer.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
itemListPlayer.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
addUIitem(catBar)
addUIitem(itemListChest)
addUIitem(itemListPlayer)

View File

@@ -233,7 +233,7 @@ class UIItemInventoryItemGrid(
posY - 2 + (4 + UIItemInventoryElem.height - catBar.catIcons.tileH) * index
/** Long/compact mode buttons */
private val gridModeButtons = Array<UIItemImageButton>(2) { index ->
internal val gridModeButtons = Array<UIItemImageButton>(2) { index ->
UIItemImageButton(
parentUI,
catBar.catIcons.get(index + 14, 0),