diff --git a/client/Assets/Vanguard/Runtime/App/DeckBuilderSceneController.cs b/client/Assets/Vanguard/Runtime/App/DeckBuilderSceneController.cs index 0528c45..9964b77 100644 --- a/client/Assets/Vanguard/Runtime/App/DeckBuilderSceneController.cs +++ b/client/Assets/Vanguard/Runtime/App/DeckBuilderSceneController.cs @@ -25,14 +25,26 @@ namespace Vanguard.App info => _ = Flow.LoadBattleAsync(info)); _topBar = new PlayerTopBar( - canvas.transform, + _view.Root, Resolve(), Resolve(), () => _ = Flow.LoadLoginAsync(), null, null, null, - () => _ = Flow.LoadLobbyAsync()); + () => _ = Flow.LoadLobbyAsync(), + overlayParent: canvas.transform); + + _topBar.Root.SetAsFirstSibling(); + + var hotkeys = canvas.gameObject.AddComponent(); + hotkeys.Cancel = () => + { + if (_topBar.IsMenuOpen) + _topBar.CloseMenu(); + else + _view.CloseTopmost(); + }; _view.Show(); } diff --git a/client/Assets/Vanguard/Runtime/UI/DeckBuilderView.cs b/client/Assets/Vanguard/Runtime/UI/DeckBuilderView.cs index 7ad8125..6a56f92 100644 --- a/client/Assets/Vanguard/Runtime/UI/DeckBuilderView.cs +++ b/client/Assets/Vanguard/Runtime/UI/DeckBuilderView.cs @@ -124,6 +124,33 @@ namespace Vanguard.UI _root.gameObject.SetActive(false); } + public RectTransform Root => _root; + + /// Esc: закрывает верхний оверлей, если он открыт. + public void CloseTopmost() + { + if (_cardOverlay.gameObject.activeSelf) + { + CloseCardOverlay(); + return; + } + + if (_confirmOverlay.gameObject.activeSelf) + { + CancelDelete(); + return; + } + + if (_deckMenuOverlay.gameObject.activeSelf) + { + CloseDeckMenu(); + return; + } + + if (_filterOverlay.gameObject.activeSelf) + CloseFilters(); + } + public void Show() { UiKit.SetActive(_root, true); diff --git a/client/Assets/Vanguard/Runtime/UI/HamburgerMenu.cs b/client/Assets/Vanguard/Runtime/UI/HamburgerMenu.cs index 0b6172e..7769233 100644 --- a/client/Assets/Vanguard/Runtime/UI/HamburgerMenu.cs +++ b/client/Assets/Vanguard/Runtime/UI/HamburgerMenu.cs @@ -24,11 +24,13 @@ namespace Vanguard.UI Action onLogout = null, Action onHistory = null, Action onLobby = null, - string title = "Меню") + string title = "Меню", + Transform overlayParent = null) { _onLogout = onLogout; _onHistory = onHistory; _onLobby = onLobby; + var overlayRoot = overlayParent != null ? overlayParent : parent; _blocker = new GameObject( "MenuBlocker", @@ -36,7 +38,7 @@ namespace Vanguard.UI typeof(Image), typeof(Button)); var blockerRect = (RectTransform)_blocker.transform; - blockerRect.SetParent(parent, false); + blockerRect.SetParent(overlayRoot, false); UiKit.Stretch(blockerRect); var blockerImage = _blocker.GetComponent(); @@ -98,7 +100,7 @@ namespace Vanguard.UI + (onLobby != null ? 46f : 0f); var panelGo = new GameObject("MenuPanel", typeof(RectTransform), typeof(Image)); _panel = (RectTransform)panelGo.transform; - _panel.SetParent(parent, false); + _panel.SetParent(overlayRoot, false); _panel.anchorMin = new Vector2(1f, 1f); _panel.anchorMax = new Vector2(1f, 1f); _panel.pivot = new Vector2(1f, 1f); @@ -133,6 +135,7 @@ namespace Vanguard.UI public void Open() { _blocker.SetActive(true); + _blocker.transform.SetAsLastSibling(); _panel.gameObject.SetActive(true); _panel.SetAsLastSibling(); } diff --git a/client/Assets/Vanguard/Runtime/UI/LobbyView.cs b/client/Assets/Vanguard/Runtime/UI/LobbyView.cs index 8481aaf..b447b62 100644 --- a/client/Assets/Vanguard/Runtime/UI/LobbyView.cs +++ b/client/Assets/Vanguard/Runtime/UI/LobbyView.cs @@ -77,7 +77,8 @@ namespace Vanguard.UI onLoggedOut, onHistory, onRating, - onCommunity); + onCommunity, + overlayParent: _root); BuildActions(onBattle, onDecks, onStore); BuildMissions(out _status); diff --git a/client/Assets/Vanguard/Runtime/UI/PlayerTopBar.cs b/client/Assets/Vanguard/Runtime/UI/PlayerTopBar.cs index aa8e5d4..efa56b1 100644 --- a/client/Assets/Vanguard/Runtime/UI/PlayerTopBar.cs +++ b/client/Assets/Vanguard/Runtime/UI/PlayerTopBar.cs @@ -26,6 +26,7 @@ namespace Vanguard.UI private readonly PlayerState _player; private readonly HamburgerMenu _menu; + private readonly RectTransform _root; private Text _avatar; private Text _playerName; private Text _mmr; @@ -39,11 +40,13 @@ namespace Vanguard.UI Action onHistory, Action onRating, Action onCommunity, - Action onLobby = null) + Action onLobby = null, + Transform overlayParent = null) { _player = player; var top = Surface(parent, RootName, new Color(0.012f, 0.03f, 0.08f, 0.94f), 0); + _root = top; top.anchorMin = new Vector2(0f, 1f); top.anchorMax = new Vector2(1f, 1f); top.pivot = new Vector2(0.5f, 1f); @@ -113,7 +116,14 @@ namespace Vanguard.UI AddAction(top, "Rating", "Рейтинг", -312f, 180f, onRating, LobbyIcon.Chart); AddAction(top, "Community", "Сообщество", -96f, 200f, onCommunity, LobbyIcon.Friends); - _menu = new HamburgerMenu(parent, config, onLoggedOut, onHistory, onLobby); + _menu = new HamburgerMenu( + top, + config, + onLoggedOut, + onHistory, + onLobby, + "Меню", + overlayParent); _player.Changed += UpdateTexts; Loc.LanguageChanged += UpdateTexts; @@ -122,6 +132,8 @@ namespace Vanguard.UI public bool IsMenuOpen => _menu != null && _menu.IsOpen; + public RectTransform Root => _root; + public void CloseMenu() { if (_menu != null)