diff --git a/NEG/UI/UiManager.cs b/NEG/UI/UiManager.cs index 68d7efe..f55b0da 100644 --- a/NEG/UI/UiManager.cs +++ b/NEG/UI/UiManager.cs @@ -170,7 +170,7 @@ namespace NEG.UI protected void SetDefaultPopup(IDefaultPopup popup) => currentDefaultPopup = popup; - private void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null) + protected virtual void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null) { if (forceShow) { diff --git a/NEG/UI/UnityUi/MonoUiInputManger.cs b/NEG/UI/UnityUi/MonoUiInputManger.cs index dfff504..4aac796 100644 --- a/NEG/UI/UnityUi/MonoUiInputManger.cs +++ b/NEG/UI/UnityUi/MonoUiInputManger.cs @@ -12,12 +12,10 @@ namespace NEG.UI.UnityUi Direction } - public class UiInputModule { } + public class UiInputModule { public SelectionSource CurrentSelectionSource { get; protected set; }} public class DefaultInputModule : UiInputModule { - public SelectionSource CurrentSelectionSource { get; private set; } - public DefaultInputModule() { var defaultActions = new DefaultInputActions(); diff --git a/NEG/UI/UnityUi/MonoUiManager.cs b/NEG/UI/UnityUi/MonoUiManager.cs index e5ced8c..7db2fb4 100644 --- a/NEG/UI/UnityUi/MonoUiManager.cs +++ b/NEG/UI/UnityUi/MonoUiManager.cs @@ -3,11 +3,13 @@ using NEG.UI.Popup; using NEG.UI.UnityUi.Buttons.Reaction; using NEG.UI.UnityUi.Buttons.Settings; using NEG.UI.UnityUi.Popup; +using NEG.UI.UnityUi.Window; using NEG.Utils; using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Assertions; +using UnityEngine.EventSystems; using UnityEngine.SceneManagement; using Object = UnityEngine.Object; @@ -68,6 +70,17 @@ namespace NEG.UI.UnityUi Instance = null; } + protected override void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null) + { + base.UpdatePopupsState(forceShow, priority, data); + if(inputModule.CurrentSelectionSource != SelectionSource.Direction) + return; + if (CurrentPopup == null && (EventSystem.current.currentSelectedGameObject != null || !EventSystem.current.currentSelectedGameObject.activeInHierarchy)) + { + EventSystem.current.SetSelectedGameObject(((MonoWindow)CurrentMainWindow).DefaultSelectedItem); + } + } + private void SpawnDefaultPopup() { var canvas = Object.Instantiate(canvasPrefab); diff --git a/NEG/UI/UnityUi/Window/NoReactionOnBack.cs b/NEG/UI/UnityUi/Window/NoReactionOnBack.cs new file mode 100644 index 0000000..7ba12ee --- /dev/null +++ b/NEG/UI/UnityUi/Window/NoReactionOnBack.cs @@ -0,0 +1,13 @@ +using NegUtils.NEG.UI; + +namespace NEG.UI.UnityUi.Window +{ + public class NoReactionOnBack : MonoController + { + protected override void OnBackUsed(IControllable.BackUsed backUsed) + { + base.OnBackUsed(backUsed); + backUsed.Used = true; + } + } +} \ No newline at end of file diff --git a/NEG/UI/UnityUi/Window/NoReactionOnBack.cs.meta b/NEG/UI/UnityUi/Window/NoReactionOnBack.cs.meta new file mode 100644 index 0000000..8be0e77 --- /dev/null +++ b/NEG/UI/UnityUi/Window/NoReactionOnBack.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c4a5380c95244c76ac79f820d16ea11c +timeCreated: 1702565120 \ No newline at end of file