2020-08-07 22:19:03 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEngine;
|
2020-10-08 06:15:42 +11:00
|
|
|
|
using Explorer.Config;
|
|
|
|
|
using Explorer.UI.Main;
|
|
|
|
|
using Explorer.UI.Shared;
|
|
|
|
|
using Explorer.UI.Inspectors;
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
namespace Explorer.UI
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
|
|
|
|
public class MainMenu
|
|
|
|
|
{
|
|
|
|
|
public static MainMenu Instance;
|
|
|
|
|
|
|
|
|
|
public MainMenu()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
|
|
|
|
|
|
|
|
|
Pages.Add(new ScenePage());
|
|
|
|
|
Pages.Add(new SearchPage());
|
2020-08-07 23:45:09 +10:00
|
|
|
|
Pages.Add(new ConsolePage());
|
2020-10-01 20:20:52 +10:00
|
|
|
|
Pages.Add(new OptionsPage());
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-09-12 02:20:27 +10:00
|
|
|
|
for (int i = 0; i < Pages.Count; i++)
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-09-12 02:20:27 +10:00
|
|
|
|
var page = Pages[i];
|
2020-08-07 22:19:03 +10:00
|
|
|
|
page.Init();
|
2020-10-01 20:20:52 +10:00
|
|
|
|
|
|
|
|
|
// If page failed to init, it will remove itself from the list. Lower the iterate counter.
|
|
|
|
|
if (!Pages.Contains(page)) i--;
|
2020-08-07 22:19:03 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 20:31:09 +10:00
|
|
|
|
public const int MainWindowID = 5000;
|
2020-10-01 20:20:52 +10:00
|
|
|
|
public static Rect MainRect = new Rect(5, 5, ModConfig.Instance.Default_Window_Size.x, ModConfig.Instance.Default_Window_Size.y);
|
2020-09-10 20:31:09 +10:00
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
public static readonly List<BaseMainMenuPage> Pages = new List<BaseMainMenuPage>();
|
2020-08-07 22:19:03 +10:00
|
|
|
|
private static int m_currentPage = 0;
|
|
|
|
|
|
|
|
|
|
public static void SetCurrentPage(int index)
|
|
|
|
|
{
|
|
|
|
|
if (index < 0 || Pages.Count <= index)
|
|
|
|
|
{
|
2020-09-27 22:04:23 +10:00
|
|
|
|
ExplorerCore.Log("cannot set page " + index);
|
2020-08-07 22:19:03 +10:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_currentPage = index;
|
2020-09-27 22:04:23 +10:00
|
|
|
|
GUIUnstrip.BringWindowToFront(MainWindowID);
|
2020-08-07 22:19:03 +10:00
|
|
|
|
GUI.FocusWindow(MainWindowID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
|
|
|
|
Pages[m_currentPage].Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnGUI()
|
|
|
|
|
{
|
2020-09-27 22:04:23 +10:00
|
|
|
|
MainRect = GUIUnstrip.Window(MainWindowID, MainRect, (GUI.WindowFunction)MainWindow, ExplorerCore.NAME);
|
2020-08-07 22:19:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainWindow(int id)
|
|
|
|
|
{
|
|
|
|
|
GUI.DragWindow(new Rect(0, 0, MainRect.width - 90, 20));
|
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
if (GUIUnstrip.Button(new Rect(MainRect.width - 90, 2, 80, 20), $"Hide ({ModConfig.Instance.Main_Menu_Toggle})"))
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-09-27 22:04:23 +10:00
|
|
|
|
ExplorerCore.ShowMenu = false;
|
2020-08-07 22:19:03 +10:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 17:11:15 +10:00
|
|
|
|
GUIUnstrip.BeginArea(new Rect(5, 25, MainRect.width - 10, MainRect.height - 35), GUI.skin.box);
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
|
|
|
|
MainHeader();
|
|
|
|
|
|
|
|
|
|
var page = Pages[m_currentPage];
|
2020-09-04 01:27:44 +10:00
|
|
|
|
|
2020-09-04 21:36:40 +10:00
|
|
|
|
page.scroll = GUIUnstrip.BeginScrollView(page.scroll);
|
2020-09-04 01:27:44 +10:00
|
|
|
|
|
2020-08-07 22:19:03 +10:00
|
|
|
|
page.DrawWindow();
|
2020-09-04 01:27:44 +10:00
|
|
|
|
|
2020-09-04 21:36:40 +10:00
|
|
|
|
GUIUnstrip.EndScrollView();
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-08-28 00:45:34 +10:00
|
|
|
|
MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID);
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-09-13 17:11:15 +10:00
|
|
|
|
GUIUnstrip.EndArea();
|
2020-08-07 22:19:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainHeader()
|
|
|
|
|
{
|
2020-10-08 06:15:42 +11:00
|
|
|
|
GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]);
|
2020-08-07 22:19:03 +10:00
|
|
|
|
for (int i = 0; i < Pages.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (m_currentPage == i)
|
|
|
|
|
GUI.color = Color.green;
|
|
|
|
|
else
|
|
|
|
|
GUI.color = Color.white;
|
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
if (GUILayout.Button(Pages[i].Name, new GUILayoutOption[0]))
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
|
|
|
|
m_currentPage = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-14 20:25:38 +10:00
|
|
|
|
GUILayout.EndHorizontal();
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]);
|
2020-08-24 01:42:19 +10:00
|
|
|
|
GUI.color = Color.white;
|
2020-09-27 22:04:23 +10:00
|
|
|
|
InspectUnderMouse.EnableInspect = GUILayout.Toggle(InspectUnderMouse.EnableInspect, "Inspect Under Mouse (Shift + RMB)", new GUILayoutOption[0]);
|
2020-08-24 01:42:19 +10:00
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
bool mouseState = ForceUnlockCursor.Unlock;
|
2020-09-27 22:04:23 +10:00
|
|
|
|
bool setMouse = GUILayout.Toggle(mouseState, "Force Unlock Mouse (Left Alt)", new GUILayoutOption[0]);
|
2020-10-08 06:15:42 +11:00
|
|
|
|
if (setMouse != mouseState) ForceUnlockCursor.Unlock = setMouse;
|
2020-08-30 01:08:48 +10:00
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
//WindowManager.TabView = GUILayout.Toggle(WindowManager.TabView, "Tab View", new GUILayoutOption[0]);
|
2020-09-14 20:25:38 +10:00
|
|
|
|
GUILayout.EndHorizontal();
|
2020-08-27 18:05:55 +10:00
|
|
|
|
|
2020-09-12 00:59:59 +10:00
|
|
|
|
//GUIUnstrip.Space(10);
|
|
|
|
|
GUIUnstrip.Space(10);
|
|
|
|
|
|
2020-08-07 22:19:03 +10:00
|
|
|
|
GUI.color = Color.white;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|