UnityExplorer/src/ExplorerCore.cs

120 lines
2.7 KiB
C#
Raw Normal View History

using UnityEngine;
2020-08-07 22:19:03 +10:00
namespace Explorer
{
public class ExplorerCore
2020-08-07 22:19:03 +10:00
{
public const string NAME = "Explorer (" + PLATFORM + ", " + MODLOADER + ")";
public const string VERSION = "1.8.22";
2020-09-27 22:52:08 +10:00
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.explorer";
public const string PLATFORM =
#if CPP
2020-09-27 22:52:08 +10:00
"Il2Cpp";
#else
2020-09-27 22:52:08 +10:00
"Mono";
#endif
public const string MODLOADER =
#if ML
"MelonLoader";
#else
"BepInEx";
#endif
public static ExplorerCore Instance { get; private set; }
2020-08-07 22:19:03 +10:00
public ExplorerCore()
2020-08-07 22:19:03 +10:00
{
Instance = this;
ModConfig.OnLoad();
2020-08-07 22:19:03 +10:00
new MainMenu();
new WindowManager();
InputHelper.Init();
CursorControl.Init();
Log($"{NAME} {VERSION} initialized.");
2020-08-07 22:19:03 +10:00
}
public static bool ShowMenu
2020-08-07 22:19:03 +10:00
{
get => m_showMenu;
set => SetShowMenu(value);
2020-08-07 22:19:03 +10:00
}
public static bool m_showMenu;
2020-08-07 22:19:03 +10:00
private static void SetShowMenu(bool show)
{
m_showMenu = show;
CursorControl.UpdateCursorControl();
}
public static void Update()
2020-08-07 22:19:03 +10:00
{
if (InputHelper.GetKeyDown(ModConfig.Instance.Main_Menu_Toggle))
2020-08-07 22:19:03 +10:00
{
ShowMenu = !ShowMenu;
}
if (ShowMenu)
{
CursorControl.Update();
InspectUnderMouse.Update();
2020-08-12 03:51:47 +10:00
2020-08-07 22:19:03 +10:00
MainMenu.Instance.Update();
WindowManager.Instance.Update();
}
}
public static void OnGUI()
2020-08-07 22:19:03 +10:00
{
if (!ShowMenu) return;
var origSkin = GUI.skin;
GUI.skin = UIStyles.WindowSkin;
2020-08-07 22:19:03 +10:00
MainMenu.Instance.OnGUI();
WindowManager.Instance.OnGUI();
InspectUnderMouse.OnGUI();
GUI.skin = origSkin;
}
public static void OnSceneChange()
{
ScenePage.Instance?.OnSceneChange();
SearchPage.Instance?.OnSceneChange();
}
public static void Log(string message)
{
#if ML
MelonLoader.MelonLogger.Log(message);
#else
ExplorerBepInPlugin.Logging?.LogMessage(message);
#endif
}
public static void LogWarning(string message)
{
#if ML
MelonLoader.MelonLogger.LogWarning(message);
#else
ExplorerBepInPlugin.Logging?.LogWarning(message);
#endif
}
public static void LogError(string message)
{
#if ML
MelonLoader.MelonLogger.LogError(message);
#else
ExplorerBepInPlugin.Logging?.LogError(message);
#endif
}
2020-08-07 22:19:03 +10:00
}
}