diff --git a/src/CachedObjects/Object/CacheDictionary.cs b/src/CachedObjects/Object/CacheDictionary.cs index cb40877..a84ce68 100644 --- a/src/CachedObjects/Object/CacheDictionary.cs +++ b/src/CachedObjects/Object/CacheDictionary.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Threading; using UnityEngine; #if CPP using UnhollowerBaseLib; @@ -15,8 +16,8 @@ namespace Explorer public PageHelper Pages = new PageHelper(); - private CacheObjectBase[] m_cachedKeys; - private CacheObjectBase[] m_cachedValues; + private CacheObjectBase[] m_cachedKeys = new CacheObjectBase[0]; + private CacheObjectBase[] m_cachedValues = new CacheObjectBase[0]; public Type TypeOfKeys { @@ -119,6 +120,11 @@ namespace Explorer base.UpdateValue(); + CacheEntries(); + } + + public void CacheEntries() + { // reset IDict = null; @@ -190,8 +196,6 @@ namespace Explorer var whitespace = CalcWhitespace(window); - int count = m_cachedKeys.Length; - if (!IsExpanded) { if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) @@ -209,6 +213,8 @@ namespace Explorer var negativeWhitespace = window.width - (whitespace + 100f); + int count = m_cachedKeys.Length; + GUI.skin.button.alignment = TextAnchor.MiddleLeft; string btnLabel = $"[{count}] Dictionary<{TypeOfKeys.FullName}, {TypeOfValues.FullName}>"; if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) })) @@ -260,21 +266,27 @@ namespace Explorer //GUIUnstrip.Space(whitespace); - if (key == null || val == null) + if (key == null && val == null) { GUILayout.Label($"[{i}] (null)", new GUILayoutOption[0]); } else { GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) }); + GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(40) }); GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) }); - key.DrawValue(window, (window.width / 2) - 80f); + if (key != null) + key.DrawValue(window, (window.width / 2) - 80f); + else + GUILayout.Label("null", new GUILayoutOption[0]); GUILayout.Label("Value:", new GUILayoutOption[] { GUILayout.Width(40) }); - val.DrawValue(window, (window.width / 2) - 80f); + if (Value != null) + val.DrawValue(window, (window.width / 2) - 80f); + else + GUILayout.Label("null", new GUILayoutOption[0]); } } diff --git a/src/CachedObjects/Object/CacheList.cs b/src/CachedObjects/Object/CacheList.cs index b3fcf73..be4e11c 100644 --- a/src/CachedObjects/Object/CacheList.cs +++ b/src/CachedObjects/Object/CacheList.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Threading; using System.Reflection; using UnityEngine; @@ -13,7 +14,7 @@ namespace Explorer public PageHelper Pages = new PageHelper(); - private CacheObjectBase[] m_cachedEntries; + private CacheObjectBase[] m_cachedEntries = new CacheObjectBase[0]; // Type of Entries in the Array public Type EntryType @@ -218,6 +219,11 @@ namespace Explorer return; } + CacheEntries(); + } + + public void CacheEntries() + { var enumerator = Enumerable.GetEnumerator(); if (enumerator == null) { @@ -276,8 +282,6 @@ namespace Explorer var whitespace = CalcWhitespace(window); - int count = m_cachedEntries.Length; - if (!IsExpanded) { if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) @@ -295,6 +299,8 @@ namespace Explorer var negativeWhitespace = window.width - (whitespace + 100f); + int count = m_cachedEntries.Length; + GUI.skin.button.alignment = TextAnchor.MiddleLeft; string btnLabel = $"[{count}] {EntryType.FullName}"; if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) })) diff --git a/src/CachedObjects/Struct/CacheEnum.cs b/src/CachedObjects/Struct/CacheEnum.cs index 5de045c..184c733 100644 --- a/src/CachedObjects/Struct/CacheEnum.cs +++ b/src/CachedObjects/Struct/CacheEnum.cs @@ -9,6 +9,8 @@ namespace Explorer { public class CacheEnum : CacheObjectBase { + internal static Dictionary EnumNamesInternalCache = new Dictionary(); + // public Type EnumType; public string[] EnumNames = new string[0]; @@ -21,18 +23,7 @@ namespace Explorer if (ValueType != null) { - // using GetValues not GetNames, to catch instances of weird enums (eg CameraClearFlags) - var values = Enum.GetValues(ValueType); - - var list = new List(); - foreach (var value in values) - { - var v = value.ToString(); - if (list.Contains(v)) continue; - list.Add(v); - } - - EnumNames = list.ToArray(); + GetNames(); } else { @@ -40,6 +31,27 @@ namespace Explorer } } + internal void GetNames() + { + if (!EnumNamesInternalCache.ContainsKey(ValueType)) + { + // using GetValues not GetNames, to catch instances of weird enums (eg CameraClearFlags) + var values = Enum.GetValues(ValueType); + + var set = new HashSet(); + foreach (var value in values) + { + var v = value.ToString(); + if (set.Contains(v)) continue; + set.Add(v); + } + + EnumNamesInternalCache.Add(ValueType, set.ToArray()); + } + + EnumNames = EnumNamesInternalCache[ValueType]; + } + public override void DrawValue(Rect window, float width) { if (CanWrite) diff --git a/src/Explorer.csproj b/src/Explorer.csproj index 6a6bd33..afbc34f 100644 --- a/src/Explorer.csproj +++ b/src/Explorer.csproj @@ -28,11 +28,11 @@ D:\Steam\steamapps\common\Hellpoint - D:\Steam\steamapps\common\Outward_Mono + D:\Steam\steamapps\common\Outward - D:\Steam\steamapps\common\Outward + D:\Steam\steamapps\common\Outward_Il2Cpp - D:\Steam\steamapps\common\Outward_Mono + D:\Steam\steamapps\common\Outward diff --git a/src/Menu/ResizeDrag.cs b/src/Menu/ResizeDrag.cs index 25cac76..5843b50 100644 --- a/src/Menu/ResizeDrag.cs +++ b/src/Menu/ResizeDrag.cs @@ -32,7 +32,7 @@ namespace Explorer #if ML GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) }); #else - GUILayout.Button(gcDrag.ToString(), new GUILayoutOption[] { GUILayout.Height(15) }); + GUILayout.Button("<-- Drag to resize -->", new GUILayoutOption[] { GUILayout.Height(15) }); #endif //var r = GUILayoutUtility.GetLastRect(); diff --git a/src/Menu/Windows/ReflectionWindow.cs b/src/Menu/Windows/ReflectionWindow.cs index 4d47fbc..8e45db9 100644 --- a/src/Menu/Windows/ReflectionWindow.cs +++ b/src/Menu/Windows/ReflectionWindow.cs @@ -202,7 +202,7 @@ namespace Explorer continue; } - // ExplorerCore.Log($"Trying to cache member {signature}..."); + //ExplorerCore.Log($"Trying to cache member {sig}..."); try {