diff --git a/src/main/kotlin/Rs2MapEditor.kt b/src/main/kotlin/Rs2MapEditor.kt index e899b68..90b9a0d 100644 --- a/src/main/kotlin/Rs2MapEditor.kt +++ b/src/main/kotlin/Rs2MapEditor.kt @@ -13,7 +13,7 @@ import kotlin.system.exitProcess object Rs2MapEditor { - val library = CacheLibrary.create("K:\\RSPSDev\\RS-2009Toolset\\data\\cache578_preservation") + val library = CacheLibrary.create("/home/ceikry/IdeaProjects/rs09-remake/Server/data/cache/") @JvmStatic fun main(args: Array) { @@ -34,10 +34,12 @@ object Rs2MapEditor { get() = (64 - field) - 1 // Stores the underlay ID for each point - var colorPointMap: MutableMap = mutableMapOf() + var colorPointMap: HashMap = hashMapOf() + + val componentPointMap = hashMapOf() // Stores the underlay ID with the Underlay Definition - lateinit var underlayMap: MutableMap + lateinit var underlayMap: HashMap var selectedUnderlayId: Int? = null @@ -88,10 +90,12 @@ object Rs2MapEditor { gbc.gridy = row val border: Border = MatteBorder(1, 1, if (row == height) 1 else 0, if (column == width) 1 else 0, Color.GRAY) val flippedY = (64 - row) - 1 - colorPointMap[Point(column, flippedY)] = MapTileParser.definition.getTile(column, flippedY, 0).underlayId + val point = Point(column, flippedY) + colorPointMap[point] = MapTileParser.definition.getTile(column, flippedY, 0).underlayId val cellPane = CellPane() cellPane.background = underlayMap[MapTileParser.definition.getTile(column, flippedY, 0).underlayId]!!.getRGB() cellPane.border = border + componentPointMap[point] = cellPane add(cellPane, gbc) } } @@ -234,6 +238,18 @@ object Rs2MapEditor { init { underlayMap.forEach { val underlay = UnderlaySquarePanel(it.value.getRGB(),30, it.key) + underlay.addMouseListener(object : MouseAdapter(){ + val border: Border = MatteBorder(1, 1, 1, 1, Color.GRAY) + val highlight: Border = MatteBorder(1, 1, 1, 1, Color.YELLOW) + + override fun mouseEntered(e: MouseEvent?) { + colorPointMap.filter { it.value == underlay.id }.forEach{ componentPointMap[it.key]!!.border = highlight} + } + + override fun mouseExited(e: MouseEvent?) { + colorPointMap.filter { it.value == underlay.id }.forEach{ componentPointMap[it.key]!!.border = border} + } + }) add(underlay) } val addAnUnderlay = UnderlaySquarePanel(Color.darkGray,30, "+") @@ -241,7 +257,7 @@ object Rs2MapEditor { } } - class UnderlaySquarePanel(color: Color, size: Int, id: Any) : JPanel() { + class UnderlaySquarePanel(color: Color, size: Int, val id: Any) : JPanel() { init { when (id) { is Int -> { diff --git a/src/main/kotlin/decoders/FloorUnderlayConfiguration.kt b/src/main/kotlin/decoders/FloorUnderlayConfiguration.kt index 81e6d75..91f43ef 100644 --- a/src/main/kotlin/decoders/FloorUnderlayConfiguration.kt +++ b/src/main/kotlin/decoders/FloorUnderlayConfiguration.kt @@ -10,7 +10,7 @@ object FloorUnderlayConfiguration { val cache = Rs2MapEditor.library.index(Indices.CONFIGURATION).archive(Archives.FLOOR_UNDERLAYS) - var floorUnderlays = mutableMapOf() + var floorUnderlays = hashMapOf() @JvmStatic fun main(args: Array) {