Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
MessengerPresenter.h
이 파일의 문서화 페이지로 가기
1#pragma once
2
3#include "CK_UE.h"
8#include "Containers/Ticker.h"
9#include "MessengerPresenter.generated.h"
10
11class APlayerController;
12class UMessengerData;
13class UTexture2D;
14class UWorld;
15struct FStreamableHandle;
16
17DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDialogOpenChanged, bool, bOpen);
18
19DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnDialogLineAdded, const FDT_MessengeTable&, Row, UTexture2D*, ProfileIcon, bool, bPlayer, bool, bAnimate);
20
21DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDialogSeparatorAdded, const FText&, Title);
22
23DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDialogCompleteChanged, bool, bComplete);
24
25DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnDialogViewRefreshRequested);
26
27
28// 대화 상태와 입력 수명은 C++, 파생 BP는 Input Action을 전달한다.
29UCLASS(BlueprintType, Blueprintable)
31{
32 GENERATED_BODY()
33
34public:
35 virtual void InitializePresenter(UUIManagementSubsystem* Subsystem) override;
36 virtual void DeinitializePresenter() override;
37 virtual void OnViewBound(UUserWidgetBase* View) override;
38 virtual void OnViewUnbound(UUserWidgetBase* View) override;
39 void OnViewStateChanged(UUserWidgetBase* View);
40
41 virtual bool ShouldReceiveStageEvent_Implementation(const FStageEventMessage& Message, const FInstancedStruct& ListenerContext) override;
42 virtual void HandleStageEvent_Implementation(const FStageEventMessage& Message, const FInstancedStruct& ListenerContext) override;
43
44 void SetDialogData(UMessengerData* InDialogData);
45 FText GetScenarioTitle(FName ScenarioID) const;
46 void ResolveLine(const FDT_MessengeTable& Row, UTexture2D*& ProfileIcon, bool& bPlayer) const;
47
48public:
49 // 외부에서 지정한 시나리오를 시작하고 대화창을 연다.
50 UFUNCTION(BlueprintCallable, Category = "Dialog")
51 bool StartScenario(FName ScenarioID);
52
53 // 플레이어가 대화 목록을 열거나 닫는다. 시나리오를 시작하지 않는다.
54 UFUNCTION(BlueprintCallable, Category = "Dialog")
55 void ToggleDialog();
56
57 UFUNCTION(BlueprintCallable, Category = "Dialog")
58 void AdvanceDialog();
59
60 UFUNCTION(BlueprintCallable, Category = "Dialog")
61 void SkipRemainingRows();
62
63 UFUNCTION(BlueprintCallable, Category = "Dialog|Input")
64 void BeginSkipHold();
65
66 UFUNCTION(BlueprintCallable, Category = "Dialog|Input")
67 void ConfirmSkipHold();
68
69 UFUNCTION(BlueprintCallable, Category = "Dialog|Input")
70 void CancelSkipHold();
71
72 UFUNCTION(BlueprintPure, Category = "Dialog")
73 bool IsDialogInputAvailable() const;
74
75 UFUNCTION(BlueprintPure, Category = "Dialog")
76 UUserWidgetBase* GetDialogView() const;
77
78public:
79 UFUNCTION(BlueprintPure, Category = "Dialog")
80 FORCEINLINE bool IsDialogOpen() const
81 {
82 return bDialogOpen;
83 }
84
85 UFUNCTION(BlueprintPure, Category = "Dialog")
86 FORCEINLINE bool IsDialogComplete() const
87 {
88 return bScenarioActive == false;
89 }
90
91 FORCEINLINE const TArray<FDT_MessengeTable>& GetHistory() const
92 {
93 return HistoryRows;
94 }
95
96public:
97 UPROPERTY(BlueprintAssignable, Category = "Dialog|Events")
98 FOnDialogOpenChanged OnDialogOpenChanged;
99
100 UPROPERTY(BlueprintAssignable, Category = "Dialog|Events")
101 FOnDialogLineAdded OnDialogLineAdded;
102
103 UPROPERTY(BlueprintAssignable, Category = "Dialog|Events")
104 FOnDialogSeparatorAdded OnDialogSeparatorAdded;
105
106 UPROPERTY(BlueprintAssignable, Category = "Dialog|Events")
107 FOnDialogCompleteChanged OnDialogCompleteChanged;
108
109 UPROPERTY(BlueprintAssignable, Category = "Dialog|Events")
110 FOnDialogViewRefreshRequested OnViewRefreshRequested;
111
112protected:
113 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialog")
114 TSoftObjectPtr<UMessengerData> DialogDataAsset;
115
116private:
117 UFUNCTION()
118 void RefreshInput();
119
120 void LoadDialogData();
121 void OnDialogDataLoaded(TSharedPtr<FStreamableHandle> Handle);
122 void InitializeRuntime();
123 void ResumeDialog();
124 void ReleaseRuntime();
125 void SetOpen(bool bNewOpen, bool bForceUpdate = false);
126 void TryStartScenario();
127 void ShowNextRow(bool bAnimate);
128 void ScheduleRowCompletion();
129 void CompleteCurrentRow();
130 void DispatchRowEndEvent(FName EventID);
131 void AddSeparator(FName ScenarioID);
132 void PresentRow(const FDT_MessengeTable& Row, bool bAnimate);
133
134private:
135 UPROPERTY(Transient)
136 TObjectPtr<UMessengerData> LoadedDialogData;
137
138 UPROPERTY(Transient)
139 FStageEventMessage CurrentScenarioMessage;
140
141private:
142 TSharedPtr<FStreamableHandle> DialogLoadHandle;
143 TWeakObjectPtr<APlayerController> DialogController;
144 TWeakObjectPtr<UUserWidgetBase> ActiveView;
145 TWeakObjectPtr<UWorld> ActiveWorld;
146
147 TArray<FDT_MessengeTable> DialogRows;
148 TArray<FDT_MessengeTable> ActiveRows;
149 TArray<FDT_MessengeTable> HistoryRows;
150
151 TSet<FName> CompletedScenarios;
152
153private:
154 FTSTicker::FDelegateHandle RowCompletionTicker;
155
156private:
157 int32 NextRowIndex = 0;
158 int32 PendingRowIndex = INDEX_NONE;
159 bool bRuntimeInitialized = false;
160 bool bDataReady = false;
161 bool bDialogOpen = false;
162 bool bScenarioActive = false;
163 bool bCompletingRow = false;
164 bool bSkipping = false;
165 bool bInputEnabled = false;
166 bool bSkipArmed = false;
167};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnDialogLineAdded, const FDT_MessengeTable &, Row, UTexture2D *, ProfileIcon, bool, bPlayer, bool, bAnimate)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDialogOpenChanged, bool, bOpen)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnDialogViewRefreshRequested)
Definition StageEventBehaviorInterface.h:22
Definition MessengerData.h:17
Definition MessengerPresenter.h:31
FORCEINLINE const TArray< FDT_MessengeTable > & GetHistory() const
Definition MessengerPresenter.h:91
Definition UIManagementSubsystem.h:28
Definition UserPresenterBase.h:19
Definition UserWidgetBase.h:35
Definition DT_MessengeTable.h:10
Definition StageEventMessage.h:14