Complete Match Results modal: standalone overlay, auto-open on resolution

MatchResultScreen becomes a self-contained modal (IsOpen/Open/Close,
_panelRoot, pause handling); resolution auto-open moves there from the
session browser. OverviewMenu integrates it into the Esc chain and hides
the Match Results button until results exist (same pattern as the
role-scoped mode buttons).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Fable 5 committed 2026-07-12 12:55:05 +02:00
1 parent fdb562bba5
commit 7669ae1b66
3 files changed
+101 -28

No files matched your search

+30 -7
View File
@@ -8,10 +8,10 @@ using UnityEngine.InputSystem;
/// <summary>
/// The Esc overview menu (the "Overview UI" canvas in Main). Owns ALL Escape handling: Esc toggles
/// this panel as a modal pause overlay (gameplay suspended via <see cref="GameModeManager.SetPaused"/>);
/// while the session browser overlay is open instead, Esc closes that, and while paint mode is active
/// Esc exits to the camera mode (Player Control, or First Person for the hunter). Buttons switch game modes
/// (via <see cref="GameModeManager.TrySwitchTo{T}"/>) or open the session browser, and every click
/// closes the panel. Mode buttons are only shown for modes present in the current role-scoped set
/// while the session browser or match results overlay is open instead, Esc closes that, and while paint
/// mode is active Esc exits to the camera mode (Player Control, or First Person for the hunter). Buttons
/// switch game modes (via <see cref="GameModeManager.TrySwitchTo{T}"/>) or open the session browser /
/// match results overlay, and every click closes the panel. Mode buttons are only shown for modes present in the current role-scoped set
/// (<see cref="GameModeManager.Modes"/>); the active mode's button is disabled. Attach to the
/// always-active canvas root; <see cref="panelRoot"/> is the toggled visual child.
/// </summary>
@@ -24,6 +24,10 @@ public class OverviewMenu : MonoBehaviour
"stays closed. Empty = found automatically.")]
[SerializeField] private OnlineSessionBrowserUI sessionBrowser;
[Tooltip("Match results screen binder. While its overlay is open it owns Esc (close-only) and this " +
"menu stays closed. Empty = found automatically.")]
[SerializeField] private MatchResultScreen matchResultScreen;
[Header("Panel")]
[Tooltip("Visual container toggled by Esc. Must be a CHILD of this binder's object so the binder " +
"keeps reading Esc while the panel is hidden.")]
@@ -31,6 +35,7 @@ public class OverviewMenu : MonoBehaviour
[Header("Buttons")]
[SerializeField] private Button sessionButton;
[SerializeField] private Button matchResultButton;
[Tooltip("Enters Player Control (third-person orbit) mode.")]
[SerializeField] private Button playerControlButton;
[SerializeField] private Button paintButton;
@@ -43,12 +48,14 @@ public class OverviewMenu : MonoBehaviour
{
if (!gameMode) gameMode = FindFirstObjectByType<GameModeManager>();
if (!sessionBrowser) sessionBrowser = FindFirstObjectByType<OnlineSessionBrowserUI>();
if (!matchResultScreen) matchResultScreen = FindFirstObjectByType<MatchResultScreen>();
if (panelRoot) panelRoot.SetActive(false);
}
private void OnEnable()
{
if (sessionButton) sessionButton.onClick.AddListener(OnSession);
if (matchResultButton) matchResultButton.onClick.AddListener(OnMatchResult);
if (playerControlButton) playerControlButton.onClick.AddListener(OnPlayerControl);
if (paintButton) paintButton.onClick.AddListener(OnPaint);
if (firstPersonButton) firstPersonButton.onClick.AddListener(OnFirstPerson);
@@ -58,6 +65,7 @@ public class OverviewMenu : MonoBehaviour
private void OnDisable()
{
if (sessionButton) sessionButton.onClick.RemoveListener(OnSession);
if (matchResultButton) matchResultButton.onClick.RemoveListener(OnMatchResult);
if (playerControlButton) playerControlButton.onClick.RemoveListener(OnPlayerControl);
if (paintButton) paintButton.onClick.RemoveListener(OnPaint);
if (firstPersonButton) firstPersonButton.onClick.RemoveListener(OnFirstPerson);
@@ -67,12 +75,13 @@ public class OverviewMenu : MonoBehaviour
private void Update()
{
bool browserOpen = sessionBrowser && sessionBrowser.IsOpen;
bool resultsOpen = matchResultScreen && matchResultScreen.IsOpen;
if (_open)
{
// The browser overlay took over (its Resolution auto-open) -> hide this panel; the pause
// is the browser's now, so don't release it.
if (browserOpen)
// Another overlay took over (results Resolution auto-open) -> hide this panel; the pause
// is that overlay's now, so don't release it.
if (browserOpen || resultsOpen)
HidePanel();
// An external state reset (respawn/bind, disconnect) dropped the pause underneath the
// open panel -> don't linger as a stale overlay over live gameplay.
@@ -84,6 +93,8 @@ public class OverviewMenu : MonoBehaviour
if (browserOpen)
sessionBrowser.Close();
else if (resultsOpen)
matchResultScreen.Close();
else if (_open)
Close(resume: true);
// Paint mode: Esc exits back to the camera mode instead of opening the menu. Player Control
@@ -129,6 +140,13 @@ public class OverviewMenu : MonoBehaviour
gameMode.SetPaused(false);
}
private void OnMatchResult()
{
Close(resume: false);
if (!(matchResultScreen && matchResultScreen.Open()) && gameMode)
gameMode.SetPaused(false);
}
private void OnPlayerControl() => SwitchMode<PlayerControlMode>();
private void OnPaint() => SwitchMode<PaintMode>();
private void OnFirstPerson() => SwitchMode<FirstPersonMode>();
@@ -151,6 +169,11 @@ public class OverviewMenu : MonoBehaviour
IReadOnlyList<GameMode> modes = gameMode.Modes;
GameMode active = gameMode.EffectiveMode;
// Match results only exist from the first Hide phase on - hide the button until then
// (same pattern as the role-scoped mode buttons).
if (matchResultButton)
matchResultButton.gameObject.SetActive(matchResultScreen && matchResultScreen.HasResults);
SetModeButton<PlayerControlMode>(playerControlButton, modes, active);
SetModeButton<PaintMode>(paintButton, modes, active);
SetModeButton<FirstPersonMode>(firstPersonButton, modes, active);