From ca92e104ae88717e307593b777f4d360612c08fc Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:05:41 +0200 Subject: Fixed display name for new features if they are just the main toggle to a category --- .../misc/massconfiguration/FeatureToggleProcessor.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt index fc8c4bd92..b3d3f74b7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt @@ -11,8 +11,9 @@ import java.util.* class FeatureToggleProcessor : ConfigStructureReader { - var latestCategory: Category? = null - val pathStack = Stack() + private var latestCategory: Category? = null + private val pathStack = Stack() + private val accordionStack = Stack() val allOptions = mutableListOf() val orderedOptions by lazy { @@ -26,10 +27,13 @@ class FeatureToggleProcessor : ConfigStructureReader { override fun endCategory() { } - override fun beginAccordion(baseObject: Any?, field: Field?, option: ConfigOption?, id: Int) { + override fun beginAccordion(baseObject: Any?, field: Field?, o: ConfigOption?, id: Int) { + val option = o ?: return + accordionStack.push(option.name) } override fun endAccordion() { + accordionStack.pop() } override fun pushPath(fieldPath: String) { @@ -63,9 +67,15 @@ class FeatureToggleProcessor : ConfigStructureReader { else -> error("Invalid FeatureToggle type: $field") } + + var name = option.name + if ((name == "Enable" || name == "Enabled") && !accordionStack.empty()) { + name = accordionStack.peek() + } + allOptions.add( FeatureToggleableOption( - option.name, + name, option.desc, value, featureToggle.trueIsEnabled, -- cgit