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

Commit 48ed78e

Browse files
committed
A few small fixes
1 parent 3c964cf commit 48ed78e

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

src/CacheObject/CacheMember.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public void DrawArgsInput()
128128
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
129129

130130
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
131-
GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) });
132-
this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) });
131+
GUILayout.Label(label, new GUILayoutOption[] { GUIHelper.ExpandWidth(false) });
132+
this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) });
133133

134134
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
135135

src/UI/InteractiveValue/InteractiveValue.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ public string GetButtonLabel()
224224
{
225225
label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString();
226226

227+
if (label.Length > 100)
228+
{
229+
label = label.Substring(0, 99);
230+
}
231+
227232
var classColor = valueType.IsAbstract && valueType.IsSealed
228233
? Syntax.Class_Static
229234
: Syntax.Class_Instance;

src/UI/InteractiveValue/Struct/InteractivePrimitive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public override void DrawValue(Rect window, float width)
104104

105105
GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) });
106106

107-
m_valueToString = GUIHelper.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.ExpandWidth(true) });
107+
m_valueToString = GUIHelper.TextArea(m_valueToString, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) });
108108

109109
DrawApplyButton();
110110

src/UI/Shared/PageHelper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using UnityEngine;
1+
using System;
2+
using UnityEngine;
23

34
namespace Explorer.UI.Shared
45
{
@@ -38,7 +39,7 @@ public int ItemCount
3839

3940
private int CalculateMaxOffset()
4041
{
41-
return MaxPageOffset = (int)Mathf.Ceil((float)(ItemCount / (decimal)ItemsPerPage)) - 1;
42+
return MaxPageOffset = (int)Math.Ceiling((float)(ItemCount / (decimal)ItemsPerPage)) - 1;
4243
}
4344

4445
public void CurrentPageLabel()

src/Unstrip/IMGUI/GUIHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ namespace Explorer
1313

1414
public class GUIHelper
1515
{
16+
internal static GUILayoutOption ExpandWidth(bool expand)
17+
{
18+
#if CPP
19+
return GUIUnstrip.ExpandWidth(expand);
20+
#else
21+
return GUIHelper.ExpandWidth(expand);
22+
#endif
23+
}
1624

1725
internal static GUILayoutOption ExpandHeight(bool expand)
1826
{

src/Unstrip/IMGUI/GUIUnstrip.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
namespace Explorer.Unstrip.IMGUI
1010
{
11-
// Also contains some stuff from GUI.
12-
// This class was meant to be temporary but who knows.
13-
1411
public class GUIUnstrip
1512
{
1613
#region Properties
@@ -93,12 +90,41 @@ public static GUILayoutOption ExpandHeight(bool expand)
9390

9491
public static void BeginLayoutDirection(bool vertical, GUIContent content, GUIStyle style, GUILayoutOption[] options)
9592
{
96-
var g = GUILayoutUtility.BeginLayoutGroup(style, options, Il2CppType.Of<GUILayoutGroup>());
93+
var g = BeginLayoutGroup(style, options, Il2CppType.Of<GUILayoutGroup>());
9794
g.isVertical = vertical;
9895
if (style != GUIStyle.none || content != GUIContent.none)
9996
GUI.Box(g.rect, content, style);
10097
}
10198

99+
public static GUILayoutGroup BeginLayoutGroup(GUIStyle style, GUILayoutOption[] options, Il2CppSystem.Type layoutType)
100+
{
101+
EventType type = Event.current.type;
102+
GUILayoutGroup guilayoutGroup;
103+
if (type != EventType.Used && type != EventType.Layout)
104+
{
105+
guilayoutGroup = GUILayoutUtility.current.topLevel.GetNext().TryCast<GUILayoutGroup>();
106+
107+
if (guilayoutGroup == null)
108+
{
109+
throw new ArgumentException("GUILayout: Mismatched LayoutGroup." + Event.current.type);
110+
}
111+
guilayoutGroup.ResetCursor();
112+
}
113+
else
114+
{
115+
guilayoutGroup = GUILayoutUtility.CreateGUILayoutGroupInstanceOfType(layoutType);
116+
guilayoutGroup.style = style;
117+
if (options != null)
118+
{
119+
guilayoutGroup.ApplyOptions(options);
120+
}
121+
GUILayoutUtility.current.topLevel.entries.Add(guilayoutGroup);
122+
}
123+
GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup);
124+
GUILayoutUtility.current.topLevel = guilayoutGroup;
125+
return guilayoutGroup;
126+
}
127+
102128
public static string TextField(string text, GUILayoutOption[] options, bool multiLine)
103129
{
104130
text = text ?? string.Empty;
@@ -347,7 +373,7 @@ internal static GUILayoutGroup BeginLayoutArea(GUIStyle style, Type layoutType)
347373
{
348374
guilayoutGroup = (GUILayoutGroup)Activator.CreateInstance(layoutType);
349375
guilayoutGroup.style = style;
350-
GUILayoutUtility.current.windows.Add(guilayoutGroup);
376+
GUILayoutUtility.current.windows.entries.Add(guilayoutGroup);
351377
}
352378
GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup);
353379
GUILayoutUtility.current.topLevel = guilayoutGroup;

0 commit comments

Comments
 (0)