2020-10-08 06:15:42 +11:00
|
|
|
|
using Explorer.Config;
|
|
|
|
|
using Explorer.UI;
|
|
|
|
|
using Explorer.UI.Inspectors;
|
|
|
|
|
using Explorer.UI.Main;
|
|
|
|
|
using Explorer.UI.Shared;
|
|
|
|
|
using UnityEngine;
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
|
|
|
|
namespace Explorer
|
|
|
|
|
{
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public class ExplorerCore
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-10-08 06:15:42 +11:00
|
|
|
|
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
|
2020-10-12 20:15:41 +11:00
|
|
|
|
public const string VERSION = "2.0.5";
|
2020-09-27 22:52:08 +10:00
|
|
|
|
public const string AUTHOR = "Sinai";
|
|
|
|
|
public const string GUID = "com.sinai.explorer";
|
|
|
|
|
|
|
|
|
|
public const string PLATFORM =
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#if CPP
|
2020-09-27 22:52:08 +10:00
|
|
|
|
"Il2Cpp";
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#else
|
2020-09-27 22:52:08 +10:00
|
|
|
|
"Mono";
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#endif
|
2020-10-01 18:57:28 +10:00
|
|
|
|
public const string MODLOADER =
|
|
|
|
|
#if ML
|
|
|
|
|
"MelonLoader";
|
|
|
|
|
#else
|
|
|
|
|
"BepInEx";
|
|
|
|
|
#endif
|
2020-08-13 23:34:21 +10:00
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public static ExplorerCore Instance { get; private set; }
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public ExplorerCore()
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-10-11 22:57:46 +11:00
|
|
|
|
if (Instance != null)
|
|
|
|
|
{
|
|
|
|
|
Log("An instance of Explorer is already active!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-07 22:19:03 +10:00
|
|
|
|
Instance = this;
|
|
|
|
|
|
2020-09-10 20:31:09 +10:00
|
|
|
|
ModConfig.OnLoad();
|
|
|
|
|
|
2020-08-07 22:19:03 +10:00
|
|
|
|
new MainMenu();
|
|
|
|
|
new WindowManager();
|
|
|
|
|
|
2020-10-03 20:19:44 +10:00
|
|
|
|
InputManager.Init();
|
2020-10-08 06:15:42 +11:00
|
|
|
|
ForceUnlockCursor.Init();
|
2020-08-27 18:05:55 +10:00
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
ShowMenu = true;
|
|
|
|
|
|
|
|
|
|
Log($"{NAME} initialized.");
|
2020-08-07 22:19:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public static bool ShowMenu
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-09-27 22:04:23 +10:00
|
|
|
|
get => m_showMenu;
|
|
|
|
|
set => SetShowMenu(value);
|
2020-08-07 22:19:03 +10:00
|
|
|
|
}
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public static bool m_showMenu;
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
private static void SetShowMenu(bool show)
|
|
|
|
|
{
|
|
|
|
|
m_showMenu = show;
|
2020-10-08 06:15:42 +11:00
|
|
|
|
ForceUnlockCursor.UpdateCursorControl();
|
2020-09-27 22:04:23 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Update()
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-10-03 20:19:44 +10:00
|
|
|
|
if (InputManager.GetKeyDown(ModConfig.Instance.Main_Menu_Toggle))
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
|
|
|
|
ShowMenu = !ShowMenu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ShowMenu)
|
|
|
|
|
{
|
2020-10-09 21:11:15 +11:00
|
|
|
|
ForceUnlockCursor.Update();
|
2020-09-11 18:53:17 +10:00
|
|
|
|
InspectUnderMouse.Update();
|
2020-08-12 03:51:47 +10:00
|
|
|
|
|
2020-08-07 22:19:03 +10:00
|
|
|
|
MainMenu.Instance.Update();
|
|
|
|
|
WindowManager.Instance.Update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public static void OnGUI()
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-09-04 01:27:44 +10:00
|
|
|
|
if (!ShowMenu) return;
|
|
|
|
|
|
2020-09-11 18:53:17 +10:00
|
|
|
|
var origSkin = GUI.skin;
|
|
|
|
|
GUI.skin = UIStyles.WindowSkin;
|
|
|
|
|
|
2020-08-07 22:19:03 +10:00
|
|
|
|
MainMenu.Instance.OnGUI();
|
|
|
|
|
WindowManager.Instance.OnGUI();
|
2020-08-18 17:11:58 +10:00
|
|
|
|
InspectUnderMouse.OnGUI();
|
2020-08-27 18:05:55 +10:00
|
|
|
|
|
2020-10-11 22:57:46 +11:00
|
|
|
|
if (!ResizeDrag.IsMouseInResizeArea && WindowManager.IsMouseInWindow)
|
2020-10-11 20:49:14 +11:00
|
|
|
|
{
|
|
|
|
|
InputManager.ResetInputAxes();
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-11 18:53:17 +10:00
|
|
|
|
GUI.skin = origSkin;
|
2020-08-30 01:08:48 +10:00
|
|
|
|
}
|
2020-09-27 22:04:23 +10:00
|
|
|
|
|
|
|
|
|
public static void OnSceneChange()
|
|
|
|
|
{
|
|
|
|
|
ScenePage.Instance?.OnSceneChange();
|
|
|
|
|
SearchPage.Instance?.OnSceneChange();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
public static void Log(object message)
|
2020-09-27 22:04:23 +10:00
|
|
|
|
{
|
|
|
|
|
#if ML
|
2020-10-12 20:15:41 +11:00
|
|
|
|
MelonLoader.MelonLogger.Log(message?.ToString());
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#else
|
2020-10-12 20:15:41 +11:00
|
|
|
|
ExplorerBepInPlugin.Logging?.LogMessage(message?.ToString());
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
public static void LogWarning(object message)
|
2020-09-27 22:04:23 +10:00
|
|
|
|
{
|
|
|
|
|
#if ML
|
2020-10-12 20:15:41 +11:00
|
|
|
|
MelonLoader.MelonLogger.LogWarning(message?.ToString());
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#else
|
2020-10-12 20:15:41 +11:00
|
|
|
|
ExplorerBepInPlugin.Logging?.LogWarning(message?.ToString());
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-08 06:15:42 +11:00
|
|
|
|
public static void LogError(object message)
|
2020-09-27 22:04:23 +10:00
|
|
|
|
{
|
|
|
|
|
#if ML
|
2020-10-12 20:15:41 +11:00
|
|
|
|
MelonLoader.MelonLogger.LogError(message?.ToString());
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#else
|
2020-10-12 20:15:41 +11:00
|
|
|
|
ExplorerBepInPlugin.Logging?.LogError(message?.ToString());
|
2020-09-27 22:04:23 +10:00
|
|
|
|
#endif
|
|
|
|
|
}
|
2020-08-07 22:19:03 +10:00
|
|
|
|
}
|
|
|
|
|
}
|