From c6c8d0211815fc39cab2601b7574728e6e719362 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 4 Aug 2021 17:20:10 +0900 Subject: [PATCH] better drop shadow for tooltip --- .../graphics/gui/message_black_tileable.tga | 4 +- .../graphics/gui/message_white_tileable.tga | 4 +- .../torvald/terrarum/gameworld/GameWorld.kt | 42 +++++++++++++++++-- .../terrarum/modulebasegame/ui/FloatDrawer.kt | 2 +- .../terrarum/modulebasegame/ui/UITooltip.kt | 2 +- work_files/graphics/gui/message.psd | 4 +- 6 files changed, 46 insertions(+), 12 deletions(-) diff --git a/assets/graphics/gui/message_black_tileable.tga b/assets/graphics/gui/message_black_tileable.tga index 3acd65f3d..550c42c48 100644 --- a/assets/graphics/gui/message_black_tileable.tga +++ b/assets/graphics/gui/message_black_tileable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f09ec19777faf73fc4ba34708d98582033a4dc25a095eac5a825c84b1ed5d0a6 -size 9234 +oid sha256:3c617a8a83164eb5ff875dcc7920cb16cfc3598ccce0e716c2fbbef041a73aa7 +size 46674 diff --git a/assets/graphics/gui/message_white_tileable.tga b/assets/graphics/gui/message_white_tileable.tga index f0aaa0e44..9aca9bd8c 100644 --- a/assets/graphics/gui/message_white_tileable.tga +++ b/assets/graphics/gui/message_white_tileable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b16bca272ca1caf838c1bd04fa070d48c206722d41ac34219359720f294ff1b1 -size 9234 +oid sha256:6eb533ec57a8ec2d6a62d7a8238b6bc334783239040782c8a1e3becffc335b9a +size 46674 diff --git a/src/net/torvald/terrarum/gameworld/GameWorld.kt b/src/net/torvald/terrarum/gameworld/GameWorld.kt index 5f9bb4b06..a6b2fe6aa 100644 --- a/src/net/torvald/terrarum/gameworld/GameWorld.kt +++ b/src/net/torvald/terrarum/gameworld/GameWorld.kt @@ -79,7 +79,7 @@ open class GameWorld : Disposable { @TEMzPayload("WiNt", TEMzPayload.EXTERNAL_JSON) private val wirings: HashMap - private val wiringGraph = HashMap>() + private val wiringGraph = HashMap>() private val WIRE_POS_MAP = byteArrayOf(1,2,4,8) /** @@ -353,7 +353,17 @@ open class GameWorld : Disposable { } fun getWireGraphUnsafe(blockAddr: BlockAddress, itemID: ItemID): Byte? { - return wiringGraph[blockAddr]?.get(itemID) + return wiringGraph[blockAddr]?.get(itemID)?.con + } + + fun getWireStateOf(x: Int, y: Int, itemID: ItemID): Vector2? { + val (x, y) = coerceXY(x, y) + val blockAddr = LandUtil.getBlockAddr(this, x, y) + return getWireStateUnsafe(blockAddr, itemID) + } + + fun getWireStateUnsafe(blockAddr: BlockAddress, itemID: ItemID): Vector2? { + return wiringGraph[blockAddr]?.get(itemID)?.state } fun setWireGraphOf(x: Int, y: Int, itemID: ItemID, byte: Byte) { @@ -363,10 +373,29 @@ open class GameWorld : Disposable { } fun setWireGraphOfUnsafe(blockAddr: BlockAddress, itemID: ItemID, byte: Byte) { - if (wiringGraph[blockAddr] == null) + if (wiringGraph[blockAddr] == null) { wiringGraph[blockAddr] = HashMap() + wiringGraph[blockAddr]!![itemID] = WiringSimCell(byte) + } + else { + wiringGraph[blockAddr]!![itemID]!!.con = byte + } + } - wiringGraph[blockAddr]!![itemID] = byte + fun setWireStateOf(x: Int, y: Int, itemID: ItemID, vector: Vector2) { + val (x, y) = coerceXY(x, y) + val blockAddr = LandUtil.getBlockAddr(this, x, y) + return setWireStateOfUnsafe(blockAddr, itemID, vector) + } + + fun setWireStateOfUnsafe(blockAddr: BlockAddress, itemID: ItemID, vector: Vector2) { + if (wiringGraph[blockAddr] == null) { + wiringGraph[blockAddr] = HashMap() + wiringGraph[blockAddr]!![itemID] = WiringSimCell(0, vector) + } + else { + wiringGraph[blockAddr]!![itemID]!!.state = vector + } } fun getAllWiresFrom(x: Int, y: Int): SortedArrayList? { @@ -560,6 +589,11 @@ open class GameWorld : Disposable { } } + data class WiringSimCell( + var con: Byte = 0, // connections + var state: Vector2 = Vector2(0.0, 0.0) + ) + fun getTemperature(worldTileX: Int, worldTileY: Int): Float? { return null } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/FloatDrawer.kt b/src/net/torvald/terrarum/modulebasegame/ui/FloatDrawer.kt index 6bd468629..6c93aeacd 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/FloatDrawer.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/FloatDrawer.kt @@ -10,7 +10,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack */ object FloatDrawer : Disposable { - val tile = TextureRegionPack("assets/graphics/gui/message_white_tileable.tga", 16, 16) + val tile = TextureRegionPack("assets/graphics/gui/message_white_tileable.tga", 36, 36) init { AppLoader.disposableSingletonsPool.add(this) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt b/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt index cdcf17ed6..43d2d904b 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt @@ -40,7 +40,7 @@ class UITooltip : UICanvas() { val mouseX = 4f val mouseY = 6f - val tooltipYoff = 12 + val tooltipYoff = 50 val tooltipY = mouseY - height + tooltipYoff val txtW = msgWidth + 2f * textMarginX diff --git a/work_files/graphics/gui/message.psd b/work_files/graphics/gui/message.psd index 4d8d743bd..c22d87c20 100755 --- a/work_files/graphics/gui/message.psd +++ b/work_files/graphics/gui/message.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bece510530e21da2e65437c2c3c72faa64ad99a6643be26e5c2c2c055e14df85 -size 44808 +oid sha256:54217ccafe7013a4561264d6208b90dc91717dfbf81e7631479b99d4bf521acc +size 35389