diff --git a/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt b/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt index 2d8e962e1..446987b20 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt @@ -23,12 +23,13 @@ class UIItemInventoryElemSimple( override var amount: Long, override var itemImage: TextureRegion?, override var quickslot: Int? = null, - override var equippedSlot: Int? = null, + override var equippedSlot: Int? = null, // remnants of wide cell displaying slot number and highlighting; in this style of cell this field only determines highlightedness at render val drawBackOnNull: Boolean = true, keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self - extraInfo: Any? = null -) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo) { + extraInfo: Any? = null, + highlightEquippedItem: Boolean = true // for some UIs that only cares about getting equipped slot number but not highlighting +) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem) { companion object { val height = UIItemInventoryElemWide.height @@ -55,7 +56,7 @@ class UIItemInventoryElemSimple( Toolkit.fillArea(batch, posX, posY, width, height) } // cell border - batch.color = if (equippedSlot != null || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT + batch.color = if ((equippedSlot != null && highlightEquippedItem) || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT else if (mouseUp && item != null) Toolkit.Theme.COL_ACTIVE else Toolkit.Theme.COL_INVENTORY_CELL_BORDER Toolkit.drawBoxBorder(batch, posX, posY, width, height) @@ -95,7 +96,7 @@ class UIItemInventoryElemSimple( // if mouse is over, text lights up // highlight item count (blocks/walls) if the item is equipped batch.color = item!!.nameColour mul ( - if (equippedSlot != null || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT + if ((equippedSlot != null && highlightEquippedItem) || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT else if (mouseUp && item != null) Toolkit.Theme.COL_ACTIVE else Color.WHITE ) diff --git a/src/net/torvald/terrarum/UIItemInventoryElemWide.kt b/src/net/torvald/terrarum/UIItemInventoryElemWide.kt index a04df6e66..84ea41e80 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElemWide.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElemWide.kt @@ -30,8 +30,9 @@ class UIItemInventoryElemWide( val drawBackOnNull: Boolean = true, keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self - extraInfo: Any? = null -) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo) { + extraInfo: Any? = null, + highlightEquippedItem: Boolean = true // for some UIs that only cares about getting equipped slot number but not highlighting +) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem) { companion object { val height = 48 @@ -73,7 +74,7 @@ class UIItemInventoryElemWide( Toolkit.fillArea(batch, posX, posY, width, height) } // cell border - batch.color = if (equippedSlot != null || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT + batch.color = if ((equippedSlot != null && highlightEquippedItem) || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT else if (mouseUp && item != null) Toolkit.Theme.COL_ACTIVE else Toolkit.Theme.COL_INVENTORY_CELL_BORDER Toolkit.drawBoxBorder(batch, posX, posY, width, height) @@ -91,7 +92,7 @@ class UIItemInventoryElemWide( // if mouse is over, text lights up // highlight item name and count (blocks/walls) if the item is equipped batch.color = item!!.nameColour mul ( - if (equippedSlot != null || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT + if ((equippedSlot != null && highlightEquippedItem) || forceHighlighted) Toolkit.Theme.COL_HIGHLIGHT else if (mouseUp && item != null) Toolkit.Theme.COL_ACTIVE else Color.WHITE ) diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/UICrafting.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/UICrafting.kt index 60296a9ee..f153f9229 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/UICrafting.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/UICrafting.kt @@ -116,6 +116,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory { 6, UIInventoryFull.CELLS_VRT, drawScrollOnRightside = true, drawWallet = false, + highlightEquippedItem = false, keyDownFun = { _, _, _, _, _ -> }, touchDownFun = { gameItem, amount, _, _, button -> recipeClicked?.let { recipe -> gameItem?.let { gameItem -> val itemID = gameItem.dynamicID @@ -239,7 +240,9 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory { private fun changeIngredient(old: InventoryPair, new: ItemID) { itemListPlayer.removeFromForceHighlightList(oldSelectedItems) + oldSelectedItems.remove(old.itm) + oldSelectedItems.add(new) itemListPlayer.addToForceHighlightList(oldSelectedItems) itemListPlayer.rebuild(catAll) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt index 68b90c177..9bed42797 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt @@ -28,7 +28,8 @@ abstract class UIItemInventoryCellBase( open var equippedSlot: Int? = null, val keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self val touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self - open var extraInfo: Any? + open var extraInfo: Any?, + open protected val highlightEquippedItem: Boolean = true // for some UIs that only cares about getting equipped slot number but not highlighting ) : UIItem(parentUI, initialX, initialY) { abstract override fun update(delta: Float) abstract override fun render(batch: SpriteBatch, camera: Camera) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt index 4194b6983..a36298202 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt @@ -45,7 +45,8 @@ open class UIItemInventoryItemGrid( val hideSidebar: Boolean = false, keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self - protected val useHighlightingManager: Boolean = true // only used by UIItemCraftingCandidateGrid which addresses buttons directly to set highlighting + protected val useHighlightingManager: Boolean = true, // only used by UIItemCraftingCandidateGrid which addresses buttons directly to set highlighting + open protected val highlightEquippedItem: Boolean = true // for some UIs that only cares about getting equipped slot number but not highlighting ) : UIItem(parentUI, initialX, initialY) { // deal with the moving position @@ -184,7 +185,8 @@ open class UIItemInventoryItemGrid( itemImage = null, drawBackOnNull = true, keyDownFun = keyDownFun, - touchDownFun = touchDownFun + touchDownFun = touchDownFun, + highlightEquippedItem = highlightEquippedItem ) } // automatically determine how much columns are needed. Minimum Width = 5 grids @@ -202,7 +204,8 @@ open class UIItemInventoryItemGrid( itemImage = null, drawBackOnNull = true, keyDownFun = keyDownFun, - touchDownFun = touchDownFun + touchDownFun = touchDownFun, + highlightEquippedItem = highlightEquippedItem ) }