mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
fix:restore vanilla button layout when returning to the Main page.
This commit is contained in:
1 parent
11e894a29a
commit
b6df13a2de
1 file changed
+23
-5
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
@@ -12,10 +9,15 @@ using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using static UnityEngine.ProBuilder.AutoUnwrapSettings;
|
||||
using static UnityEngine.UI.Image;
|
||||
|
||||
namespace MiraAPI.Patches.Options;
|
||||
|
||||
@@ -50,7 +52,8 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
private readonly Dictionary<MenuButton, PassiveButton> _smallButtons = [];
|
||||
private readonly Dictionary<MenuButton, PassiveButton> _largeButtons = [];
|
||||
|
||||
private Vector3 _gameSettingsButtonOrig;
|
||||
private Vector3 _roleSettingsButtonOrig;
|
||||
[HideFromIl2Cpp]
|
||||
public Dictionary<MenuCategory, Dictionary<int, GameObject>> Containers { get; } = new()
|
||||
{
|
||||
@@ -145,6 +148,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 +416,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 +544,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}");
|
||||
|
||||
Reference in new issue
Block a user