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

Commit 25e48f2

Browse files
committed
Project refactor, namespace cleanup, splitting UI/functionality.
1 parent 1c0011b commit 25e48f2

File tree

99 files changed

+3367
-3076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+3367
-3076
lines changed

src/CSConsole/ScriptEvaluator.cs renamed to src/Core/CSharp/ScriptEvaluator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
using System.Reflection;
55
using Mono.CSharp;
66

7-
// Thanks to ManlyMarco for this
7+
// Thanks to ManlyMarco for most of this
88

9-
namespace UnityExplorer.CSConsole
9+
namespace UnityExplorer.Core.CSharp
1010
{
1111
public class ScriptEvaluator : Evaluator, IDisposable
1212
{

src/CSConsole/ScriptInteraction.cs renamed to src/Core/CSharp/ScriptInteraction.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
22
using Mono.CSharp;
33
using UnityExplorer.UI;
4-
using UnityExplorer.UI.Modules;
5-
using UnityExplorer.Inspectors;
4+
using UnityExplorer.UI.Main;
5+
using UnityExplorer.Core.Inspectors;
66

7-
namespace UnityExplorer.CSConsole
7+
namespace UnityExplorer.Core.CSharp
88
{
99
public class ScriptInteraction : InteractiveBase
1010
{
@@ -15,17 +15,17 @@ public static void Log(object message)
1515

1616
public static void AddUsing(string directive)
1717
{
18-
CSConsolePage.Instance.AddUsing(directive);
18+
CSharpConsole.Instance.AddUsing(directive);
1919
}
2020

2121
public static void GetUsing()
2222
{
23-
ExplorerCore.Log(CSConsolePage.Instance.m_evaluator.GetUsing());
23+
ExplorerCore.Log(CSharpConsole.Instance.m_evaluator.GetUsing());
2424
}
2525

2626
public static void Reset()
2727
{
28-
CSConsolePage.Instance.ResetConsole();
28+
CSharpConsole.Instance.ResetConsole();
2929
}
3030

3131
public static object CurrentTarget()

src/CSConsole/Suggestion.cs renamed to src/Core/CSharp/Suggestion.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using System.Linq;
44
using System.Reflection;
55
using UnityEngine;
6-
using UnityExplorer.Helpers;
6+
using UnityExplorer.Core;
7+
using UnityExplorer.Core.Unity;
8+
using UnityExplorer.UI.CSConsole;
79

8-
namespace UnityExplorer.CSConsole
10+
namespace UnityExplorer.Core.CSharp
911
{
1012
public struct Suggestion
1113
{
@@ -48,7 +50,7 @@ private Color GetTextColor()
4850
public static HashSet<string> Namespaces => m_namspaces ?? GetNamespaces();
4951
private static HashSet<string> m_namspaces;
5052

51-
public static HashSet<string> Keywords => m_keywords ?? (m_keywords = new HashSet<string>(CSharpLexer.validKeywordMatcher.Keywords));
53+
public static HashSet<string> Keywords => m_keywords ?? (m_keywords = new HashSet<string>(CSLexerHighlighter.validKeywordMatcher.Keywords));
5254
private static HashSet<string> m_keywords;
5355

5456
private static readonly Color keywordColor = new Color(80f / 255f, 150f / 255f, 215f / 255f);

src/Config/ExplorerConfig.cs renamed to src/Core/Config/ExplorerConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using IniParser.Parser;
66
using UnityExplorer.UI;
77

8-
namespace UnityExplorer.Config
8+
namespace UnityExplorer.Core.Config
99
{
1010
public class ExplorerConfig
1111
{

src/Input/IHandleInput.cs renamed to src/Core/Input/IHandleInput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using UnityEngine;
22
using UnityEngine.EventSystems;
33

4-
namespace UnityExplorer.Input
4+
namespace UnityExplorer.Core.Input
55
{
66
public interface IHandleInput
77
{

src/Input/InputManager.cs renamed to src/Core/Input/InputManager.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
using System;
22
using UnityEngine;
3-
using UnityExplorer.Helpers;
43
using System.Diagnostics.CodeAnalysis;
54
using UnityEngine.EventSystems;
6-
#if CPP
7-
using UnhollowerBaseLib;
8-
#endif
95

10-
namespace UnityExplorer.Input
6+
namespace UnityExplorer.Core.Input
117
{
128
public enum InputType
139
{
@@ -43,12 +39,12 @@ public static void AddUIModule()
4339

4440
public static void Init()
4541
{
46-
if (InputSystem.TKeyboard != null || (ReflectionHelpers.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null))
42+
if (InputSystem.TKeyboard != null || (ReflectionUtility.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null))
4743
{
4844
m_inputModule = new InputSystem();
4945
CurrentType = InputType.InputSystem;
5046
}
51-
else if (LegacyInput.TInput != null || (ReflectionHelpers.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
47+
else if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
5248
{
5349
m_inputModule = new LegacyInput();
5450
CurrentType = InputType.Legacy;

src/Input/InputSystem.cs renamed to src/Core/Input/InputSystem.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using System;
22
using System.Reflection;
3-
using UnityExplorer.Helpers;
3+
using UnityExplorer.Core.Unity;
44
using UnityEngine;
55
using UnityEngine.EventSystems;
66
using UnityExplorer.UI;
77
using System.Collections.Generic;
88

9-
namespace UnityExplorer.Input
9+
namespace UnityExplorer.Core.Input
1010
{
1111
public class InputSystem : IHandleInput
1212
{
@@ -17,29 +17,29 @@ public InputSystem()
1717
m_kbCurrentProp = TKeyboard.GetProperty("current");
1818
m_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
1919

20-
var btnControl = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Controls.ButtonControl");
20+
var btnControl = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Controls.ButtonControl");
2121
m_btnIsPressedProp = btnControl.GetProperty("isPressed");
2222
m_btnWasPressedProp = btnControl.GetProperty("wasPressedThisFrame");
2323

2424
m_mouseCurrentProp = TMouse.GetProperty("current");
2525
m_leftButtonProp = TMouse.GetProperty("leftButton");
2626
m_rightButtonProp = TMouse.GetProperty("rightButton");
2727

28-
m_positionProp = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Pointer")
28+
m_positionProp = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Pointer")
2929
.GetProperty("position");
3030

31-
m_readVector2InputMethod = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.InputControl`1")
31+
m_readVector2InputMethod = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputControl`1")
3232
.MakeGenericType(typeof(Vector2))
3333
.GetMethod("ReadValue");
3434
}
3535

36-
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
36+
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
3737
private static Type m_tKeyboard;
3838

39-
public static Type TMouse => m_tMouse ?? (m_tMouse = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Mouse"));
39+
public static Type TMouse => m_tMouse ?? (m_tMouse = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Mouse"));
4040
private static Type m_tMouse;
4141

42-
public static Type TKey => m_tKey ?? (m_tKey = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Key"));
42+
public static Type TKey => m_tKey ?? (m_tKey = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Key"));
4343
private static Type m_tKey;
4444

4545
private static PropertyInfo m_btnIsPressedProp;

src/Input/LegacyInput.cs renamed to src/Core/Input/LegacyInput.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
22
using System.Reflection;
3-
using UnityExplorer.Helpers;
3+
using UnityExplorer.Core.Unity;
44
using UnityEngine;
55
using UnityEngine.EventSystems;
66
using UnityExplorer.UI;
77

8-
namespace UnityExplorer.Input
8+
namespace UnityExplorer.Core.Input
99
{
1010
public class LegacyInput : IHandleInput
1111
{
@@ -20,7 +20,7 @@ public LegacyInput()
2020
m_getMouseButtonDownMethod = TInput.GetMethod("GetMouseButtonDown", new Type[] { typeof(int) });
2121
}
2222

23-
public static Type TInput => m_tInput ?? (m_tInput = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
23+
public static Type TInput => m_tInput ?? (m_tInput = ReflectionUtility.GetTypeByName("UnityEngine.Input"));
2424
private static Type m_tInput;
2525

2626
private static PropertyInfo m_mousePositionProp;

src/Input/NoInput.cs renamed to src/Core/Input/NoInput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using UnityEngine;
22
using UnityEngine.EventSystems;
33

4-
namespace UnityExplorer.Input
4+
namespace UnityExplorer.Core.Input
55
{
66
// Just a stub for games where no Input module was able to load at all.
77

src/Core/InspectorManager.cs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using UnityExplorer.Core.Unity;
5+
using UnityExplorer.UI;
6+
using UnityExplorer.UI.Main;
7+
using UnityEngine;
8+
using UnityEngine.SceneManagement;
9+
using UnityEngine.UI;
10+
using UnityExplorer.Core.Inspectors.Reflection;
11+
using UnityExplorer.Core.Runtime;
12+
using UnityExplorer.UI.Main.Home;
13+
14+
namespace UnityExplorer.Core.Inspectors
15+
{
16+
public class InspectorManager
17+
{
18+
public static InspectorManager Instance { get; private set; }
19+
20+
internal static InspectorManagerUI UI;
21+
22+
public InspectorManager()
23+
{
24+
Instance = this;
25+
26+
UI = new InspectorManagerUI();
27+
UI.ConstructInspectorPane();
28+
}
29+
30+
public InspectorBase m_activeInspector;
31+
public readonly List<InspectorBase> m_currentInspectors = new List<InspectorBase>();
32+
33+
public void Update()
34+
{
35+
for (int i = 0; i < m_currentInspectors.Count; i++)
36+
{
37+
if (i >= m_currentInspectors.Count)
38+
break;
39+
40+
m_currentInspectors[i].Update();
41+
}
42+
}
43+
44+
public void Inspect(object obj, CacheObjectBase parentMember = null)
45+
{
46+
obj = ReflectionProvider.Instance.Cast(obj, ReflectionProvider.Instance.GetActualType(obj));
47+
48+
UnityEngine.Object unityObj = obj as UnityEngine.Object;
49+
50+
if (obj.IsNullOrDestroyed(false))
51+
{
52+
return;
53+
}
54+
55+
// check if currently inspecting this object
56+
foreach (InspectorBase tab in m_currentInspectors)
57+
{
58+
if (ReferenceEquals(obj, tab.Target))
59+
{
60+
SetInspectorTab(tab);
61+
return;
62+
}
63+
#if CPP
64+
else if (unityObj && tab.Target is UnityEngine.Object uTabObj)
65+
{
66+
if (unityObj.m_CachedPtr == uTabObj.m_CachedPtr)
67+
{
68+
SetInspectorTab(tab);
69+
return;
70+
}
71+
}
72+
#endif
73+
}
74+
75+
InspectorBase inspector;
76+
if (obj is GameObject go)
77+
inspector = new GameObjectInspector(go);
78+
else
79+
inspector = new InstanceInspector(obj);
80+
81+
if (inspector is ReflectionInspector ri)
82+
ri.ParentMember = parentMember;
83+
84+
m_currentInspectors.Add(inspector);
85+
SetInspectorTab(inspector);
86+
}
87+
88+
public void Inspect(Type type)
89+
{
90+
if (type == null)
91+
{
92+
ExplorerCore.LogWarning("The provided type was null!");
93+
return;
94+
}
95+
96+
foreach (var tab in m_currentInspectors.Where(x => x is StaticInspector))
97+
{
98+
if (ReferenceEquals(tab.Target as Type, type))
99+
{
100+
SetInspectorTab(tab);
101+
return;
102+
}
103+
}
104+
105+
var inspector = new StaticInspector(type);
106+
107+
m_currentInspectors.Add(inspector);
108+
SetInspectorTab(inspector);
109+
}
110+
111+
public void SetInspectorTab(InspectorBase inspector)
112+
{
113+
MainMenu.Instance.SetPage(HomePage.Instance);
114+
115+
if (m_activeInspector == inspector)
116+
return;
117+
118+
UnsetInspectorTab();
119+
120+
m_activeInspector = inspector;
121+
inspector.SetActive();
122+
123+
UI.OnSetInspectorTab(inspector);
124+
}
125+
126+
public void UnsetInspectorTab()
127+
{
128+
if (m_activeInspector == null)
129+
return;
130+
131+
m_activeInspector.SetInactive();
132+
133+
UI.OnUnsetInspectorTab();
134+
135+
m_activeInspector = null;
136+
}
137+
}
138+
}

0 commit comments

Comments
 (0)