diff --git a/src/CacheObject/CacheMember.cs b/src/CacheObject/CacheMember.cs index e2cbeed..e896ac7 100644 --- a/src/CacheObject/CacheMember.cs +++ b/src/CacheObject/CacheMember.cs @@ -128,8 +128,8 @@ namespace Explorer.CacheObject GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) }); - GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); - this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); + GUILayout.Label(label, new GUILayoutOption[] { GUIHelper.ExpandWidth(false) }); + this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) }); GUI.skin.label.alignment = TextAnchor.MiddleLeft; diff --git a/src/UI/InteractiveValue/InteractiveValue.cs b/src/UI/InteractiveValue/InteractiveValue.cs index ec358dd..a921baf 100644 --- a/src/UI/InteractiveValue/InteractiveValue.cs +++ b/src/UI/InteractiveValue/InteractiveValue.cs @@ -224,6 +224,11 @@ namespace Explorer.UI { label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString(); + if (label.Length > 100) + { + label = label.Substring(0, 99); + } + var classColor = valueType.IsAbstract && valueType.IsSealed ? Syntax.Class_Static : Syntax.Class_Instance; diff --git a/src/UI/InteractiveValue/Struct/InteractivePrimitive.cs b/src/UI/InteractiveValue/Struct/InteractivePrimitive.cs index 9503a58..78250ae 100644 --- a/src/UI/InteractiveValue/Struct/InteractivePrimitive.cs +++ b/src/UI/InteractiveValue/Struct/InteractivePrimitive.cs @@ -104,7 +104,7 @@ namespace Explorer.UI GUILayout.Label("" + ValueType.Name + "", new GUILayoutOption[] { GUILayout.Width(50) }); - m_valueToString = GUIHelper.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); + m_valueToString = GUIHelper.TextArea(m_valueToString, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) }); DrawApplyButton(); diff --git a/src/UI/Shared/PageHelper.cs b/src/UI/Shared/PageHelper.cs index e809264..a308f66 100644 --- a/src/UI/Shared/PageHelper.cs +++ b/src/UI/Shared/PageHelper.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System; +using UnityEngine; namespace Explorer.UI.Shared { @@ -38,7 +39,7 @@ namespace Explorer.UI.Shared private int CalculateMaxOffset() { - return MaxPageOffset = (int)Mathf.Ceil((float)(ItemCount / (decimal)ItemsPerPage)) - 1; + return MaxPageOffset = (int)Math.Ceiling((float)(ItemCount / (decimal)ItemsPerPage)) - 1; } public void CurrentPageLabel() diff --git a/src/Unstrip/IMGUI/GUIHelper.cs b/src/Unstrip/IMGUI/GUIHelper.cs index e5d7102..dc219ef 100644 --- a/src/Unstrip/IMGUI/GUIHelper.cs +++ b/src/Unstrip/IMGUI/GUIHelper.cs @@ -13,6 +13,14 @@ namespace Explorer public class GUIHelper { + internal static GUILayoutOption ExpandWidth(bool expand) + { +#if CPP + return GUIUnstrip.ExpandWidth(expand); +#else + return GUIHelper.ExpandWidth(expand); +#endif + } internal static GUILayoutOption ExpandHeight(bool expand) { diff --git a/src/Unstrip/IMGUI/GUIUnstrip.cs b/src/Unstrip/IMGUI/GUIUnstrip.cs index 88b98aa..bee7e06 100644 --- a/src/Unstrip/IMGUI/GUIUnstrip.cs +++ b/src/Unstrip/IMGUI/GUIUnstrip.cs @@ -8,9 +8,6 @@ using UnhollowerRuntimeLib; namespace Explorer.Unstrip.IMGUI { - // Also contains some stuff from GUI. - // This class was meant to be temporary but who knows. - public class GUIUnstrip { #region Properties @@ -93,12 +90,41 @@ namespace Explorer.Unstrip.IMGUI public static void BeginLayoutDirection(bool vertical, GUIContent content, GUIStyle style, GUILayoutOption[] options) { - var g = GUILayoutUtility.BeginLayoutGroup(style, options, Il2CppType.Of()); + var g = BeginLayoutGroup(style, options, Il2CppType.Of()); g.isVertical = vertical; if (style != GUIStyle.none || content != GUIContent.none) GUI.Box(g.rect, content, style); } + public static GUILayoutGroup BeginLayoutGroup(GUIStyle style, GUILayoutOption[] options, Il2CppSystem.Type layoutType) + { + EventType type = Event.current.type; + GUILayoutGroup guilayoutGroup; + if (type != EventType.Used && type != EventType.Layout) + { + guilayoutGroup = GUILayoutUtility.current.topLevel.GetNext().TryCast(); + + if (guilayoutGroup == null) + { + throw new ArgumentException("GUILayout: Mismatched LayoutGroup." + Event.current.type); + } + guilayoutGroup.ResetCursor(); + } + else + { + guilayoutGroup = GUILayoutUtility.CreateGUILayoutGroupInstanceOfType(layoutType); + guilayoutGroup.style = style; + if (options != null) + { + guilayoutGroup.ApplyOptions(options); + } + GUILayoutUtility.current.topLevel.entries.Add(guilayoutGroup); + } + GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup); + GUILayoutUtility.current.topLevel = guilayoutGroup; + return guilayoutGroup; + } + public static string TextField(string text, GUILayoutOption[] options, bool multiLine) { text = text ?? string.Empty; @@ -347,7 +373,7 @@ namespace Explorer.Unstrip.IMGUI { guilayoutGroup = (GUILayoutGroup)Activator.CreateInstance(layoutType); guilayoutGroup.style = style; - GUILayoutUtility.current.windows.Add(guilayoutGroup); + GUILayoutUtility.current.windows.entries.Add(guilayoutGroup); } GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup); GUILayoutUtility.current.topLevel = guilayoutGroup;