Cleanup, extend ParseUtility to dict keys

This commit is contained in:
Sinai 2021-05-09 02:22:03 +10:00
parent c04a864b74
commit 7b700cbe55
19 changed files with 44 additions and 36 deletions

View File

@ -92,7 +92,7 @@ namespace UnityExplorer
public static string ReflectionExToString(this Exception e, bool innerMost = true)
{
if (innerMost)
e.GetInnerMostException();
e = e.GetInnerMostException();
return $"{e.GetType()}: {e.Message}";
}

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnityExplorer
{

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnityExplorer
{

View File

@ -4,7 +4,6 @@ using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace UnityExplorer
@ -264,7 +263,7 @@ namespace UnityExplorer
if (!(obj is Quaternion quaternion))
return null;
Vector3 vector = Quaternion.ToEulerAngles(quaternion);
Vector3 vector = quaternion.eulerAngles;
return string.Format(en_US, "{0}, {1}, {2}", new object[]
{

View File

@ -7,7 +7,7 @@ using System.Text;
using UnityEngine;
using UnityExplorer.Core.Runtime;
namespace UnityExplorer.UI.Utility
namespace UnityExplorer
{
/// <summary>
/// Syntax-highlights a member's signature, by either the Type name or a Type and Member together.

View File

@ -8,7 +8,7 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityExplorer.Core.Runtime;
namespace UnityExplorer.UI.Utility
namespace UnityExplorer
{
public static class ToStringUtility
{

View File

@ -41,10 +41,10 @@ namespace UnityExplorer.UI.CacheObject
this.DisplayedKey = key.TryCast();
var type = DisplayedKey.GetType();
if (type == typeof(string) || (type.IsPrimitive && !(type == typeof(bool))))
if (ParseUtility.CanParse(type))
{
KeyInputWanted = true;
KeyInputText = DisplayedKey.ToString();
KeyInputText = ParseUtility.ToStringForInput(DisplayedKey, type);
KeyInputTypeText = SignatureHighlighter.Parse(type, false);
}
else

View File

@ -98,7 +98,13 @@ namespace UnityExplorer.UI.CacheObject
TrySetUserValue(value);
if (CellView != null)
SetDataToCell(CellView);
// If the owner's parent CacheObject is set, we are setting the value of an inspected struct.
// Set the inspector target as the value back to that parent cacheobject.
if (Owner.ParentCacheObject != null)
Owner.ParentCacheObject.SetUserValue(Owner.Target);
}
public abstract void TrySetUserValue(object value);
@ -114,7 +120,12 @@ namespace UnityExplorer.UI.CacheObject
ProcessOnEvaluate();
if (this.IValue != null)
{
if (SubContentShowWanted)
this.IValue.SetValue(Value);
else
IValue.PendingValueWanted = true;
}
}
protected virtual void ProcessOnEvaluate()
@ -348,8 +359,6 @@ namespace UnityExplorer.UI.CacheObject
// CacheObjectCell Apply
// todo make this a reusable utility method
public virtual void OnCellApplyClicked()
{
if (State == ValueState.Boolean)
@ -399,6 +408,14 @@ namespace UnityExplorer.UI.CacheObject
{
SubContentShowWanted = !SubContentShowWanted;
CellView.SubContentHolder.SetActive(SubContentShowWanted);
if (SubContentShowWanted && IValue.PendingValueWanted)
{
IValue.PendingValueWanted = false;
this.ProcessOnEvaluate();
this.SetDataToCell(this.CellView);
IValue.SetValue(this.Value);
}
}
CellView.RefreshSubcontentButton();

View File

@ -61,7 +61,7 @@ namespace UnityExplorer.UI.CacheObject.Views
KeyInspectButton = UIFactory.CreateButton(keyGroup, "KeyInspectButton", "Inspect", new Color(0.15f, 0.15f, 0.15f));
UIFactory.SetLayoutElement(KeyInspectButton.Button.gameObject, minWidth: 60, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
InspectButton.OnClick += KeyInspectClicked;
KeyInspectButton.OnClick += KeyInspectClicked;
// label

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.CacheObject;

View File

@ -167,6 +167,7 @@ namespace UnityExplorer.UI.IValues
var entry = cachedEntries[keyIndex];
entry.SetValueFromSource(value);
if (entry.CellView != null)
entry.SetDataToCell(entry.CellView);
}
catch (Exception ex)

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.CacheObject;
@ -84,7 +83,7 @@ namespace UnityExplorer.UI.IValues
values.Add(ValueAtIdx(i).Name);
}
CurrentOwner.SetUserValue(Enum.Parse(EnumType, string.Join(", ", values)));
CurrentOwner.SetUserValue(Enum.Parse(EnumType, string.Join(", ", values.ToArray())));
}
catch (Exception ex)
{

View File

@ -149,6 +149,8 @@ namespace UnityExplorer.UI.IValues
var entry = cachedEntries[index];
entry.SetValueFromSource(value);
if (entry.CellView != null)
entry.SetDataToCell(entry.CellView);
}
catch (Exception ex)

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Core.Config;

View File

@ -39,6 +39,8 @@ namespace UnityExplorer.UI.IValues
public CacheObjectBase CurrentOwner => m_owner;
private CacheObjectBase m_owner;
public bool PendingValueWanted;
public virtual void OnBorrowed(CacheObjectBase owner)
{
if (this.m_owner != null)

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.CacheObject;

View File

@ -77,8 +77,12 @@ namespace UnityExplorer.UI.Inspectors
Inspectors.Add(inspector);
inspector.Target = target;
if (sourceCache != null && inspector is ReflectionInspector ri)
if (sourceCache != null && sourceCache.CanWrite)
{
// only set parent cache object if we are inspecting a struct, otherwise there is no point.
if (target.GetType().IsValueType && inspector is ReflectionInspector ri)
ri.ParentCacheObject = sourceCache;
}
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
inspector.UIRoot.transform.SetParent(InspectorPanel.Instance.ContentHolder.transform, false);

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.Models;

View File

@ -306,20 +306,10 @@
<Compile Include="UI\UIFactory.cs" />
<Compile Include="UI\UIManager.cs" />
<Compile Include="UI\Panels\PanelDragger.cs" />
<Compile Include="UI\Utility\SignatureHighlighter.cs" />
<Compile Include="UI\Utility\ToStringUtility.cs" />
<Compile Include="Core\Utility\SignatureHighlighter.cs" />
<Compile Include="Core\Utility\ToStringUtility.cs" />
<Compile Include="UI\Widgets\AutoComplete\AutoCompleter.cs" />
<Compile Include="UI\Widgets\AutoComplete\TypeCompleter.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveBool.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveColor.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveDictionary.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveEnum.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveEnumerable.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveFlags.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveFloatStruct.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveNumber.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveString.cs" />
<Compile Include="UI\IValues\OLD_IVALUES\InteractiveValue.cs" />
<Compile Include="UI\Models\ButtonRef.cs" />
<Compile Include="UI\ObjectExplorer\ObjectSearch.cs" />
<Compile Include="UI\ObjectExplorer\SceneExplorer.cs" />