diff --git a/src/net/torvald/terrarum/gameitems/GameItem.kt b/src/net/torvald/terrarum/gameitems/GameItem.kt index 2d381c7c1..e556e418c 100644 --- a/src/net/torvald/terrarum/gameitems/GameItem.kt +++ b/src/net/torvald/terrarum/gameitems/GameItem.kt @@ -70,6 +70,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable, Cloneabl var nameColour = Color.WHITE + var nameSecondary: String = "" + /** In kg. Weapon with different material must have different mass. In this case, you MUST use IRON as a reference (or default) material. */ abstract var baseMass: Double diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/MusicDisc.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/MusicDisc.kt index d0c0086ac..354416d3d 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/MusicDisc.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/MusicDisc.kt @@ -49,7 +49,8 @@ open class MusicDiscPrototype(originalID: ItemID, module: String, path: String) originalName = meta.title author = meta.author collection = meta.album - name = "$author $EMDASH $originalName" + name = meta.title + nameSecondary = "${meta.author} $EMDASH ${meta.album}" } @Transient override val itemImage: TextureRegion = generateSprite() diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt index d2e48305d..0104dfa69 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt @@ -329,13 +329,16 @@ open class UIItemInventoryItemGrid( // set tooltip accordingly if ((App.IS_DEVELOPMENT_BUILD || isCompactMode) && tooltipShowing[hash] != true && it.item != null && it.mouseUp) { // printdbg(this, "calling INGAME.setTooltipMessage by $hash") + + val grey = App.fontGame.toColorCode(11, 11, 11) + val itemIDstr = "\n$grey(${it.item?.originalID}${if (it.item?.originalID == it.item?.dynamicID) "" else "/${it.item?.dynamicID}"})" + val nameStr = if (it.item?.nameSecondary?.isNotBlank() == true) "${it.item?.name}\n$grey${it.item?.nameSecondary}" else "${it.item?.name}" + INGAME.setTooltipMessage( - if (App.IS_DEVELOPMENT_BUILD) { - it.item?.name + "\n(${it.item?.originalID}${if (it.item?.originalID == it.item?.dynamicID) "" else "/${it.item?.dynamicID}"})" - } - else { - it.item?.name - } + if (App.IS_DEVELOPMENT_BUILD) + nameStr + itemIDstr + else + nameStr ) tooltipShowing[hash] = true diff --git a/src/net/torvald/terrarum/ui/UIItemInventoryElemWide.kt b/src/net/torvald/terrarum/ui/UIItemInventoryElemWide.kt index 990391916..fefb43d50 100644 --- a/src/net/torvald/terrarum/ui/UIItemInventoryElemWide.kt +++ b/src/net/torvald/terrarum/ui/UIItemInventoryElemWide.kt @@ -4,16 +4,13 @@ import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.TextureRegion -import net.torvald.terrarum.App +import net.torvald.terrarum.* import net.torvald.terrarum.App.printdbg -import net.torvald.terrarum.CommonResourcePool -import net.torvald.terrarum.blendNormalStraightAlpha import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.modulebasegame.ui.InventoryCellColourTheme import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.toItemCountText -import net.torvald.terrarum.mul import kotlin.math.roundToInt /*** @@ -105,11 +102,17 @@ class UIItemInventoryElemWide( // if mouse is over, text lights up // highlight item name and count (blocks/walls) if the item is equipped - batch.color = item!!.nameColour mul ( + val nameColour = item!!.nameColour mul ( if (highlightToMainCol) colourTheme.textHighlightMainCol else if (highlightToSubCol) colourTheme.textHighlightSubCol else if (mouseUp && item != null) colourTheme.textHighlightMouseUpCol else colourTheme.textHighlightNormalCol) + val nameColour2 = nameColour mul Color(0.75f, 0.75f, 0.75f, 1f) + + batch.color = nameColour + val hasSecondaryName = (item?.nameSecondary?.isNotBlank() == true) + val itemNameRow1Y = if (hasSecondaryName) 1f else if (item!!.maxDurability > 0.0) textOffsetY else ((height - App.fontGame.lineHeight) / 2).roundToFloat() + val itemNameRow2Y = App.fontGame.lineHeight.toInt() - 2*itemNameRow1Y // draw name of the item App.fontGame.draw(batch, @@ -120,7 +123,7 @@ class UIItemInventoryElemWide( item!!.name, posX + textOffsetX, - posY + textOffsetY + posY + itemNameRow1Y ) @@ -136,6 +139,15 @@ class UIItemInventoryElemWide( batch.color = durabilityCol Toolkit.drawStraightLine(batch, barOffset, posY + durabilityBarOffY, barOffset + (barFullLen * percentage).roundToInt(), durabilityBarThickness, false) } + // secondary name + else if (hasSecondaryName) { + batch.color = nameColour2 + App.fontGame.draw(batch, + item!!.nameSecondary, + posX + textOffsetX, + posY + itemNameRow2Y + ) + } // quickslot marker (TEMPORARY UNTIL WE GET BETTER DESIGN)