Add OverviewMenu escape menu, remove Tab mode cycling
- New OverviewMenu component: Esc toggles the pause overlay, buttons switch modes via GameModeManager.TrySwitchTo<T>() and close the panel; visibility follows the role-scoped mode set, active mode disabled. - Esc in paint mode exits to camera mode instead (PlayerControlMode, hunter falls back to FirstPersonMode) rather than opening the menu. - Centralized all Esc handling in OverviewMenu (browser close included) to avoid frame races; OnlineSessionBrowserUI gains IsOpen/Open/Close. - GameModeManager: switchKey Tab-cycle removed, TrySwitchTo<T> added. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
367bc9cee0
commit
7ac6038121
4 files changed
+239
-53
No files matched your search
@@ -3,9 +3,6 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// uGUI binding for <see cref="OnlineSessionManager"/>: Host / Refresh / row select / Join / Disconnect
|
||||
@@ -13,13 +10,15 @@ using UnityEngine.InputSystem;
|
||||
/// <see cref="OnlineSessionManager.SessionsChanged"/> events; the session logic stays on the manager.
|
||||
///
|
||||
/// The panel is always shown in Main (not connected); once a connection is up it hides, and in the
|
||||
/// lobby/map Esc toggles it back as a modal pause overlay (cursor freed, gameplay suspended via
|
||||
/// <see cref="GameModeManager.SetPaused"/>). It also auto-opens when the Resolution sub-phase begins so
|
||||
/// lobby/map the overview (Esc) menu reopens it via <see cref="Open"/> as a modal pause overlay
|
||||
/// (cursor freed, gameplay suspended via <see cref="GameModeManager.SetPaused"/>) - all Esc key
|
||||
/// handling lives in <see cref="OverviewMenu"/>, which closes this overlay through <see cref="Close"/>.
|
||||
/// It also auto-opens when the Resolution sub-phase begins so
|
||||
/// the final match scoreboard (a section of this panel) is presented. The Disconnect button is
|
||||
/// context-sensitive: in Main it is an
|
||||
/// application "Exit"; on the map it becomes "Back to Lobby" for the match authority (ends the match);
|
||||
/// everyone else gets a plain disconnect. Only the visual <see cref="panelRoot"/> is toggled - this binder
|
||||
/// stays alive on its (always-active) canvas so it keeps reading Esc while the panel is hidden.
|
||||
/// stays alive on its (always-active) canvas so it keeps tracking state while the panel is hidden.
|
||||
/// </summary>
|
||||
public class OnlineSessionBrowserUI : MonoBehaviour
|
||||
{
|
||||
@@ -41,8 +40,8 @@ public class OnlineSessionBrowserUI : MonoBehaviour
|
||||
[SerializeField] private TMP_Text statusLabel;
|
||||
|
||||
[Header("Overlay")]
|
||||
[Tooltip("Visual container toggled by Esc while connected (the panel root). Must be a CHILD of this " +
|
||||
"binder's object so the binder keeps running - and reading Esc - while the panel is hidden.")]
|
||||
[Tooltip("Visual container toggled while connected (the panel root). Must be a CHILD of this " +
|
||||
"binder's object so the binder keeps running while the panel is hidden.")]
|
||||
[SerializeField] private GameObject panelRoot;
|
||||
|
||||
[Tooltip("Background tint of the selected row.")]
|
||||
@@ -58,7 +57,7 @@ public class OnlineSessionBrowserUI : MonoBehaviour
|
||||
private GameModeManager _gameMode; // pause hook for the modal overlay; found at runtime
|
||||
private TMP_Text _disconnectLabel; // disconnect button caption (relabelled to "Back to Lobby")
|
||||
|
||||
private bool _open; // Esc-toggled visibility while connected
|
||||
private bool _open; // overlay visibility while connected (toggled via Open/Close)
|
||||
private bool _connected; // last-seen connection state (to detect transitions)
|
||||
private Scene _lastScene; // last-seen active scene (to auto-close on a scene change)
|
||||
private string _disconnectText; // last applied caption (avoids per-frame TMP churn)
|
||||
@@ -123,10 +122,10 @@ public class OnlineSessionBrowserUI : MonoBehaviour
|
||||
SetOpen(false);
|
||||
_lastScene = scene;
|
||||
|
||||
if (!connected) return; // Main: panel always shown, Esc ignored
|
||||
if (!connected) return; // Main: panel always shown
|
||||
|
||||
// Resolution just began -> auto-open the overlay so the final scoreboard is presented. Esc can
|
||||
// still close it; the lobby scene swap afterwards auto-closes it (see above).
|
||||
// still close it (via the overview menu); the lobby scene swap afterwards auto-closes it (see above).
|
||||
MatchManager.MatchSubPhase subPhase = _match ? _match.LocalSubPhase : MatchManager.MatchSubPhase.None;
|
||||
if (subPhase != _lastSubPhase)
|
||||
{
|
||||
@@ -135,13 +134,25 @@ public class OnlineSessionBrowserUI : MonoBehaviour
|
||||
SetOpen(true);
|
||||
}
|
||||
|
||||
bool inLobbyOrMap = _match && (_match.IsLocalSceneLobby || _match.IsLocalSceneMap);
|
||||
if (inLobbyOrMap && EscapePressed())
|
||||
SetOpen(!_open);
|
||||
|
||||
RefreshDisconnectLabel();
|
||||
}
|
||||
|
||||
/// <summary>True while the modal overlay is open on a live connection (the always-shown Main panel
|
||||
/// does not count). The overview menu yields Esc to this overlay while it is open.</summary>
|
||||
public bool IsOpen => _open;
|
||||
|
||||
/// <summary>Opens the modal overlay (used by the overview menu's Session button); false when
|
||||
/// not connected - in Main the panel is always visible and never a pause overlay.</summary>
|
||||
public bool Open()
|
||||
{
|
||||
if (!(manager && manager.IsConnected)) return false;
|
||||
SetOpen(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Closes the modal overlay and resumes gameplay (Esc handling in <see cref="OverviewMenu"/>).</summary>
|
||||
public void Close() => SetOpen(false);
|
||||
|
||||
private void OnHost() { if (manager) manager.Host(); }
|
||||
private void OnRefresh() { if (manager) manager.Refresh(); }
|
||||
private void OnJoin() { if (manager && !string.IsNullOrEmpty(_selectedId)) manager.Join(_selectedId); }
|
||||
@@ -308,13 +319,4 @@ public class OnlineSessionBrowserUI : MonoBehaviour
|
||||
return t ? t.GetComponent<TMP_Text>() : null;
|
||||
}
|
||||
|
||||
// NOT TypingGuard-gated (GameplayKeyPressed): Esc must close the panel even while a text field has focus.
|
||||
private static bool EscapePressed()
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
return InputUtil.KeyPressedThisFrame(Key.Escape);
|
||||
#else
|
||||
return InputUtil.KeyPressedThisFrame(KeyCode.Escape);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user