mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
simple tooltip system for fixtures
This commit is contained in:
@@ -9,6 +9,7 @@ import net.torvald.terrarum.gameactors.*
|
|||||||
import net.torvald.terrarum.gameitems.GameItem
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore
|
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
@@ -49,6 +50,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
|
|
||||||
@Transient var inOperation = false
|
@Transient var inOperation = false
|
||||||
|
|
||||||
|
@Transient private val tooltipObjects = ArrayList<Pair<String?, ()-> String>>()
|
||||||
|
|
||||||
// @Transient var mainUIopenFun: ((UICanvas) -> Unit)? = null
|
// @Transient var mainUIopenFun: ((UICanvas) -> Unit)? = null
|
||||||
|
|
||||||
internal var actorThatInstalledThisFixture: UUID? = null
|
internal var actorThatInstalledThisFixture: UUID? = null
|
||||||
@@ -56,6 +59,15 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE(), null)
|
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE(), null)
|
||||||
protected constructor(renderOrder: RenderOrder, physProp: PhysProperties, id: ActorID?) : super(renderOrder, physProp, id)
|
protected constructor(renderOrder: RenderOrder, physProp: PhysProperties, id: ActorID?) : super(renderOrder, physProp, id)
|
||||||
|
|
||||||
|
// call on init()
|
||||||
|
fun addQuickLookupParam(name: String?, valueFun: () -> String) {
|
||||||
|
tooltipObjects.add(name to valueFun)
|
||||||
|
}
|
||||||
|
// call on init()
|
||||||
|
fun addQuickLookupParam(valueFun: () -> String) {
|
||||||
|
tooltipObjects.add(null to valueFun)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callend whenever the fixture was spawned successfully.
|
* Callend whenever the fixture was spawned successfully.
|
||||||
*
|
*
|
||||||
@@ -427,6 +439,18 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
override fun updateImpl(delta: Float) {
|
override fun updateImpl(delta: Float) {
|
||||||
super.updateImpl(delta)
|
super.updateImpl(delta)
|
||||||
chunkAnchoring = inOperation
|
chunkAnchoring = inOperation
|
||||||
|
|
||||||
|
tooltipObjects.map { (name, valueFun) ->
|
||||||
|
if (name != null)
|
||||||
|
"${Lang[name]}: ${valueFun()}"
|
||||||
|
else
|
||||||
|
"${valueFun()}"
|
||||||
|
}.filter { it.isNotBlank() }.let {
|
||||||
|
tooltipText = if (it.isNotEmpty())
|
||||||
|
it.joinToString("\n")
|
||||||
|
else
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ class FixtureJukebox : Electric, PlaysMusic {
|
|||||||
despawnHook = {
|
despawnHook = {
|
||||||
stopGracefully()
|
stopGracefully()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addQuickLookupParam {
|
||||||
|
musicNowPlaying.let {
|
||||||
|
if (it == null) "" else "♫ ${App.fontGame.toColorCode(5,15,5)}${it.name}${App.fontGame.noColorCode}"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 0.0, TILE_SIZED * 2, TILE_SIZED * 3), Cvec(0.44f, 0.41f, 0.40f, 0.2f)))
|
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 0.0, TILE_SIZED * 2, TILE_SIZED * 3), Cvec(0.44f, 0.41f, 0.40f, 0.2f)))
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ class FixtureMusicalTurntable : Electric, PlaysMusic {
|
|||||||
despawnHook = {
|
despawnHook = {
|
||||||
stopGracefully()
|
stopGracefully()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addQuickLookupParam {
|
||||||
|
musicNowPlaying.let {
|
||||||
|
if (it == null) "" else "♫ ${App.fontGame.toColorCode(5,15,5)}${it.name}${App.fontGame.noColorCode}"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var disc: ItemID? = null
|
internal var disc: ItemID? = null
|
||||||
|
|||||||
Reference in New Issue
Block a user