diff --git a/src/CachedObjects/CacheObjectBase.cs b/src/CachedObjects/CacheObjectBase.cs index 8c148d5..909ff4c 100644 --- a/src/CachedObjects/CacheObjectBase.cs +++ b/src/CachedObjects/CacheObjectBase.cs @@ -244,7 +244,6 @@ namespace Explorer var input = m_argumentInput[i]; var type = m_arguments[i].ParameterType; - // First, try parse the input and use that. if (!string.IsNullOrEmpty(input)) { // strings can obviously just be used directly diff --git a/src/CppExplorer.cs b/src/CppExplorer.cs index a335cfc..7b6a0db 100644 --- a/src/CppExplorer.cs +++ b/src/CppExplorer.cs @@ -13,7 +13,7 @@ namespace Explorer public class CppExplorer : MelonMod { public const string NAME = "CppExplorer"; - public const string VERSION = "1.7.0"; + public const string VERSION = "1.7.1"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.cppexplorer"; @@ -36,17 +36,13 @@ namespace Explorer { Instance = this; - // First, load config ModConfig.OnLoad(); - // Setup InputHelper class (UnityEngine.Input) InputHelper.Init(); - // Create CppExplorer modules new MainMenu(); new WindowManager(); - // Init cursor control CursorControl.Init(); MelonLogger.Log($"CppExplorer {VERSION} initialized."); diff --git a/src/Helpers/ReflectionHelpers.cs b/src/Helpers/ReflectionHelpers.cs index 80bd93b..ba08773 100644 --- a/src/Helpers/ReflectionHelpers.cs +++ b/src/Helpers/ReflectionHelpers.cs @@ -101,7 +101,6 @@ namespace Explorer return typeof(ILType); } - // Get the System.Type using the qualified name, or fallback to GetType. return Type.GetType(ilObject.GetIl2CppType().AssemblyQualifiedName) ?? obj.GetType(); } diff --git a/src/Menu/MainMenu/MainMenu.cs b/src/Menu/MainMenu/MainMenu.cs index da7f7f1..f57865e 100644 --- a/src/Menu/MainMenu/MainMenu.cs +++ b/src/Menu/MainMenu/MainMenu.cs @@ -64,7 +64,7 @@ namespace Explorer return; } - GUILayout.BeginArea(new Rect(5, 25, MainRect.width - 10, MainRect.height - 35), GUI.skin.box); + GUIUnstrip.BeginArea(new Rect(5, 25, MainRect.width - 10, MainRect.height - 35), GUI.skin.box); MainHeader(); @@ -78,7 +78,7 @@ namespace Explorer MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID); - GUILayout.EndArea(); + GUIUnstrip.EndArea(); } private void MainHeader() diff --git a/src/Menu/Windows/GameObjectWindow.cs b/src/Menu/Windows/GameObjectWindow.cs index 7963b25..7347879 100644 --- a/src/Menu/Windows/GameObjectWindow.cs +++ b/src/Menu/Windows/GameObjectWindow.cs @@ -210,7 +210,7 @@ namespace Explorer if (!WindowManager.TabView) { Header(); - GUILayout.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); + GUIUnstrip.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); } scroll = GUIUnstrip.BeginScrollView(scroll); @@ -270,7 +270,7 @@ namespace Explorer { m_rect = ResizeDrag.ResizeWindow(rect, windowID); - GUILayout.EndArea(); + GUIUnstrip.EndArea(); } } catch (Exception e) diff --git a/src/Menu/Windows/ReflectionWindow.cs b/src/Menu/Windows/ReflectionWindow.cs index 810e0d5..b4ed926 100644 --- a/src/Menu/Windows/ReflectionWindow.cs +++ b/src/Menu/Windows/ReflectionWindow.cs @@ -228,7 +228,7 @@ namespace Explorer if (!WindowManager.TabView) { Header(); - GUILayout.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); + GUIUnstrip.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); } GUILayout.BeginHorizontal(null); @@ -354,7 +354,7 @@ namespace Explorer { m_rect = ResizeDrag.ResizeWindow(rect, windowID); - GUILayout.EndArea(); + GUIUnstrip.EndArea(); } } catch (Il2CppException e) diff --git a/src/Menu/Windows/TabViewWindow.cs b/src/Menu/Windows/TabViewWindow.cs index 7a4973b..3213172 100644 --- a/src/Menu/Windows/TabViewWindow.cs +++ b/src/Menu/Windows/TabViewWindow.cs @@ -65,7 +65,7 @@ namespace Explorer return; } - GUILayout.BeginArea(new Rect(5, 25, m_rect.width - 10, m_rect.height - 35), GUI.skin.box); + GUIUnstrip.BeginArea(new Rect(5, 25, m_rect.width - 10, m_rect.height - 35), GUI.skin.box); GUILayout.BeginVertical(GUI.skin.box, null); GUILayout.BeginHorizontal(null); @@ -109,7 +109,7 @@ namespace Explorer } catch { } - GUILayout.EndArea(); + GUIUnstrip.EndArea(); } catch { } } diff --git a/src/UnstripFixes/GUIUnstrip.cs b/src/UnstripFixes/GUIUnstrip.cs index cb7f930..80f5704 100644 --- a/src/UnstripFixes/GUIUnstrip.cs +++ b/src/UnstripFixes/GUIUnstrip.cs @@ -17,13 +17,15 @@ namespace Explorer { public static int s_ScrollControlId; - public static bool ScrollFailed = false; + public static bool ScrollFailed = true; public static bool ManualUnstripFailed = false; private static GenericStack ScrollStack => m_scrollStack ?? GetScrollStack(); private static PropertyInfo m_scrollViewStatesInfo; private static GenericStack m_scrollStack; + public static DateTime nextScrollStepTime; + private static GenericStack GetScrollStack() { if (m_scrollViewStatesInfo == null) @@ -55,7 +57,6 @@ namespace Explorer GUIUtility.CheckOnGUI(); if (GUILayoutUtility.current.topLevel.isVertical) - LayoutUtilityUnstrip.GetRect(0, pixels, GUILayoutUtility.spaceStyle, new GUILayoutOption[] { GUILayout.Height(pixels) }); else LayoutUtilityUnstrip.GetRect(pixels, 0, GUILayoutUtility.spaceStyle, new GUILayoutOption[] { GUILayout.Width(pixels) }); @@ -66,6 +67,78 @@ namespace Explorer } } + // Fix for BeginArea + + static public void BeginArea(Rect screenRect) { BeginArea(screenRect, GUIContent.none, GUIStyle.none); } + static public void BeginArea(Rect screenRect, string text) { BeginArea(screenRect, GUIContent.Temp(text), GUIStyle.none); } + static public void BeginArea(Rect screenRect, Texture image) { BeginArea(screenRect, GUIContent.Temp(image), GUIStyle.none); } + static public void BeginArea(Rect screenRect, GUIContent content) { BeginArea(screenRect, content, GUIStyle.none); } + static public void BeginArea(Rect screenRect, GUIStyle style) { BeginArea(screenRect, GUIContent.none, style); } + static public void BeginArea(Rect screenRect, string text, GUIStyle style) { BeginArea(screenRect, GUIContent.Temp(text), style); } + static public void BeginArea(Rect screenRect, Texture image, GUIStyle style) { BeginArea(screenRect, GUIContent.Temp(image), style); } + + // Begin a GUILayout block of GUI controls in a fixed screen area. + static public void BeginArea(Rect screenRect, GUIContent content, GUIStyle style) + { + GUILayoutGroup g = GUILayoutUtility.BeginLayoutArea(style, Il2CppType.Of()); + if (Event.current.type == EventType.Layout) + { + g.resetCoords = true; + g.minWidth = g.maxWidth = screenRect.width; + g.minHeight = g.maxHeight = screenRect.height; + g.rect = Rect.MinMaxRect(screenRect.xMin, screenRect.yMin, g.rect.xMax, g.rect.yMax); + } + + GUI.BeginGroup(g.rect, content, style); + } + + // Close a GUILayout block started with BeginArea + static public void EndArea() + { + if (Event.current.type == EventType.Used) + return; + GUILayoutUtility.current.layoutGroups.Pop(); + GUILayoutUtility.current.topLevel = GUILayoutUtility.current.layoutGroups.Peek().TryCast(); + GUI.EndGroup(); + } + + // Fix for BeginGroup + + public static void BeginGroup(Rect position) { BeginGroup(position, GUIContent.none, GUIStyle.none); } + public static void BeginGroup(Rect position, string text) { BeginGroup(position, GUIContent.Temp(text), GUIStyle.none); } + public static void BeginGroup(Rect position, Texture image) { BeginGroup(position, GUIContent.Temp(image), GUIStyle.none); } + public static void BeginGroup(Rect position, GUIContent content) { BeginGroup(position, content, GUIStyle.none); } + public static void BeginGroup(Rect position, GUIStyle style) { BeginGroup(position, GUIContent.none, style); } + public static void BeginGroup(Rect position, string text, GUIStyle style) { BeginGroup(position, GUIContent.Temp(text), style); } + public static void BeginGroup(Rect position, Texture image, GUIStyle style) { BeginGroup(position, GUIContent.Temp(image), style); } + + public static void BeginGroup(Rect position, GUIContent content, GUIStyle style) { BeginGroup(position, content, style, Vector2.zero); } + + internal static void BeginGroup(Rect position, GUIContent content, GUIStyle style, Vector2 scrollOffset) + { + int id = GUIUtility.GetControlID(GUI.s_BeginGroupHash, FocusType.Passive); + + if (content != GUIContent.none || style != GUIStyle.none) + { + switch (Event.current.type) + { + case EventType.Repaint: + style.Draw(position, content, id); + break; + default: + if (position.Contains(Event.current.mousePosition)) + GUIUtility.mouseUsed = true; + break; + } + } + GUIClip.Push(position, scrollOffset, Vector2.zero, false); + } + + public static void EndGroup() + { + GUIClip.Internal_Pop(); + } + // Fix for BeginScrollView. public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options) @@ -120,8 +193,6 @@ namespace Explorer private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options) { - GUIUtility.CheckOnGUI(); - var guiscrollGroup = GUILayoutUtility.BeginLayoutGroup(background, null, Il2CppType.Of()) .TryCast(); @@ -396,12 +467,12 @@ namespace Explorer if (flag) { result = true; - GUI.nextScrollStepTime = Il2CppSystem.DateTime.Now.AddMilliseconds(250.0); + nextScrollStepTime = DateTime.Now.AddMilliseconds(250.0); } - else if (Il2CppSystem.DateTime.Now >= GUI.nextScrollStepTime) + else if (DateTime.Now >= nextScrollStepTime) { result = true; - GUI.nextScrollStepTime = Il2CppSystem.DateTime.Now.AddMilliseconds(30.0); + nextScrollStepTime = DateTime.Now.AddMilliseconds(30.0); } if (Event.current.type == EventType.Repaint) { diff --git a/src/UnstripFixes/SliderHandlerUnstrip.cs b/src/UnstripFixes/SliderHandlerUnstrip.cs index 0259c07..4ec8533 100644 --- a/src/UnstripFixes/SliderHandlerUnstrip.cs +++ b/src/UnstripFixes/SliderHandlerUnstrip.cs @@ -81,7 +81,7 @@ namespace Explorer if (this.SupportsPageMovements()) { this.SliderState().isDragging = false; - GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(250.0); + GUIUnstrip.nextScrollStepTime = DateTime.Now.AddMilliseconds(250.0); GUI.scrollTroughSide = this.CurrentScrollTroughSide(); result = this.PageMovementValue(); } @@ -155,7 +155,7 @@ namespace Explorer else { GUI.InternalRepaintEditorWindow(); - if (SystemClock.now < GUI.nextScrollStepTime) + if (DateTime.Now < GUIUnstrip.nextScrollStepTime) { result = this.currentValue; } @@ -165,7 +165,7 @@ namespace Explorer } else { - GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(30.0); + GUIUnstrip.nextScrollStepTime = DateTime.Now.AddMilliseconds(30.0); if (this.SupportsPageMovements()) { this.SliderState().isDragging = false;