Working pause menu re-worked with exlusive views
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem
|
||||
{
|
||||
public class BackpackInput : MonoBehaviour, ITouchInputConsumer
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnTap(Vector2 position)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void OnHoldStart(Vector2 position)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void OnHoldMove(Vector2 position)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void OnHoldEnd(Vector2 position)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7ea50a695c58944799b4f27a9014301
|
||||
@@ -44,9 +44,6 @@ namespace UI.CardSystem
|
||||
backpackButton.onClick.AddListener(OnBackpackButtonClicked);
|
||||
}
|
||||
|
||||
// Initially show only the backpack icon
|
||||
ShowOnlyBackpackIcon();
|
||||
|
||||
// Hide notification dot initially
|
||||
if (boosterNotificationDot != null)
|
||||
boosterNotificationDot.gameObject.SetActive(false);
|
||||
@@ -57,6 +54,9 @@ namespace UI.CardSystem
|
||||
|
||||
private void InitializePostBoot()
|
||||
{
|
||||
// Initially show only the backpack icon
|
||||
ShowOnlyBackpackIcon();
|
||||
|
||||
// Initialize pages and hide them
|
||||
InitializePages();
|
||||
}
|
||||
@@ -142,10 +142,6 @@ namespace UI.CardSystem
|
||||
if (notificationSound != null)
|
||||
notificationSound.Play();
|
||||
|
||||
// Eat input so the characters don't walk around
|
||||
var backpackInput = backpackIcon.gameObject.GetComponentInParent<BackpackInput>();
|
||||
InputManager.Instance.RegisterOverrideConsumer(backpackInput);
|
||||
|
||||
PageController.PushPage(mainMenuPage);
|
||||
|
||||
// Clear notification for unseen cards when opening menu
|
||||
@@ -159,6 +155,8 @@ namespace UI.CardSystem
|
||||
{
|
||||
backpackButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
GameManager.Instance.RequestPause(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -170,8 +168,6 @@ namespace UI.CardSystem
|
||||
if (newPage == null)
|
||||
{
|
||||
ShowOnlyBackpackIcon();
|
||||
var backpackInput = backpackIcon.gameObject.GetComponentInParent<BackpackInput>();
|
||||
InputManager.Instance.UnregisterOverrideConsumer(backpackInput);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -225,6 +221,8 @@ namespace UI.CardSystem
|
||||
boosterNotificationDot.gameObject.SetActive(hasBooters || _hasUnseenCards);
|
||||
}
|
||||
}
|
||||
|
||||
GameManager.Instance.ReleasePause(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace UI
|
||||
public class PauseMenu : UIPage
|
||||
{
|
||||
private static PauseMenu _instance;
|
||||
private static bool _isQuitting;
|
||||
|
||||
/// <summary>
|
||||
/// Singleton instance of the PauseMenu. No longer creates an instance if one doesn't exist.
|
||||
@@ -64,11 +63,6 @@ namespace UI
|
||||
SceneManagerService.Instance.SceneLoadCompleted -= SetPauseMenuByLevel;
|
||||
}
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
_isQuitting = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the pause menu game object active or inactive based on the current level
|
||||
@@ -76,7 +70,7 @@ namespace UI
|
||||
/// <param name="levelName">The name of the level/scene</param>
|
||||
public void SetPauseMenuByLevel(string levelName)
|
||||
{
|
||||
HidePauseMenu(false);
|
||||
HidePauseMenu();
|
||||
// TODO: Implement level-based pause menu visibility logic if needed
|
||||
/*if (string.IsNullOrEmpty(levelName))
|
||||
return;
|
||||
@@ -94,7 +88,6 @@ namespace UI
|
||||
/// </summary>
|
||||
public void ShowPauseMenu()
|
||||
{
|
||||
if (GameManager.Instance.IsPaused) return;
|
||||
if (UIPageController.Instance != null)
|
||||
{
|
||||
UIPageController.Instance.PushPage(this);
|
||||
@@ -119,7 +112,7 @@ namespace UI
|
||||
/// <summary>
|
||||
/// Hides the pause menu and shows the pause button. Sets input mode to Game.
|
||||
/// </summary>
|
||||
public void HidePauseMenu(bool resetInput = true)
|
||||
public void HidePauseMenu()
|
||||
{
|
||||
if (!GameManager.Instance.IsPaused)
|
||||
{
|
||||
@@ -139,7 +132,7 @@ namespace UI
|
||||
pauseMenuPanel.SetActive(false);
|
||||
if (pauseButton != null)
|
||||
pauseButton.SetActive(true);
|
||||
EndPauseSideEffects(resetInput);
|
||||
EndPauseSideEffects();
|
||||
if (canvasGroup != null)
|
||||
{
|
||||
canvasGroup.alpha = 0f;
|
||||
@@ -161,15 +154,13 @@ namespace UI
|
||||
private void BeginPauseSideEffects()
|
||||
{
|
||||
if (pauseButton != null) pauseButton.SetActive(false);
|
||||
InputManager.Instance.SetInputMode(InputMode.UI);
|
||||
GameManager.Instance.RequestPause(this);;
|
||||
GameManager.Instance.RequestPause(this);
|
||||
Logging.Debug("[PauseMenu] Game Paused");
|
||||
}
|
||||
|
||||
private void EndPauseSideEffects(bool invokeEvent)
|
||||
private void EndPauseSideEffects()
|
||||
{
|
||||
if (pauseButton != null) pauseButton.SetActive(true);
|
||||
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
|
||||
GameManager.Instance.ReleasePause(this);
|
||||
Logging.Debug("[PauseMenu] Game Resumed");
|
||||
}
|
||||
@@ -178,6 +169,8 @@ namespace UI
|
||||
{
|
||||
// Ensure the panel root is active
|
||||
if (pauseMenuPanel != null) pauseMenuPanel.SetActive(true);
|
||||
// Pause side effects should run immediately (hide button, set input mode, etc.).
|
||||
// The tween itself must run in unscaled time so it still animates while the game is paused.
|
||||
BeginPauseSideEffects();
|
||||
|
||||
if (canvasGroup != null)
|
||||
@@ -185,7 +178,16 @@ namespace UI
|
||||
canvasGroup.interactable = true;
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
canvasGroup.alpha = 0f;
|
||||
Tween.Value(0f, 1f, v => canvasGroup.alpha = v, transitionDuration, 0f, Tween.EaseInOut, Tween.LoopType.None, null, onComplete);
|
||||
// pass obeyTimescale = false so this tween runs even when Time.timeScale == 0
|
||||
Tween.Value(0f, 1f, (v) =>
|
||||
{
|
||||
Logging.Debug($"[PauseMenu] Tweening pause menu alpha: {v}");
|
||||
canvasGroup.alpha = v;
|
||||
}, transitionDuration, 0f, Tween.EaseInOut, Tween.LoopType.None, null, () =>
|
||||
{
|
||||
Logging.Debug("[PauseMenu] Finished tweening pause menu in.");
|
||||
onComplete?.Invoke();
|
||||
}, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -199,16 +201,17 @@ namespace UI
|
||||
{
|
||||
canvasGroup.interactable = false;
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
// Run out-tween in unscaled time as well so the fade completes while paused.
|
||||
Tween.Value(canvasGroup.alpha, 0f, v => canvasGroup.alpha = v, transitionDuration, 0f, Tween.EaseInOut, Tween.LoopType.None, null, () =>
|
||||
{
|
||||
EndPauseSideEffects(true);
|
||||
if (pauseMenuPanel != null) pauseMenuPanel.SetActive(false);
|
||||
onComplete?.Invoke();
|
||||
});
|
||||
{
|
||||
EndPauseSideEffects();
|
||||
if (pauseMenuPanel != null) pauseMenuPanel.SetActive(false);
|
||||
onComplete?.Invoke();
|
||||
}, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
EndPauseSideEffects(true);
|
||||
EndPauseSideEffects();
|
||||
if (pauseMenuPanel != null) pauseMenuPanel.SetActive(false);
|
||||
onComplete?.Invoke();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user