screenUi -> popupUi 통합

This commit is contained in:
NTG_Lenovo 2025-07-22 13:09:38 +09:00
parent e8a7e1c289
commit 10dbd0dc62
2 changed files with 2 additions and 87 deletions

View File

@ -9,8 +9,6 @@ public static class GameEvents
public static TimeScaleChangeEvent RequestTimeScaleChangeEvent = new();
public static FadeInEvent FadeInEvent = new();
public static FadeOutEvent FadeOutEvent = new();
public static OpenScreenUiEvent OpenScreenUiEvent = new();
public static CloseScreenUiEvent CloseScreenUiEvent = new();
public static OpenPopupUiEvent OpenPopupUiEvent = new();
public static ClosePopupUiEvent ClosePopupUiEvent = new();
public static ShowGlobalMessageEvent RequestShowGlobalMessageEvent = new();
@ -56,16 +54,6 @@ public class ShowGlobalMessageEvent : IEvent
public float ShowDuration;
public float FadeDuration;
}
public class OpenScreenUiEvent : IEvent
{
public Type UiType;
}
public class CloseScreenUiEvent : IEvent
{
public Type UiType;
}
public class OpenPopupUiEvent : IEvent
{

View File

@ -4,18 +4,14 @@
namespace DDD
{
public class UiManager : Singleton<UiManager>, IManager, IEventHandler<OpenScreenUiEvent>, IEventHandler<CloseScreenUiEvent>,
IEventHandler<OpenPopupUiEvent>, IEventHandler<ClosePopupUiEvent>
public class UiManager : Singleton<UiManager>, IManager, IEventHandler<OpenPopupUiEvent>, IEventHandler<ClosePopupUiEvent>
{
private readonly Dictionary<Type, ScreenUi> _screenUIs = new();
private readonly Dictionary<Type, PopupUi> _popupUIs = new();
private readonly object _uiPauseRequester = new();
public void PreInit()
{
EventBus.Register<OpenScreenUiEvent>(this);
EventBus.Register<CloseScreenUiEvent>(this);
EventBus.Register<OpenPopupUiEvent>(this);
EventBus.Register<ClosePopupUiEvent>(this);
}
@ -32,27 +28,10 @@ public void PostInit()
private void OnDestroy()
{
EventBus.Unregister<OpenScreenUiEvent>(this);
EventBus.Unregister<CloseScreenUiEvent>(this);
EventBus.Unregister<OpenPopupUiEvent>(this);
EventBus.Unregister<ClosePopupUiEvent>(this);
}
public void RegisterScreenUI(ScreenUi ui)
{
var type = ui.GetType();
_screenUIs.TryAdd(type, ui);
}
public void UnregisterScreenUI(ScreenUi ui)
{
var type = ui.GetType();
if (_screenUIs.TryGetValue(type, out var value) && value == ui)
{
_screenUIs.Remove(type);
}
}
public void RegisterPopupUI(PopupUi ui)
{
var type = ui.GetType();
@ -68,58 +47,6 @@ public void UnregisterPopupUI(PopupUi ui)
}
}
private void CloseAllScreenUIs()
{
foreach (var screen in _screenUIs.Values)
{
if (screen.IsOpen)
{
screen.Close();
if (screen.IsBlockingTime)
{
var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent;
timeScaleChangeEvent.Requester = _uiPauseRequester;
timeScaleChangeEvent.NewTimeScale = 1f;
EventBus.Broadcast(timeScaleChangeEvent);
}
}
}
}
public void Invoke(OpenScreenUiEvent evt)
{
if (_screenUIs.TryGetValue(evt.UiType, out var screen))
{
CloseAllScreenUIs();
screen.Open();
if (screen.IsBlockingTime)
{
var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent;
timeScaleChangeEvent.Requester = screen;
timeScaleChangeEvent.NewTimeScale = 0f;
EventBus.Broadcast(timeScaleChangeEvent);
}
}
}
public void Invoke(CloseScreenUiEvent evt)
{
if (_screenUIs.TryGetValue(evt.UiType, out var screen))
{
screen.Close();
if (screen.IsBlockingTime)
{
var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent;
timeScaleChangeEvent.Requester = screen;
timeScaleChangeEvent.NewTimeScale = 1f;
EventBus.Broadcast(timeScaleChangeEvent);
}
}
}
public void Invoke(OpenPopupUiEvent evt)
{
if (_popupUIs.TryGetValue(evt.UiType, out var popup))
@ -138,7 +65,7 @@ public void Invoke(OpenPopupUiEvent evt)
public void Invoke(ClosePopupUiEvent evt)
{
if (_screenUIs.TryGetValue(evt.UiType, out var popup))
if (_popupUIs.TryGetValue(evt.UiType, out var popup))
{
popup.Close();