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

Commit 939861b

Browse files
committed
Cleanup
1 parent ad5fc04 commit 939861b

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

src/CachedObjects/CacheObjectBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace Explorer
1010
public abstract class CacheObjectBase
1111
{
1212
public object Value;
13-
public string ValueTypeName;
1413
public Type ValueType;
1514

1615
public MemberInfo MemInfo { get; set; }
@@ -175,7 +174,6 @@ private static CacheObjectBase GetCacheObjectImpl(object obj, MemberInfo memberI
175174

176175
holder.Value = obj;
177176
holder.ValueType = valueType;
178-
holder.ValueTypeName = valueType.FullName;
179177

180178
if (memberInfo != null)
181179
{
@@ -517,17 +515,19 @@ public void Draw(Rect window, float labelWidth = 215f)
517515
GUIUnstrip.Space(labelWidth);
518516
}
519517

518+
string typeName = $"<color={UIStyles.Syntax.Class_Instance}>{ValueType.FullName}</color>";
519+
520520
if (!string.IsNullOrEmpty(ReflectionException))
521521
{
522522
GUILayout.Label("<color=red>Reflection failed!</color> (" + ReflectionException + ")", null);
523523
}
524524
else if ((HasParameters || this is CacheMethod) && !m_evaluated)
525525
{
526-
GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> (<color={UIStyles.Syntax.Class_Instance}>{ValueTypeName}</color>)", null);
526+
GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> ({typeName})", null);
527527
}
528528
else if (Value == null && !(this is CacheMethod))
529529
{
530-
GUILayout.Label("<i>null (<color=" + UIStyles.Syntax.Class_Instance + ">" + ValueTypeName + "</color>)</i>", null);
530+
GUILayout.Label($"<i>null ({typeName})</i>", null);
531531
}
532532
else
533533
{

src/CachedObjects/Other/CacheMethod.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public override void Init()
2929
GenericArgInput = new string[GenericArgs.Length];
3030

3131
ValueType = mi.ReturnType;
32-
ValueTypeName = ValueType.FullName;
3332
}
3433

3534
public override void UpdateValue()
@@ -121,7 +120,7 @@ private MethodInfo MakeGenericMethodFromInput()
121120

122121
public override void DrawValue(Rect window, float width)
123122
{
124-
string typeLabel = $"<color={UIStyles.Syntax.Class_Instance}>{ValueTypeName}</color>";
123+
string typeLabel = $"<color={UIStyles.Syntax.Class_Instance}>{ValueType.FullName}</color>";
125124

126125
if (m_evaluated)
127126
{

src/CachedObjects/Other/CacheOther.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,21 @@ private string GetButtonLabel()
5656
? UIStyles.Syntax.Class_Static
5757
: UIStyles.Syntax.Class_Instance;
5858

59+
string typeLabel = $"<color={classColor}>{ValueType.FullName}</color>";
60+
5961
if (Value is UnityEngine.Object)
6062
{
61-
int typeStart = label.LastIndexOf("("); // get where the '(Type)' starts
62-
var newLabel = label.Substring(0, typeStart + 1); // get just the name and first '('
63-
newLabel += $"<color={classColor}>"; // add color tag
64-
newLabel += label.Substring(typeStart + 1); // add the TypeName back in
65-
newLabel = newLabel.Substring(0, newLabel.Length - 1); // remove the ending ')'
66-
newLabel += "</color>)"; // close color tag and put the ')' back.
67-
label = newLabel;
63+
label = label.Replace($"({ValueType.FullName})", $"({typeLabel})");
6864
}
6965
else
7066
{
71-
string classLabel = $"<color={classColor}>{ValueTypeName}</color>";
72-
73-
if (!label.Contains(ValueTypeName))
67+
if (!label.Contains(ValueType.FullName))
7468
{
75-
label += $" ({classLabel})";
69+
label += $" ({typeLabel})";
7670
}
7771
else
7872
{
79-
label = label.Replace(ValueTypeName, $"<color={classColor}>{ValueTypeName}</color>");
73+
label = label.Replace(ValueType.FullName, typeLabel);
8074
}
8175
}
8276

0 commit comments

Comments
 (0)