Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
UIManagementSubsystem.h
이 파일의 문서화 페이지로 가기
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "GameplayTagContainer.h"
7#include "Data/UI/UIContext.h"
9#include "Subsystems/GameInstanceSubsystem.h"
10#include "UIManagementSubsystem.generated.h"
11
12class UUILayer;
13class APlayerController;
14class UUserWidgetBase;
16class UPanelWidget;
17class UInputMappingContext;
18struct FUILayerConfig;
19
21
22
26UCLASS(BlueprintType)
27class CK_UE_API UUIManagementSubsystem : public UGameInstanceSubsystem, public IStreamingEventListenerInterface
28{
29 GENERATED_BODY()
30
31public:
33
34public:
35 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
36 virtual void Deinitialize() override;
37
38 virtual void OnLevelLoaded(ULevel* NewLevel, const ULevelStreamingData* LevelStreamingData) override { }
39
40 virtual void OnLevelUnloaded() override;
41
42 virtual void OnLevelStreamingStarted() override { }
43
44 virtual void OnLevelStreamingEnded() override { }
45
47 FGameplayTag GetActivePresenterInputLayer() const;
48
50 TArray<UUserWidgetBase*> GetBoundPresenterViews() const;
51
52 // PushToLayer_Implementation 에서 호출하는 직접 경로. BP 오버라이드를 거치지 않는다.
53 void PushWidgetDirect(UUserWidgetBase* Widget, int32 ZOrder, UUILayer*& OutLayer);
54
55#if WITH_EDITOR
56 void PrintAllLayers();
57#endif
58
59public:
60 // Presenter 클래스당 하나를 보관하며 여러 View가 상태를 공유한다.
61 UFUNCTION(BlueprintCallable, Category = "UI|Presenter", meta = (DeterminesOutputType = "PresenterClass"))
62 UUserPresenterBase* RequestPresenter(TSubclassOf<UUserPresenterBase> PresenterClass);
63
64 UFUNCTION(BlueprintPure, Category = "UI|Presenter", meta = (DeterminesOutputType = "PresenterClass"))
65 UUserPresenterBase* FindPresenter(TSubclassOf<UUserPresenterBase> PresenterClass) const;
66
68 UFUNCTION(BlueprintPure, Category = "UI|Presenter")
69 TArray<UUserWidgetBase*> GetWidgetsByPresenter(UUserPresenterBase* Presenter) const;
70
71 UFUNCTION(BlueprintCallable, Category = "UI|Presenter")
72 void ReleasePresenter(TSubclassOf<UUserPresenterBase> PresenterClass);
73
74 UFUNCTION(BlueprintCallable, Category = "UI|Presenter")
75 void RegisterWidgetView(UUserWidgetBase* View, TSubclassOf<UUserPresenterBase> PresenterClass);
76
77 UFUNCTION(BlueprintCallable, Category = "UI|Presenter")
78 void UnregisterWidgetView(UUserWidgetBase* View);
79
80 // 위젯을 생성해 레이어에 푸시한다.
81 // ParentPanel을 지정하면 Viewport 대신 해당 패널에 부착한다. 이 경우 ZOrder는 사용하지 않는다.
82 // Context.bActivateOnPush == true(기본값)이고 레이어가 보이는 상태면 Activate(), 숨김 상태면 Collapsed.
83 // Context.bActivateOnPush == false면 레이어 가시성과 무관하게 Activate()를 호출하지 않는다.
84 // Context.bCanIncludeInSnapshot == true면 체크포인트 롤백 시 Pop되도록 SnapshotSubsystem에 기록할 수 있다.
85 UFUNCTION(BlueprintCallable, Category = "UI")
86 UUserWidgetBase* PushWidget(const FUIContext& Context, AActor* OwningActor, UUILayer*& OutLayer, UPanelWidget* ParentPanel = nullptr);
87
88 // PushWidget 의 PlayerController 자동 주입 버전. 활성화 규칙은 PushWidget 과 동일.
89 UFUNCTION(BlueprintCallable, Category = "UI")
90 UUserWidgetBase* PushPlayerWidget(const FUIContext& Context, UUILayer*& OutLayer, UPanelWidget* ParentPanel = nullptr);
91
92 // 이미 생성된 위젯 인스턴스를 푸시한다. Widget->PushToLayer()를 통해 BP 오버라이드를 거친다.
93 UFUNCTION(BlueprintCallable, Category = "UI")
94 UUserWidgetBase* PushWidgetInstance(UUserWidgetBase* Widget, int32 ZOrder, UUILayer*& OutLayer);
95
96
97 UFUNCTION(BlueprintCallable, Category = "UI", meta = (DefaultToSelf = "Widget", HidePin = "Widget"))
98 bool PopWidget(UUserWidgetBase* Widget);
99
100 // 최상위 Popup 하나를 닫고, Popup이 없으면 PauseMenu를 연다.
101 UFUNCTION(BlueprintCallable, Category = "UI")
102 void HandleBackInput();
103
104 UFUNCTION(BlueprintCallable, Category = "UI", meta = (DefaultToSelf = "Widget"))
105 void PopWidgetFromLayer(UUserWidgetBase* Widget, UUILayer* Layer);
106
107 UFUNCTION(BlueprintCallable, Category = "UI")
108 void PopAllWidgetsInLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag);
109
110 UFUNCTION(BlueprintCallable, Category = "UI")
111 void PopAllLayer(bool WithPrimaryWidgets = false);
112
113 UFUNCTION(BlueprintCallable, Category = "UI")
114 UUILayer* GetLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag) const;
115
116 UFUNCTION(BlueprintCallable, Category = "UI")
117 UUserWidgetBase* FindFirstWidgetByArgs(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag, const TSubclassOf<UUserWidget> ClassType) const;
118
119 UFUNCTION(BlueprintCallable, Category = "UI")
120 UUserWidgetBase* FindFirstWidgetInLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag, const TSubclassOf<UUserWidget> ClassType, bool& Valid) const;
121
122 UFUNCTION(BlueprintCallable, Category = "UI")
123 UUILayer* GetTopLayer() const;
124
125 UFUNCTION(BlueprintCallable, Category = "UI")
126 UUILayer* GetRootLayer() const;
127
128 UFUNCTION(BlueprintCallable, Category = "UI")
129 UUILayer* CreateLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag, TSubclassOf<UUILayer> LayerClass = nullptr);
130
131 UFUNCTION(BlueprintCallable, Category = "UI")
132 void RemoveLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag);
133
134 UFUNCTION(BlueprintCallable, Category = "UI")
135 void ShowLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag);
136
137 UFUNCTION(BlueprintCallable, Category = "UI")
138 void HideLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag LayerTag);
139
140 UFUNCTION(BlueprintCallable, Category = "UI")
141 void ClearAllLayers();
142
143 // 현재 입력 설정을 결정하는 표시 중인 최상위 레이어.
144 UFUNCTION(BlueprintPure, Category = "UI|Input")
145 FGameplayTag GetActiveInputLayer() const;
146
147 UFUNCTION(BlueprintPure, Category = "UI|Input")
148 UInputMappingContext* GetUIInputMappingContext() const;
149
151 UFUNCTION(BlueprintPure, Category = "UI")
152 int32 GetWidgetCountInLayer(UPARAM(meta = (Categories = "UI.Layer")) FGameplayTag UILayerTag, bool bIncludeHiddenWidgets = true) const;
153
154public:
156 UFUNCTION(BlueprintPure, Category = "UI|Presenter")
157 FORCEINLINE TArray<UUserWidgetBase*> GetWidgetsByPresenterClass(TSubclassOf<UUserPresenterBase> PresenterClass) const
158 {
159 return GetWidgetsByPresenter(FindPresenter(PresenterClass));
160 }
161
162
164 FORCEINLINE TArray<UUILayer*> GetLayers() const
165 {
166 return LayerStack;
167 }
168
169
170 FORCEINLINE FOnInputLayerChanged& GetOnInputLayerChanged()
171 {
172 return OnInputLayerChanged;
173 }
174
175private:
176 // 푸시 단일 진입점. 레이어 확보 → 패널 또는 뷰포트 부착 → 활성화(bActivateOnPush && 레이어 보임 → Activate(),
177 // bActivateOnPush && 레이어 숨김 → Collapsed, !bActivateOnPush → 아무것도 안 함) → 입력 모드 갱신.
178 UUserWidgetBase* PushWidgetToLayer(UUserWidgetBase* Widget, FGameplayTag LayerTag, int32 ZOrder, UUILayer*& OutLayer, bool bActivateOnPush = true, bool bCanIncludeInSnapshot = false, UPanelWidget* ParentPanel = nullptr);
179 UUILayer* GetOrCreateLayer(FGameplayTag LayerTag);
180 void RefreshLayerState();
181 UUserWidgetBase* GetTopVisiblePopupWidget() const;
182 void HandleWidgetVisibilityChanged(ESlateVisibility InVisibility);
183
184 // 최상위 레이어가 요구하는 배율을 TimeManagementSubsystem 에 반영한다.
185 void ApplyLayerTimeScale(float LayerTimeScale);
186
187 // 현재 최상위 레이어가 요구하는 전역 시간 배율.
188 float GetActiveLayerTimeScale() const;
189
190 // 다른 시스템이 시간을 되돌렸을 때, 아직 떠 있는 레이어의 요구를 다시 주장한다.
191 void HandleTimeScaleRaised(float NewTimeScale);
192
193 void BindWidgetPresenter(UUserWidgetBase* View, TSubclassOf<UUserPresenterBase> PresenterClass);
194
195 void UnbindWidgetPresenter(UUserWidgetBase* View);
196
197private:
198 UPROPERTY(BlueprintAssignable, Category = "UI|Input", meta = (AllowPrivateAccess = "true"))
199 FOnInputLayerChanged OnInputLayerChanged;
200
201private:
202 UPROPERTY(Transient)
203 TMap<TSubclassOf<UUserPresenterBase>, TObjectPtr<UUserPresenterBase>> WidgetPresenters;
204
205 UPROPERTY(Transient)
206 TArray<TObjectPtr<UUILayer>> LayerStack;
207
208private:
209 TMap<TWeakObjectPtr<UUserWidgetBase>, TSubclassOf<UUserPresenterBase>> WidgetViews;
210 TMap<TWeakObjectPtr<UUserWidgetBase>, TWeakObjectPtr<UUserPresenterBase>> BoundWidgetViews;
211 TSet<TWeakObjectPtr<UUserWidgetBase>> UnbindingWidgetViews;
212 TSet<TSubclassOf<UUserPresenterBase>> InitializingPresenters;
213 TSet<TSubclassOf<UUserPresenterBase>> ReleasingPresenters;
214
215private:
216 bool bPresenterShutdown = false;
217};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInputLayerChanged)
Definition StreamingEventListenerInterface.h:23
Definition LevelStreamingData.h:17
Definition UILayer.h:14
Definition UIManagementSubsystem.h:28
virtual void OnLevelLoaded(ULevel *NewLevel, const ULevelStreamingData *LevelStreamingData) override
Definition UIManagementSubsystem.h:38
FORCEINLINE FOnInputLayerChanged & GetOnInputLayerChanged()
Definition UIManagementSubsystem.h:170
virtual void OnLevelStreamingEnded() override
Definition UIManagementSubsystem.h:44
virtual void OnLevelStreamingStarted() override
Definition UIManagementSubsystem.h:42
FORCEINLINE TArray< UUILayer * > GetLayers() const
Definition UIManagementSubsystem.h:164
Definition UserPresenterBase.h:19
Definition UserWidgetBase.h:35
Definition UIContext.h:10
Definition UISettings.h:18