diff --git a/src/CachedObjects/CacheObjectBase.cs b/src/CachedObjects/CacheObjectBase.cs
index 19a051e..a95a6f2 100644
--- a/src/CachedObjects/CacheObjectBase.cs
+++ b/src/CachedObjects/CacheObjectBase.cs
@@ -400,10 +400,11 @@ namespace Explorer
var input = m_argumentInput[i];
var type = m_arguments[i].ParameterType.Name;
- var label = "" + type + " " + name + "";
+ var label = $"{type} ";
+ label += $"{name}";
if (m_arguments[i].HasDefaultValue)
{
- label = $"[{label} = {m_arguments[i].DefaultValue}]";
+ label = $"[{label} = {m_arguments[i].DefaultValue ?? "null"}]";
}
GUILayout.BeginHorizontal(null);
@@ -469,7 +470,7 @@ namespace Explorer
}
else if ((HasParameters || this is CacheMethod) && !m_evaluated)
{
- GUILayout.Label($"Not yet evaluated ({ValueTypeName})", null);
+ GUILayout.Label($"Not yet evaluated ({ValueTypeName})", null);
}
else if (Value == null && !(this is CacheMethod))
{
@@ -484,31 +485,62 @@ namespace Explorer
private string GetRichTextName()
{
string memberColor = "";
- switch (MemInfo.MemberType)
- {
- case MemberTypes.Field:
- memberColor = "#c266ff"; break;
- case MemberTypes.Property:
- memberColor = "#72a6a6"; break;
- case MemberTypes.Method:
- memberColor = "#ff8000"; break;
- };
+ bool isStatic = false;
- m_richTextName = $"{MemInfo.DeclaringType.Name}.{MemInfo.Name}";
-
- if (m_arguments.Length > 0 || this is CacheMethod)
+ if (MemInfo is FieldInfo fi)
{
- m_richTextName += "(";
- var _params = "";
- foreach (var param in m_arguments)
+ if (fi.IsStatic)
{
- if (_params != "") _params += ", ";
-
- _params += $"{param.ParameterType.Name} {param.Name}";
+ isStatic = true;
+ memberColor = UIStyles.Syntax.Field_Static;
}
- m_richTextName += _params;
- m_richTextName += ")";
+ else
+ memberColor = UIStyles.Syntax.Field_Instance;
}
+ else if (MemInfo is MethodInfo mi)
+ {
+ if (mi.IsStatic)
+ {
+ isStatic = true;
+ memberColor = UIStyles.Syntax.Method_Static;
+ }
+ else
+ memberColor = UIStyles.Syntax.Method_Instance;
+ }
+ else if (MemInfo is PropertyInfo pi)
+ {
+ if (pi.GetAccessors()[0].IsStatic)
+ {
+ isStatic = true;
+ memberColor = UIStyles.Syntax.Prop_Static;
+ }
+ else
+ memberColor = UIStyles.Syntax.Prop_Instance;
+ }
+
+ string classColor = MemInfo.DeclaringType.IsAbstract && MemInfo.DeclaringType.IsSealed
+ ? UIStyles.Syntax.Class_Static
+ : UIStyles.Syntax.Class_Instance;
+
+ m_richTextName = $"{MemInfo.DeclaringType.Name}.";
+ if (isStatic) m_richTextName += "";
+ m_richTextName += $"{MemInfo.Name}";
+ if (isStatic) m_richTextName += "";
+
+ //if (m_arguments.Length > 0 || this is CacheMethod)
+ //{
+ // m_richTextName += "(";
+ // var args = "";
+ // foreach (var param in m_arguments)
+ // {
+ // if (args != "") args += ", ";
+
+ // args += $"{param.ParameterType.Name} ";
+ // args += $"{param.Name}";
+ // }
+ // m_richTextName += args;
+ // m_richTextName += ")";
+ //}
return m_richTextName;
}
diff --git a/src/CachedObjects/Other/CacheMethod.cs b/src/CachedObjects/Other/CacheMethod.cs
index 6ce890e..03f3bcf 100644
--- a/src/CachedObjects/Other/CacheMethod.cs
+++ b/src/CachedObjects/Other/CacheMethod.cs
@@ -70,6 +70,8 @@ namespace Explorer
public override void DrawValue(Rect window, float width)
{
+ string typeLabel = $"{ValueTypeName}";
+
if (m_evaluated)
{
if (m_cachedReturnValue != null)
@@ -78,12 +80,12 @@ namespace Explorer
}
else
{
- GUILayout.Label($"null ({ValueTypeName})", null);
+ GUILayout.Label($"null ({typeLabel})", null);
}
}
else
{
- GUILayout.Label($"Not yet evaluated ({ValueTypeName})", null);
+ GUILayout.Label($"Not yet evaluated ({typeLabel})", null);
}
}
}
diff --git a/src/CachedObjects/Other/CacheOther.cs b/src/CachedObjects/Other/CacheOther.cs
index 97ce07b..55cc58d 100644
--- a/src/CachedObjects/Other/CacheOther.cs
+++ b/src/CachedObjects/Other/CacheOther.cs
@@ -11,55 +11,72 @@ namespace Explorer
{
public class CacheOther : CacheObjectBase
{
+ public string ButtonLabel => m_btnLabel ?? GetButtonLabel();
+ private string m_btnLabel;
+
+ public MethodInfo ToStringMethod => m_toStringMethod ?? GetToStringMethod();
private MethodInfo m_toStringMethod;
- public MethodInfo ToStringMethod
- {
- get
- {
- if (m_toStringMethod == null)
- {
- try
- {
- m_toStringMethod = ReflectionHelpers.GetActualType(Value).GetMethod("ToString", new Type[0])
- ?? typeof(object).GetMethod("ToString", new Type[0]);
-
- // test invoke
- m_toStringMethod.Invoke(Value, null);
- }
- catch
- {
- m_toStringMethod = typeof(object).GetMethod("ToString", new Type[0]);
- }
- }
- return m_toStringMethod;
- }
- }
-
public override void DrawValue(Rect window, float width)
{
- string label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString();
-
- if (!label.Contains(ValueTypeName))
- {
- label += $" ({ValueTypeName})";
- }
- else
- {
- label = label.Replace(ValueTypeName, $"{ValueTypeName}");
- }
-
- if (Value is UnityEngine.Object unityObj && !label.Contains(unityObj.name))
- {
- label = unityObj.name + " | " + label;
- }
-
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
- if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Width(width - 15) }))
+ if (GUILayout.Button(ButtonLabel, new GUILayoutOption[] { GUILayout.Width(width - 15) }))
{
WindowManager.InspectObject(Value, out bool _);
}
GUI.skin.button.alignment = TextAnchor.MiddleCenter;
}
+
+ private MethodInfo GetToStringMethod()
+ {
+ try
+ {
+ m_toStringMethod = ReflectionHelpers.GetActualType(Value).GetMethod("ToString", new Type[0])
+ ?? typeof(object).GetMethod("ToString", new Type[0]);
+
+ // test invoke
+ m_toStringMethod.Invoke(Value, null);
+ }
+ catch
+ {
+ m_toStringMethod = typeof(object).GetMethod("ToString", new Type[0]);
+ }
+ return m_toStringMethod;
+ }
+
+ private string GetButtonLabel()
+ {
+ string label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString();
+
+ var classColor = ValueType.IsAbstract && ValueType.IsSealed
+ ? UIStyles.Syntax.Class_Static
+ : UIStyles.Syntax.Class_Instance;
+
+ if (Value is UnityEngine.Object)
+ {
+ int typeStart = label.LastIndexOf("("); // get where the '(Type)' starts
+ var newLabel = label.Substring(0, typeStart + 1); // get just the name and first '('
+ newLabel += $""; // add color tag
+ newLabel += label.Substring(typeStart + 1); // add the TypeName back in
+ newLabel = newLabel.Substring(0, newLabel.Length - 1); // remove the ending ')'
+ newLabel += ")"; // close color tag and put the ')' back.
+ label = newLabel;
+ }
+ else
+ {
+ string classLabel = $"{ValueTypeName}";
+
+ if (!label.Contains(ValueTypeName))
+ {
+ label += $" ({classLabel})";
+ }
+ else
+ {
+ label = label.Replace(ValueTypeName, $"{ValueTypeName}");
+ }
+ }
+
+ return m_btnLabel = label;
+ }
}
}
diff --git a/src/CppExplorer.cs b/src/CppExplorer.cs
index 531b887..c70ec95 100644
--- a/src/CppExplorer.cs
+++ b/src/CppExplorer.cs
@@ -13,7 +13,7 @@ namespace Explorer
public class CppExplorer : MelonMod
{
public const string NAME = "CppExplorer";
- public const string VERSION = "1.7.31";
+ public const string VERSION = "1.7.4";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.cppexplorer";
diff --git a/src/Menu/MainMenu/Pages/ConsolePage.cs b/src/Menu/MainMenu/Pages/ConsolePage.cs
index d07b4d8..4a5dd14 100644
--- a/src/Menu/MainMenu/Pages/ConsolePage.cs
+++ b/src/Menu/MainMenu/Pages/ConsolePage.cs
@@ -43,7 +43,7 @@ namespace Explorer
try
{
- MethodInput = @"// This is a basic C# REPL console.
+ MethodInput = @"// This is a basic C# console.
// Some common using directives are added by default, you can add more below.
// If you want to return some output, MelonLogger.Log() it.
@@ -123,7 +123,7 @@ MelonLogger.Log(""hello world"");";
public override void DrawWindow()
{
- GUILayout.Label("C# REPL Console", null);
+ GUILayout.Label("C# Console", null);
GUI.skin.label.alignment = TextAnchor.UpperLeft;
diff --git a/src/Menu/UIStyles.cs b/src/Menu/UIStyles.cs
index 4af7df4..d2fc84e 100644
--- a/src/Menu/UIStyles.cs
+++ b/src/Menu/UIStyles.cs
@@ -11,6 +11,23 @@ namespace Explorer
{
public class UIStyles
{
+ public class Syntax
+ {
+ public const string Field_Static = "#8d8dc6";
+ public const string Field_Instance = "#c266ff";
+
+ public const string Method_Static = "#b55b02";
+ public const string Method_Instance = "#ff8000";
+
+ public const string Prop_Static = "#588075";
+ public const string Prop_Instance = "#55a38e";
+
+ public const string Class_Static = "#3a8d71";
+ public const string Class_Instance = "#2df7b2";
+
+ public const string Local = "#a6e9e9";
+ }
+
public static Color LightGreen = new Color(Color.green.r - 0.3f, Color.green.g - 0.3f, Color.green.b - 0.3f);
public static GUISkin WindowSkin
diff --git a/src/Menu/Windows/GameObjectWindow.cs b/src/Menu/Windows/GameObjectWindow.cs
index 76dc372..26b4023 100644
--- a/src/Menu/Windows/GameObjectWindow.cs
+++ b/src/Menu/Windows/GameObjectWindow.cs
@@ -363,7 +363,8 @@ namespace Explorer
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null);
- m_addComponentInput = GUILayout.TextField(m_addComponentInput, new GUILayoutOption[] { GUILayout.Width(130) });
+ var width = m_rect.width / 2 - 115f;
+ m_addComponentInput = GUILayout.TextField(m_addComponentInput, new GUILayoutOption[] { GUILayout.Width(width) });
if (GUILayout.Button("Add Comp", null))
{
if (ReflectionHelpers.GetTypeByName(m_addComponentInput) is Type compType)
diff --git a/src/Tests/TestClass.cs b/src/Tests/TestClass.cs
index 272ef3b..f6e59e2 100644
--- a/src/Tests/TestClass.cs
+++ b/src/Tests/TestClass.cs
@@ -22,6 +22,10 @@ namespace Explorer.Tests
ILHashSetTest.Add("3");
}
+ public static int StaticProperty => 5;
+ public static int StaticField = 5;
+ public int NonStaticField;
+
// test a non-generic dictionary
public Hashtable TestNonGenericDict()