Skip to content

Commit f6e7f93

Browse files
committed
refactor: add toggles for hud elements
[no ci]
1 parent 93bc58d commit f6e7f93

File tree

25 files changed

+463
-318
lines changed

25 files changed

+463
-318
lines changed

mod/src/main/kotlin/gg/skytils/skytilsmod/commands/impl/TrackCooldownCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object TrackCooldownCommand {
3636
@Greedy
3737
@Argument("ability") ability: String
3838
) {
39-
if (!Skytils.config.itemCooldownDisplay) return UChat.chat("$failPrefix §cYou must turn on Item Cooldown Display to use this command!")
39+
if (!Skytils.config.itemCooldownDisplay.getUntracked()) return UChat.chat("$failPrefix §cYou must turn on Item Cooldown Display to use this command!")
4040
if (seconds < 0) throw IllegalArgumentException("You must specify a valid number")
4141
if (ability.isBlank()) throw IllegalArgumentException("You must specify valid arguments.")
4242
if (CooldownTracker.itemCooldowns[ability] == seconds) {

mod/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt

Lines changed: 336 additions & 276 deletions
Large diffs are not rendered by default.

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/crimson/KuudraChestProfit.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object KuudraChestProfit : EventSubscriber {
7575
}
7676

7777
fun onGUIDrawnEvent(event: GuiContainerForegroundDrawnEvent) {
78-
if (!Skytils.config.kuudraChestProfit || !KuudraFeatures.kuudraOver || KuudraFeatures.myFaction == null) return
78+
if (!Skytils.config.kuudraChestProfit.getUntracked() || !KuudraFeatures.kuudraOver || KuudraFeatures.myFaction == null) return
7979

8080
if (event.chestName.endsWith(" Chest")) {
8181
val matrixStack = UMatrixStack.Compat.get()
@@ -100,7 +100,7 @@ object KuudraChestProfit : EventSubscriber {
100100
if (element.currentlyDisplayingChest.getUntracked() != null && event.screen == null) {
101101
element.currentlyDisplayingChest.set(null)
102102
} else {
103-
if (!Skytils.config.kuudraChestProfit || !KuudraFeatures.kuudraOver || KuudraFeatures.myFaction == null) return
103+
if (!Skytils.config.kuudraChestProfit.getUntracked() || !KuudraFeatures.kuudraOver || KuudraFeatures.myFaction == null) return
104104
(event.screen as? GenericContainerScreen)?.let { container ->
105105
val inv = container.screenHandler.inventory
106106
val chestName = container.title.string
@@ -219,6 +219,8 @@ object KuudraChestProfit : EventSubscriber {
219219
override fun compareTo(other: KuudraChestLootItem): Int = value.compareTo(other.value)
220220
}
221221
private class KuudraChestProfitHud : HudElement("Kuudra Chest Profit", 200f, 120f) {
222+
override val toggleState = Skytils.config.kuudraChestProfit
223+
222224
override fun LayoutScope.render() {
223225
column {
224226
KuudraChest.entries.forEach { chest ->

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/crimson/TrophyFish.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package gg.skytils.skytilsmod.features.impl.crimson
2020

2121
import gg.essential.elementa.layoutdsl.LayoutScope
2222
import gg.essential.elementa.layoutdsl.column
23+
import gg.essential.elementa.state.v2.State
2324
import gg.essential.elementa.state.v2.combinators.and
2425
import gg.essential.elementa.state.v2.mutableListStateOf
2526
import gg.essential.elementa.state.v2.setAll
@@ -64,7 +65,7 @@ object TrophyFish : EventSubscriber {
6465
}
6566

6667
fun onChat(event: ChatMessageReceivedEvent) {
67-
if (!Utils.inSkyblock || SBInfo.mode != SkyblockIsland.CrimsonIsle.mode || !Config.trophyFishTracker) return
68+
if (!Utils.inSkyblock || SBInfo.mode != SkyblockIsland.CrimsonIsle.mode || !Config.trophyFishTracker.getUntracked()) return
6869
printDevMessage({ event.message.string }, "trophyspam")
6970
trophyFishRegex.matchEntire(event.message.string.stripControlCodes())?.destructured?.let { (type, tier) ->
7071
printDevMessage({ "Found trophy fish of $type of tier $tier" }, "trophy")
@@ -145,6 +146,8 @@ object TrophyFish : EventSubscriber {
145146
}
146147

147148
object TrophyFishDisplay : HudElement("Trophy Fish Display", 0f, 0f) {
149+
override val toggleState: State<Boolean> = Config.trophyFishTracker
150+
148151
private val text = mutableListStateOf<String>()
149152

150153
fun update() =

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/BossHPDisplays.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ package gg.skytils.skytilsmod.features.impl.dungeons
1919

2020
import gg.essential.elementa.layoutdsl.LayoutScope
2121
import gg.essential.elementa.layoutdsl.column
22-
import gg.essential.elementa.state.v2.clear
23-
import gg.essential.elementa.state.v2.mutableListStateOf
24-
import gg.essential.elementa.state.v2.setAll
25-
import gg.essential.elementa.state.v2.stateOf
2622
import gg.essential.universal.UMatrixStack
2723
import gg.skytils.event.EventPriority
2824
import gg.skytils.event.EventSubscriber
@@ -48,6 +44,7 @@ import java.awt.Color
4844
import gg.skytils.skytilsmod.utils.formattedText
4945
import net.minecraft.entity.EntityType
5046
import com.mojang.blaze3d.opengl.GlStateManager
47+
import gg.essential.elementa.state.v2.*
5148
import java.util.LinkedList
5249
//#endif
5350

@@ -92,7 +89,7 @@ object BossHPDisplays : EventSubscriber {
9289
if (!Utils.inDungeons) return
9390
val world = mc.world
9491

95-
if (world != null && canGiantsSpawn && (Skytils.config.showGiantHPAtFeet || Skytils.config.showGiantHP)) {
92+
if (world != null && canGiantsSpawn && (Skytils.config.showGiantHPAtFeet || Skytils.config.showGiantHP.getUntracked())) {
9693
val hasSadanPlayer = world.players.any {
9794
"Sadan " == it.name
9895
//#if MC>=11602
@@ -115,7 +112,7 @@ object BossHPDisplays : EventSubscriber {
115112
)
116113
} else giantNames.clear()
117114

118-
if (Skytils.config.showGuardianRespawnTimer && DungeonFeatures.hasBossSpawned && dungeonFloorNumber == 3 && world != null) {
115+
if (Skytils.config.showGuardianRespawnTimer.getUntracked() && DungeonFeatures.hasBossSpawned && dungeonFloorNumber == 3 && world != null) {
119116
guardianRespawnTimers.setAll(mutableListOf<String>().apply {
120117
for (entity in world.entities) {
121118
if (size >= 4) break
@@ -171,6 +168,8 @@ object BossHPDisplays : EventSubscriber {
171168
}
172169

173170
class GuardianRespawnTimer : HudElement("Guardian Respawn Timer", x = 200f, y = 30f) {
171+
override val toggleState: State<Boolean> = Skytils.config.showGuardianRespawnTimer
172+
174173
override fun LayoutScope.render() {
175174
column {
176175
forEach(guardianRespawnTimers) { timer ->
@@ -186,6 +185,8 @@ object BossHPDisplays : EventSubscriber {
186185
}
187186

188187
class GiantHPElement : HudElement("Show Giant HP", x = 200f, y = 30f) {
188+
override val toggleState: State<Boolean> = Skytils.config.showGiantHP
189+
189190
override fun LayoutScope.render() {
190191
column {
191192
forEach(giantNames) { (name, _) ->

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonChestProfit.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ object DungeonChestProfit : EventSubscriber {
7474
}
7575

7676
fun onGUIDrawnEvent(event: GuiContainerForegroundDrawnEvent) {
77-
if (!Skytils.config.dungeonChestProfit) return
77+
if (!Skytils.config.dungeonChestProfit.getUntracked()) return
7878
if ((!Utils.inDungeons || DungeonTimer.scoreShownAt == null) && SBInfo.mode != SkyblockIsland.DungeonHub.mode) return
7979
val inv = (event.container as? GenericContainerScreenHandler ?: return).inventory
8080

@@ -330,6 +330,9 @@ object DungeonChestProfit : EventSubscriber {
330330
}
331331

332332
object DungeonChestProfitHud : HudElement("Dungeon Chest Profit", 200f, 120f) {
333+
override val toggleState: State<Boolean>
334+
get() = Skytils.config.dungeonChestProfit
335+
333336
override fun LayoutScope.render() {
334337
if_(SBInfo.dungeonsState or State { SBInfo.modeState() == SkyblockIsland.DungeonHub.mode }) {
335338
column {

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import gg.essential.elementa.layoutdsl.LayoutScope
5454
import gg.essential.elementa.layoutdsl.Modifier
5555
import gg.essential.elementa.layoutdsl.color
5656
import gg.essential.elementa.state.v2.MutableState
57+
import gg.essential.elementa.state.v2.State
5758
import gg.essential.elementa.state.v2.combinators.map
5859
import gg.essential.elementa.state.v2.mutableStateOf
5960
import gg.essential.elementa.state.v2.stateUsingSystemTime
@@ -165,7 +166,7 @@ object DungeonFeatures : EventSubscriber {
165166
}
166167

167168
fun onBlockChange(event: BlockStateUpdateEvent) {
168-
if (hasBossSpawned && Skytils.config.spiritBearTimer && dungeonFloor?.endsWith('4') == true) {
169+
if (hasBossSpawned && Skytils.config.spiritBearTimer.getUntracked() && dungeonFloor?.endsWith('4') == true) {
169170
if (event.pos == lastBlockPos) {
170171
lastLitUpTime.set {
171172
if (event.update.block === Blocks.SEA_LANTERN && event.old.block === Blocks.COAL_BLOCK) Instant.now() else null
@@ -182,7 +183,7 @@ object DungeonFeatures : EventSubscriber {
182183

183184
fun onReceivePacketHighest(event: PacketReceiveEvent<*>) {
184185
event.apply {
185-
if (hasBossSpawned && Skytils.config.spiritBearTimer && dungeonFloor?.endsWith('4') == true) {
186+
if (hasBossSpawned && Skytils.config.spiritBearTimer.getUntracked() && dungeonFloor?.endsWith('4') == true) {
186187
when (packet) {
187188
is BlockUpdateS2CPacket -> {
188189
if (packet.pos == lastBlockPos) {
@@ -694,6 +695,9 @@ object DungeonFeatures : EventSubscriber {
694695
}
695696

696697
object SpiritBearSpawnTimer : HudElement("Spirit Bear Spawn Timer", 0.05, 0.4) {
698+
override val toggleState: State<Boolean>
699+
get() = Skytils.config.spiritBearTimer
700+
697701
val diff = stateUsingSystemTime { currentTime ->
698702
lastLitUpTime()?.plusMillis(3400)?.let { time -> currentTime.until(time) }
699703
}
@@ -711,6 +715,9 @@ object DungeonFeatures : EventSubscriber {
711715
}
712716

713717
object DungeonSecretDisplay : HudElement("Dungeon Secret Display", x = 0.05, y = 0.4) {
718+
override val toggleState: State<Boolean>
719+
get() = Skytils.config.dungeonSecretDisplay
720+
714721
val secretsState = mutableStateOf(-1)
715722
val maxSecretsState = mutableStateOf(-1)
716723

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonTimer.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ object DungeonTimer : EventSubscriber {
280280
}
281281

282282
object DungeonTimerHud: HudElement("Dungeon Timer", 200f, 80f) {
283+
override val toggleState: State<Boolean>
284+
get() = Skytils.config.dungeonTimerState
285+
283286
private val timeElapsed = State {
284287
val start = dungeonStartTimeState()
285288
bossClearTimeState()?.let { bossClearTime ->
@@ -332,6 +335,9 @@ object DungeonTimer : EventSubscriber {
332335
}
333336

334337
object NecronPhaseTimerHud : HudElement("Necron Phase Timer", 200f, 120f) {
338+
override val toggleState: State<Boolean>
339+
get() = Skytils.config.necronPhaseTimerState
340+
335341
override fun LayoutScope.render() {
336342
if_(SBInfo.dungeonsState and State { bossEntryTimeState() != null} and State { dungeonFloorNumberState() == 7 }) {
337343
column {
@@ -373,6 +379,9 @@ object DungeonTimer : EventSubscriber {
373379
}
374380

375381
object SadanPhaseTimer : HudElement("Sadan Phase Timer", 200f, 120f) {
382+
override val toggleState: State<Boolean>
383+
get() = Skytils.config.sadanPhaseTimerState
384+
376385
override fun LayoutScope.render() {
377386
if_(SBInfo.dungeonsState and State { bossEntryTimeState() != null && dungeonFloorNumberState() == 6 }) {
378387
column {

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/LividFinder.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons
2020

2121
import gg.essential.elementa.layoutdsl.LayoutScope
2222
import gg.essential.elementa.state.v2.MutableState
23+
import gg.essential.elementa.state.v2.State
2324
import gg.essential.elementa.state.v2.mutableStateOf
2425
import gg.essential.universal.UChat
2526
import gg.skytils.event.EventSubscriber
@@ -177,6 +178,9 @@ object LividFinder : EventSubscriber {
177178
get() = block.defaultMapColor.let { mapColor -> DyeColor.entries.find { it.mapColor == mapColor } }
178179

179180
private class LividHud : HudElement("Livid HP", 0.05, 0.4) {
181+
override val toggleState: State<Boolean>
182+
get() = Skytils.config.findCorrectLividState
183+
180184
override fun LayoutScope.render() {
181185
if_(SBInfo.dungeonsState) {
182186
ifNotNull(lividTag) { lividTag ->

mod/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ object ScoreCalculation: EventSubscriber {
510510
}
511511

512512
class HugeCryptsHud : HudElement("Dungeon Crypts Counter", 200f, 200f) {
513+
override val toggleState: gg.essential.elementa.state.v2.State<Boolean>
514+
get() = Skytils.config.bigCryptsCounter
515+
513516
override fun LayoutScope.render() {
514517
if_(SBInfo.dungeonsState and { DungeonTimer.dungeonStartTimeState() != null }) {
515518
text({ "Crypts: ${crypts.toV2()()}" }, Modifier.color { if (crypts.toV2()() < 5) Color.RED else Color(0x49ff59) })
@@ -523,6 +526,9 @@ object ScoreCalculation: EventSubscriber {
523526
}
524527

525528
object ScoreCalculationHud : HudElement("Dungeon Score Estimate", 200f, 100f) {
529+
override val toggleState: gg.essential.elementa.state.v2.State<Boolean>
530+
get() = Skytils.config.showScoreCalculation
531+
526532
val text = mutableListStateOf<String>()
527533
override fun LayoutScope.render() {
528534
if_(SBInfo.dungeonsState) {

0 commit comments

Comments
 (0)