crafting ui item cell highlighting works as intended

This commit is contained in:
minjaesong
2022-07-02 18:06:52 +09:00
parent 60497e4201
commit 4eb3ad07f3
5 changed files with 22 additions and 13 deletions

View File

@@ -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
)