From 164fd2f79419eef52f0a86315a5cbe16bd08db80 Mon Sep 17 00:00:00 2001 From: Hubert Mattusch Date: Tue, 3 Oct 2023 15:55:02 +0200 Subject: [PATCH] ui update --- Editor/BuildingUtils.cs | 27 ++++++++++++++++++- NEG/UI/UiManager.cs | 12 ++++++--- NEG/UI/UnityUi/MonoUiInputManger.cs | 6 +++-- NEG/UI/UnityUi/Window/MonoWindow.cs | 1 + NEG/UI/UnityUi/Window/MonoWindow.cs.meta | 12 +++++++-- NEG/UI/UnityUi/WindowSlot/SingleWindowSlot.cs | 8 +++++- .../WindowSlot/SingleWindowSlotWithHistory.cs | 2 +- 7 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Editor/BuildingUtils.cs b/Editor/BuildingUtils.cs index 7cc5407..a95774f 100644 --- a/Editor/BuildingUtils.cs +++ b/Editor/BuildingUtils.cs @@ -55,6 +55,18 @@ public static class BuildingUtils BuildDevelopment(); UploadSteam(); } + + + [MenuItem("Tools/Build/Steam/Demo")] + public static void SteamDemo() + { + if(!CanBuild()) + return; + + IncreaseBuildNumber(); + BuildDemo(); + UploadSteam(true); + } [MenuItem("Tools/Build/All Release")] public static void BuildRelease() @@ -72,6 +84,15 @@ public static class BuildingUtils return; BuildWindowsDevelopment(); } + + [MenuItem("Tools/Build/All Demo")] + public static void BuildDemo() + { + if(!CanBuild()) + return; + BuildWindows(true, new[] {"DEMO"}); + BuildLinux(true, new[] {"DEMO"}); + } [MenuItem("Tools/Build/Platform/Windows/x64-Development")] public static void BuildWindowsDevelopment() @@ -163,9 +184,13 @@ public static class BuildingUtils PlayerSettings.bundleVersion = string.Join(".", versionParts); } - private static void UploadSteam() + private static void UploadSteam(bool demo = false) { string command = $"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_build.bat"; + if (demo) + { + command = $"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_demo.bat"; + } var processInfo = new ProcessStartInfo("cmd.exe", $"/c {command}") { diff --git a/NEG/UI/UiManager.cs b/NEG/UI/UiManager.cs index 59c2bb0..1be26f6 100644 --- a/NEG/UI/UiManager.cs +++ b/NEG/UI/UiManager.cs @@ -6,6 +6,7 @@ using NEG.Utils; using NegUtils.NEG.UI; using System; using System.Collections.Generic; +using System.Linq; using UnityEngine; namespace NEG.UI @@ -34,7 +35,7 @@ namespace NEG.UI /// /// Current window that is considered main (focused, lastly opened). Can be null. /// - public IWindow CurrentMainWindow { get; protected set; } + public IWindow CurrentMainWindow => mainWindows.LastOrDefault(); public PopupData CurrentPopup => currentShownPopup.data; @@ -47,6 +48,8 @@ namespace NEG.UI //TODO: localize private string localizedYes = "Yes", localizedNo = "No", localizedOk = "Ok"; + private List mainWindows; + protected UiManager(IArea startArea) { if (Instance != null) @@ -58,6 +61,7 @@ namespace NEG.UI Instance = this; CurrentArea = startArea; + mainWindows = new List(); } /// @@ -146,14 +150,16 @@ namespace NEG.UI public virtual void Dispose() => Instance = null; - public void SetMainWindow(IWindow window) => CurrentMainWindow = window; + public void SetMainWindow(IWindow window) => mainWindows.Add(window); + + public void MainWindowClosed(IWindow window) => mainWindows.Remove(window); public void OnWindowClosed(IWindow window) { if(CurrentMainWindow != window) return; - CurrentMainWindow = null; + MainWindowClosed(window); //TODO: select new main window } diff --git a/NEG/UI/UnityUi/MonoUiInputManger.cs b/NEG/UI/UnityUi/MonoUiInputManger.cs index f6b55ac..202a724 100644 --- a/NEG/UI/UnityUi/MonoUiInputManger.cs +++ b/NEG/UI/UnityUi/MonoUiInputManger.cs @@ -48,14 +48,14 @@ namespace NEG.UI.UnityUi private void OnSelectionChangeStarted() { - if(CurrentSelectionSource == SelectionSource.Direction) + if(CurrentSelectionSource == SelectionSource.Direction && EventSystem.current.currentSelectedGameObject != null) return; SetDirectionInput(); } private void SetDirectionInput() { - if (EventSystem.current == null || MonoUiManager.Instance == null || CurrentSelectionSource == SelectionSource.Direction) + if (EventSystem.current == null || MonoUiManager.Instance == null ) { return; } @@ -95,6 +95,8 @@ namespace NEG.UI.UnityUi if (EventSystem.current.currentInputModule == null) return; + EventSystem.current.SetSelectedGameObject(null); + var module = (InputSystemUIInputModule)EventSystem.current.currentInputModule; var result = module.GetLastRaycastResult(0); if(result.gameObject == null) diff --git a/NEG/UI/UnityUi/Window/MonoWindow.cs b/NEG/UI/UnityUi/Window/MonoWindow.cs index b6b8986..e1f0dfc 100644 --- a/NEG/UI/UnityUi/Window/MonoWindow.cs +++ b/NEG/UI/UnityUi/Window/MonoWindow.cs @@ -12,6 +12,7 @@ using UnityEngine.Serialization; namespace NEG.UI.UnityUi.Window { + [DefaultExecutionOrder(10)] public class MonoWindow : MonoBehaviour, IWindow { public event Action OnOpened; diff --git a/NEG/UI/UnityUi/Window/MonoWindow.cs.meta b/NEG/UI/UnityUi/Window/MonoWindow.cs.meta index 4f6091a..d50bd3d 100644 --- a/NEG/UI/UnityUi/Window/MonoWindow.cs.meta +++ b/NEG/UI/UnityUi/Window/MonoWindow.cs.meta @@ -1,3 +1,11 @@ -fileFormatVersion: 2 +fileFormatVersion: 2 guid: 85d136d6850728d4b96c26fa286ffe3c -timeCreated: 1670709296 \ No newline at end of file +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 10 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/NEG/UI/UnityUi/WindowSlot/SingleWindowSlot.cs b/NEG/UI/UnityUi/WindowSlot/SingleWindowSlot.cs index 04c49b9..9fff830 100644 --- a/NEG/UI/UnityUi/WindowSlot/SingleWindowSlot.cs +++ b/NEG/UI/UnityUi/WindowSlot/SingleWindowSlot.cs @@ -24,7 +24,13 @@ namespace NEG.UI.WindowSlot window.SetOpenedState(this, data); } - public override void DetachWindow(IWindow window) => CurrentWindow = null; + public override void DetachWindow(IWindow window) + { + if(UiManager.Instance.CurrentMainWindow == window) + UiManager.Instance.MainWindowClosed(window); + CurrentWindow = null; + } + public override void CloseAllWindows() => CurrentWindow = null; } } \ No newline at end of file diff --git a/NEG/UI/UnityUi/WindowSlot/SingleWindowSlotWithHistory.cs b/NEG/UI/UnityUi/WindowSlot/SingleWindowSlotWithHistory.cs index 10d010e..fc3390c 100644 --- a/NEG/UI/UnityUi/WindowSlot/SingleWindowSlotWithHistory.cs +++ b/NEG/UI/UnityUi/WindowSlot/SingleWindowSlotWithHistory.cs @@ -47,7 +47,7 @@ namespace NegUtils.NEG.UI.UnityUi.WindowSlot currentWindow = windowsHistory[^1]; currentWindow.SeVisibleState(); if(UiManager.Instance.CurrentMainWindow == window) - UiManager.Instance.SetMainWindow(currentWindow); + UiManager.Instance.MainWindowClosed(window); EventSystem.current.SetSelectedGameObject(((MonoWindow)currentWindow).DefaultSelectedItem); } public override void CloseAllWindows()