Fix the ClickBoxes not being positioned correctly when one of them is hidden

This commit is contained in:
Username404 2021-06-19 21:31:24 +02:00
parent 1aa4c374d1
commit 674d630db0
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 7 additions and 7 deletions

View File

@ -18,7 +18,7 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
ClickGui.clickBoxes.find { box -> ClickGui.clickBoxes.find { box ->
it.let { impl -> it.let { impl ->
with(impl) { with(impl) {
if (info.kind == Type.TOGGLE) { if (info.kind == Type.TOGGLE && !info.parent.shouldHide) {
Configuration.enabledFeatures[title]?.let { bool -> Configuration.enabledFeatures[title]?.let { bool ->
toggled = bool toggled = bool
} }
@ -48,8 +48,6 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
it.getDeclaredField("INSTANCE").get(null) it.getDeclaredField("INSTANCE").get(null)
} catch (e: NoSuchFieldException) {} } catch (e: NoSuchFieldException) {}
} as? ButtonImpl } as? ButtonImpl
}.filterNot {
(it.info.parent == Category.RISKY) && !riskyCheats
}.plus(Configuration.foundMacros).toTypedArray() }.plus(Configuration.foundMacros).toTypedArray()
) )
} }

View File

@ -25,9 +25,9 @@ annotation class ButtonInfo(
CLICK CLICK
} }
} }
}; enum class Category(val translationKey: String, val categoryColor: Int) { }; enum class Category(val translationKey: String, val categoryColor: Int, val shouldHide: Boolean = false) {
MISC("snowy.clickbox.misc", Colors.BLUE), MISC("snowy.clickbox.misc", Colors.BLUE),
RISKY("snowy.clickbox.risky", Colors.RED), RISKY("snowy.clickbox.risky", Colors.RED, !riskyCheats),
MACROS("snowy.clickbox.macros", Colors.GREEN); MACROS("snowy.clickbox.macros", Colors.GREEN);
companion object { companion object {
fun fromBox(box: ClickBox): Category? = values().find { fun fromBox(box: ClickBox): Category? = values().find {
@ -41,9 +41,11 @@ annotation class ButtonInfo(
name = TranslatableComponent(translationKey), name = TranslatableComponent(translationKey),
color = categoryColor color = categoryColor
); private set ); private set
constructor(translationKey: String, categoryColor: Colors): this(translationKey, categoryColor.hexValue) constructor(
translationKey: String, categoryColor: Colors, condition: Boolean = false
): this(translationKey, categoryColor.hexValue, condition)
constructor(box: ClickBox): this(translationKey = box.name.key, categoryColor = box.color) { this.box = box } constructor(box: ClickBox): this(translationKey = box.name.key, categoryColor = box.color) { this.box = box }
init { init {
ClickGui.components.add(box) ClickGui.components.add(box.apply { if (shouldHide) hidden = true })
} }
} }