mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 12:34:05 +09:00
same for the tooltip
This commit is contained in:
@@ -70,6 +70,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
|
|
||||||
var nameColour = Color.WHITE
|
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. */
|
/** 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
|
abstract var baseMass: Double
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ open class MusicDiscPrototype(originalID: ItemID, module: String, path: String)
|
|||||||
originalName = meta.title
|
originalName = meta.title
|
||||||
author = meta.author
|
author = meta.author
|
||||||
collection = meta.album
|
collection = meta.album
|
||||||
name = "$author $EMDASH $originalName"
|
name = meta.title
|
||||||
|
nameSecondary = "${meta.author} $EMDASH ${meta.album}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transient override val itemImage: TextureRegion = generateSprite()
|
@Transient override val itemImage: TextureRegion = generateSprite()
|
||||||
|
|||||||
@@ -329,13 +329,16 @@ open class UIItemInventoryItemGrid(
|
|||||||
// set tooltip accordingly
|
// set tooltip accordingly
|
||||||
if ((App.IS_DEVELOPMENT_BUILD || isCompactMode) && tooltipShowing[hash] != true && it.item != null && it.mouseUp) {
|
if ((App.IS_DEVELOPMENT_BUILD || isCompactMode) && tooltipShowing[hash] != true && it.item != null && it.mouseUp) {
|
||||||
// printdbg(this, "calling INGAME.setTooltipMessage by $hash")
|
// 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(
|
INGAME.setTooltipMessage(
|
||||||
if (App.IS_DEVELOPMENT_BUILD) {
|
if (App.IS_DEVELOPMENT_BUILD)
|
||||||
it.item?.name + "\n(${it.item?.originalID}${if (it.item?.originalID == it.item?.dynamicID) "" else "/${it.item?.dynamicID}"})"
|
nameStr + itemIDstr
|
||||||
}
|
else
|
||||||
else {
|
nameStr
|
||||||
it.item?.name
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
tooltipShowing[hash] = true
|
tooltipShowing[hash] = true
|
||||||
|
|||||||
@@ -4,16 +4,13 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
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.App.printdbg
|
||||||
import net.torvald.terrarum.CommonResourcePool
|
|
||||||
import net.torvald.terrarum.blendNormalStraightAlpha
|
|
||||||
import net.torvald.terrarum.gameitems.GameItem
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
import net.torvald.terrarum.modulebasegame.ui.InventoryCellColourTheme
|
import net.torvald.terrarum.modulebasegame.ui.InventoryCellColourTheme
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.toItemCountText
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.toItemCountText
|
||||||
import net.torvald.terrarum.mul
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@@ -105,11 +102,17 @@ class UIItemInventoryElemWide(
|
|||||||
|
|
||||||
// if mouse is over, text lights up
|
// if mouse is over, text lights up
|
||||||
// highlight item name and count (blocks/walls) if the item is equipped
|
// 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
|
if (highlightToMainCol) colourTheme.textHighlightMainCol
|
||||||
else if (highlightToSubCol) colourTheme.textHighlightSubCol
|
else if (highlightToSubCol) colourTheme.textHighlightSubCol
|
||||||
else if (mouseUp && item != null) colourTheme.textHighlightMouseUpCol
|
else if (mouseUp && item != null) colourTheme.textHighlightMouseUpCol
|
||||||
else colourTheme.textHighlightNormalCol)
|
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
|
// draw name of the item
|
||||||
App.fontGame.draw(batch,
|
App.fontGame.draw(batch,
|
||||||
@@ -120,7 +123,7 @@ class UIItemInventoryElemWide(
|
|||||||
item!!.name,
|
item!!.name,
|
||||||
|
|
||||||
posX + textOffsetX,
|
posX + textOffsetX,
|
||||||
posY + textOffsetY
|
posY + itemNameRow1Y
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -136,6 +139,15 @@ class UIItemInventoryElemWide(
|
|||||||
batch.color = durabilityCol
|
batch.color = durabilityCol
|
||||||
Toolkit.drawStraightLine(batch, barOffset, posY + durabilityBarOffY, barOffset + (barFullLen * percentage).roundToInt(), durabilityBarThickness, false)
|
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)
|
// quickslot marker (TEMPORARY UNTIL WE GET BETTER DESIGN)
|
||||||
|
|||||||
Reference in New Issue
Block a user