Compare commits

...

7 Commits
2.0.7 ... 2.0.9

Author SHA1 Message Date
4263cef26a Update ExplorerCore.cs 2020-10-28 20:49:53 +11:00
626e680510 2.0.9
* Fix an issue in mono builds causing a crash
* Fix for games which only contain one scene
* A few small cleanups
2020-10-28 20:49:18 +11:00
7c85969085 Update ExplorerCore.cs 2020-10-24 15:46:11 +11:00
1fce3465c2 Fix bug in ForceUnlockCursor, fix mistake in Reflection Inspector, reduced amount casting with Reflection Inspector 2020-10-24 15:45:37 +11:00
8949e3dc7d Revert "some early steps remaking the GUI with UnityEngine.UI, working in all tested game so far"
This reverts commit 4280a071f6.
2020-10-23 01:48:18 +11:00
4280a071f6 some early steps remaking the GUI with UnityEngine.UI, working in all tested game so far 2020-10-23 01:48:00 +11:00
48ed78ec36 A few small fixes 2020-10-22 21:00:33 +11:00
13 changed files with 93 additions and 49 deletions

View File

@ -128,8 +128,8 @@ namespace Explorer.CacheObject
GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.skin.label.alignment = TextAnchor.MiddleCenter;
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) }); GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); GUILayout.Label(label, new GUILayoutOption[] { GUIHelper.ExpandWidth(false) });
this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) });
GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUI.skin.label.alignment = TextAnchor.MiddleLeft;

View File

@ -25,7 +25,7 @@
<RootNamespace>Explorer</RootNamespace> <RootNamespace>Explorer</RootNamespace>
<AssemblyName>Explorer</AssemblyName> <AssemblyName>Explorer</AssemblyName>
<!-- 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:\Steam\steamapps\common\Hellpoint</MLCppGameFolder> <MLCppGameFolder>D:\Steam\steamapps\common\VRChat</MLCppGameFolder>
<!-- 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. -->

View File

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

View File

@ -1,6 +1,7 @@
using System; using System;
using UnityEngine; using UnityEngine;
using Explorer.Helpers; using Explorer.Helpers;
using BF = System.Reflection.BindingFlags;
#if ML #if ML
using Harmony; using Harmony;
#else #else
@ -40,8 +41,16 @@ namespace Explorer.UI
} }
// Get current cursor state and enable cursor // Get current cursor state and enable cursor
m_lastLockMode = Cursor.lockState; try
m_lastVisibleState = Cursor.visible; {
m_lastLockMode = (CursorLockMode)typeof(Cursor).GetProperty("lockState", BF.Public | BF.Static).GetValue(null, null);
m_lastVisibleState = (bool)typeof(Cursor).GetProperty("visible", BF.Public | BF.Static).GetValue(null, null);
}
catch
{
m_lastLockMode = CursorLockMode.None;
m_lastVisibleState = true;
}
// Setup Harmony Patches // Setup Harmony Patches
TryPatch("lockState", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_lockState))), true); TryPatch("lockState", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_lockState))), true);

View File

