From 8aeed037c83ec6d37e6da43108ddc2378f44c2ec Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 25 Oct 2017 05:53:39 +0900 Subject: [PATCH] "equipped" indicator on item grid --- src/net/torvald/terrarum/UIItemInventoryElem.kt | 4 +++- src/net/torvald/terrarum/UIItemInventoryElemSimple.kt | 10 +++++++++- .../torvald/terrarum/ui/UIItemInventoryDynamicList.kt | 1 + src/net/torvald/terrarum/ui/UIItemTextButton.kt | 5 +++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/net/torvald/terrarum/UIItemInventoryElem.kt b/src/net/torvald/terrarum/UIItemInventoryElem.kt index d3c716aef..9de67897d 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElem.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElem.kt @@ -95,9 +95,11 @@ class UIItemInventoryElem( batch.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol // draw name of the item 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 "") + + // TEMPORARY print eqipped slot info as well (if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""), + posX + textOffsetX, posY + textOffsetY ) diff --git a/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt b/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt index f5a5b171f..1c95cb619 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElemSimple.kt @@ -24,6 +24,7 @@ class UIItemInventoryElemSimple( val inactiveTextCol: Color = UIItemTextButton.defaultInactiveCol, val backCol: Color = Color(0), val backBlendMode: String = BlendMode.NORMAL, + val highlightCol: Color = UIItemTextButton.defaultHighlightCol, override var quickslot: Int? = null, override var equippedSlot: Int? = null, val drawBackOnNull: Boolean = true @@ -51,7 +52,7 @@ class UIItemInventoryElemSimple( // mouseover background if (item != null || drawBackOnNull) { // 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) batch.color = mouseoverBackCol } @@ -95,6 +96,13 @@ class UIItemInventoryElemSimple( else { // draw item count val amountString = amount.toString() + + // highlight item count (blocks/walls) if the item is equipped + if (equippedSlot != null) { + batch.color = highlightCol + } + + Terrarum.fontSmallNumbers.draw(batch, amountString, posX + (width - Terrarum.fontSmallNumbers.getWidth(amountString)).toFloat(), diff --git a/src/net/torvald/terrarum/ui/UIItemInventoryDynamicList.kt b/src/net/torvald/terrarum/ui/UIItemInventoryDynamicList.kt index 71360e361..cabb65e21 100644 --- a/src/net/torvald/terrarum/ui/UIItemInventoryDynamicList.kt +++ b/src/net/torvald/terrarum/ui/UIItemInventoryDynamicList.kt @@ -182,6 +182,7 @@ class UIItemInventoryDynamicList( items[k].amount = 0 items[k].itemImage = null items[k].quickslot = null + items[k].equippedSlot = null } } } diff --git a/src/net/torvald/terrarum/ui/UIItemTextButton.kt b/src/net/torvald/terrarum/ui/UIItemTextButton.kt index ed56b9ead..4e744e0b5 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButton.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButton.kt @@ -22,10 +22,10 @@ open class UIItemTextButton( val activeCol: Color = Color.WHITE, val activeBackCol: Color = Color(0), val activeBackBlendMode: String = BlendMode.NORMAL, - val highlightCol: Color = Color(0x00f8ff_ff), + val highlightCol: Color = defaultHighlightCol, val highlightBackCol: Color = Color(0xb0b0b0_ff.toInt()), val highlightBackBlendMode: String = BlendMode.MULTIPLY, - val inactiveCol: Color = UIItemTextButton.defaultInactiveCol, + val inactiveCol: Color = defaultInactiveCol, val preGapX: Int = 0, val postGapX: Int = 0 ) : UIItem(parentUI) { @@ -34,6 +34,7 @@ open class UIItemTextButton( val font = Terrarum.fontGame val height = font.lineHeight.toInt() * 2 val defaultInactiveCol: Color = Color(0xc8c8c8_ff.toInt()) + val defaultHighlightCol: Color = Color(0x00f8ff_ff) } val label: String