From ca462fe2ccee72a7b08fc4dc8168c151d4e52d61 Mon Sep 17 00:00:00 2001 From: My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> Date: Wed, 22 May 2024 00:05:48 -0400 Subject: [PATCH] feat: add found room secrets to Catlas --- .../impl/dungeons/catlas/core/CatlasConfig.kt | 11 +++++++++++ .../impl/dungeons/catlas/core/CatlasElement.kt | 13 +++++++++---- .../skytilsmod/listeners/DungeonListener.kt | 15 +++++++-------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasConfig.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasConfig.kt index 50bf6cc0e..e69b81d5e 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasConfig.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasConfig.kt @@ -226,6 +226,17 @@ object CatlasConfig : Vigilant( ) var mapRoomSecrets = 0 + // TODO: Add translation + @Property( + name = "Found Room Secrets", + type = PropertyType.SELECTOR, + description = "Shows found secrets of rooms on map.", + category = "Rooms", + options = ["Off", "On", "Replace Total"], + i18nCategory = "catlas.config.rooms" + ) + var foundRoomSecrets = 0 + @Property( name = "Color Text", type = PropertyType.SWITCH, diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasElement.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasElement.kt index 293aa2498..3877ee4af 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasElement.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/catlas/core/CatlasElement.kt @@ -142,7 +142,7 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) { DungeonInfo.uniqueRooms.forEach { unq -> val room = unq.mainRoom - if (room.state == RoomState.UNDISCOVERED) return@forEach + if (room.state == RoomState.UNDISCOVERED || room.state == RoomState.UNOPENED) return@forEach val size = MapUtils.mapRoomSize + DungeonMapColorParser.quarterRoom val checkPos = unq.getCheckmarkPosition() val namePos = unq.getNamePosition() @@ -161,7 +161,12 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) { val roomType = room.data.type val hasSecrets = secretCount > 0 - if (room.state == RoomState.UNOPENED) return@forEach + val secretText = when (CatlasConfig.foundRoomSecrets) { + 0 -> secretCount.toString() + 1 -> "${unq.foundSecrets ?: "?"}/${secretCount}" + 2 -> unq.foundSecrets?.toString() ?: "?" + else -> error("Invalid foundRoomSecrets value") + } if (CatlasConfig.mapRoomSecrets == 2 && hasSecrets) { GlStateManager.pushMatrix() @@ -171,7 +176,7 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) { 0f ) GlStateManager.scale(2f, 2f, 1f) - RenderUtils.renderCenteredText(listOf(secretCount.toString()), 0, 0, color) + RenderUtils.renderCenteredText(listOf(secretText), 0, 0, color) GlStateManager.popMatrix() } else if (CatlasConfig.mapCheckmark != 0) { drawCheckmark(room, xOffsetCheck, yOffsetCheck, checkmarkSize) @@ -191,7 +196,7 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) { name.addAll(room.data.name.split(" ")) } if (room.data.type == RoomType.NORMAL && CatlasConfig.mapRoomSecrets == 1) { - name.add(secretCount.toString()) + name.add(secretText) } // Offset + half of roomsize RenderUtils.renderCenteredText( diff --git a/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt b/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt index de2472857..9e0bfedce 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt @@ -143,15 +143,14 @@ object DungeonListener { DungeonFeatures.DungeonSecretDisplay.secrets = sec DungeonFeatures.DungeonSecretDisplay.maxSecrets = max - if (team.size > 1) { - IO.launch { - val tile = ScanUtils.getRoomFromPos(mc.thePlayer.position) - if (tile is Room && tile.data.name != "Unknown") { - val room = DungeonInfo.uniqueRooms.find { tile in it.tiles } ?: return@launch - if (room.foundSecrets != sec) { - room.foundSecrets = sec + IO.launch { + val tile = ScanUtils.getRoomFromPos(mc.thePlayer.position) + if (tile is Room && tile.data.name != "Unknown") { + val room = DungeonInfo.uniqueRooms.find { tile in it.tiles } ?: return@launch + if (room.foundSecrets != sec) { + room.foundSecrets = sec + if (team.size > 1) WSClient.sendPacket(C2SPacketDungeonRoomSecret(SBInfo.server ?: return@launch, room.mainRoom.data.name, sec)) - } } } }