"equipped" indicator on item grid

This commit is contained in:
minjaesong
2017-10-25 05:53:39 +09:00
parent 07d609ca72
commit c2ac328cab
4 changed files with 16 additions and 4 deletions

View File

@@ -95,9 +95,11 @@ class UIItemInventoryElem(
batch.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol batch.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol
// draw name of the item // draw name of the item
Terrarum.fontGame.draw(batch, Terrarum.fontGame.draw(batch,
//"$item" + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") + // print name and amount in parens
item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") + item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
// TEMPORARY print eqipped slot info as well
(if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""), (if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""),
posX + textOffsetX, posX + textOffsetX,
posY + textOffsetY posY + textOffsetY
) )

View File

@@ -24,6 +24,7 @@ class UIItemInventoryElemSimple(
val inactiveTextCol: Color = UIItemTextButton.defaultInactiveCol, val inactiveTextCol: Color = UIItemTextButton.defaultInactiveCol,
val backCol: Color = Color(0), val backCol: Color = Color(0),
val backBlendMode: String = BlendMode.NORMAL, val backBlendMode: String = BlendMode.NORMAL,
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
override var quickslot: Int? = null, override var quickslot: Int? = null,
override var equippedSlot: Int? = null, override var equippedSlot: Int? = null,
val drawBackOnNull: Boolean = true val drawBackOnNull: Boolean = true
@@ -51,7 +52,7 @@ class UIItemInventoryElemSimple(
// mouseover background // mouseover background
if (item != null || drawBackOnNull) { if (item != null || drawBackOnNull) {
// do not highlight even if drawBackOnNull is true // do not highlight even if drawBackOnNull is true
if (mouseUp && item != null) { if (mouseUp && item != null || equippedSlot != null) { // "equippedSlot != null": also highlight back if equipped
BlendMode.resolve(mouseoverBackBlendMode) BlendMode.resolve(mouseoverBackBlendMode)
batch.color = mouseoverBackCol batch.color = mouseoverBackCol
} }
@@ -95,6 +96,13 @@ class UIItemInventoryElemSimple(
else { else {
// draw item count // draw item count
val amountString = amount.toString() val amountString = amount.toString()
// highlight item count (blocks/walls) if the item is equipped
if (equippedSlot != null) {
batch.color = highlightCol
}
Terrarum.fontSmallNumbers.draw(batch, Terrarum.fontSmallNumbers.draw(batch,
amountString, amountString,
posX + (width - Terrarum.fontSmallNumbers.getWidth(amountString)).toFloat(), posX + (width - Terrarum.fontSmallNumbers.getWidth(amountString)).toFloat(),

View File

@@ -182,6 +182,7 @@ class UIItemInventoryDynamicList(
items[k].amount = 0 items[k].amount = 0
items[k].itemImage = null items[k].itemImage = null
items[k].quickslot = null items[k].quickslot = null
items[k].equippedSlot = null
} }
} }
} }

View File

@@ -22,10 +22,10 @@ open class UIItemTextButton(
val activeCol: Color = Color.WHITE, val activeCol: Color = Color.WHITE,
val activeBackCol: Color = Color(0), val activeBackCol: Color = Color(0),
val activeBackBlendMode: String = BlendMode.NORMAL, val activeBackBlendMode: String = BlendMode.NORMAL,
val highlightCol: Color = Color(0x00f8ff_ff), val highlightCol: Color = defaultHighlightCol,
val highlightBackCol: Color = Color(0xb0b0b0_ff.toInt()), val highlightBackCol: Color = Color(0xb0b0b0_ff.toInt()),
val highlightBackBlendMode: String = BlendMode.MULTIPLY, val highlightBackBlendMode: String = BlendMode.MULTIPLY,
val inactiveCol: Color = UIItemTextButton.defaultInactiveCol, val inactiveCol: Color = defaultInactiveCol,
val preGapX: Int = 0, val preGapX: Int = 0,
val postGapX: Int = 0 val postGapX: Int = 0
) : UIItem(parentUI) { ) : UIItem(parentUI) {
@@ -34,6 +34,7 @@ open class UIItemTextButton(
val font = Terrarum.fontGame val font = Terrarum.fontGame
val height = font.lineHeight.toInt() * 2 val height = font.lineHeight.toInt() * 2
val defaultInactiveCol: Color = Color(0xc8c8c8_ff.toInt()) val defaultInactiveCol: Color = Color(0xc8c8c8_ff.toInt())
val defaultHighlightCol: Color = Color(0x00f8ff_ff)
} }
val label: String val label: String