UnityExplorer/src/Core/Config/ConfigManager.cs

112 lines
4.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
2021-04-16 17:49:19 +10:00
using UnityExplorer.UI;
namespace UnityExplorer.Core.Config
{
public static class ConfigManager
{
// Each Mod Loader has its own ConfigHandler.
// See the UnityExplorer.Loader namespace for the implementations.
public static ConfigHandler Handler { get; private set; }
public static ConfigElement<KeyCode> Main_Menu_Toggle;
public static ConfigElement<bool> Force_Unlock_Mouse;
//public static ConfigElement<MenuPages> Default_Tab;
public static ConfigElement<int> Default_Page_Limit;
public static ConfigElement<string> Default_Output_Path;
public static ConfigElement<bool> Log_Unity_Debug;
public static ConfigElement<bool> Hide_On_Startup;
2021-04-11 20:45:02 +10:00
public static ConfigElement<float> Startup_Delay_Time;
2021-04-16 17:49:19 +10:00
// internal configs
internal static InternalConfigHandler InternalHandler { get; private set; }
public static ConfigElement<string> SceneExplorerData;
public static ConfigElement<string> GameObjectInspectorData;
public static ConfigElement<string> MainWindowData;
public static ConfigElement<string> DebugConsoleData;
internal static readonly Dictionary<string, IConfigElement> ConfigElements = new Dictionary<string, IConfigElement>();
2021-04-16 17:49:19 +10:00
internal static readonly Dictionary<string, IConfigElement> InternalConfigs = new Dictionary<string, IConfigElement>();
public static void Init(ConfigHandler configHandler)
{
Handler = configHandler;
Handler.Init();
2021-04-16 17:49:19 +10:00
InternalHandler = new InternalConfigHandler();
InternalHandler.Init();
CreateConfigElements();
Handler.LoadConfig();
2021-04-16 17:49:19 +10:00
InternalHandler.LoadConfig();
2021-04-16 17:49:19 +10:00
//InitConsoleCallback();
}
internal static void RegisterConfigElement<T>(ConfigElement<T> configElement)
{
2021-04-16 17:49:19 +10:00
if (!configElement.IsInternal)
{
Handler.RegisterConfigElement(configElement);
ConfigElements.Add(configElement.Name, configElement);
}
else
{
InternalHandler.RegisterConfigElement(configElement);
InternalConfigs.Add(configElement.Name, configElement);
}
}
private static void CreateConfigElements()
{
Main_Menu_Toggle = new ConfigElement<KeyCode>("Main Menu Toggle",
"The UnityEngine.KeyCode to toggle the UnityExplorer Menu.",
KeyCode.F7);
Hide_On_Startup = new ConfigElement<bool>("Hide On Startup",
"Should UnityExplorer be hidden on startup?",
false);
//Default_Tab = new ConfigElement<MenuPages>("Default Tab",
// "The default menu page when starting the game.",
// MenuPages.Home);
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
false);
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
true);
Default_Page_Limit = new ConfigElement<int>("Default Page Limit",
"The default maximum number of elements per 'page' in UnityExplorer.",
25);
Default_Output_Path = new ConfigElement<string>("Default Output Path",
"The default output path when exporting things from UnityExplorer.",
Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Output"));
2021-04-11 20:45:02 +10:00
Startup_Delay_Time = new ConfigElement<float>("Startup Delay Time",
"The delay on startup before the UI is created.",
1f);
// Internal configs
2021-04-16 17:49:19 +10:00
SceneExplorerData = new ConfigElement<string>("SceneExplorer", "", "", true);
GameObjectInspectorData = new ConfigElement<string>("GameObjectInspector", "", "", true);
MainWindowData = new ConfigElement<string>("MainWindow", "", "", true);
DebugConsoleData = new ConfigElement<string>("DebugConsole", "", "", true);
}
}
}