From 60580c818321c9af7fdbf6724bd1a0f372771d85 Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Sat, 14 Nov 2020 00:46:26 +1100 Subject: [PATCH] some UI cleanups --- src/CSConsole/AutoCompleter.cs | 8 ++++---- src/CSConsole/CodeEditor.cs | 20 +++++++++---------- src/CSConsole/ScriptInteraction.cs | 6 +++--- src/Inspectors/InspectorManager.cs | 18 ++++++++--------- src/Inspectors/SceneExplorer.cs | 10 +++++----- src/Properties/AssemblyInfo.cs | 4 ++-- src/UI/MainMenu.cs | 17 ++++++---------- .../{ConsolePage.cs => CSConsolePage.cs} | 4 ++-- src/UI/Modules/DebugConsole.cs | 6 +++--- src/UI/Modules/HomePage.cs | 10 +++++----- src/UI/PanelDragger.cs | 6 ++++-- src/UI/UIFactory.cs | 20 +++++++------------ src/UnityExplorer.csproj | 6 ++++-- 13 files changed, 64 insertions(+), 71 deletions(-) rename src/UI/Modules/{ConsolePage.cs => CSConsolePage.cs} (96%) diff --git a/src/CSConsole/AutoCompleter.cs b/src/CSConsole/AutoCompleter.cs index c690d64..42dade8 100644 --- a/src/CSConsole/AutoCompleter.cs +++ b/src/CSConsole/AutoCompleter.cs @@ -132,7 +132,7 @@ namespace UnityExplorer.CSConsole { try { - var editor = ConsolePage.Instance.m_codeEditor; + var editor = CSConsolePage.Instance.m_codeEditor; if (!editor.InputField.isFocused) return; @@ -164,7 +164,7 @@ namespace UnityExplorer.CSConsole public static void CheckAutocomplete() { - var m_codeEditor = ConsolePage.Instance.m_codeEditor; + var m_codeEditor = CSConsolePage.Instance.m_codeEditor; string input = m_codeEditor.InputField.text; int caretIndex = m_codeEditor.InputField.caretPosition; @@ -204,7 +204,7 @@ namespace UnityExplorer.CSConsole { // Credit ManylMarco CodeEditor.AutoCompletes.Clear(); - string[] completions = ConsolePage.Instance.m_evaluator.GetCompletions(input, out string prefix); + string[] completions = CSConsolePage.Instance.m_evaluator.GetCompletions(input, out string prefix); if (completions != null) { if (prefix == null) @@ -301,7 +301,7 @@ namespace UnityExplorer.CSConsole void UseAutocompleteButton() { - ConsolePage.Instance.m_codeEditor.UseAutocomplete(hiddenText.text); + CSConsolePage.Instance.m_codeEditor.UseAutocomplete(hiddenText.text); } m_suggestionButtons.Add(buttonObj); diff --git a/src/CSConsole/CodeEditor.cs b/src/CSConsole/CodeEditor.cs index 9c18677..88a9598 100644 --- a/src/CSConsole/CodeEditor.cs +++ b/src/CSConsole/CodeEditor.cs @@ -86,7 +86,7 @@ The following helper methods are available: var text = InputField.text.Trim(); if (!string.IsNullOrEmpty(text)) { - ConsolePage.Instance.Evaluate(text); + CSConsolePage.Instance.Evaluate(text); return; } } @@ -105,7 +105,7 @@ The following helper methods are available: { if (!m_fixwanted) { - EventSystem.current.SetSelectedGameObject(ConsolePage.Instance.m_codeEditor.InputField.gameObject, null); + EventSystem.current.SetSelectedGameObject(CSConsolePage.Instance.m_codeEditor.InputField.gameObject, null); m_fixwanted = true; } else @@ -308,13 +308,13 @@ The following helper methods are available: public void ConstructUI() { - ConsolePage.Instance.Content = UIFactory.CreateUIObject("C# Console", MainMenu.Instance.PageViewport); + CSConsolePage.Instance.Content = UIFactory.CreateUIObject("C# Console", MainMenu.Instance.PageViewport); - var mainLayout = ConsolePage.Instance.Content.AddComponent(); - mainLayout.preferredHeight = 9900; + var mainLayout = CSConsolePage.Instance.Content.AddComponent(); + mainLayout.preferredHeight = 500; mainLayout.flexibleHeight = 9000; - var mainGroup = ConsolePage.Instance.Content.AddComponent(); + var mainGroup = CSConsolePage.Instance.Content.AddComponent(); mainGroup.childControlHeight = true; mainGroup.childControlWidth = true; mainGroup.childForceExpandHeight = true; @@ -324,7 +324,7 @@ The following helper methods are available: // Main group object - var topBarObj = UIFactory.CreateHorizontalGroup(ConsolePage.Instance.Content); + var topBarObj = UIFactory.CreateHorizontalGroup(CSConsolePage.Instance.Content); LayoutElement topBarLayout = topBarObj.AddComponent(); topBarLayout.minHeight = 50; topBarLayout.flexibleHeight = 0; @@ -402,7 +402,7 @@ The following helper methods are available: int fontSize = 16; - var inputObj = UIFactory.CreateSrollInputField(ConsolePage.Instance.Content, out InputFieldScroller consoleScroll, fontSize); + var inputObj = UIFactory.CreateSrollInputField(CSConsolePage.Instance.Content, out InputFieldScroller consoleScroll, fontSize); var inputField = consoleScroll.inputField; @@ -431,7 +431,7 @@ The following helper methods are available: #region COMPILE BUTTON - var compileBtnObj = UIFactory.CreateButton(ConsolePage.Instance.Content); + var compileBtnObj = UIFactory.CreateButton(CSConsolePage.Instance.Content); var compileBtnLayout = compileBtnObj.AddComponent(); compileBtnLayout.preferredWidth = 80; compileBtnLayout.flexibleWidth = 0; @@ -452,7 +452,7 @@ The following helper methods are available: { if (!string.IsNullOrEmpty(inputField.text)) { - ConsolePage.Instance.Evaluate(inputField.text.Trim()); + CSConsolePage.Instance.Evaluate(inputField.text.Trim()); } } diff --git a/src/CSConsole/ScriptInteraction.cs b/src/CSConsole/ScriptInteraction.cs index 78a8272..8efa1ee 100644 --- a/src/CSConsole/ScriptInteraction.cs +++ b/src/CSConsole/ScriptInteraction.cs @@ -15,17 +15,17 @@ namespace UnityExplorer.CSConsole public static void AddUsing(string directive) { - ConsolePage.Instance.AddUsing(directive); + CSConsolePage.Instance.AddUsing(directive); } public static void GetUsing() { - ExplorerCore.Log(ConsolePage.Instance.m_evaluator.GetUsing()); + ExplorerCore.Log(CSConsolePage.Instance.m_evaluator.GetUsing()); } public static void Reset() { - ConsolePage.Instance.ResetConsole(); + CSConsolePage.Instance.ResetConsole(); } public static object CurrentTarget() diff --git a/src/Inspectors/InspectorManager.cs b/src/Inspectors/InspectorManager.cs index c261396..6b7a043 100644 --- a/src/Inspectors/InspectorManager.cs +++ b/src/Inspectors/InspectorManager.cs @@ -153,7 +153,7 @@ namespace UnityExplorer.Inspectors mainGroup.childForceExpandWidth = true; mainGroup.childControlHeight = true; mainGroup.childControlWidth = true; - mainGroup.spacing = 2; + mainGroup.spacing = 4; mainGroup.padding.left = 4; mainGroup.padding.right = 4; mainGroup.padding.top = 4; @@ -184,10 +184,10 @@ namespace UnityExplorer.Inspectors m_tabBarContent = UIFactory.CreateGridGroup(mainObj, new Vector2(185, 20), new Vector2(5, 2), new Color(0.1f, 0.1f, 0.1f, 1)); var gridGroup = m_tabBarContent.GetComponent(); - gridGroup.padding.top = 4; - gridGroup.padding.left = 4; - gridGroup.padding.right = 4; - gridGroup.padding.bottom = 4; + gridGroup.padding.top = 3; + gridGroup.padding.left = 3; + gridGroup.padding.right = 3; + gridGroup.padding.bottom = 3; // inspector content area @@ -204,10 +204,10 @@ namespace UnityExplorer.Inspectors contentGroup.childForceExpandWidth = true; contentGroup.childControlHeight = true; contentGroup.childControlWidth = true; - contentGroup.padding.top = 5; - contentGroup.padding.left = 5; - contentGroup.padding.right = 5; - contentGroup.padding.bottom = 5; + contentGroup.padding.top = 2; + contentGroup.padding.left = 2; + contentGroup.padding.right = 2; + contentGroup.padding.bottom = 2; var contentLayout = m_inspectorContent.AddComponent(); contentLayout.preferredHeight = 900; diff --git a/src/Inspectors/SceneExplorer.cs b/src/Inspectors/SceneExplorer.cs index bd39def..1243b0e 100644 --- a/src/Inspectors/SceneExplorer.cs +++ b/src/Inspectors/SceneExplorer.cs @@ -294,11 +294,11 @@ namespace UnityExplorer.Inspectors leftLayout.flexibleWidth = 0; VerticalLayoutGroup leftGroup = leftPane.GetComponent(); - leftGroup.padding.left = 8; - leftGroup.padding.right = 8; + leftGroup.padding.left = 4; + leftGroup.padding.right = 4; leftGroup.padding.top = 8; - leftGroup.padding.bottom = 8; - leftGroup.spacing = 5; + leftGroup.padding.bottom = 4; + leftGroup.spacing = 4; leftGroup.childControlWidth = true; leftGroup.childControlHeight = true; leftGroup.childForceExpandWidth = true; @@ -430,7 +430,7 @@ namespace UnityExplorer.Inspectors Hiding = true; hideText.text = "►"; - leftLayout.minWidth = 20; + leftLayout.minWidth = 15; titleObj.SetActive(false); sceneDropdownObj.SetActive(false); scenePathGroupObj.SetActive(false); diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 2994beb..ed488b3 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using MelonLoader; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion(ExplorerCore.VERSION)] +[assembly: AssemblyFileVersion(ExplorerCore.VERSION)] diff --git a/src/UI/MainMenu.cs b/src/UI/MainMenu.cs index f0b9b2a..db313a8 100644 --- a/src/UI/MainMenu.cs +++ b/src/UI/MainMenu.cs @@ -57,7 +57,7 @@ namespace UnityExplorer.UI Pages.Add(new HomePage()); Pages.Add(new SearchPage()); - Pages.Add(new ConsolePage()); + Pages.Add(new CSConsolePage()); Pages.Add(new OptionsPage()); ConstructMenu(); @@ -118,7 +118,7 @@ namespace UnityExplorer.UI m_activePage?.Content?.SetActive(false); // unique case for console page, at the moment this will just go here - if (m_activePage is ConsolePage) + if (m_activePage is CSConsolePage) AutoCompleter.m_mainObj?.SetActive(false); m_activePage = page; @@ -186,7 +186,7 @@ namespace UnityExplorer.UI titleGroup.padding.bottom = 3; LayoutElement titleLayout = titleBar.AddComponent(); - titleLayout.minHeight = 35; + titleLayout.minHeight = 25; titleLayout.flexibleHeight = 0; // Explorer label @@ -198,9 +198,8 @@ namespace UnityExplorer.UI text.resizeTextForBestFit = true; text.resizeTextMinSize = 12; text.resizeTextMaxSize = 20; - LayoutElement textLayout = textObj.AddComponent(); - textLayout.flexibleWidth = 50; + textLayout.flexibleWidth = 5000; // Add PanelDragger using the label object @@ -226,7 +225,7 @@ namespace UnityExplorer.UI hideText.color = Color.white; hideText.resizeTextForBestFit = true; hideText.resizeTextMinSize = 8; - hideText.resizeTextMaxSize = 16; + hideText.resizeTextMaxSize = 14; hideText.text = $"Hide ({ModConfig.Instance.Main_Menu_Toggle})"; ModConfig.OnConfigChanged += ModConfig_OnConfigChanged; @@ -242,10 +241,6 @@ namespace UnityExplorer.UI GameObject navbarObj = UIFactory.CreateHorizontalGroup(content); HorizontalLayoutGroup navGroup = navbarObj.GetComponent(); - navGroup.padding.left = 3; - navGroup.padding.right = 3; - navGroup.padding.top = 3; - navGroup.padding.bottom = 3; navGroup.spacing = 5; navGroup.childControlHeight = true; navGroup.childControlWidth = true; @@ -253,7 +248,7 @@ namespace UnityExplorer.UI navGroup.childForceExpandWidth = true; LayoutElement navLayout = navbarObj.AddComponent(); - navLayout.minHeight = 35; + navLayout.minHeight = 25; navLayout.flexibleHeight = 0; foreach (Page page in Pages) diff --git a/src/UI/Modules/ConsolePage.cs b/src/UI/Modules/CSConsolePage.cs similarity index 96% rename from src/UI/Modules/ConsolePage.cs rename to src/UI/Modules/CSConsolePage.cs index 548c02e..6ce05e4 100644 --- a/src/UI/Modules/ConsolePage.cs +++ b/src/UI/Modules/CSConsolePage.cs @@ -7,11 +7,11 @@ using UnityExplorer.CSConsole; namespace UnityExplorer.UI.Modules { - public class ConsolePage : MainMenu.Page + public class CSConsolePage : MainMenu.Page { public override string Name => "C# Console"; - public static ConsolePage Instance { get; private set; } + public static CSConsolePage Instance { get; private set; } public CodeEditor m_codeEditor; public ScriptEvaluator m_evaluator; diff --git a/src/UI/Modules/DebugConsole.cs b/src/UI/Modules/DebugConsole.cs index 2e5f63d..858b11b 100644 --- a/src/UI/Modules/DebugConsole.cs +++ b/src/UI/Modules/DebugConsole.cs @@ -160,7 +160,7 @@ namespace UnityExplorer.UI.Modules var bottomBarObj = UIFactory.CreateHorizontalGroup(mainObj); LayoutElement topBarLayout = bottomBarObj.AddComponent(); - topBarLayout.minHeight = 40; + topBarLayout.minHeight = 30; topBarLayout.flexibleHeight = 0; var bottomGroup = bottomBarObj.GetComponent(); @@ -202,7 +202,7 @@ namespace UnityExplorer.UI.Modules { logAreaObj.SetActive(false); hideBtnText.text = "Show"; - mainLayout.minHeight = 40; + mainLayout.minHeight = 30; } else { @@ -267,7 +267,7 @@ namespace UnityExplorer.UI.Modules var unityToggleRect = unityToggleObj.transform.Find("Background").GetComponent(); var pos = unityToggleRect.localPosition; - pos.y = -8; + pos.y = -4; unityToggleRect.localPosition = pos; // // Save to disk button diff --git a/src/UI/Modules/HomePage.cs b/src/UI/Modules/HomePage.cs index 4acd35b..3c6da32 100644 --- a/src/UI/Modules/HomePage.cs +++ b/src/UI/Modules/HomePage.cs @@ -38,11 +38,11 @@ namespace UnityExplorer.UI.Modules Content = UIFactory.CreateHorizontalGroup(parent); var mainGroup = Content.GetComponent(); - mainGroup.padding.left = 3; - mainGroup.padding.right = 3; - mainGroup.padding.top = 3; - mainGroup.padding.bottom = 3; - mainGroup.spacing = 5; + mainGroup.padding.left = 1; + mainGroup.padding.right = 1; + mainGroup.padding.top = 1; + mainGroup.padding.bottom = 1; + mainGroup.spacing = 3; mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandWidth = true; mainGroup.childControlHeight = true; diff --git a/src/UI/PanelDragger.cs b/src/UI/PanelDragger.cs index ed7a443..08c138e 100644 --- a/src/UI/PanelDragger.cs +++ b/src/UI/PanelDragger.cs @@ -35,7 +35,9 @@ namespace UnityExplorer.UI ResizeTypes type; Vector3 resizePos = Panel.InverseTransformPoint(rawMousePos); + Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos); + bool inDragPos = DragableArea.rect.Contains(dragPos); if (WasHoveringResize && s_resizeCursorImage) { @@ -45,7 +47,7 @@ namespace UnityExplorer.UI // If Mouse pressed this frame if (InputManager.GetMouseButtonDown(0)) { - if (DragableArea.rect.Contains(dragPos)) + if (inDragPos) { OnBeginDrag(); return; @@ -82,7 +84,7 @@ namespace UnityExplorer.UI { OnEndResize(); } - else if (MouseInResizeArea(resizePos) && (type = GetResizeType(resizePos)) != ResizeTypes.NONE) + else if (!inDragPos && MouseInResizeArea(resizePos) && (type = GetResizeType(resizePos)) != ResizeTypes.NONE) { OnHoverResize(type); } diff --git a/src/UI/UIFactory.cs b/src/UI/UIFactory.cs index 406dae3..f661f58 100644 --- a/src/UI/UIFactory.cs +++ b/src/UI/UIFactory.cs @@ -93,15 +93,7 @@ namespace UnityExplorer.UI rect.anchoredPosition = Vector2.zero; rect.sizeDelta = Vector2.zero; - Image image = panelObj.AddComponent(); - image.type = Image.Type.Filled; - image.color = new Color(0.05f, 0.05f, 0.05f); - VerticalLayoutGroup group = panelObj.AddComponent(); - group.padding.left = 3; - group.padding.right = 3; - group.padding.bottom = 3; - group.padding.top = 3; group.childControlHeight = true; group.childControlWidth = true; group.childForceExpandHeight = true; @@ -114,12 +106,14 @@ namespace UnityExplorer.UI image2.type = Image.Type.Filled; image2.color = new Color(0.1f, 0.1f, 0.1f); + content.gameObject.AddComponent(); + VerticalLayoutGroup group2 = content.AddComponent(); - group2.padding.left = 5; - group2.padding.right = 5; - group2.padding.bottom = 5; - group2.padding.top = 5; - group2.spacing = 5; + group2.padding.left = 3; + group2.padding.right = 3; + group2.padding.bottom = 3; + group2.padding.top = 3; + group2.spacing = 3; group2.childControlHeight = true; group2.childControlWidth = true; group2.childForceExpandHeight = false; diff --git a/src/UnityExplorer.csproj b/src/UnityExplorer.csproj index e0073a5..0dcf910 100644 --- a/src/UnityExplorer.csproj +++ b/src/UnityExplorer.csproj @@ -24,7 +24,6 @@ x64 false UnityExplorer - UnityExplorer D:\Steam\steamapps\common\Outward @@ -44,6 +43,7 @@ ..\Release\UnityExplorer.MelonLoader.Il2Cpp\ CPP,ML + UnityExplorer.ML.IL2CPP true true true @@ -52,6 +52,7 @@ v4.0 ..\Release\UnityExplorer.MelonLoader.Mono\ MONO,ML + UnityExplorer.ML.Mono false false true @@ -69,6 +70,7 @@ v4.0 ..\Release\UnityExplorer.BepInEx.Mono\ MONO,BIE + UnityExplorer.BIE.Mono false false true @@ -353,7 +355,7 @@ - +