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

Commit f490203

Browse files
committed
2.0.5
* Added Max Results option to Search (default 5000) * Fixed a TypeInitializationException which can happen when inspecting some classes with Dictionary members * Fixed an issue which could prevent Input support from initializating * Improved and fixed the display of TextAsset objects * A few other minor fixes
1 parent 39d9585 commit f490203

15 files changed

+357
-262
lines changed

src/CacheObject/CacheField.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Reflection;
6+
using Explorer.UI;
67

78
namespace Explorer.CacheObject
89
{
@@ -21,6 +22,15 @@ public override void InitMember(MemberInfo member, object declaringInstance)
2122

2223
public override void UpdateValue()
2324
{
25+
if (IValue is InteractiveDictionary iDict)
26+
{
27+
if (!iDict.EnsureDictionaryIsSupported())
28+
{
29+
ReflectionException = "Not supported due to TypeInitializationException";
30+
return;
31+
}
32+
}
33+
2434
try
2535
{
2636
var fi = MemInfo as FieldInfo;

src/CacheObject/CacheProperty.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Reflection;
6+
using Explorer.UI;
67

78
namespace Explorer.CacheObject
89
{
@@ -32,6 +33,15 @@ public override void UpdateValue()
3233
return;
3334
}
3435

36+
if (IValue is InteractiveDictionary iDict)
37+
{
38+
if (!iDict.EnsureDictionaryIsSupported())
39+
{
40+
ReflectionException = "Not supported due to TypeInitializationException";
41+
return;
42+
}
43+
}
44+
3545
try
3646
{
3747
var pi = MemInfo as PropertyInfo;

src/Explorer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
<Compile Include="Extensions\UnityExtensions.cs" />
232232
<Compile Include="Helpers\ReflectionHelpers.cs" />
233233
<Compile Include="Helpers\UnityHelpers.cs" />
234-
<Compile Include="Input\AbstractInput.cs" />
234+
<Compile Include="Input\IAbstractInput.cs" />
235235
<Compile Include="Tests\TestClass.cs" />
236236
<Compile Include="UI\ForceUnlockCursor.cs" />
237237
<Compile Include="Input\InputManager.cs" />

src/ExplorerCore.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Explorer
1010
public class ExplorerCore
1111
{
1212
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
13-
public const string VERSION = "2.0.4";
13+
public const string VERSION = "2.0.5";
1414
public const string AUTHOR = "Sinai";
1515
public const string GUID = "com.sinai.explorer";
1616

@@ -110,27 +110,27 @@ public static void OnSceneChange()
110110
public static void Log(object message)
111111
{
112112
#if ML
113-
MelonLoader.MelonLogger.Log(message.ToString());
113+
MelonLoader.MelonLogger.Log(message?.ToString());
114114
#else
115-
ExplorerBepInPlugin.Logging?.LogMessage(message.ToString());
115+
ExplorerBepInPlugin.Logging?.LogMessage(message?.ToString());
116116
#endif
117117
}
118118

119119
public static void LogWarning(object message)
120120
{
121121
#if ML
122-
MelonLoader.MelonLogger.LogWarning(message.ToString());
122+
MelonLoader.MelonLogger.LogWarning(message?.ToString());
123123
#else
124-
ExplorerBepInPlugin.Logging?.LogWarning(message.ToString());
124+
ExplorerBepInPlugin.Logging?.LogWarning(message?.ToString());
125125
#endif
126126
}
127127

128128
public static void LogError(object message)
129129
{
130130
#if ML
131-
MelonLoader.MelonLogger.LogError(message.ToString());
131+
MelonLoader.MelonLogger.LogError(message?.ToString());
132132
#else
133-
ExplorerBepInPlugin.Logging?.LogError(message.ToString());
133+
ExplorerBepInPlugin.Logging?.LogError(message?.ToString());
134134
#endif
135135
}
136136
}

src/Input/AbstractInput.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Input/IAbstractInput.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using UnityEngine;
6+
7+
namespace Explorer.Input
8+
{
9+
public interface IAbstractInput
10+
{
11+
void Init();
12+
13+
Vector2 MousePosition { get; }
14+
15+
bool GetKeyDown(KeyCode key);
16+
bool GetKey(KeyCode key);
17+
18+
bool GetMouseButtonDown(int btn);
19+
bool GetMouseButton(int btn);
20+
}
21+
}

src/Input/InputManager.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,35 @@ namespace Explorer
1010
{
1111
public static class InputManager
1212
{
13-
private static AbstractInput inputModule;
13+
private static IAbstractInput m_inputModule;
1414

1515
public static void Init()
1616
{
17-
if (InputSystem.TKeyboard != null || TryLoadModule("Unity.InputSystem", InputSystem.TKeyboard))
17+
if (InputSystem.TKeyboard != null || (ReflectionHelpers.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null))
1818
{
19-
inputModule = new InputSystem();
19+
m_inputModule = new InputSystem();
2020
}
21-
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.InputLegacyModule", LegacyInput.TInput))
21+
else if (LegacyInput.TInput != null || (ReflectionHelpers.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
2222
{
23-
inputModule = new LegacyInput();
23+
m_inputModule = new LegacyInput();
2424
}
2525

26-
if (inputModule == null)
26+
if (m_inputModule == null)
2727
{
2828
ExplorerCore.LogWarning("Could not find any Input module!");
29-
inputModule = new NoInput();
29+
m_inputModule = new NoInput();
3030
}
3131

32-
inputModule.Init();
33-
34-
bool TryLoadModule(string dll, Type check) => ReflectionHelpers.LoadModule(dll) && check != null;
32+
m_inputModule.Init();
3533
}
3634

37-
public static Vector3 MousePosition => inputModule.MousePosition;
35+
public static Vector3 MousePosition => m_inputModule.MousePosition;
3836

39-
public static bool GetKeyDown(KeyCode key) => inputModule.GetKeyDown(key);
40-
public static bool GetKey(KeyCode key) => inputModule.GetKey(key);
37+
public static bool GetKeyDown(KeyCode key) => m_inputModule.GetKeyDown(key);
38+
public static bool GetKey(KeyCode key) => m_inputModule.GetKey(key);
4139

42-
public static bool GetMouseButtonDown(int btn) => inputModule.GetMouseButtonDown(btn);
43-
public static bool GetMouseButton(int btn) => inputModule.GetMouseButton(btn);
40+
public static bool GetMouseButtonDown(int btn) => m_inputModule.GetMouseButtonDown(btn);
41+
public static bool GetMouseButton(int btn) => m_inputModule.GetMouseButton(btn);
4442

4543
#if CPP
4644
internal delegate void d_ResetInputAxes();

src/Input/InputSystem.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Explorer.Input
99
{
10-
public class InputSystem : AbstractInput
10+
public class InputSystem : IAbstractInput
1111
{
1212
public static Type TKeyboard => _keyboard ?? (_keyboard = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
1313
private static Type _keyboard;
@@ -43,25 +43,25 @@ public class InputSystem : AbstractInput
4343
private static PropertyInfo _positionProp;
4444
private static MethodInfo _readVector2InputMethod;
4545

46-
public override Vector2 MousePosition => (Vector2)_readVector2InputMethod.Invoke(MousePositionInfo, new object[0]);
46+
public Vector2 MousePosition => (Vector2)_readVector2InputMethod.Invoke(MousePositionInfo, new object[0]);
4747

48-
public override bool GetKeyDown(KeyCode key)
48+
public bool GetKeyDown(KeyCode key)
4949
{
5050
var parsedKey = Enum.Parse(TKey, key.ToString());
5151
var actualKey = _kbIndexer.GetValue(CurrentKeyboard, new object[] { parsedKey });
5252

5353
return (bool)_btnWasPressedProp.GetValue(actualKey, null);
5454
}
5555

56-
public override bool GetKey(KeyCode key)
56+
public bool GetKey(KeyCode key)
5757
{
5858
var parsed = Enum.Parse(TKey, key.ToString());
5959
var actualKey = _kbIndexer.GetValue(CurrentKeyboard, new object[] { parsed });
6060

6161
return (bool)_btnIsPressedProp.GetValue(actualKey, null);
6262
}
6363

64-
public override bool GetMouseButtonDown(int btn)
64+
public bool GetMouseButtonDown(int btn)
6565
{
6666
switch (btn)
6767
{
@@ -72,7 +72,7 @@ public override bool GetMouseButtonDown(int btn)
7272
}
7373
}
7474

75-
public override bool GetMouseButton(int btn)
75+
public bool GetMouseButton(int btn)
7676
{
7777
switch (btn)
7878
{
@@ -83,7 +83,7 @@ public override bool GetMouseButton(int btn)
8383
}
8484
}
8585

86-
public override void Init()
86+
public void Init()
8787
{
8888
ExplorerCore.Log("Initializing new InputSystem support...");
8989

src/Input/LegacyInput.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Explorer.Input
99
{
10-
public class LegacyInput : AbstractInput
10+
public class LegacyInput : IAbstractInput
1111
{
1212
public static Type TInput => _input ?? (_input = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
1313
private static Type _input;
@@ -18,17 +18,17 @@ public class LegacyInput : AbstractInput
1818
private static MethodInfo _getMouseButtonMethod;
1919
private static MethodInfo _getMouseButtonDownMethod;
2020

21-
public override Vector2 MousePosition => (Vector3)_mousePositionProp.GetValue(null, null);
21+
public Vector2 MousePosition => (Vector3)_mousePositionProp.GetValue(null, null);
2222

23-
public override bool GetKey(KeyCode key) => (bool)_getKeyMethod.Invoke(null, new object[] { key });
23+
public bool GetKey(KeyCode key) => (bool)_getKeyMethod.Invoke(null, new object[] { key });
2424

25-
public override bool GetKeyDown(KeyCode key) => (bool)_getKeyDownMethod.Invoke(null, new object[] { key });
25+
public bool GetKeyDown(KeyCode key) => (bool)_getKeyDownMethod.Invoke(null, new object[] { key });
2626

27-
public override bool GetMouseButton(int btn) => (bool)_getMouseButtonMethod.Invoke(null, new object[] { btn });
27+
public bool GetMouseButton(int btn) => (bool)_getMouseButtonMethod.Invoke(null, new object[] { btn });
2828

29-
public override bool GetMouseButtonDown(int btn) => (bool)_getMouseButtonDownMethod.Invoke(null, new object[] { btn });
29+
public bool GetMouseButtonDown(int btn) => (bool)_getMouseButtonDownMethod.Invoke(null, new object[] { btn });
3030

31-
public override void Init()
31+
public void Init()
3232
{
3333
ExplorerCore.Log("Initializing Legacy Input support...");
3434

src/Input/NoInput.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ namespace Explorer.Input
88
{
99
// Just a stub for games where no Input module was able to load at all.
1010

11-
public class NoInput : AbstractInput
11+
public class NoInput : IAbstractInput
1212
{
13-
public override Vector2 MousePosition => Vector2.zero;
13+
public Vector2 MousePosition => Vector2.zero;
1414

15-
public override bool GetKey(KeyCode key) => false;
15+
public bool GetKey(KeyCode key) => false;
16+
public bool GetKeyDown(KeyCode key) => false;
1617

17-
public override bool GetKeyDown(KeyCode key) => false;
18+
public bool GetMouseButton(int btn) => false;
19+
public bool GetMouseButtonDown(int btn) => false;
1820

19-
public override bool GetMouseButton(int btn) => false;
20-
21-
public override bool GetMouseButtonDown(int btn) => false;
22-
23-
public override void Init() { }
21+
public void Init() { }
2422
}
2523
}

0 commit comments

Comments
 (0)