A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueEvent_Details.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4#include "IDetailPropertyRow.h"
5#include "IPropertyUtilities.h"
6#include "IDetailChildrenBuilder.h"
7
8#include "Nodes/DlgNode.h"
14#include "DlgHelper.h"
17
18#define LOCTEXT_NAMESPACE "DialogueEvent_Details"
19
21// FDialogueCustomEventization
22void FDialogueEvent_Details::CustomizeHeader(TSharedRef<IPropertyHandle> InStructPropertyHandle,
23 FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
24{
25 StructPropertyHandle = InStructPropertyHandle;
27 PropertyUtils = StructCustomizationUtils.GetPropertyUtilities();
28
29 // Cache the Property Handle for the EventType
30 ParticipantNamePropertyHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, ParticipantName));
31 EventTypePropertyHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, EventType));
32 check(ParticipantNamePropertyHandle.IsValid());
33 check(EventTypePropertyHandle.IsValid());
34
35 // Register handler for event type change
36 EventTypePropertyHandle->SetOnPropertyValueChanged(
37 FSimpleDelegate::CreateSP(this, &Self::OnEventTypeChanged, true)
38 );
39
40 const bool bShowOnlyInnerProperties = StructPropertyHandle->GetProperty()->HasMetaData(META_ShowOnlyInnerProperties);
41 if (!bShowOnlyInnerProperties)
42 {
43 HeaderRow.NameContent()
44 [
45 StructPropertyHandle->CreatePropertyNameWidget()
46 ];
47 }
48}
49
50void FDialogueEvent_Details::CustomizeChildren(TSharedRef<IPropertyHandle> InStructPropertyHandle,
51 IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
52{
53 const bool bHasDialogue = Dialogue != nullptr;
54
55
56 // Common ParticipantName
57 {
58 FDetailWidgetRow* DetailWidgetRow = &StructBuilder.AddCustomRow(LOCTEXT("ParticipantNameSearchKey", "Participant Name"));
59
60 ParticipantNamePropertyRow = MakeShared<FDialogueTextPropertyPickList_CustomRowHelper>(DetailWidgetRow, ParticipantNamePropertyHandle);
61 ParticipantNamePropertyRow->SetTextPropertyPickListWidget(
63 .AvailableSuggestions(this, &Self::GetAllDialoguesParticipantNames)
64 .OnTextCommitted(this, &Self::HandleTextCommitted)
65 .HasContextCheckbox(bHasDialogue)
66 .IsContextCheckBoxChecked(true)
67 .CurrentContextAvailableSuggestions(this, &Self::GetCurrentDialogueParticipantNames)
68 )
69 .Update();
70 }
71
72 // EventType
73 {
74 EventTypePropertyRow = &StructBuilder.AddProperty(EventTypePropertyHandle.ToSharedRef());
75
76 // Add Custom buttons
77 EventTypePropertyRow_CustomDisplay = MakeShared<FDialogueEnumTypeWithObject_CustomRowHelper>(
81 );
84 }
85
86 // EventName
87 {
88 const TSharedPtr<IPropertyHandle> EventNamePropertyHandle = StructPropertyHandle->GetChildHandle(
89 GET_MEMBER_NAME_CHECKED(FDlgEvent, EventName)
90 );
91 FDetailWidgetRow* DetailWidgetRow = &StructBuilder.AddCustomRow(LOCTEXT("EventNameSearchKey", "Event Name"));
92
93 EventNamePropertyRow = MakeShared<FDialogueTextPropertyPickList_CustomRowHelper>(DetailWidgetRow, EventNamePropertyHandle);
94 EventNamePropertyRow->SetTextPropertyPickListWidget(
96 .AvailableSuggestions(this, &Self::GetAllDialoguesEventNames)
97 .OnTextCommitted(this, &Self::HandleTextCommitted)
98 .HasContextCheckbox(bHasDialogue)
99 .IsContextCheckBoxChecked(false)
100 .CurrentContextAvailableSuggestions(this, &Self::GetCurrentDialogueEventNames)
101 )
103 .Update();
104 }
105
106 // IntValue
107 {
108 IntValuePropertyRow = &StructBuilder.AddProperty(
109 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, IntValue)).ToSharedRef()
110 );
112 }
113
114 // FloatValue
115 {
116 FloatValuePropertyRow = &StructBuilder.AddProperty(
117 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, FloatValue)).ToSharedRef()
118 );
120 }
121
122 // NameValue
123 {
124 NameValuePropertyRow = &StructBuilder.AddProperty(
125 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, NameValue)).ToSharedRef()
126 );
128 }
129
130 // bDelta
131 {
132 BoolDeltaPropertyRow = &StructBuilder.AddProperty(
133 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, bDelta)).ToSharedRef()
134 );
136 }
137
138 // bValue
139 {
140 BoolValuePropertyRow = &StructBuilder.AddProperty(
141 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, bValue)).ToSharedRef()
142 );
144 }
145
146 // CustomEvent
147 {
148 CustomEventPropertyRow = &StructBuilder.AddProperty(
149 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEvent, CustomEvent)).ToSharedRef()
150 );
152
153 // Add Custom buttons
154 CustomEventPropertyRow_CustomDisplay = MakeShared<FDialogueObject_CustomRowHelper>(CustomEventPropertyRow);
156 CustomEventPropertyRow_CustomDisplay->SetFunctionNameToOpen(
158 GET_FUNCTION_NAME_CHECKED(UDlgEventCustom, EnterEvent)
159 );
160 }
161
162 // Cache the initial event type
163 OnEventTypeChanged(false);
164}
165
167{
168 // Update to the new type
169 uint8 Value = 0;
170 if (EventTypePropertyHandle->GetValue(Value) != FPropertyAccess::Success)
171 {
172 return;
173 }
174 EventType = static_cast<EDlgEventType>(Value);
175
176 // Update the display name/tooltips
177 FText EventNameDisplayName = LOCTEXT("EventNameDisplayName", "Variable Name");
178 FText EventNameToolTip = LOCTEXT("EventNameToolTip", "Name of the relevant variable");
180 {
181 EventNameDisplayName = LOCTEXT("DlgEvent_EventNameDisplayName", "Event Name");
182 EventNameToolTip = LOCTEXT("DlgEvent_EventNameToolTip", "Name of the relevant event");
183 }
184
185 EventNamePropertyRow->SetDisplayName(EventNameDisplayName)
186 .SetToolTip(EventNameToolTip)
187 .Update();
188
189 // Refresh the view, without this some names/tooltips won't get refreshed
190 if (bForceRefresh && PropertyUtils.IsValid())
191 {
192 PropertyUtils->ForceRefresh();
193 }
194}
195
197{
198 TArray<FName> Suggestions;
200
201 switch (EventType)
202 {
204 UDlgManager::GetAllDialoguesBoolNames(ParticipantName, Suggestions);
205 break;
206
208 UDlgManager::GetAllDialoguesFloatNames(ParticipantName, Suggestions);
209 break;
210
212 UDlgManager::GetAllDialoguesIntNames(ParticipantName, Suggestions);
213 break;
214
216 UDlgManager::GetAllDialoguesNameNames(ParticipantName, Suggestions);
217 break;
218
220 if (Dialogue)
221 {
223 Dialogue->GetParticipantClass(ParticipantName),
224 FNYIntProperty::StaticClass(),
225 Suggestions,
226 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
227 );
228 FDlgHelper::SortDefault(Suggestions);
229 }
230 break;
231
233 if (Dialogue)
234 {
236 Dialogue->GetParticipantClass(ParticipantName),
237 FNYFloatProperty::StaticClass(),
238 Suggestions,
239 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
240 );
241 FDlgHelper::SortDefault(Suggestions);
242 }
243 break;
244
246 if (Dialogue)
247 {
249 Dialogue->GetParticipantClass(ParticipantName),
250 FNYBoolProperty::StaticClass(),
251 Suggestions,
252 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
253 );
254 FDlgHelper::SortDefault(Suggestions);
255 }
256 break;
257
259 if (Dialogue)
260 {
262 Dialogue->GetParticipantClass(ParticipantName),
263 FNYNameProperty::StaticClass(),
264 Suggestions,
265 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
266 );
267 FDlgHelper::SortDefault(Suggestions);
268 }
269 break;
270
271
273 default:
274 UDlgManager::GetAllDialoguesEventNames(ParticipantName, Suggestions);
275 break;
276 }
277
278 return Suggestions;
279}
280
282{
283 if (Dialogue == nullptr)
284 {
285 return {};
286 }
287
289 TSet<FName> Suggestions;
290
291 switch (EventType)
292 {
294 Dialogue->GetBoolNames(ParticipantName, Suggestions);
295 break;
296
298 Dialogue->GetNameNames(ParticipantName, Suggestions);
299 break;
300
302 Dialogue->GetFloatNames(ParticipantName, Suggestions);
303 break;
304
306 Dialogue->GetIntNames(ParticipantName, Suggestions);
307 break;
308
311 Dialogue->GetParticipantClass(ParticipantName),
312 FNYIntProperty::StaticClass(),
313 Suggestions,
314 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
315 );
316 break;
317
320 Dialogue->GetParticipantClass(ParticipantName),
321 FNYFloatProperty::StaticClass(),
322 Suggestions,
323 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
324 );
325 break;
326
329 Dialogue->GetParticipantClass(ParticipantName),
330 FNYBoolProperty::StaticClass(),
331 Suggestions,
332 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
333 );
334 break;
335
338 Dialogue->GetParticipantClass(ParticipantName),
339 FNYNameProperty::StaticClass(),
340 Suggestions,
341 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
342 );
343 break;
344
346 default:
347 Dialogue->GetEvents(ParticipantName, Suggestions);
348 break;
349 }
350
351 FDlgHelper::SortDefault(Suggestions);
352 return Suggestions.Array();
353}
354
355#undef LOCTEXT_NAMESPACE
static const TCHAR * META_ShowOnlyInnerProperties
#define CREATE_VISIBILITY_CALLBACK(_SelfMethod)
EDlgEventType
UENUM(BlueprintType)
Definition DlgEvent.h:16
@ ModifyClassFloatVariable
TSharedPtr< FDialogueEnumTypeWithObject_CustomRowHelper > EventTypePropertyRow_CustomDisplay
EVisibility GetBoolDeltaVisibility() const
void HandleTextCommitted(const FText &InSearchText, ETextCommit::Type CommitInfo) const
TArray< FName > GetAllDialoguesParticipantNames() const
void CustomizeHeader(TSharedRef< IPropertyHandle > StructPropertyHandle, FDetailWidgetRow &HeaderRow, IPropertyTypeCustomizationUtils &StructCustomizationUtils) override
IDetailPropertyRow * IntValuePropertyRow
EVisibility GetCustomEventVisibility() const
TArray< FName > GetCurrentDialogueParticipantNames() const
TSharedPtr< IPropertyHandle > EventTypePropertyHandle
TArray< FName > GetAllDialoguesEventNames() const
EVisibility GetBoolValueVisibility() const
void CustomizeChildren(TSharedRef< IPropertyHandle > StructPropertyHandle, IDetailChildrenBuilder &StructBuilder, IPropertyTypeCustomizationUtils &StructCustomizationUtils) override
EVisibility GetNameValueVisibility() const
EVisibility GetIntValueVisibility() const
void OnEventTypeChanged(bool bForceRefresh)
IDetailPropertyRow * BoolDeltaPropertyRow
TArray< FName > GetCurrentDialogueEventNames() const
TSharedPtr< FDialogueTextPropertyPickList_CustomRowHelper > ParticipantNamePropertyRow
IDetailPropertyRow * BoolValuePropertyRow
TSharedPtr< IPropertyHandle > StructPropertyHandle
IDetailPropertyRow * NameValuePropertyRow
EVisibility GetEventNameVisibility() const
TSharedPtr< FDialogueTextPropertyPickList_CustomRowHelper > EventNamePropertyRow
TSharedPtr< FDialogueObject_CustomRowHelper > CustomEventPropertyRow_CustomDisplay
IDetailPropertyRow * EventTypePropertyRow
IDetailPropertyRow * CustomEventPropertyRow
IDetailPropertyRow * FloatValuePropertyRow
TSharedPtr< IPropertyHandle > ParticipantNamePropertyHandle
EVisibility GetFloatValueVisibility() const
TSharedPtr< IPropertyUtilities > PropertyUtils
static void SortDefault(TArray< FName > &OutArray)
Definition DlgHelper.h:452
static void GetVariableNames(const UClass *ParticipantClass, const FNYPropertyClass *PropertyClass, ContainerType &OutContainer, const TArray< UClass * > &BlacklistedClasses)
UClass * GetParticipantClass(FName ParticipantName) const
EDITOR function, it only works if the participant class is setup in the ParticipantsClasses array.
void GetEvents(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetBoolNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetNameNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetFloatNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetIntNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)
static void GetAllDialoguesNameNames(FName ParticipantName, TArray< FName > &OutArray)
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
static void GetAllDialoguesBoolNames(FName ParticipantName, TArray< FName > &OutArray)
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
static void GetAllDialoguesEventNames(FName ParticipantName, TArray< FName > &OutArray)
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
static void GetAllDialoguesIntNames(FName ParticipantName, TArray< FName > &OutArray)
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
static void GetAllDialoguesFloatNames(FName ParticipantName, TArray< FName > &OutArray)
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
static FName GetParticipantNameFromPropertyHandle(const TSharedRef< IPropertyHandle > &ParticipantNamePropertyHandle)
static UDlgDialogue * GetDialogueFromPropertyHandle(const TSharedRef< IPropertyHandle > &PropertyHandle)
USTRUCT(BlueprintType)
Definition DlgEvent.h:59