Skip to content

Commit

Permalink
feat: add found room secrets to Catlas
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed May 22, 2024
1 parent 2db992d commit ca462fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
}
Expand Down

0 comments on commit ca462fe

Please sign in to comment.