]> git.deb.at Git - rhonda/theotherroles.git/commitdiff
Fix nested option hiding fix-nested-option-bug
authorRhonda D'Vine <rhonda@deb.at>
Sun, 6 Sep 2026 07:43:34 +0000 (09:43 +0200)
committerRhonda D'Vine <rhonda@deb.at>
Sun, 6 Sep 2026 07:43:34 +0000 (09:43 +0200)
The code checked only two layers deep for nested hidden flag.  In the
case of the deputy but also at least with the jackal this wasn't
sufficient.  The checking was put into a helper method that would loop
until it doesn't find another parent anymore that is hidden.

On top of that, in drawTab the check didn't consider invertedParent so
that was is now also properly considered.

TheOtherRoles/Modules/CustomOptions.cs

index f1af1fd788d91cd3c03863a4f9c648b9ffbc67e8..9149c2aa7022f4b45ffb23c919e7dc3d68fc7054 100644 (file)
@@ -233,6 +233,17 @@ namespace TheOtherRoles {
 
         }
 
+        public bool isHiddenByParentChain() {
+            // helper function for checking hidden status up to option root
+            CustomOption current = this;
+            while (current.parent != null) {
+                if (!current.invertedParent && current.parent.selection == 0) return true;
+                if (current.invertedParent && current.parent.selection != 0) return true;
+                current = current.parent;
+            }
+            return false;
+        }
+
         public static byte[] serializeOptions() {
             using (MemoryStream memoryStream = new MemoryStream()) {
                 using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) {
@@ -500,7 +511,7 @@ namespace TheOtherRoles {
                     __instance.settingsInfo.Add(categoryHeaderMasked.gameObject);
                     num -= 1.05f;
                     i = 0;
-                } else if (option.parent != null && (option.parent.selection == 0 || option.parent.parent != null && option.parent.parent.selection == 0)) continue;  // Hides options, for which the parent is disabled!
+                } else if (option.isHiddenByParentChain()) continue;  // Hides options, for which the parent is disabled!
                 if (option == CustomOptionHolder.crewmateRolesCountMax || option == CustomOptionHolder.neutralRolesCountMax || option == CustomOptionHolder.impostorRolesCountMax || option == CustomOptionHolder.modifiersCountMax || option == CustomOptionHolder.crewmateRolesFill)
                     continue;
 
@@ -722,7 +733,7 @@ namespace TheOtherRoles {
                     categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
                     categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num, -2f);
                     num -= 0.63f;
-                } else if (option.parent != null && (option.parent.selection == 0 && !option.invertedParent || option.parent.parent != null && option.parent.parent.selection == 0 && !option.parent.invertedParent)) continue;  // Hides options, for which the parent is disabled!
+                } else if (option.isHiddenByParentChain()) continue;  // Hides options, for which the parent is disabled!
                 else if (option.parent != null && option.parent.selection != 0 && option.invertedParent) continue;
                 OptionBehaviour optionBehaviour = UnityEngine.Object.Instantiate<StringOption>(menu.stringOptionOrigin, Vector3.zero, Quaternion.identity, menu.settingsContainer);
                 optionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f);
@@ -1015,7 +1026,7 @@ namespace TheOtherRoles {
                 if (TORMapOptions.gameMode == CustomGamemodes.HideNSeek && option.type != CustomOptionType.HideNSeekMain && option.type != CustomOptionType.HideNSeekRoles) continue;
                 if (TORMapOptions.gameMode == CustomGamemodes.PropHunt && option.type != CustomOptionType.PropHunt) continue;
                 if (option.parent != null) {
-                    bool isIrrelevant = (option.parent.getSelection() == 0 && !option.invertedParent) || (option.parent.parent != null && option.parent.parent.getSelection() == 0 && !option.parent.invertedParent);
+                    bool isIrrelevant = option.isHiddenByParentChain();
 
                     Color c = isIrrelevant ? Color.grey : Color.white;  // No use for now
                     if (isIrrelevant) continue;