Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit ddd271c

Browse files
committed
Cleanup
1 parent 30fe9e4 commit ddd271c

File tree

6 files changed

+82
-85
lines changed

6 files changed

+82
-85
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
#if ML
2-
using MelonLoader;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using UnityEngine;
8-
using UnityExplorer.Core;
9-
using UnityExplorer.Core.Config;
10-
11-
namespace UnityExplorer.Loader.ML
12-
{
13-
public class MelonLoaderConfigHandler : ConfigHandler
14-
{
15-
internal const string CTG_NAME = "UnityExplorer";
16-
17-
internal MelonPreferences_Category prefCategory;
18-
19-
public override void Init()
20-
{
21-
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings", false, true);
22-
}
23-
24-
public override void LoadConfig()
25-
{
26-
foreach (var entry in ConfigManager.ConfigElements)
27-
{
28-
var key = entry.Key;
29-
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
30-
{
31-
var config = entry.Value;
32-
config.BoxedValue = config.GetLoaderConfigValue();
33-
}
34-
}
35-
}
36-
37-
public override void RegisterConfigElement<T>(ConfigElement<T> config)
38-
{
39-
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.Description, config.IsInternal, false);
40-
41-
entry.OnValueChangedUntyped += () =>
42-
{
43-
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
44-
return;
45-
46-
config.Value = entry.Value;
47-
};
48-
}
49-
50-
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
51-
{
52-
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
53-
{
54-
entry.Value = value;
55-
//entry.Save();
56-
}
57-
}
58-
59-
public override T GetConfigValue<T>(ConfigElement<T> config)
60-
{
61-
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
62-
return entry.Value;
63-
64-
return default;
65-
}
66-
67-
public override void OnAnyConfigChanged()
68-
{
69-
}
70-
71-
public override void SaveConfig()
72-
{
73-
MelonPreferences.Save();
74-
}
75-
}
76-
}
1+
#if ML
2+
using MelonLoader;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using UnityEngine;
8+
using UnityExplorer.Core;
9+
using UnityExplorer.Core.Config;
10+
11+
namespace UnityExplorer.Loader.ML
12+
{
13+
public class MelonLoaderConfigHandler : ConfigHandler
14+
{
15+
internal const string CTG_NAME = "UnityExplorer";
16+
17+
internal MelonPreferences_Category prefCategory;
18+
19+
public override void Init()
20+
{
21+
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings", false, true);
22+
}
23+
24+
public override void LoadConfig()
25+
{
26+
foreach (var entry in ConfigManager.ConfigElements)
27+
{
28+
var key = entry.Key;
29+
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
30+
{
31+
var config = entry.Value;
32+
config.BoxedValue = config.GetLoaderConfigValue();
33+
}
34+
}
35+
}
36+
37+
public override void RegisterConfigElement<T>(ConfigElement<T> config)
38+
{
39+
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.Description, config.IsInternal, false);
40+
41+
entry.OnValueChangedUntyped += () =>
42+
{
43+
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
44+
return;
45+
46+
config.Value = entry.Value;
47+
};
48+
}
49+
50+
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
51+
{
52+
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
53+
{
54+
entry.Value = value;
55+
//entry.Save();
56+
}
57+
}
58+
59+
public override T GetConfigValue<T>(ConfigElement<T> config)
60+
{
61+
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
62+
return entry.Value;
63+
64+
return default;
65+
}
66+
67+
public override void OnAnyConfigChanged()
68+
{
69+
}
70+
71+
public override void SaveConfig()
72+
{
73+
MelonPreferences.Save();
74+
}
75+
}
76+
}
7777
#endif

src/Loader/STANDALONE/ExplorerStandalone.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ public static ExplorerStandalone CreateInstance(Action<string, LogType> logListe
4848
/// </summary>
4949
public static event Action<string, LogType> OnLog;
5050

51-
public Harmony HarmonyInstance => s_harmony;
52-
public static readonly Harmony s_harmony = new Harmony(ExplorerCore.GUID);
53-
5451
public ConfigHandler ConfigHandler => _configHandler;
5552
private StandaloneConfigHandler _configHandler;
5653

src/UnityExplorer.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,13 @@
298298
<Compile Include="Core\Tests\TestClass.cs" />
299299
<Compile Include="Core\Utility\UnityHelpers.cs" />
300300
<Compile Include="ExplorerCore.cs" />
301-
<Compile Include="Loader\BIE\BepInExConfigHandler.cs" />
302-
<Compile Include="Loader\BIE\ExplorerBepInPlugin.cs" />
301+
<Compile Include="Loader\BepInEx\BepInExConfigHandler.cs" />
302+
<Compile Include="Loader\BepInEx\ExplorerBepInPlugin.cs" />
303303
<Compile Include="Loader\IExplorerLoader.cs" />
304-
<Compile Include="Loader\ML\ExplorerMelonMod.cs" />
305-
<Compile Include="Loader\ML\MelonLoaderConfigHandler.cs" />
306-
<Compile Include="Loader\STANDALONE\ExplorerStandalone.cs" />
307-
<Compile Include="Loader\STANDALONE\StandaloneConfigHandler.cs" />
304+
<Compile Include="Loader\MelonLoader\ExplorerMelonMod.cs" />
305+
<Compile Include="Loader\MelonLoader\MelonLoaderConfigHandler.cs" />
306+
<Compile Include="Loader\Standalone\ExplorerStandalone.cs" />
307+
<Compile Include="Loader\Standalone\StandaloneConfigHandler.cs" />
308308
<Compile Include="Properties\AssemblyInfo.cs" />
309309
<Compile Include="UI\Models\UIBehaviourModel.cs" />
310310
<Compile Include="UI\Models\UIModel.cs" />

0 commit comments

Comments
 (0)