@ -99,20 +99,20 @@ namespace Explorer.UI.Inspectors
if (m_typeFilter != MemberTypes.All && m_typeFilter != holder.MemInfo?.MemberType) if (m_typeFilter != MemberTypes.All && m_typeFilter != holder.MemInfo?.MemberType)
return false; return false;
// check scope filter
if (m_scopeFilter == MemberScopes.Instance)
{
return !holder.IsStatic;
}
else if (m_scopeFilter == MemberScopes.Static)
{
return holder.IsStatic;
}
// hide failed reflection // hide failed reflection
if (!string.IsNullOrEmpty(holder.ReflectionException) && m_hideFailedReflection) if (!string.IsNullOrEmpty(holder.ReflectionException) && m_hideFailedReflection)
return false; return false;
// check scope filter
if (m_scopeFilter == MemberScopes.Instance && holder.IsStatic)
{
return false;
}
else if (m_scopeFilter == MemberScopes.Static && !holder.IsStatic)
{
return false;
}
// see if we should do name search // see if we should do name search
if (m_search == "" || holder.MemInfo == null) if (m_search == "" || holder.MemInfo == null)
return true; return true;
@ -141,22 +141,6 @@ namespace Explorer.UI.Inspectors
continue; continue;
} }
object target = Target;
string exception = null;
#if CPP
if (!IsStaticInspector && target is Il2CppSystem.Object ilObject)
{
try
{
target = ilObject.Il2CppCast(declaringType);
}
catch (Exception e)
{
exception = ReflectionHelpers.ExceptionToString(e);
}
}
#endif
foreach (var member in infos) foreach (var member in infos)
{ {
try try
@ -166,13 +150,12 @@ namespace Explorer.UI.Inspectors
if (m < 4 || m > 16) if (m < 4 || m > 16)
continue; continue;
var fi = member as FieldInfo;
var pi = member as PropertyInfo; var pi = member as PropertyInfo;
var mi = member as MethodInfo; var mi = member as MethodInfo;
if (IsStaticInspector) if (IsStaticInspector)
{ {
if (fi != null && !fi.IsStatic) continue; if (member is FieldInfo fi && !fi.IsStatic) continue;
else if (pi != null && !pi.GetAccessors()[0].IsStatic) continue; else if (pi != null && !pi.GetAccessors()[0].IsStatic) continue;
else if (mi != null && !mi.IsStatic) continue; else if (mi != null && !mi.IsStatic) continue;
} }
@ -211,17 +194,14 @@ namespace Explorer.UI.Inspectors
try try
{ {
var cached = CacheFactory.GetCacheObject(member, target); // ExplorerCore.Log($"Trying to cache member {sig}...");
var cached = CacheFactory.GetCacheObject(member, Target);
if (cached != null) if (cached != null)
{ {
cachedSigs.Add(sig); cachedSigs.Add(sig);
list.Add(cached); list.Add(cached);
if (string.IsNullOrEmpty(cached.ReflectionException))
{
cached.ReflectionException = exception;
}
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -224,6 +224,11 @@ namespace Explorer.UI
{ {
label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString(); label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString();
if (label.Length > 100)
{
label = label.Substring(0, 99);
}
var classColor = valueType.IsAbstract && valueType.IsSealed var classColor = valueType.IsAbstract && valueType.IsSealed
? Syntax.Class_Static ? Syntax.Class_Static
: Syntax.Class_Instance; : Syntax.Class_Instance;

View File

@ -11,6 +11,11 @@ namespace Explorer.UI
{ {
private Sprite refSprite; private Sprite refSprite;
public override void Init()
{
base.Init();
}
public override void UpdateValue() public override void UpdateValue()
{ {
#if CPP #if CPP
@ -30,7 +35,7 @@ namespace Explorer.UI
public override void GetTexture2D() public override void GetTexture2D()
{ {
if (refSprite) if (refSprite && refSprite.texture)
{ {
currentTex = refSprite.texture; currentTex = refSprite.texture;
} }

View File

@ -104,7 +104,7 @@ namespace Explorer.UI
GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) }); GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) });
m_valueToString = GUIHelper.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); m_valueToString = GUIHelper.TextArea(m_valueToString, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) });
DrawApplyButton(); DrawApplyButton();

View File

@ -35,6 +35,7 @@ namespace Explorer.UI.Main
public override void Init() public override void Init()
{ {
Instance = this; Instance = this;
m_currentScene = UnityHelpers.ActiveSceneName;
} }
public void OnSceneChange() public void OnSceneChange()

View File

@ -1,4 +1,5 @@
using UnityEngine; using System;
using UnityEngine;
namespace Explorer.UI.Shared namespace Explorer.UI.Shared
{ {
@ -38,7 +39,7 @@ namespace Explorer.UI.Shared
private int CalculateMaxOffset() private int CalculateMaxOffset()
{ {
return MaxPageOffset = (int)Mathf.Ceil((float)(ItemCount / (decimal)ItemsPerPage)) - 1; return MaxPageOffset = (int)Math.Ceiling((float)(ItemCount / (decimal)ItemsPerPage)) - 1;
} }
public void CurrentPageLabel() public void CurrentPageLabel()

View File

@ -2,6 +2,7 @@
using UnityEngine; using UnityEngine;
using Explorer.Config; using Explorer.Config;
using Explorer.UI.Inspectors; using Explorer.UI.Inspectors;
using Explorer.Helpers;
namespace Explorer.UI namespace Explorer.UI
{ {
@ -26,7 +27,15 @@ namespace Explorer.UI
{ {
var window = Activator.CreateInstance<T>(); var window = Activator.CreateInstance<T>();
#if CPP
if (target is Il2CppSystem.Object ilObject)
{
target = ilObject.Il2CppCast(ReflectionHelpers.GetActualType(ilObject));
}
#endif
window.Target = target; window.Target = target;
window.windowID = WindowManager.NextWindowID(); window.windowID = WindowManager.NextWindowID();
window.m_rect = WindowManager.GetNewWindowRect(); window.m_rect = WindowManager.GetNewWindowRect();

View File

@ -13,6 +13,14 @@ namespace Explorer
public class GUIHelper public class GUIHelper
{ {
internal static GUILayoutOption ExpandWidth(bool expand)
{
#if CPP
return GUIUnstrip.ExpandWidth(expand);
#else
return GUILayout.ExpandWidth(expand);
#endif
}
internal static GUILayoutOption ExpandHeight(bool expand) internal static GUILayoutOption ExpandHeight(bool expand)
{ {

View File

@ -8,9 +8,6 @@ using UnhollowerRuntimeLib;
namespace Explorer.Unstrip.IMGUI namespace Explorer.Unstrip.IMGUI
{ {
// Also contains some stuff from GUI.
// This class was meant to be temporary but who knows.
public class GUIUnstrip public class GUIUnstrip
{ {
#region Properties #region Properties
@ -93,12 +90,41 @@ namespace Explorer.Unstrip.IMGUI
public static void BeginLayoutDirection(bool vertical, GUIContent content, GUIStyle style, GUILayoutOption[] options) public static void BeginLayoutDirection(bool vertical, GUIContent content, GUIStyle style, GUILayoutOption[] options)
{ {
var g = GUILayoutUtility.BeginLayoutGroup(style, options, Il2CppType.Of<GUILayoutGroup>()); var g = BeginLayoutGroup(style, options, Il2CppType.Of<GUILayoutGroup>());
g.isVertical = vertical; g.isVertical = vertical;
if (style != GUIStyle.none || content != GUIContent.none) if (style != GUIStyle.none || content != GUIContent.none)
GUI.Box(g.rect, content, style); GUI.Box(g.rect, content, style);
} }
public static GUILayoutGroup BeginLayoutGroup(GUIStyle style, GUILayoutOption[] options, Il2CppSystem.Type layoutType)
{
EventType type = Event.current.type;
GUILayoutGroup guilayoutGroup;
if (type != EventType.Used && type != EventType.Layout)
{
guilayoutGroup = GUILayoutUtility.current.topLevel.GetNext().TryCast<GUILayoutGroup>();
if (guilayoutGroup == null)
{
throw new ArgumentException("GUILayout: Mismatched LayoutGroup." + Event.current.type);
}
guilayoutGroup.ResetCursor();
}
else
{
guilayoutGroup = GUILayoutUtility.CreateGUILayoutGroupInstanceOfType(layoutType);
guilayoutGroup.style = style;
if (options != null)
{
guilayoutGroup.ApplyOptions(options);
}
GUILayoutUtility.current.topLevel.entries.Add(guilayoutGroup);
}
GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup);
GUILayoutUtility.current.topLevel = guilayoutGroup;
return guilayoutGroup;
}
public static string TextField(string text, GUILayoutOption[] options, bool multiLine) public static string TextField(string text, GUILayoutOption[] options, bool multiLine)
{ {
text = text ?? string.Empty; text = text ?? string.Empty;
@ -347,7 +373,7 @@ namespace Explorer.Unstrip.IMGUI
{ {
guilayoutGroup = (GUILayoutGroup)Activator.CreateInstance(layoutType); guilayoutGroup = (GUILayoutGroup)Activator.CreateInstance(layoutType);
guilayoutGroup.style = style; guilayoutGroup.style = style;
GUILayoutUtility.current.windows.Add(guilayoutGroup); GUILayoutUtility.current.windows.entries.Add(guilayoutGroup);
} }
GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup); GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup);
GUILayoutUtility.current.topLevel = guilayoutGroup; GUILayoutUtility.current.topLevel = guilayoutGroup;