A few small fixes

This commit is contained in:
sinaioutlander 2020-10-22 21:00:33 +11:00
parent 3c964cfef9
commit 48ed78ec36
6 changed files with 50 additions and 10 deletions

View File

@ -128,8 +128,8 @@ namespace Explorer.CacheObject
GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.skin.label.alignment = TextAnchor.MiddleCenter;
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) }); GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); GUILayout.Label(label, new GUILayoutOption[] { GUIHelper.ExpandWidth(false) });
this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) });
GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUI.skin.label.alignment = TextAnchor.MiddleLeft;

View File

@ -224,6 +224,11 @@ namespace Explorer.UI
{ {
label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString(); label = (string)ToStringMethod?.Invoke(Value, null) ?? Value.ToString();
if (label.Length > 100)
{
label = label.Substring(0, 99);
}
var classColor = valueType.IsAbstract && valueType.IsSealed var classColor = valueType.IsAbstract && valueType.IsSealed
? Syntax.Class_Static ? Syntax.Class_Static
: Syntax.Class_Instance; : Syntax.Class_Instance;

View File

@ -104,7 +104,7 @@ namespace Explorer.UI
GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) }); GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", 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(); DrawApplyButton();

View File

@ -1,4 +1,5 @@
using UnityEngine; using System;
using UnityEngine;
namespace Explorer.UI.Shared namespace Explorer.UI.Shared
{ {
@ -38,7 +39,7 @@ namespace Explorer.UI.Shared
private int CalculateMaxOffset() 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() public void CurrentPageLabel()

View File

@ -13,6 +13,14 @@ namespace Explorer
public class GUIHelper 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) internal static GUILayoutOption ExpandHeight(bool expand)
{ {

View File

@ -8,9 +8,6 @@ using UnhollowerRuntimeLib;
namespace Explorer.Unstrip.IMGUI namespace Explorer.Unstrip.IMGUI
{ {
// Also contains some stuff from GUI.
// This class was meant to be temporary but who knows.
public class GUIUnstrip public class GUIUnstrip
{ {
#region Properties #region Properties
@ -93,12 +90,41 @@ namespace Explorer.Unstrip.IMGUI
public static void BeginLayoutDirection(bool vertical, GUIContent content, GUIStyle style, GUILayoutOption[] options) public static void BeginLayoutDirection(bool vertical, GUIContent content, GUIStyle style, GUILayoutOption[] options)
{ {
var g = GUILayoutUtility.BeginLayoutGroup(style, options, Il2CppType.Of<GUILayoutGroup>()); var g = BeginLayoutGroup(style, options, Il2CppType.Of<GUILayoutGroup>());
g.isVertical = vertical; g.isVertical = vertical;
if (style != GUIStyle.none || content != GUIContent.none) if (style != GUIStyle.none || content != GUIContent.none)
GUI.Box(g.rect, content, style); 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<GUILayoutGroup>();
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) public static string TextField(string text, GUILayoutOption[] options, bool multiLine)
{ {
text = text ?? string.Empty; text = text ?? string.Empty;
@ -347,7 +373,7 @@ namespace Explorer.Unstrip.IMGUI
{ {
guilayoutGroup = (GUILayoutGroup)Activator.CreateInstance(layoutType); guilayoutGroup = (GUILayoutGroup)Activator.CreateInstance(layoutType);
guilayoutGroup.style = style; guilayoutGroup.style = style;
GUILayoutUtility.current.windows.Add(guilayoutGroup); GUILayoutUtility.current.windows.entries.Add(guilayoutGroup);
} }
GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup); GUILayoutUtility.current.layoutGroups.Push(guilayoutGroup);
GUILayoutUtility.current.topLevel = guilayoutGroup; GUILayoutUtility.current.topLevel = guilayoutGroup;