mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 13:57:31 +08:00
Swapping to INI instead of XML config, including an AssetBundle for old (5.6.1) Unity versions.
This commit is contained in:
parent
687f56eac9
commit
be635e46a0
BIN
lib/INIFileParser.dll
Normal file
BIN
lib/INIFileParser.dll
Normal file
Binary file not shown.
BIN
resources/Older Unity bundle/explorerui.bundle
Normal file
BIN
resources/Older Unity bundle/explorerui.bundle
Normal file
Binary file not shown.
Binary file not shown.
@ -1,18 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml.Serialization;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using IniParser;
|
||||||
|
using IniParser.Parser;
|
||||||
|
|
||||||
namespace UnityExplorer.Config
|
namespace UnityExplorer.Config
|
||||||
{
|
{
|
||||||
public class ModConfig
|
public class ModConfig
|
||||||
{
|
{
|
||||||
[XmlIgnore] public static readonly XmlSerializer Serializer = new XmlSerializer(typeof(ModConfig));
|
public static ModConfig Instance;
|
||||||
|
|
||||||
//[XmlIgnore] private const string EXPLORER_FOLDER = @"Mods\UnityExplorer";
|
internal static readonly IniDataParser _parser = new IniDataParser();
|
||||||
[XmlIgnore] private const string SETTINGS_PATH = ExplorerCore.EXPLORER_FOLDER + @"\config.xml";
|
internal const string INI_PATH = ExplorerCore.EXPLORER_FOLDER + @"\config.ini";
|
||||||
|
|
||||||
[XmlIgnore] public static ModConfig Instance;
|
static ModConfig()
|
||||||
|
{
|
||||||
|
_parser.Configuration.CommentString = "#";
|
||||||
|
}
|
||||||
|
|
||||||
// Actual configs
|
// Actual configs
|
||||||
public KeyCode Main_Menu_Toggle = KeyCode.F7;
|
public KeyCode Main_Menu_Toggle = KeyCode.F7;
|
||||||
@ -31,38 +35,66 @@ namespace UnityExplorer.Config
|
|||||||
|
|
||||||
public static void OnLoad()
|
public static void OnLoad()
|
||||||
{
|
{
|
||||||
|
Instance = new ModConfig();
|
||||||
|
|
||||||
if (LoadSettings())
|
if (LoadSettings())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Instance = new ModConfig();
|
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool LoadSettings()
|
public static bool LoadSettings()
|
||||||
{
|
{
|
||||||
if (!File.Exists(SETTINGS_PATH))
|
if (!File.Exists(INI_PATH))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try
|
string ini = File.ReadAllText(INI_PATH);
|
||||||
|
|
||||||
|
var data = _parser.Parse(ini);
|
||||||
|
|
||||||
|
foreach (var config in data.Sections["Config"])
|
||||||
{
|
{
|
||||||
using (var file = File.OpenRead(SETTINGS_PATH))
|
switch (config.KeyName)
|
||||||
Instance = (ModConfig)Serializer.Deserialize(file);
|
{
|
||||||
}
|
case "Main_Menu_Toggle":
|
||||||
catch
|
Instance.Main_Menu_Toggle = (KeyCode)Enum.Parse(typeof(KeyCode), config.Value);
|
||||||
{
|
break;
|
||||||
return false;
|
case "Force_Unlock_Mouse":
|
||||||
|
Instance.Force_Unlock_Mouse = bool.Parse(config.Value);
|
||||||
|
break;
|
||||||
|
case "Default_Page_Limit":
|
||||||
|
Instance.Default_Page_Limit = int.Parse(config.Value);
|
||||||
|
break;
|
||||||
|
case "Log_Unity_Debug":
|
||||||
|
Instance.Log_Unity_Debug = bool.Parse(config.Value);
|
||||||
|
break;
|
||||||
|
case "Save_Logs_To_Disk":
|
||||||
|
Instance.Save_Logs_To_Disk = bool.Parse(config.Value);
|
||||||
|
break;
|
||||||
|
case "Default_Output_Path":
|
||||||
|
Instance.Default_Output_Path = config.Value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Instance != null;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveSettings()
|
public static void SaveSettings()
|
||||||
{
|
{
|
||||||
if (File.Exists(SETTINGS_PATH))
|
var data = new IniParser.Model.IniData();
|
||||||
File.Delete(SETTINGS_PATH);
|
|
||||||
|
|
||||||
using (var file = File.Create(SETTINGS_PATH))
|
data.Sections.AddSection("Config");
|
||||||
Serializer.Serialize(file, Instance);
|
|
||||||
|
var sec = data.Sections["Config"];
|
||||||
|
sec.AddKey("Main_Menu_Toggle", Instance.Main_Menu_Toggle.ToString());
|
||||||
|
sec.AddKey("Force_Unlock_Mouse", Instance.Force_Unlock_Mouse.ToString());
|
||||||
|
sec.AddKey("Default_Page_Limit", Instance.Default_Page_Limit.ToString());
|
||||||
|
sec.AddKey("Log_Unity_Debug", Instance.Log_Unity_Debug.ToString());
|
||||||
|
sec.AddKey("Save_Logs_To_Disk", Instance.Save_Logs_To_Disk.ToString());
|
||||||
|
sec.AddKey("Default_Output_Path", Instance.Default_Output_Path);
|
||||||
|
|
||||||
|
File.WriteAllText(INI_PATH, data.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<InputAssemblies Include="$(OutputPath)$(AssemblyName).dll" />
|
<InputAssemblies Include="$(OutputPath)$(AssemblyName).dll" />
|
||||||
<InputAssemblies Include="..\lib\mcs.dll" />
|
<InputAssemblies Include="..\lib\mcs.dll" />
|
||||||
|
<InputAssemblies Include="..\lib\INIFileParser.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ILRepack
|
<ILRepack
|
||||||
|
@ -4,7 +4,6 @@ using UnityEngine.UI;
|
|||||||
using UnityExplorer.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
using UnityExplorer.UI.Modules;
|
using UnityExplorer.UI.Modules;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
//using TMPro;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityExplorer.Helpers;
|
using UnityExplorer.Helpers;
|
||||||
using UnityExplorer.UI.Shared;
|
using UnityExplorer.UI.Shared;
|
||||||
@ -20,9 +19,11 @@ namespace UnityExplorer.UI
|
|||||||
public static GameObject CanvasRoot { get; private set; }
|
public static GameObject CanvasRoot { get; private set; }
|
||||||
public static EventSystem EventSys { get; private set; }
|
public static EventSystem EventSys { get; private set; }
|
||||||
|
|
||||||
internal static Sprite ResizeCursor { get; private set; }
|
|
||||||
internal static Font ConsoleFont { get; private set; }
|
internal static Font ConsoleFont { get; private set; }
|
||||||
|
|
||||||
|
internal static Sprite ResizeCursor { get; private set; }
|
||||||
|
internal static Shader BackupShader { get; private set; }
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
LoadBundle();
|
LoadBundle();
|
||||||
@ -100,11 +101,13 @@ namespace UnityExplorer.UI
|
|||||||
{
|
{
|
||||||
var bundle = AssetBundle.LoadFromFile(bundlePath);
|
var bundle = AssetBundle.LoadFromFile(bundlePath);
|
||||||
|
|
||||||
|
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
|
||||||
|
|
||||||
// Fix for games which don't ship with 'UI/Default' shader.
|
// Fix for games which don't ship with 'UI/Default' shader.
|
||||||
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
|
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
|
||||||
{
|
{
|
||||||
ExplorerCore.Log("This game does not ship with the 'UI/Default' shader, using manual Default Shader...");
|
ExplorerCore.Log("This game does not ship with the 'UI/Default' shader, using manual Default Shader...");
|
||||||
Graphic.defaultGraphicMaterial.shader = bundle.LoadAsset<Shader>("DefaultUI");
|
Graphic.defaultGraphicMaterial.shader = BackupShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeCursor = bundle.LoadAsset<Sprite>("cursor");
|
ResizeCursor = bundle.LoadAsset<Sprite>("cursor");
|
||||||
|
@ -24,13 +24,10 @@
|
|||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<RootNamespace>UnityExplorer</RootNamespace>
|
<RootNamespace>UnityExplorer</RootNamespace>
|
||||||
|
|
||||||
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
|
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
|
||||||
<BIECppGameFolder>D:\source\Unity Projects\Test\_BUILD</BIECppGameFolder>
|
<BIECppGameFolder>D:\source\Unity Projects\Test\_BUILD</BIECppGameFolder>
|
||||||
|
|
||||||
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
||||||
<MLCppGameFolder>D:\source\Unity Projects\Test\_BUILD</MLCppGameFolder>
|
<MLCppGameFolder>D:\source\Unity Projects\Test\_BUILD</MLCppGameFolder>
|
||||||
|
|
||||||
<NuGetPackageImportStamp>
|
<NuGetPackageImportStamp>
|
||||||
</NuGetPackageImportStamp>
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -72,6 +69,10 @@
|
|||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="INIFileParser, Version=2.5.2.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\ini-parser.2.5.2\lib\net20\INIFileParser.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.1" targetFramework="net472" />
|
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.1" targetFramework="net472" />
|
||||||
|
<package id="ini-parser" version="2.5.2" targetFramework="net35" />
|
||||||
</packages>
|
</packages>
|
Loading…
x
Reference in New Issue
Block a user