Skip to content

Commit d926035

Browse files
committed
feat: toggle system to hide when toggled off
toggles default to on by default [no ci]
1 parent 8e7f4a2 commit d926035

File tree

1 file changed

+13
-3
lines changed
  • mod/src/main/kotlin/gg/skytils/skytilsmod/core/structure/v2

1 file changed

+13
-3
lines changed

mod/src/main/kotlin/gg/skytils/skytilsmod/core/structure/v2/HudElement.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import gg.essential.elementa.layoutdsl.*
2424
import gg.essential.elementa.state.v2.MutableState
2525
import gg.essential.elementa.state.v2.memo
2626
import gg.essential.elementa.state.v2.mutableStateOf
27+
import gg.essential.elementa.state.v2.stateOf
2728
import gg.essential.elementa.utils.withAlpha
2829
import gg.essential.universal.UResolution
2930
import gg.skytils.skytilsmod.core.GuiManager
@@ -67,10 +68,16 @@ abstract class HudElement(
6768
}.then(mouseConstraint)
6869
}
6970

71+
open val toggleState = stateOf(true)
72+
7073
val component
7174
get() = UIContainer()
7275
.apply {
73-
layout(Modifier.then(position).childBasedSize(2f)) { render() }
76+
layout(Modifier.then(position).childBasedSize(2f)) {
77+
if_(toggleState) {
78+
render()
79+
}
80+
}
7481
}
7582

7683
val demoComponent
@@ -82,8 +89,11 @@ abstract class HudElement(
8289
.childBasedSize(2f)
8390
.hoverScope()
8491
.hoverColor(Color.WHITE.withAlpha(100))
85-
, block = { demoRender() }
86-
)
92+
) {
93+
if_(toggleState) {
94+
demoRender()
95+
}
96+
}
8797
}
8898

8999

0 commit comments

Comments
 (0)