mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 07:56:41 +08:00
Add "Default Tab" config setting instead of "last active tab"
This commit is contained in:
@ -13,6 +13,8 @@ namespace UnityExplorer.UI.Main.Home
|
||||
|
||||
public static HomePage Instance { get; internal set; }
|
||||
|
||||
public override MenuPages Type => MenuPages.Home;
|
||||
|
||||
public override bool Init()
|
||||
{
|
||||
Instance = this;
|
||||
|
@ -26,7 +26,7 @@ namespace UnityExplorer.UI.Main
|
||||
public readonly List<BaseMenuPage> Pages = new List<BaseMenuPage>();
|
||||
private BaseMenuPage m_activePage;
|
||||
|
||||
public static Action<int> OnActiveTabChanged;
|
||||
public static Action<MenuPages> OnActiveTabChanged;
|
||||
|
||||
// Navbar buttons
|
||||
private Button m_lastNavButtonPressed;
|
||||
@ -38,8 +38,6 @@ namespace UnityExplorer.UI.Main
|
||||
internal bool pageLayoutInit;
|
||||
internal int layoutInitIndex;
|
||||
|
||||
private int origDesiredPage = -1;
|
||||
|
||||
public static void Create()
|
||||
{
|
||||
if (Instance != null)
|
||||
@ -67,6 +65,7 @@ namespace UnityExplorer.UI.Main
|
||||
|
||||
if (!page.Init())
|
||||
{
|
||||
page.WasDisabled = true;
|
||||
// page init failed.
|
||||
Pages.RemoveAt(i);
|
||||
i--;
|
||||
@ -88,9 +87,6 @@ namespace UnityExplorer.UI.Main
|
||||
{
|
||||
if (!pageLayoutInit)
|
||||
{
|
||||
if (origDesiredPage == -1)
|
||||
origDesiredPage = ConfigManager.Last_Active_Tab?.Value ?? 0;
|
||||
|
||||
if (layoutInitIndex < Pages.Count)
|
||||
{
|
||||
SetPage(Pages[layoutInitIndex]);
|
||||
@ -100,7 +96,8 @@ namespace UnityExplorer.UI.Main
|
||||
{
|
||||
pageLayoutInit = true;
|
||||
MainPanel.transform.position = initPos;
|
||||
SetPage(Pages[origDesiredPage]);
|
||||
|
||||
SetPage(ConfigManager.Default_Tab.Value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -108,9 +105,17 @@ namespace UnityExplorer.UI.Main
|
||||
m_activePage?.Update();
|
||||
}
|
||||
|
||||
public void SetPage(MenuPages page)
|
||||
{
|
||||
var pageObj = Pages.Find(it => it.Type == page);
|
||||
if (pageObj == null || pageObj.WasDisabled)
|
||||
return;
|
||||
SetPage(pageObj);
|
||||
}
|
||||
|
||||
public void SetPage(BaseMenuPage page)
|
||||
{
|
||||
if (page == null || m_activePage == page)
|
||||
if (page == null || m_activePage == page || page.WasDisabled)
|
||||
return;
|
||||
|
||||
m_activePage?.Content?.SetActive(false);
|
||||
@ -131,7 +136,7 @@ namespace UnityExplorer.UI.Main
|
||||
|
||||
m_lastNavButtonPressed = button;
|
||||
|
||||
OnActiveTabChanged?.Invoke(Pages.IndexOf(m_activePage));
|
||||
OnActiveTabChanged?.Invoke(m_activePage.Type);
|
||||
}
|
||||
|
||||
internal void SetButtonActiveColors(Button button)
|
||||
|
@ -12,6 +12,7 @@ namespace UnityExplorer.UI.Main.Options
|
||||
public class OptionsPage : BaseMenuPage
|
||||
{
|
||||
public override string Name => "Options";
|
||||
public override MenuPages Type => MenuPages.Options;
|
||||
|
||||
internal static readonly List<CacheConfigEntry> _cachedConfigEntries = new List<CacheConfigEntry>();
|
||||
|
||||
|
@ -17,6 +17,7 @@ namespace UnityExplorer.UI.Main.Search
|
||||
public class SearchPage : BaseMenuPage
|
||||
{
|
||||
public override string Name => "Search";
|
||||
public override MenuPages Type => MenuPages.Search;
|
||||
|
||||
public static SearchPage Instance;
|
||||
|
||||
|
Reference in New Issue
Block a user