mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
Cleanup
This commit is contained in:
parent
30fe9e4dde
commit
ddd271c00d
@ -1,77 +1,77 @@
|
|||||||
#if ML
|
#if ML
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
|
|
||||||
namespace UnityExplorer.Loader.ML
|
namespace UnityExplorer.Loader.ML
|
||||||
{
|
{
|
||||||
public class MelonLoaderConfigHandler : ConfigHandler
|
public class MelonLoaderConfigHandler : ConfigHandler
|
||||||
{
|
{
|
||||||
internal const string CTG_NAME = "UnityExplorer";
|
internal const string CTG_NAME = "UnityExplorer";
|
||||||
|
|
||||||
internal MelonPreferences_Category prefCategory;
|
internal MelonPreferences_Category prefCategory;
|
||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings", false, true);
|
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings", false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void LoadConfig()
|
public override void LoadConfig()
|
||||||
{
|
{
|
||||||
foreach (var entry in ConfigManager.ConfigElements)
|
foreach (var entry in ConfigManager.ConfigElements)
|
||||||
{
|
{
|
||||||
var key = entry.Key;
|
var key = entry.Key;
|
||||||
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
|
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
|
||||||
{
|
{
|
||||||
var config = entry.Value;
|
var config = entry.Value;
|
||||||
config.BoxedValue = config.GetLoaderConfigValue();
|
config.BoxedValue = config.GetLoaderConfigValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
||||||
{
|
{
|
||||||
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.Description, config.IsInternal, false);
|
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.Description, config.IsInternal, false);
|
||||||
|
|
||||||
entry.OnValueChangedUntyped += () =>
|
entry.OnValueChangedUntyped += () =>
|
||||||
{
|
{
|
||||||
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
|
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
config.Value = entry.Value;
|
config.Value = entry.Value;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
|
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
|
||||||
{
|
{
|
||||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||||
{
|
{
|
||||||
entry.Value = value;
|
entry.Value = value;
|
||||||
//entry.Save();
|
//entry.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override T GetConfigValue<T>(ConfigElement<T> config)
|
public override T GetConfigValue<T>(ConfigElement<T> config)
|
||||||
{
|
{
|
||||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||||
return entry.Value;
|
return entry.Value;
|
||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnAnyConfigChanged()
|
public override void OnAnyConfigChanged()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SaveConfig()
|
public override void SaveConfig()
|
||||||
{
|
{
|
||||||
MelonPreferences.Save();
|
MelonPreferences.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -48,9 +48,6 @@ namespace UnityExplorer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static event Action<string, LogType> OnLog;
|
public static event Action<string, LogType> OnLog;
|
||||||
|
|
||||||
public Harmony HarmonyInstance => s_harmony;
|
|
||||||
public static readonly Harmony s_harmony = new Harmony(ExplorerCore.GUID);
|
|
||||||
|
|
||||||
public ConfigHandler ConfigHandler => _configHandler;
|
public ConfigHandler ConfigHandler => _configHandler;
|
||||||
private StandaloneConfigHandler _configHandler;
|
private StandaloneConfigHandler _configHandler;
|
||||||
|
|
||||||
|
@ -298,13 +298,13 @@
|
|||||||
<Compile Include="Core\Tests\TestClass.cs" />
|
<Compile Include="Core\Tests\TestClass.cs" />
|
||||||
<Compile Include="Core\Utility\UnityHelpers.cs" />
|
<Compile Include="Core\Utility\UnityHelpers.cs" />
|
||||||
<Compile Include="ExplorerCore.cs" />
|
<Compile Include="ExplorerCore.cs" />
|
||||||
<Compile Include="Loader\BIE\BepInExConfigHandler.cs" />
|
<Compile Include="Loader\BepInEx\BepInExConfigHandler.cs" />
|
||||||
<Compile Include="Loader\BIE\ExplorerBepInPlugin.cs" />
|
<Compile Include="Loader\BepInEx\ExplorerBepInPlugin.cs" />
|
||||||
<Compile Include="Loader\IExplorerLoader.cs" />
|
<Compile Include="Loader\IExplorerLoader.cs" />
|
||||||
<Compile Include="Loader\ML\ExplorerMelonMod.cs" />
|
<Compile Include="Loader\MelonLoader\ExplorerMelonMod.cs" />
|
||||||
<Compile Include="Loader\ML\MelonLoaderConfigHandler.cs" />
|
<Compile Include="Loader\MelonLoader\MelonLoaderConfigHandler.cs" />
|
||||||
<Compile Include="Loader\STANDALONE\ExplorerStandalone.cs" />
|
<Compile Include="Loader\Standalone\ExplorerStandalone.cs" />
|
||||||
<Compile Include="Loader\STANDALONE\StandaloneConfigHandler.cs" />
|
<Compile Include="Loader\Standalone\StandaloneConfigHandler.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="UI\Models\UIBehaviourModel.cs" />
|
<Compile Include="UI\Models\UIBehaviourModel.cs" />
|
||||||
<Compile Include="UI\Models\UIModel.cs" />
|
<Compile Include="UI\Models\UIModel.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user