Restructured for new direction.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace BriarQueen.Framework.Managers.UI.Base
|
||||
{
|
||||
public interface IUIBackHandler
|
||||
{
|
||||
bool HandleBackRequest();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18b01f6ab9d3468ba9a99360acbe4e5c
|
||||
timeCreated: 1778300000
|
||||
@@ -57,7 +57,18 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
|
||||
private bool _useVirtualCursor;
|
||||
|
||||
public CursorStyleEntry CurrentStyleEntry => _styleMap[_currentStyle];
|
||||
public CursorStyleEntry CurrentStyleEntry
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TryGetStyleEntry(GetEffectiveStyle(), out var entry))
|
||||
{
|
||||
return entry;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private void Construct(EventCoordinator eventCoordinator)
|
||||
@@ -192,6 +203,22 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
return _isStyleOverridden ? _currentStyleOverride : _currentStyle;
|
||||
}
|
||||
|
||||
private bool TryGetStyleEntry(CursorStyle style, out CursorStyleEntry entry)
|
||||
{
|
||||
if (_styleMap.TryGetValue(style, out entry))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_styleMap.TryGetValue(CursorStyle.Default, out entry))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
entry = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ApplyVirtualCursorStyle(CursorStyle style)
|
||||
{
|
||||
if (_virtualCursorImage == null)
|
||||
@@ -282,4 +309,4 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
public Vector2 TooltipOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Extensions;
|
||||
using BriarQueen.Framework.Managers.Interaction;
|
||||
using BriarQueen.Framework.Managers.IO;
|
||||
using BriarQueen.Framework.Managers.Player;
|
||||
using BriarQueen.Framework.Managers.UI.Base;
|
||||
using BriarQueen.Framework.Managers.UI.Events;
|
||||
using BriarQueen.Framework.Services.Settings;
|
||||
@@ -28,6 +29,7 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
private readonly InteractManager _interactManager;
|
||||
private readonly SaveManager _saveManager;
|
||||
private readonly SettingsService _settingsService;
|
||||
private readonly PlayerManager _playerManager;
|
||||
|
||||
private readonly Dictionary<WindowType, IUIWindow> _windows = new();
|
||||
private readonly Stack<IUIWindow> _windowStack = new();
|
||||
@@ -46,12 +48,14 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
EventCoordinator eventCoordinator,
|
||||
InteractManager interactManager,
|
||||
SettingsService settingsService,
|
||||
SaveManager saveManager)
|
||||
SaveManager saveManager,
|
||||
PlayerManager playerManager)
|
||||
{
|
||||
_eventCoordinator = eventCoordinator;
|
||||
_interactManager = interactManager;
|
||||
_settingsService = settingsService;
|
||||
_saveManager = saveManager;
|
||||
_playerManager = playerManager;
|
||||
}
|
||||
|
||||
private IUIWindow ActiveWindow => _windowStack.Count > 0 ? _windowStack.Peek() : null;
|
||||
@@ -84,6 +88,7 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
private void SubscribeToEvents()
|
||||
{
|
||||
_eventCoordinator.Subscribe<PauseButtonClickedEvent>(OnPauseClickReceived);
|
||||
_eventCoordinator.Subscribe<UIBackRequestedEvent>(OnBackRequested);
|
||||
_eventCoordinator.Subscribe<ToggleCodexEvent>(ToggleCodexWindow);
|
||||
_eventCoordinator.Subscribe<UIToggleSettingsWindow>(ToggleSettingsWindow);
|
||||
_eventCoordinator.Subscribe<FadeEvent>(OnFadeEvent);
|
||||
@@ -97,6 +102,7 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
private void UnsubscribeFromEvents()
|
||||
{
|
||||
_eventCoordinator.Unsubscribe<PauseButtonClickedEvent>(OnPauseClickReceived);
|
||||
_eventCoordinator.Unsubscribe<UIBackRequestedEvent>(OnBackRequested);
|
||||
_eventCoordinator.Unsubscribe<ToggleCodexEvent>(ToggleCodexWindow);
|
||||
_eventCoordinator.Unsubscribe<UIToggleSettingsWindow>(ToggleSettingsWindow);
|
||||
_eventCoordinator.Unsubscribe<FadeEvent>(OnFadeEvent);
|
||||
@@ -175,13 +181,18 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
{
|
||||
if (_windowStack.Count > 0)
|
||||
{
|
||||
CloseTopWindow();
|
||||
TryHandleBackRequest();
|
||||
return;
|
||||
}
|
||||
|
||||
OpenWindow(WindowType.PauseMenuWindow);
|
||||
}
|
||||
|
||||
private void OnBackRequested(UIBackRequestedEvent _)
|
||||
{
|
||||
TryHandleBackRequest();
|
||||
}
|
||||
|
||||
private void ToggleSettingsWindow(UIToggleSettingsWindow eventData)
|
||||
{
|
||||
if (eventData.Show)
|
||||
@@ -192,6 +203,9 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
|
||||
private void ToggleCodexWindow(ToggleCodexEvent eventData)
|
||||
{
|
||||
if(!_playerManager.CodexUnlocked())
|
||||
return;
|
||||
|
||||
if (eventData.Shown)
|
||||
OpenWindow(WindowType.CodexWindow);
|
||||
else
|
||||
@@ -231,7 +245,7 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
{
|
||||
return codexType switch
|
||||
{
|
||||
CodexType.BookEntry => "You've acquired a new document.",
|
||||
CodexType.DocumentEntry => "You've acquired a new document.",
|
||||
CodexType.PuzzleClue => "You've acquired a new puzzle clue.",
|
||||
CodexType.Photo => "You've acquired a new photo.",
|
||||
_ => string.Empty
|
||||
@@ -246,10 +260,14 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
if (!_settingsService.AreTutorialsEnabled())
|
||||
return;
|
||||
|
||||
var duration = 3f;
|
||||
var tutorialText = TutorialPopupTexts.AllPopups[eventData.TutorialID];
|
||||
if (string.IsNullOrWhiteSpace(eventData.ResolvedText))
|
||||
{
|
||||
Debug.LogWarning($"[UIManager] Empty resolved text for tutorial '{eventData.TutorialID}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
_tutorialPopup.Play(tutorialText, duration).Forget();
|
||||
var duration = _settingsService?.Game?.PopupDisplayDuration ?? 3f;
|
||||
_tutorialPopup.Play(eventData.ResolvedText, duration).Forget();
|
||||
}
|
||||
|
||||
private void OnDisplayInteractText(DisplayInteractEvent eventData)
|
||||
@@ -340,6 +358,21 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
CloseTopWindowInternal().Forget();
|
||||
}
|
||||
|
||||
private void TryHandleBackRequest()
|
||||
{
|
||||
if (_disposed || _windowStack.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveWindow is IUIBackHandler backHandler && backHandler.HandleBackRequest())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CloseTopWindow();
|
||||
}
|
||||
|
||||
private async UniTask CloseTopWindowInternal()
|
||||
{
|
||||
if (_disposed || _windowStack.Count == 0)
|
||||
@@ -431,4 +464,4 @@ namespace BriarQueen.Framework.Managers.UI
|
||||
_eventCoordinator.Publish(new UIStackChangedEvent(_windowStack.Count > 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user