This commit is contained in:
sinaioutlander 2020-09-19 01:44:38 +10:00
parent ad5fc04a3b
commit 939861b5f0
3 changed files with 11 additions and 18 deletions

View File

@ -10,7 +10,6 @@ namespace Explorer
public abstract class CacheObjectBase public abstract class CacheObjectBase
{ {
public object Value; public object Value;
public string ValueTypeName;
public Type ValueType; public Type ValueType;
public MemberInfo MemInfo { get; set; } public MemberInfo MemInfo { get; set; }
@ -175,7 +174,6 @@ namespace Explorer
holder.Value = obj; holder.Value = obj;
holder.ValueType = valueType; holder.ValueType = valueType;
holder.ValueTypeName = valueType.FullName;
if (memberInfo != null) if (memberInfo != null)
{ {
@ -517,17 +515,19 @@ namespace Explorer
GUIUnstrip.Space(labelWidth); GUIUnstrip.Space(labelWidth);
} }
string typeName = $"<color={UIStyles.Syntax.Class_Instance}>{ValueType.FullName}</color>";
if (!string.IsNullOrEmpty(ReflectionException)) if (!string.IsNullOrEmpty(ReflectionException))
{ {
GUILayout.Label("<color=red>Reflection failed!</color> (" + ReflectionException + ")", null); GUILayout.Label("<color=red>Reflection failed!</color> (" + ReflectionException + ")", null);
} }
else if ((HasParameters || this is CacheMethod) && !m_evaluated) else if ((HasParameters || this is CacheMethod) && !m_evaluated)
{ {
GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> (<color={UIStyles.Syntax.Class_Instance}>{ValueTypeName}</color>)", null); GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> ({typeName})", null);
} }
else if (Value == null && !(this is CacheMethod)) else if (Value == null && !(this is CacheMethod))
{ {
GUILayout.Label("<i>null (<color=" + UIStyles.Syntax.Class_Instance + ">" + ValueTypeName + "</color>)</i>", null); GUILayout.Label($"<i>null ({typeName})</i>", null);
} }
else else
{ {

View File

@ -29,7 +29,6 @@ namespace Explorer
GenericArgInput = new string[GenericArgs.Length]; GenericArgInput = new string[GenericArgs.Length];
ValueType = mi.ReturnType; ValueType = mi.ReturnType;
ValueTypeName = ValueType.FullName;
} }
public override void UpdateValue() public override void UpdateValue()
@ -121,7 +120,7 @@ namespace Explorer
public override void DrawValue(Rect window, float width) public override void DrawValue(Rect window, float width)
{ {
string typeLabel = $"<color={UIStyles.Syntax.Class_Instance}>{ValueTypeName}</color>"; string typeLabel = $"<color={UIStyles.Syntax.Class_Instance}>{ValueType.FullName}</color>";
if (m_evaluated) if (m_evaluated)
{ {

View File

@ -56,27 +56,21 @@ namespace Explorer
? UIStyles.Syntax.Class_Static ? UIStyles.Syntax.Class_Static
: UIStyles.Syntax.Class_Instance; : UIStyles.Syntax.Class_Instance;
string typeLabel = $"<color={classColor}>{ValueType.FullName}</color>";
if (Value is UnityEngine.Object) if (Value is UnityEngine.Object)
{ {
int typeStart = label.LastIndexOf("("); // get where the '(Type)' starts label = label.Replace($"({ValueType.FullName})", $"({typeLabel})");
var newLabel = label.Substring(0, typeStart + 1); // get just the name and first '('
newLabel += $"<color={classColor}>"; // add color tag
newLabel += label.Substring(typeStart + 1); // add the TypeName back in
newLabel = newLabel.Substring(0, newLabel.Length - 1); // remove the ending ')'
newLabel += "</color>)"; // close color tag and put the ')' back.
label = newLabel;
} }
else else
{ {
string classLabel = $"<color={classColor}>{ValueTypeName}</color>"; if (!label.Contains(ValueType.FullName))
if (!label.Contains(ValueTypeName))
{ {
label += $" ({classLabel})"; label += $" ({typeLabel})";
} }
else else
{ {
label = label.Replace(ValueTypeName, $"<color={classColor}>{ValueTypeName}</color>"); label = label.Replace(ValueType.FullName, typeLabel);
} }
} }