diff --git a/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt b/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt index 99279eb1a..49d58ad17 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt @@ -32,8 +32,8 @@ class UIItemInventoryElemSimple( touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self extraInfo: Any? = null, highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting - var colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme -) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem) { + colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme +) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) { companion object { val height = UIItemInventoryElemWide.height @@ -62,7 +62,7 @@ class UIItemInventoryElemSimple( // cell background if (item != null || drawBackOnNull) { - batch.color = Toolkit.Theme.COL_CELL_FILL + batch.color = colourTheme.cellBackgroundCol Toolkit.fillArea(batch, posX, posY, width, height) } // cell border diff --git a/src/net/torvald/terrarum/UIItemInventoryElemWide.kt b/src/net/torvald/terrarum/UIItemInventoryElemWide.kt index 4367c3e54..e31f52e1b 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElemWide.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElemWide.kt @@ -34,8 +34,8 @@ class UIItemInventoryElemWide( touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self extraInfo: Any? = null, highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting - var colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme -) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem) { + colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme +) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) { companion object { val height = 48 @@ -87,7 +87,7 @@ class UIItemInventoryElemWide( // cell background if (item != null || drawBackOnNull) { - batch.color = Toolkit.Theme.COL_CELL_FILL + batch.color = colourTheme.cellBackgroundCol Toolkit.fillArea(batch, posX, posY, width, height) } // cell border diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt index 223fd2e0f..e3a4c53bb 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryCellBase.kt @@ -31,7 +31,8 @@ abstract class UIItemInventoryCellBase( 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 protected val highlightEquippedItem: Boolean = true // for some UIs that only cares about getting equipped slot number but not highlighting + open protected val highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting + var colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme ) : UIItem(parentUI, initialX, initialY) { abstract override fun update(delta: Float) abstract override fun render(batch: SpriteBatch, camera: OrthographicCamera) @@ -97,24 +98,27 @@ object UIItemInventoryCellCommonRes { } val defaultInventoryCellTheme = InventoryCellColourTheme( - Toolkit.Theme.COL_SELECTED, - Toolkit.Theme.COL_LIST_DEFAULT, - Toolkit.Theme.COL_MOUSE_UP, - Toolkit.Theme.COL_INVENTORY_CELL_BORDER, - Toolkit.Theme.COL_SELECTED, - Color.WHITE, - Toolkit.Theme.COL_MOUSE_UP, - Color.WHITE, + Toolkit.Theme.COL_SELECTED, + Toolkit.Theme.COL_LIST_DEFAULT, + Toolkit.Theme.COL_MOUSE_UP, + Toolkit.Theme.COL_INVENTORY_CELL_BORDER, + Toolkit.Theme.COL_SELECTED, + Color.WHITE, + Toolkit.Theme.COL_MOUSE_UP, + Color.WHITE, + Toolkit.Theme.COL_CELL_FILL ) } data class InventoryCellColourTheme( - val cellHighlightMainCol: Color, - val cellHighlightSubCol: Color, - val cellHighlightMouseUpCol: Color, - val cellHighlightNormalCol: Color, - val textHighlightMainCol: Color, - val textHighlightSubCol: Color, - val textHighlightMouseUpCol: Color, - val textHighlightNormalCol: Color, -) \ No newline at end of file + val cellHighlightMainCol: Color, + val cellHighlightSubCol: Color, + val cellHighlightMouseUpCol: Color, + val cellHighlightNormalCol: Color, + val textHighlightMainCol: Color, + val textHighlightSubCol: Color, + val textHighlightMouseUpCol: Color, + val textHighlightNormalCol: Color, + val cellBackgroundCol: Color? +) { +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt index f057028fb..563bf03f9 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt @@ -17,6 +17,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.defaultInventoryCellTheme +import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UIItem import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack @@ -377,6 +378,19 @@ open class UIItemInventoryItemGrid( forceHighlightList.removeAll(items) } + private val itemGridDefaultColourTheme = defaultInventoryCellTheme + private val itemGridCraftingResultColourTheme = InventoryCellColourTheme( + Toolkit.Theme.COL_INACTIVE, + Toolkit.Theme.COL_INACTIVE, + Toolkit.Theme.COL_INACTIVE, + Toolkit.Theme.COL_INACTIVE, + Color.WHITE, + Color.WHITE, + Color.WHITE, + Color.WHITE, + Toolkit.Theme.COL_CELL_FILL_ALT + ) + /** * Special function for UICrafting to show how much the player already has the recipe's product * @@ -404,21 +418,27 @@ open class UIItemInventoryItemGrid( inventorySortList.sortBy { ItemCodex[it.itm]!!.name } // add an appendix + var hasAppendix = false if (itemAppendix.isNotBlank()) { getInventory().filter { it.itm == itemAppendix }.let { inventorySortList.addAll(it) + hasAppendix = it.isNotEmpty() } } + val appendixIndex = if (hasAppendix) inventorySortList.lastIndex else -1 + // map sortList to item list for (k in items.indices) { val item = items[k] // we have an item try { - val sortListItem = inventorySortList[k + itemPage * items.size] + val index = k + itemPage * items.size + val sortListItem = inventorySortList[index] item.item = ItemCodex[sortListItem.itm] item.amount = sortListItem.qty * numberMultiplier item.itemImage = ItemCodex.getItemImage(sortListItem.itm) + item.colourTheme = if (k == appendixIndex) itemGridCraftingResultColourTheme else itemGridDefaultColourTheme // set quickslot number if (getInventory() is ActorInventory) { @@ -453,6 +473,7 @@ open class UIItemInventoryItemGrid( item.itemImage = null item.quickslot = null item.equippedSlot = null + item.colourTheme = itemGridDefaultColourTheme } } @@ -502,6 +523,7 @@ open class UIItemInventoryItemGrid( item.item = ItemCodex[sortListItem.itm] item.amount = sortListItem.qty * numberMultiplier item.itemImage = ItemCodex.getItemImage(sortListItem.itm) + item.colourTheme = itemGridDefaultColourTheme // set quickslot number if (getInventory() is ActorInventory) { @@ -536,6 +558,7 @@ open class UIItemInventoryItemGrid( item.itemImage = null item.quickslot = null item.equippedSlot = null + item.colourTheme = itemGridDefaultColourTheme } } diff --git a/src/net/torvald/terrarum/ui/Toolkit.kt b/src/net/torvald/terrarum/ui/Toolkit.kt index dcebfc76e..a158c610a 100644 --- a/src/net/torvald/terrarum/ui/Toolkit.kt +++ b/src/net/torvald/terrarum/ui/Toolkit.kt @@ -25,6 +25,7 @@ object Toolkit : Disposable { object Theme { val COL_INVENTORY_CELL_BORDER = Color(1f, 1f, 1f, 0.25f) val COL_CELL_FILL = Color(0x232528C8) + val COL_CELL_FILL_ALT = Color(0x3c3835C8) val COL_CELL_FILL_OPAQUE = Color(0x232528FF) val COL_LIST_DEFAULT = Color.WHITE // white