From 9836566e554b85a0bfef1dc38920f399b9a9a3a8 Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Sat, 5 Sep 2020 01:30:50 +1000 Subject: [PATCH] tidy up --- src/CppExplorer.csproj | 8 ++--- .../GUIUnstrip.cs | 29 ++----------------- .../ScrollViewStateUnstrip.cs | 10 ------- .../SliderHandlerUnstrip.cs | 7 ----- .../UnstripExtensions.cs | 10 ------- 5 files changed, 6 insertions(+), 58 deletions(-) rename src/{Unstripping => UnstripFixes}/GUIUnstrip.cs (94%) rename src/{Unstripping => UnstripFixes}/ScrollViewStateUnstrip.cs (65%) rename src/{Unstripping => UnstripFixes}/SliderHandlerUnstrip.cs (97%) rename src/{Unstripping => UnstripFixes}/UnstripExtensions.cs (74%) diff --git a/src/CppExplorer.csproj b/src/CppExplorer.csproj index 1fe7bd2..5b2705e 100644 --- a/src/CppExplorer.csproj +++ b/src/CppExplorer.csproj @@ -129,8 +129,8 @@ - - + + @@ -138,8 +138,8 @@ - - + + diff --git a/src/Unstripping/GUIUnstrip.cs b/src/UnstripFixes/GUIUnstrip.cs similarity index 94% rename from src/Unstripping/GUIUnstrip.cs rename to src/UnstripFixes/GUIUnstrip.cs index 47f85e7..886b6de 100644 --- a/src/Unstripping/GUIUnstrip.cs +++ b/src/UnstripFixes/GUIUnstrip.cs @@ -13,13 +13,6 @@ using Harmony; namespace Explorer { - // This is a copy+paste of UnityEngine source code, fixed for Il2Cpp. - // Taken from dnSpy output using Unity 2018.4.20. - - // Subject to Unity's License and ToS. - // https://unity3d.com/legal/terms-of-service - // https://unity3d.com/legal/terms-of-service/software - public class GUIUnstrip { public static int s_ScrollControlId; @@ -41,9 +34,6 @@ namespace Explorer // ======= public methods ======= // - // Fix for GUILayoutUtility.GetLastRect(). - // Calls UnstripExtensions.GetLastUnstripped(). - public static Rect GetLastRect() { EventType type = Event.current.type; @@ -59,8 +49,6 @@ namespace Explorer return last; } - // Simple unstrips for HorizontalScrollbar and VerticalScrollbar, they just call the Scroller unstrip. - public static float HorizontalScrollbar(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle style) { return Scroller_Impl(position, value, size, leftValue, rightValue, style, @@ -80,7 +68,6 @@ namespace Explorer } // Fix for BeginScrollView. - // Uses several manually unstripped methods. public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options) { @@ -98,7 +85,7 @@ namespace Explorer } } - // Try manual unstripping implementation. + // Try manual implementation. if (!ManualUnstripFailed) { try @@ -107,7 +94,7 @@ namespace Explorer } catch (Exception e) { - MelonLogger.Log("Exception on GUIUnstrip.BeginScrollView_Impl: " + e.GetType() + ", " + e.Message + "\r\n" + e.StackTrace); + MelonLogger.Log("Exception on GUIUnstrip.BeginScrollView_ImplLayout: " + e.GetType() + ", " + e.Message + "\r\n" + e.StackTrace); ManualUnstripFailed = true; return scroll; @@ -136,8 +123,6 @@ namespace Explorer // ======= private methods ======= // - // Actual unstrip of GUILayout.BeginScrollView() - private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options) { @@ -171,8 +156,6 @@ namespace Explorer ); } - // Actual unstrip of GUI.BeginScrollView() - private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background) { @@ -296,8 +279,6 @@ namespace Explorer return scrollPosition; } - // Actual unstrip of GUI.EndScrollView() - private static void EndScrollView_Impl(bool handleScrollWheel) { GUIUtility.CheckOnGUI(); @@ -336,8 +317,6 @@ namespace Explorer } } - // Actual unstrip of GUI.Scroller - private static float Scroller_Impl(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz) { GUIUtility.CheckOnGUI(); @@ -384,8 +363,6 @@ namespace Explorer return value; } - // Actual unstrip of GUI.Slider - public static float Slider(Rect position, float value, float size, float start, float end, GUIStyle slider, GUIStyle thumb, bool horiz, int id) { if (id == 0) @@ -396,8 +373,6 @@ namespace Explorer return sliderHandler.Handle(); } - // Actual unstrip of GUI.ScrollerRepeatButton - private static bool ScrollerRepeatButton_Impl(int scrollerID, Rect rect, GUIStyle style) { bool result = false; diff --git a/src/Unstripping/ScrollViewStateUnstrip.cs b/src/UnstripFixes/ScrollViewStateUnstrip.cs similarity index 65% rename from src/Unstripping/ScrollViewStateUnstrip.cs rename to src/UnstripFixes/ScrollViewStateUnstrip.cs index 575011f..77f997b 100644 --- a/src/Unstripping/ScrollViewStateUnstrip.cs +++ b/src/UnstripFixes/ScrollViewStateUnstrip.cs @@ -9,13 +9,6 @@ using UnityEngine; namespace Explorer { - // This is a copy+paste of UnityEngine source code, fixed for Il2Cpp. - // Taken from dnSpy output using Unity 2018.4.20. - - // Subject to Unity's License and ToS. - // https://unity3d.com/legal/terms-of-service - // https://unity3d.com/legal/terms-of-service/software - public class ScrollViewStateUnstrip { public Rect position; @@ -24,9 +17,6 @@ namespace Explorer public Vector2 scrollPosition; public bool apply; - // The code below is not unstripped. - // This is a custom dictionary to allow for the manual implementation. - public static Dictionary Dict = new Dictionary(); public static ScrollViewStateUnstrip FromPointer(IntPtr ptr) diff --git a/src/Unstripping/SliderHandlerUnstrip.cs b/src/UnstripFixes/SliderHandlerUnstrip.cs similarity index 97% rename from src/Unstripping/SliderHandlerUnstrip.cs rename to src/UnstripFixes/SliderHandlerUnstrip.cs index c56f417..0259c07 100644 --- a/src/Unstripping/SliderHandlerUnstrip.cs +++ b/src/UnstripFixes/SliderHandlerUnstrip.cs @@ -8,13 +8,6 @@ using UnhollowerRuntimeLib; namespace Explorer { - // This is a copy+paste of UnityEngine source code, fixed for Il2Cpp. - // Taken from dnSpy output using Unity 2018.4.20. - - // Subject to Unity's License and ToS. - // https://unity3d.com/legal/terms-of-service - // https://unity3d.com/legal/terms-of-service/software - public struct SliderHandlerUnstrip { private readonly Rect position; diff --git a/src/Unstripping/UnstripExtensions.cs b/src/UnstripFixes/UnstripExtensions.cs similarity index 74% rename from src/Unstripping/UnstripExtensions.cs rename to src/UnstripFixes/UnstripExtensions.cs index a231681..a8b36ea 100644 --- a/src/Unstripping/UnstripExtensions.cs +++ b/src/UnstripFixes/UnstripExtensions.cs @@ -7,18 +7,8 @@ using UnityEngine; namespace Explorer { - // This is a copy+paste of UnityEngine source code, fixed for Il2Cpp. - // Taken from dnSpy output using Unity 2018.4.20. - - // Subject to Unity's License and ToS. - // https://unity3d.com/legal/terms-of-service - // https://unity3d.com/legal/terms-of-service/software - public static class UnstripExtensions { - // This is a manual unstrip of GUILayoutGroup.GetLast(). - // I'm using it as an Extension because it's easier this way. - public static Rect GetLastUnstripped(this GUILayoutGroup group) { Rect result;