tooltipmanager

This commit is contained in:
minjaesong
2024-10-11 15:02:11 +09:00
parent 048777a845
commit 60e54c2bc0
29 changed files with 118 additions and 238 deletions

View File

@@ -1,31 +1,26 @@
package net.torvald.terrarum.modulebasegame.gameitems
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.INGAME
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.WireActor
import net.torvald.terrarum.gameitems.FixtureInteractionBlocked
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.gameitems.mouseInInteractableRange
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
import net.torvald.terrarum.modulebasegame.gameactors.Reorientable
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.tooltipShowing
import net.torvald.unicode.getMouseButton
/**
* Created by minjaesong on 2024-03-08.
*/
class ItemWrench(originalID: ItemID) : GameItem(originalID), FixtureInteractionBlocked {
override val tooltipHash = 10003L
companion object {
private val tooltipHash = 10003L
private val SP = "\u3000"
private val ML = getMouseButton(App.getConfigInt("config_mouseprimary"))
private val MR = getMouseButton(App.getConfigInt("config_mousesecondary"))
@@ -55,17 +50,18 @@ class ItemWrench(originalID: ItemID) : GameItem(originalID), FixtureInteractionB
q = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
(INGAME as TerrarumIngame).world.getWireGraphOf(mtx, mty, "wire@basegame:256").let { cnx ->
if (cnx != null) {
INGAME.setTooltipMessage("$ML ${Lang["GAME_ACTION_DISMANTLE"]}\n$MR ${Lang["MENU_CONTROLS_ROTATE"]}")
tooltipShowing[tooltipHash] = true
acquireTooltip("$ML ${Lang["GAME_ACTION_DISMANTLE"]}\n$MR ${Lang["MENU_CONTROLS_ROTATE"]}")
}
else {
tooltipShowing[tooltipHash] = false
releaseTooltip()
}
}
0L
}
if (q == -1L)
tooltipShowing[tooltipHash] = false*/
releaseTooltip()
*/
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->

View File

@@ -19,7 +19,6 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.TOOL_DURABILITY_BASE
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.tooltipShowing
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.RenderTag
import org.dyn4j.geometry.Vector2
import kotlin.math.roundToInt
@@ -27,8 +26,8 @@ import kotlin.math.roundToInt
/**
* Created by minjaesong on 2019-03-10.
*/
object PickaxeCore {
private val tooltipHash = 10002L
object PickaxeCore : TooltipListener() {
override val tooltipHash = 10002L
private val soundPlayedForThisTick = HashMap<ActorWithBody, Long>()
/**
@@ -237,7 +236,7 @@ object PickaxeCore {
val overlayUIopen = (INGAME as? TerrarumIngame)?.uiBlur?.isVisible ?: false
var tooltipSet = false
val tooltipWasShown = tooltipShowing[tooltipHash] ?: false
val tooltipWasShown = tooltipAcquired()
mouseInInteractableRangeTools(actor, tool) {
val tileUnderCursor = INGAME.world.getTileFromOre(mx, my).item
@@ -249,8 +248,7 @@ object PickaxeCore {
Lang[ItemCodex[itemForOre]!!.originalName]
else "???"
if (App.getConfigBoolean("basegame:showpickaxetooltip")) {
INGAME.setTooltipMessage(tileName)
tooltipShowing[tooltipHash] = true
acquireTooltip(tileName)
}
tooltipSet = true
}
@@ -269,7 +267,8 @@ object PickaxeCore {
true // just a placeholder
}
if (App.getConfigBoolean("basegame:showpickaxetooltip") && !tooltipSet) tooltipShowing[tooltipHash] = false
if (App.getConfigBoolean("basegame:showpickaxetooltip") && !tooltipSet)
releaseTooltip()
}
private val soundCue = MusicContainer(

View File

@@ -13,9 +13,6 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
@Transient private val tooltipHash = System.nanoTime()
override var baseToolSize: Double? = PickaxeCore.BASE_MASS_AND_SIZE
override var inventoryCategory = Category.TOOL
override val canBeDynamic = false
@@ -65,12 +62,10 @@ class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
}
if (sb.isNotEmpty()) {
UIItemInventoryCellCommonRes.tooltipShowing[tooltipHash] = true
(Terrarum.ingame!! as TerrarumIngame).setTooltipMessage(sb.toString())
acquireTooltip(sb.toString())
}
else {
UIItemInventoryCellCommonRes.tooltipShowing[tooltipHash] = false
(Terrarum.ingame!! as TerrarumIngame).setTooltipMessage(null)
releaseTooltip()
}
}
@@ -78,6 +73,6 @@ class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
(Terrarum.ingame!! as TerrarumIngame).setTooltipMessage(null)
blockMarker.hideMarker()
UIItemInventoryCellCommonRes.tooltipShowing.remove(tooltipHash)
removeFromTooltipRecord()
}
}