Compare commits

...

6 Commits

Author SHA1 Message Date
59c5b13a05 1.8.3.1 2020-10-05 20:25:51 +11:00
b8b6cc1605 1.8.0.1
* Added some internal caching for Enum Names, should vastly improve speed when inspecting certain classes (worst case scenario I found went from over 50 seconds to less than 1 second).
* ILRepack is now done as part of the build process, should simplify things if you are building the project yourself.
2020-10-05 20:25:25 +11:00
912b1b80ff using ILRepack MSBuild task, adding some base libs 2020-10-05 18:32:38 +11:00
6a9c64c2a1 Update README for new build process 2020-10-04 20:48:08 +11:00
54deecd312 Update README.md 2020-10-04 20:11:05 +11:00
403943a41f Update README.md 2020-10-04 20:09:45 +11:00
15 changed files with 105 additions and 30 deletions

View File

@ -45,14 +45,14 @@ Requires [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) to be ins
1. Download the relevant <b>Explorer_MelonLoader_.zip</b> from above. 1. Download the relevant <b>Explorer_MelonLoader_.zip</b> from above.
2. Unzip the file into the `Mods` folder in your game's installation directory, created by MelonLoader. 2. Unzip the file into the `Mods` folder in your game's installation directory, created by MelonLoader.
3. Make sure it's not in a sub-folder, `Explorer.dll` and `mcs.dll` should be directly in the `Mods\` folder. 3. Make sure it's not in a sub-folder, `Explorer.dll` should be directly in the `Mods\` folder.
### BepInEx ### BepInEx
Requires [BepInEx](https://github.com/BepInEx/BepInEx) to be installed for your game. Requires [BepInEx](https://github.com/BepInEx/BepInEx) to be installed for your game.
1. Download the relevant <b>Explorer_BepInEx_.zip</b> from above. 1. Download the relevant <b>Explorer_BepInEx_.zip</b> from above.
2. Unzip the file into the `BepInEx\plugins\` folder in your game's installation directory, created by BepInEx. 2. Unzip the file into the `BepInEx\plugins\` folder in your game's installation directory, created by BepInEx.
3. Make sure it's not in a sub-folder, `Explorer.dll` and `mcs.dll` should be directly in the `plugins\` folder. 3. Make sure it's not in a sub-folder, `Explorer.dll` should be directly in the `plugins\` folder.
## How to use ## How to use
@ -147,7 +147,7 @@ public class MenuClass_CursorUpdate
## Building ## Building
If you'd like to build this yourself, everything you need (other than MelonLoader and/or BepInEx) is included with this repository. If you'd like to build this yourself, you will need to have installed BepInEx and/or MelonLoader for at least one Unity game. If you want to build all 6 versions, you will need at least one Il2Cpp and one Mono game, with BepInEx and MelonLoader installed for both.
1. Install MelonLoader or BepInEx for your game. 1. Install MelonLoader or BepInEx for your game.
2. Open the `src\Explorer.csproj` file in a text editor. 2. Open the `src\Explorer.csproj` file in a text editor.
@ -155,6 +155,7 @@ If you'd like to build this yourself, everything you need (other than MelonLoade
4. Open the `src\Explorer.sln` project. 4. Open the `src\Explorer.sln` project.
5. Select `Solution 'Explorer' (1 of 1 project)` in the Solution Explorer panel, and set the <b>Active config</b> property to the version you want to build, then build it. 5. Select `Solution 'Explorer' (1 of 1 project)` in the Solution Explorer panel, and set the <b>Active config</b> property to the version you want to build, then build it.
5. The DLLs are built to the `Release\` folder in the root of the repository. 5. The DLLs are built to the `Release\` folder in the root of the repository.
6. If ILRepack fails or is missing, use the NuGet package manager to re-install `ILRepack.Lib.MSBuild.Task`, then re-build.
## Credits ## Credits

BIN
lib/0Harmony.dll Normal file

Binary file not shown.

BIN
lib/BepInEx.Core.dll Normal file

Binary file not shown.

BIN
lib/BepInEx.IL2CPP.dll Normal file

Binary file not shown.

BIN
lib/BepInEx.dll Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using UnityEngine; using UnityEngine;
#if CPP #if CPP
using UnhollowerBaseLib; using UnhollowerBaseLib;
@ -15,8 +16,8 @@ namespace Explorer
public PageHelper Pages = new PageHelper(); public PageHelper Pages = new PageHelper();
private CacheObjectBase[] m_cachedKeys; private CacheObjectBase[] m_cachedKeys = new CacheObjectBase[0];
private CacheObjectBase[] m_cachedValues; private CacheObjectBase[] m_cachedValues = new CacheObjectBase[0];
public Type TypeOfKeys public Type TypeOfKeys
{ {
@ -119,6 +120,11 @@ namespace Explorer
base.UpdateValue(); base.UpdateValue();
CacheEntries();
}
public void CacheEntries()
{
// reset // reset
IDict = null; IDict = null;
@ -190,8 +196,6 @@ namespace Explorer
var whitespace = CalcWhitespace(window); var whitespace = CalcWhitespace(window);
int count = m_cachedKeys.Length;
if (!IsExpanded) if (!IsExpanded)
{ {
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
@ -209,6 +213,8 @@ namespace Explorer
var negativeWhitespace = window.width - (whitespace + 100f); var negativeWhitespace = window.width - (whitespace + 100f);
int count = m_cachedKeys.Length;
GUI.skin.button.alignment = TextAnchor.MiddleLeft; GUI.skin.button.alignment = TextAnchor.MiddleLeft;
string btnLabel = $"[{count}] <color=#2df7b2>Dictionary<{TypeOfKeys.FullName}, {TypeOfValues.FullName}></color>"; string btnLabel = $"[{count}] <color=#2df7b2>Dictionary<{TypeOfKeys.FullName}, {TypeOfValues.FullName}></color>";
if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) })) if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) }))
@ -260,21 +266,27 @@ namespace Explorer
//GUIUnstrip.Space(whitespace); //GUIUnstrip.Space(whitespace);
if (key == null || val == null) if (key == null && val == null)
{ {
GUILayout.Label($"[{i}] <i><color=grey>(null)</color></i>", new GUILayoutOption[0]); GUILayout.Label($"[{i}] <i><color=grey>(null)</color></i>", new GUILayoutOption[0]);
} }
else else
{ {
GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.skin.label.alignment = TextAnchor.MiddleCenter;
GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(40) });
GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUI.skin.label.alignment = TextAnchor.MiddleLeft;
GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) }); GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) });
if (key != null)
key.DrawValue(window, (window.width / 2) - 80f); key.DrawValue(window, (window.width / 2) - 80f);
else
GUILayout.Label("<i>null</i>", new GUILayoutOption[0]);
GUILayout.Label("Value:", new GUILayoutOption[] { GUILayout.Width(40) }); GUILayout.Label("Value:", new GUILayoutOption[] { GUILayout.Width(40) });
if (Value != null)
val.DrawValue(window, (window.width / 2) - 80f); val.DrawValue(window, (window.width / 2) - 80f);
else
GUILayout.Label("<i>null</i>", new GUILayoutOption[0]);
} }
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
@ -13,7 +14,7 @@ namespace Explorer
public PageHelper Pages = new PageHelper(); public PageHelper Pages = new PageHelper();
private CacheObjectBase[] m_cachedEntries; private CacheObjectBase[] m_cachedEntries = new CacheObjectBase[0];
// Type of Entries in the Array // Type of Entries in the Array
public Type EntryType public Type EntryType
@ -218,6 +219,11 @@ namespace Explorer
return; return;
} }
CacheEntries();
}
public void CacheEntries()
{
var enumerator = Enumerable.GetEnumerator(); var enumerator = Enumerable.GetEnumerator();
if (enumerator == null) if (enumerator == null)
{ {
@ -276,8 +282,6 @@ namespace Explorer
var whitespace = CalcWhitespace(window); var whitespace = CalcWhitespace(window);
int count = m_cachedEntries.Length;
if (!IsExpanded) if (!IsExpanded)
{ {
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
@ -295,6 +299,8 @@ namespace Explorer
var negativeWhitespace = window.width - (whitespace + 100f); var negativeWhitespace = window.width - (whitespace + 100f);
int count = m_cachedEntries.Length;
GUI.skin.button.alignment = TextAnchor.MiddleLeft; GUI.skin.button.alignment = TextAnchor.MiddleLeft;
string btnLabel = $"[{count}] <color=#2df7b2>{EntryType.FullName}</color>"; string btnLabel = $"[{count}] <color=#2df7b2>{EntryType.FullName}</color>";
if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) })) if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) }))

View File

@ -9,6 +9,8 @@ namespace Explorer
{ {
public class CacheEnum : CacheObjectBase public class CacheEnum : CacheObjectBase
{ {
internal static Dictionary<Type, string[]> EnumNamesInternalCache = new Dictionary<Type, string[]>();
// public Type EnumType; // public Type EnumType;
public string[] EnumNames = new string[0]; public string[] EnumNames = new string[0];
@ -21,18 +23,7 @@ namespace Explorer
if (ValueType != null) if (ValueType != null)
{ {
// using GetValues not GetNames, to catch instances of weird enums (eg CameraClearFlags) GetNames();
var values = Enum.GetValues(ValueType);
var list = new List<string>();
foreach (var value in values)
{
var v = value.ToString();
if (list.Contains(v)) continue;
list.Add(v);
}
EnumNames = list.ToArray();
} }
else else
{ {
@ -40,6 +31,27 @@ namespace Explorer
} }
} }
internal void GetNames()
{
if (!EnumNamesInternalCache.ContainsKey(ValueType))
{
// using GetValues not GetNames, to catch instances of weird enums (eg CameraClearFlags)
var values = Enum.GetValues(ValueType);
var set = new HashSet<string>();
foreach (var value in values)
{
var v = value.ToString();
if (set.Contains(v)) continue;
set.Add(v);
}
EnumNamesInternalCache.Add(ValueType, set.ToArray());
}
EnumNames = EnumNamesInternalCache[ValueType];
}
public override void DrawValue(Rect window, float width) public override void DrawValue(Rect window, float width)
{ {
if (CanWrite) if (CanWrite)

View File

@ -30,9 +30,11 @@
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. --> <!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
<MLMonoGameFolder>D:\Steam\steamapps\common\Outward</MLMonoGameFolder> <MLMonoGameFolder>D:\Steam\steamapps\common\Outward</MLMonoGameFolder>
<!-- 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:\Steam\steamapps\common\Outward - Il2Cpp</BIECppGameFolder> <BIECppGameFolder>D:\Steam\steamapps\common\Outward_Il2Cpp</BIECppGameFolder>
<!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. --> <!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. -->
<BIEMonoGameFolder>D:\Steam\steamapps\common\Outward</BIEMonoGameFolder> <BIEMonoGameFolder>D:\Steam\steamapps\common\Outward</BIEMonoGameFolder>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_ML_Cpp|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_ML_Cpp|AnyCPU' ">
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
@ -275,5 +277,16 @@
<Compile Include="UnstripFixes\Internal.cs" /> <Compile Include="UnstripFixes\Internal.cs" />
<Compile Include="UnstripFixes\Internal_SliderState.cs" /> <Compile Include="UnstripFixes\Internal_SliderState.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="ILRepack.targets" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets'))" />
</Target>
</Project> </Project>

View File

@ -5,7 +5,7 @@ namespace Explorer
public class ExplorerCore public class ExplorerCore
{ {
public const string NAME = "Explorer (" + PLATFORM + ", " + MODLOADER + ")"; public const string NAME = "Explorer (" + PLATFORM + ", " + MODLOADER + ")";
public const string VERSION = "1.8.3"; public const string VERSION = "1.8.3.1";
public const string AUTHOR = "Sinai"; public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.explorer"; public const string GUID = "com.sinai.explorer";

27
src/ILRepack.targets Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ILRepacker" AfterTargets="Build">
<!-- Merging DLLs -->
<ItemGroup>
<InputAssemblies Include="$(OutputPath)$(AssemblyName).dll" />
</ItemGroup>
<ItemGroup Condition="'$(IsNet35)'=='false'">
<InputAssemblies Include="..\lib\mcs.dll" />
</ItemGroup>
<ItemGroup Condition="'$(IsNet35)'=='true'">
<InputAssemblies Include="..\lib\mcs.NET35.dll" />
</ItemGroup>
<ILRepack
Parallel="true"
Internalize="true"
DebugInfo="false"
LibraryPath="..\lib\"
InputAssemblies="@(InputAssemblies)"
TargetKind="Dll"
OutputFile="$(OutputPath)$(AssemblyName).dll"
/>
</Target>
</Project>

View File

@ -32,7 +32,7 @@ namespace Explorer
#if ML #if ML
GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) }); GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) });
#else #else
GUILayout.Button(gcDrag.ToString(), new GUILayoutOption[] { GUILayout.Height(15) }); GUILayout.Button("<-- Drag to resize -->", new GUILayoutOption[] { GUILayout.Height(15) });
#endif #endif
//var r = GUILayoutUtility.GetLastRect(); //var r = GUILayoutUtility.GetLastRect();

View File

@ -202,7 +202,7 @@ namespace Explorer
continue; continue;
} }
// ExplorerCore.Log($"Trying to cache member {signature}..."); //ExplorerCore.Log($"Trying to cache member {sig}...");
try try
{ {

4
src/packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.1" targetFramework="net472" />
</packages>