mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
crafting: special 'theme' for the cell for the already-existing
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
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?
|
||||
) {
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user