uiitem and template refactoring; new smelter ui wip

This commit is contained in:
minjaesong
2024-01-29 18:51:53 +09:00
parent 8aedd7c78a
commit 3214f11375
14 changed files with 290 additions and 64 deletions

View File

@@ -35,6 +35,8 @@ class UIItemInventoryElemSimple(
highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme,
var showItemCount: Boolean = true,
var emptyCellIcon: TextureRegion? = null, // icon to draw when the cell is empty
var emptyCellIconColour: Color = Color(0xdddddd7f.toInt()),
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) {
companion object {
@@ -52,6 +54,9 @@ class UIItemInventoryElemSimple(
private val imgOffsetX: Float
get() = (this.height - itemImageOrDefault.regionWidth).div(2).toFloat() // to snap to the pixel grid
private val emptyCellIconOffsetX = (this.height - (emptyCellIcon?.regionWidth ?: 0)).div(2).toFloat()
private val emptyCellIconOffsetY = (this.height - (emptyCellIcon?.regionHeight ?: 0)).div(2).toFloat()
override fun update(delta: Float) {
}
@@ -123,6 +128,15 @@ class UIItemInventoryElemSimple(
)
}
}
else {
// empty cell image
emptyCellIcon?.let {
batch.color = emptyCellIconColour
batch.draw(it, posX + emptyCellIconOffsetX, posY + emptyCellIconOffsetY)
}
}
// see IFs above?