Fix my stupid configuration system

Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404-59 2025-04-16 20:20:05 +02:00
parent bb90bad1d1
commit bc14627b97
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 10 additions and 19 deletions

View File

@ -95,11 +95,7 @@ object Configuration {
val enabledFeatures = mutableMapOf<String, Boolean>().apply {
"enabledFeatures".let { obtained.run {
if (hasPath(it)) {
putAll(extract<Map<out String, Boolean>>(it).filterKeys { keyName -> ClickGui.clickBoxes.any {
it.buttons.any { button ->
button.info.shouldSave() && button.title == keyName
}
}})
putAll(extract<Map<out String, Boolean>>(it))
}
} }
}

View File

@ -17,25 +17,20 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
private fun addButtons(vararg buttons: ButtonImpl) {
buttons.groupBy { impl ->
ClickGui.clickBoxes.find { box ->
with(impl) {
box.isCategory(impl.info.parent)
}
}.entries.forEach { entry -> entry.run {
key?.buttons?.clear()
value.forEach { if (!it.isDisabled) {
key?.buttons?.add(it.apply {
if (info.shouldSave() && !info.parent.shouldHide) {
Configuration.enabledFeatures[title]?.let { bool ->
toggled = bool
}
}
box.isCategory(info.parent)
}
}
}.entries.forEach { entry ->
with(entry) {
key?.buttons?.clear()
value.forEach {
if (!it.isDisabled) {
key?.buttons?.add(it)
}
}
}
}
})
} }
} }
}
@JvmStatic
fun initButtons() = addButtons(