mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 13:57:31 +08:00
Cleanup libs, target ML 0.3.1
This commit is contained in:
parent
7241247d05
commit
a9f6ed8729
Binary file not shown.
BIN
lib/MelonLoader/MelonLoader.dll
Normal file
BIN
lib/MelonLoader/MelonLoader.dll
Normal file
Binary file not shown.
@ -7,11 +7,7 @@ using UnityExplorer.Core.Config;
|
||||
using UnityExplorer.Core;
|
||||
using UnityExplorer.UI;
|
||||
using System.Collections;
|
||||
#if ML
|
||||
using Harmony;
|
||||
#else
|
||||
using HarmonyLib;
|
||||
#endif
|
||||
|
||||
namespace UnityExplorer.Core.Input
|
||||
{
|
||||
@ -215,198 +211,4 @@ namespace UnityExplorer.Core.Input
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Was rewriting but something broke, not looking into it right now.
|
||||
|
||||
//using System;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.EventSystems;
|
||||
//using UnityExplorer.Core.Input;
|
||||
//using BF = System.Reflection.BindingFlags;
|
||||
//using UnityExplorer.Core.Config;
|
||||
//using UnityExplorer.Core;
|
||||
//using UnityExplorer.UI;
|
||||
//using System.Collections;
|
||||
//#if ML
|
||||
//using Harmony;
|
||||
//#else
|
||||
//using HarmonyLib;
|
||||
//#endif
|
||||
|
||||
//namespace UnityExplorer.Core.Input
|
||||
//{
|
||||
// public class CursorUnlocker
|
||||
// {
|
||||
// public static bool Unlock
|
||||
// {
|
||||
// get => unlock;
|
||||
// set
|
||||
// {
|
||||
// unlock = value;
|
||||
// UpdateCursorControl();
|
||||
// }
|
||||
// }
|
||||
// private static bool unlock;
|
||||
|
||||
// public static bool ShouldActuallyUnlock => UIManager.ShowMenu && Unlock;
|
||||
|
||||
// private static CursorLockMode lastLockMode;
|
||||
// private static bool lastVisibleState;
|
||||
|
||||
// private static bool currentlySetting = false;
|
||||
|
||||
// private static Type CursorType
|
||||
// => cursorType
|
||||
// ?? (cursorType = ReflectionUtility.GetTypeByName("UnityEngine.Cursor"));
|
||||
// private static Type cursorType;
|
||||
|
||||
// public static void Init()
|
||||
// {
|
||||
// SetupPatches();
|
||||
|
||||
// UpdateCursorControl();
|
||||
|
||||
// Unlock = ConfigManager.Force_Unlock_Mouse.Value;
|
||||
// ConfigManager.Force_Unlock_Mouse.OnValueChanged += (bool val) => { Unlock = val; };
|
||||
|
||||
// if (ConfigManager.Aggressive_Force_Unlock.Value)
|
||||
// RuntimeProvider.Instance.StartCoroutine(ForceUnlockCoroutine());
|
||||
// }
|
||||
|
||||
// private static readonly WaitForEndOfFrame _waitForEndOfFrame = new WaitForEndOfFrame();
|
||||
|
||||
// private static IEnumerator ForceUnlockCoroutine()
|
||||
// {
|
||||
// while (true)
|
||||
// {
|
||||
// yield return _waitForEndOfFrame;
|
||||
|
||||
// UpdateCursorControl();
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void UpdateCursorControl()
|
||||
// {
|
||||
// currentlySetting = true;
|
||||
|
||||
// if (ShouldActuallyUnlock)
|
||||
// {
|
||||
// if (Cursor.lockState != CursorLockMode.None)
|
||||
// Cursor.lockState = CursorLockMode.None;
|
||||
// if (!Cursor.visible)
|
||||
// Cursor.visible = true;
|
||||
|
||||
// SetEventSystem();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (Cursor.lockState != lastLockMode)
|
||||
// Cursor.lockState = lastLockMode;
|
||||
// if (Cursor.visible != lastVisibleState)
|
||||
// Cursor.visible = lastVisibleState;
|
||||
|
||||
// ReleaseEventSystem();
|
||||
// }
|
||||
|
||||
// currentlySetting = false;
|
||||
// }
|
||||
|
||||
// // Event system overrides
|
||||
|
||||
// private static bool m_settingEventSystem;
|
||||
// private static EventSystem m_lastEventSystem;
|
||||
// private static BaseInputModule m_lastInputModule;
|
||||
|
||||
// public static void SetEventSystem()
|
||||
// {
|
||||
// if (InputManager.CurrentType == InputType.InputSystem
|
||||
// || !UIManager.EventSys
|
||||
// || EventSystem.current == UIManager.EventSys)
|
||||
// return;
|
||||
|
||||
// if (EventSystem.current && EventSystem.current != UIManager.EventSys)
|
||||
// {
|
||||
// m_lastEventSystem = EventSystem.current;
|
||||
// m_lastEventSystem.enabled = false;
|
||||
// }
|
||||
|
||||
// // Set to our current system
|
||||
// m_settingEventSystem = true;
|
||||
// UIManager.EventSys.enabled = true;
|
||||
// EventSystem.current = UIManager.EventSys;
|
||||
// InputManager.ActivateUIModule();
|
||||
// m_settingEventSystem = false;
|
||||
// }
|
||||
|
||||
// public static void ReleaseEventSystem()
|
||||
// {
|
||||
// if (InputManager.CurrentType == InputType.InputSystem
|
||||
// || !UIManager.EventSys
|
||||
// || EventSystem.current != UIManager.EventSys
|
||||
// || !m_lastEventSystem)
|
||||
// return;
|
||||
|
||||
// if (m_lastEventSystem.gameObject.activeInHierarchy)
|
||||
// {
|
||||
// m_lastEventSystem.enabled = true;
|
||||
|
||||
// m_settingEventSystem = true;
|
||||
// EventSystem.current = m_lastEventSystem;
|
||||
// m_lastInputModule?.ActivateModule();
|
||||
// m_settingEventSystem = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Patches
|
||||
|
||||
// private static void SetupPatches()
|
||||
// {
|
||||
// if (CursorType == null)
|
||||
// throw new Exception("Could not load Type 'UnityEngine.Cursor'!");
|
||||
|
||||
// lastLockMode = Cursor.lockState;
|
||||
// lastVisibleState = Cursor.visible;
|
||||
|
||||
// // Let mod loader handle actual patching (only necessary until ML 0.3.1)
|
||||
// ExplorerCore.Loader.SetupCursorPatches();
|
||||
// }
|
||||
|
||||
// public static void Prefix_EventSystem_set_current(ref EventSystem value)
|
||||
// {
|
||||
// if (!m_settingEventSystem && value != UIManager.EventSys)
|
||||
// {
|
||||
// m_lastEventSystem = value;
|
||||
// m_lastInputModule = value?.currentInputModule;
|
||||
|
||||
// if (ShouldActuallyUnlock)
|
||||
// {
|
||||
// value = UIManager.EventSys;
|
||||
// value.enabled = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void Prefix_set_lockState(ref CursorLockMode value)
|
||||
// {
|
||||
// if (!currentlySetting)
|
||||
// {
|
||||
// lastLockMode = value;
|
||||
|
||||
// if (ShouldActuallyUnlock)
|
||||
// value = CursorLockMode.None;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void Prefix_set_visible(ref bool value)
|
||||
// {
|
||||
// if (!currentlySetting)
|
||||
// {
|
||||
// lastVisibleState = value;
|
||||
|
||||
// if (ShouldActuallyUnlock)
|
||||
// value = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
@ -59,40 +59,25 @@ namespace UnityExplorer
|
||||
// Default delay is 1 second which is usually enough.
|
||||
private static IEnumerator SetupCoroutine()
|
||||
{
|
||||
float f = Time.realtimeSinceStartup;
|
||||
float delay = ConfigManager.Startup_Delay_Time.Value;
|
||||
while (Time.realtimeSinceStartup - f < delay)
|
||||
yield return null;
|
||||
yield return null;
|
||||
|
||||
Log($"Creating UI, after delay of {delay} second(s).");
|
||||
float start = Time.realtimeSinceStartup;
|
||||
float delay = ConfigManager.Startup_Delay_Time.Value;
|
||||
|
||||
while (delay > 0)
|
||||
{
|
||||
float diff = Math.Max(Time.deltaTime, Time.realtimeSinceStartup - start);
|
||||
delay -= diff;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
Log($"Creating UI, after delay of {ConfigManager.Startup_Delay_Time.Value} second(s).");
|
||||
|
||||
UIManager.InitUI();
|
||||
|
||||
// TEMP DEBUG TEST FOR TRANSFORM TREE
|
||||
|
||||
var stressTest = new GameObject("StressTest");
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
var obj = new GameObject($"Parent_{i}");
|
||||
obj.transform.parent = stressTest.transform;
|
||||
for (int j = 0; j < 100; j++)
|
||||
{
|
||||
var obj2 = new GameObject($"Child_{j}");
|
||||
obj2.transform.parent = obj.transform;
|
||||
}
|
||||
}
|
||||
|
||||
// long name object
|
||||
new GameObject(new string('#', 500));
|
||||
|
||||
// END
|
||||
|
||||
//InspectorManager.Inspect(UIManager.CanvasRoot.gameObject.GetComponent<GraphicRaycaster>());
|
||||
InspectorManager.Inspect(typeof(TestClass));
|
||||
//InspectorManager.InspectType(typeof(ReflectionUtility));
|
||||
|
||||
//var tex = Resources.FindObjectsOfTypeAll<Texture2D>()[0];
|
||||
//InspectorManager.Inspect(tex);
|
||||
//InspectorManager.Inspect(typeof(TestClass));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -12,6 +12,8 @@
|
||||
<ReferenceFolders Include="..\lib\HarmonyX\Harmony\bin\Release\net35\" />
|
||||
<ReferenceFolders Include="..\lib\BepInEx.6.IL2CPP\" />
|
||||
<ReferenceFolders Include="..\lib\BepInEx.6.Mono\" />
|
||||
<ReferenceFolders Include="..\lib\BepInEx.5\" />
|
||||
<ReferenceFolders Include="..\lib\MelonLoader\" />
|
||||
</ItemGroup>
|
||||
<ILRepack
|
||||
Parallel="true"
|
||||
|
@ -9,16 +9,12 @@ using UnityExplorer.Core;
|
||||
using UnityExplorer.Core.Config;
|
||||
using UnityExplorer.Core.Input;
|
||||
using UnityExplorer.Loader.ML;
|
||||
|
||||
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
|
||||
using Harmony;
|
||||
|
||||
// ML 0.3.1 SUPPORT
|
||||
//using HarmonyLib;
|
||||
using HarmonyLib;
|
||||
|
||||
[assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
|
||||
[assembly: MelonGame(null, null)]
|
||||
//[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.UNIVERSAL)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.UNIVERSAL)]
|
||||
[assembly: MelonColor(ConsoleColor.DarkCyan)]
|
||||
|
||||
namespace UnityExplorer
|
||||
{
|
||||
@ -36,9 +32,6 @@ namespace UnityExplorer
|
||||
public Action<object> OnLogWarning => MelonLogger.Warning;
|
||||
public Action<object> OnLogError => MelonLogger.Error;
|
||||
|
||||
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
|
||||
public Harmony.HarmonyInstance HarmonyInstance => Instance.Harmony;
|
||||
|
||||
public override void OnApplicationStart()
|
||||
{
|
||||
Instance = this;
|
||||
@ -47,11 +40,6 @@ namespace UnityExplorer
|
||||
ExplorerCore.Init(this);
|
||||
}
|
||||
|
||||
//public override void OnUpdate()
|
||||
//{
|
||||
// ExplorerCore.Update();
|
||||
//}
|
||||
|
||||
public void SetupCursorPatches()
|
||||
{
|
||||
try
|
||||
|
@ -1,154 +1,78 @@
|
||||
#if ML
|
||||
using MelonLoader;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityExplorer.Core;
|
||||
using UnityExplorer.Core.Config;
|
||||
|
||||
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
|
||||
using MelonLoader.Tomlyn.Model;
|
||||
|
||||
// ML 0.3.1 SUPPORT
|
||||
//using Tomlet;
|
||||
//using Tomlet.Models;
|
||||
|
||||
namespace UnityExplorer.Loader.ML
|
||||
{
|
||||
public class MelonLoaderConfigHandler : ConfigHandler
|
||||
{
|
||||
internal const string CTG_NAME = "UnityExplorer";
|
||||
|
||||
internal MelonPreferences_Category prefCategory;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings");
|
||||
|
||||
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
|
||||
try { MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter); } catch { }
|
||||
//try { MelonPreferences.Mapper.RegisterMapper(MenuPagesReader, MenuPagesWriter); } catch { }
|
||||
|
||||
// ML 0.3.1 SUPPORT
|
||||
//try { TomletMain.RegisterMapper(KeycodeWriter, KeycodeReader); } catch { }
|
||||
}
|
||||
|
||||
public override void LoadConfig()
|
||||
{
|
||||
foreach (var entry in ConfigManager.ConfigElements)
|
||||
{
|
||||
var key = entry.Key;
|
||||
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
|
||||
{
|
||||
var config = entry.Value;
|
||||
config.BoxedValue = config.GetLoaderConfigValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
||||
{
|
||||
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.IsInternal) as MelonPreferences_Entry<T>;
|
||||
|
||||
entry.OnValueChangedUntyped += () =>
|
||||
{
|
||||
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
|
||||
return;
|
||||
|
||||
config.Value = entry.Value;
|
||||
};
|
||||
}
|
||||
|
||||
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
|
||||
{
|
||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||
{
|
||||
entry.Value = value;
|
||||
entry.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public override T GetConfigValue<T>(ConfigElement<T> config)
|
||||
{
|
||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||
return entry.Value;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public override void OnAnyConfigChanged()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SaveConfig()
|
||||
{
|
||||
MelonPreferences.Save();
|
||||
}
|
||||
|
||||
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
|
||||
public static KeyCode KeycodeReader(TomlObject value)
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyCode kc = (KeyCode)Enum.Parse(typeof(KeyCode), (value as TomlString).Value);
|
||||
|
||||
if (kc == default)
|
||||
throw new Exception();
|
||||
|
||||
return kc;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return KeyCode.F7;
|
||||
}
|
||||
}
|
||||
|
||||
public static TomlObject KeycodeWriter(KeyCode value)
|
||||
{
|
||||
return MelonPreferences.Mapper.ToToml(value.ToString());
|
||||
}
|
||||
|
||||
// ML 0.3.1 SUPPORT
|
||||
/*
|
||||
public static TomlValue KeycodeWriter(KeyCode value) => TomletMain.ValueFrom(value.ToString());
|
||||
public static KeyCode KeycodeReader(TomlValue value)
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyCode kc = (KeyCode)Enum.Parse(typeof(KeyCode), value.StringValue);
|
||||
if (kc == default)
|
||||
throw new Exception();
|
||||
return kc;
|
||||
}
|
||||
catch { }
|
||||
return KeyCode.F7;
|
||||
}
|
||||
*/
|
||||
|
||||
//public static UI.Main.MenuPages MenuPagesReader(TomlObject value)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// var kc = (UI.Main.MenuPages)Enum.Parse(typeof(UI.Main.MenuPages), (value as TomlString).Value);
|
||||
|
||||
// if (kc == default)
|
||||
// throw new Exception();
|
||||
|
||||
// return kc;
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// return UI.Main.MenuPages.Home;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static TomlObject MenuPagesWriter(UI.Main.MenuPages value)
|
||||
//{
|
||||
// return MelonPreferences.Mapper.ToToml(value.ToString());
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
#if ML
|
||||
using MelonLoader;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityExplorer.Core;
|
||||
using UnityExplorer.Core.Config;
|
||||
|
||||
namespace UnityExplorer.Loader.ML
|
||||
{
|
||||
public class MelonLoaderConfigHandler : ConfigHandler
|
||||
{
|
||||
internal const string CTG_NAME = "UnityExplorer";
|
||||
|
||||
internal MelonPreferences_Category prefCategory;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings");
|
||||
}
|
||||
|
||||
public override void LoadConfig()
|
||||
{
|
||||
foreach (var entry in ConfigManager.ConfigElements)
|
||||
{
|
||||
var key = entry.Key;
|
||||
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
|
||||
{
|
||||
var config = entry.Value;
|
||||
config.BoxedValue = config.GetLoaderConfigValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
||||
{
|
||||
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.IsInternal) as MelonPreferences_Entry<T>;
|
||||
|
||||
entry.OnValueChangedUntyped += () =>
|
||||
{
|
||||
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
|
||||
return;
|
||||
|
||||
config.Value = entry.Value;
|
||||
};
|
||||
}
|
||||
|
||||
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
|
||||
{
|
||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||
{
|
||||
entry.Value = value;
|
||||
//entry.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public override T GetConfigValue<T>(ConfigElement<T> config)
|
||||
{
|
||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||
return entry.Value;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public override void OnAnyConfigChanged()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SaveConfig()
|
||||
{
|
||||
MelonPreferences.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -10,7 +10,6 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<OutputPath>..\Release\UnityExplorer.MelonLoader.Il2Cpp\</OutputPath>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<IsCpp>false</IsCpp>
|
||||
@ -114,7 +113,7 @@
|
||||
<!-- MelonLoader refs -->
|
||||
<ItemGroup Condition="'$(IsMelonLoader)'=='true'">
|
||||
<Reference Include="MelonLoader">
|
||||
<HintPath>..\lib\MelonLoader.dll</HintPath>
|
||||
<HintPath>..\lib\MelonLoader\MelonLoader.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user