diff --git a/MiraAPI/Patches/Options/MenuState.cs b/MiraAPI/Patches/Options/MenuState.cs index cd5e6c87..9d3a38ab 100644 --- a/MiraAPI/Patches/Options/MenuState.cs +++ b/MiraAPI/Patches/Options/MenuState.cs @@ -50,7 +50,8 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr) private readonly Dictionary _smallButtons = []; private readonly Dictionary _largeButtons = []; - + private Vector3 _gameSettingsButtonOrig; + private Vector3 _roleSettingsButtonOrig; [HideFromIl2Cpp] public Dictionary> Containers { get; } = new() { @@ -145,6 +146,10 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr) // Create menu buttons _largeButtons[(int)MenuButton.Roles] = Gsm.RoleSettingsButton; + // cache + _gameSettingsButtonOrig = Gsm.GameSettingsButton.transform.localPosition; + _roleSettingsButtonOrig = Gsm.RoleSettingsButton.transform.localPosition; + // modifiers button var mBtn = Instantiate(Gsm.RoleSettingsButton, Gsm.RoleSettingsButton.transform.parent); _largeButtons[MenuButton.Modifiers] = mBtn; @@ -409,6 +414,11 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr) btn.gameObject.SetActive(false); } + // The mod options page moves RoleSettingsButton as needed. + // But when hasOptions == false, it leaves the button at the GameSettingsButton spot. + // So before each re-layout, always put the original button back into the prefab slot first. + RestoreButtonLayout(); + if (CurrentModIdx == 0) { Gsm.GameSettingsButton.gameObject.SetActive(true); @@ -532,6 +542,12 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr) } } + private void RestoreButtonLayout() + { + Gsm.GameSettingsButton.transform.localPosition = _gameSettingsButtonOrig; + Gsm.RoleSettingsButton.transform.localPosition = _roleSettingsButtonOrig; + } + internal void ChangeTabPatch(GameSettingMenu menu, int tabNum, bool previewOnly) { Info($"Changed tab to {(MenuCategory)tabNum} (previewOnly: {previewOnly}) for mod {CurrentModIdx}");