Skip to content

Commit

Permalink
feat(Catlas): Show map before dungon start
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Feb 24, 2025
1 parent f25a957 commit 22ae343
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import gg.skytils.skytilsmod.features.impl.dungeons.catlas.handlers.DungeonScann
import gg.skytils.skytilsmod.features.impl.dungeons.catlas.handlers.MapUpdater
import gg.skytils.skytilsmod.features.impl.dungeons.catlas.handlers.MimicDetector
import gg.skytils.skytilsmod.features.impl.dungeons.catlas.utils.MapUtils
import gg.skytils.skytilsmod.features.impl.dungeons.catlas.utils.ScanUtils
import gg.skytils.skytilsmod.utils.RenderUtil
import gg.skytils.skytilsmod.utils.Utils
import net.minecraft.network.play.server.S34PacketMaps
Expand Down Expand Up @@ -79,6 +80,12 @@ object Catlas {
if (DungeonScanner.shouldScan) {
DungeonScanner.scan()
}

if (CatlasConfig.mapShowBeforeStart && DungeonTimer.dungeonStartTime == -1L) {
ScanUtils.getRoomFromPos(mc.thePlayer.position)?.uniqueRoom?.let {
DungeonInfo.preStartVisitedRooms.add(it)
}
}
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ object CatlasConfig : Vigilant(
)
var mapHideInBoss = false

@Property(
name = "Show Before Start",
type = PropertyType.SWITCH,
description = "Shows the map before the dungeon starts.",
category = "Map",
subcategory = "Toggle",
i18nName = "catlas.config.map.toggle.show_before_start",
i18nCategory = "catlas.config.map",
i18nSubcategory = "catlas.config.map.toggle"
)
var mapShowBeforeStart = false

@Property(
name = "Show Player Names",
type = PropertyType.SELECTOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) {
GlStateManager.pushMatrix()
GlStateManager.translate(MapUtils.startCorner.first.toFloat(), MapUtils.startCorner.second.toFloat(), 0f)

val connectorSize = DungeonMapColorParser.quarterRoom
val connectorSize = (DungeonMapColorParser.quarterRoom.takeUnless { it == -1 } ?: 4)
val checkmarkSize = when (CatlasConfig.mapCheckmark) {
1 -> 8.0 // default
else -> 10.0 // neu
Expand All @@ -89,7 +89,8 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) {
for (y in 0..10) {
for (x in 0..10) {
val tile = DungeonInfo.dungeonList[y * 11 + x]
if (tile is Unknown || tile.state == RoomState.UNDISCOVERED) continue

if (tile is Unknown || (tile.state == RoomState.UNDISCOVERED && !isAlwaysVisible(tile))) continue

val xOffset = (x shr 1) * (MapUtils.mapRoomSize + connectorSize)
val yOffset = (y shr 1) * (MapUtils.mapRoomSize + connectorSize)
Expand Down Expand Up @@ -131,6 +132,15 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) {
GlStateManager.popMatrix()
}

private fun isAlwaysVisible(tile: Tile): Boolean {
if (!CatlasConfig.mapShowBeforeStart || DungeonTimer.dungeonStartTime != -1L) return false

return when (tile) {
is Room -> tile.uniqueRoom in DungeonInfo.preStartVisitedRooms
else -> false
}
}

private fun renderText() {
GlStateManager.pushMatrix()
GlStateManager.translate(MapUtils.startCorner.first.toFloat(), MapUtils.startCorner.second.toFloat(), 0f)
Expand All @@ -142,8 +152,8 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) {

DungeonInfo.uniqueRooms.forEach { unq ->
val room = unq.mainRoom
if (room.state == RoomState.UNDISCOVERED || room.state == RoomState.UNOPENED) return@forEach
val size = MapUtils.mapRoomSize + DungeonMapColorParser.quarterRoom
if ((room.state == RoomState.UNDISCOVERED || room.state == RoomState.UNOPENED) && !isAlwaysVisible(room)) return@forEach
val size = MapUtils.mapRoomSize + (DungeonMapColorParser.quarterRoom.takeUnless { it == -1 } ?: 4)
val checkPos = unq.getCheckmarkPosition()
val namePos = unq.getNamePosition()
val xOffsetCheck = (checkPos.first / 2f) * size
Expand Down Expand Up @@ -276,7 +286,7 @@ object CatlasElement : GuiElement(name = "Dungeon Map", x = 0, y = 0) {

override fun render() {
if (!toggled || SBInfo.mode != SkyblockIsland.Dungeon.mode || mc.thePlayer == null || mc.theWorld == null) return
if (DungeonTimer.dungeonStartTime == -1L) return
if (DungeonTimer.dungeonStartTime == -1L && !CatlasConfig.mapShowBeforeStart) return
if (CatlasConfig.mapHideInBoss && DungeonTimer.bossEntryTime != -1L) return
mc.mcProfiler.startSection("border")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ object DungeonInfo {
var dungeonMap: MapData? = null
var guessMapData: MapData? = null

val preStartVisitedRooms = mutableSetOf<UniqueRoom>()

fun reset() {
dungeonList.fill(Unknown(0, 0))
roomCount = 0
Expand All @@ -53,5 +55,7 @@ object DungeonInfo {

dungeonMap = null
guessMapData = null

preStartVisitedRooms.clear()
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/catlas/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ catlas.config.map.toggle.rotate_map=Rotate Map
catlas.config.map.toggle.center_map=Center Map
catlas.config.map.toggle.dynamic_rotate=Dynamic Rotate
catlas.config.map.toggle.hide_in_boss=Hide In Boss
catlas.config.map.toggle.show_before_start=Show Before Start
catlas.config.map.toggle.show_player_names=Show Player Names
catlas.config.map.toggle.vanilla_head_marker=Vanilla Head Marker
catlas.config.map.size.map_text_scale=Map Text Scale
Expand Down

0 comments on commit 22ae343

Please sign in to comment.