A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueTextArgument_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#include "UObject/TextProperty.h"
8
14#include "DlgHelper.h"
16
17#define LOCTEXT_NAMESPACE "DialogueTextArgument_Details"
18
20// FDialogueEventCustomization
21void FDialogueTextArgument_Details::CustomizeHeader(TSharedRef<IPropertyHandle> InStructPropertyHandle,
22 FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
23{
24 StructPropertyHandle = InStructPropertyHandle;
26 PropertyUtils = StructCustomizationUtils.GetPropertyUtilities();
27
28 // Cache the Property Handle for the ArgumentType
29 ParticipantNamePropertyHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgTextArgument, ParticipantName));
30 ArgumentTypePropertyHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgTextArgument, Type));
31 check(ParticipantNamePropertyHandle.IsValid());
32 check(ArgumentTypePropertyHandle.IsValid());
33
34 // Register handler for event type change
35 ArgumentTypePropertyHandle->SetOnPropertyValueChanged(
36 FSimpleDelegate::CreateSP(this, &Self::OnArgumentTypeChanged, true));
37
38 const bool bShowOnlyInnerProperties = StructPropertyHandle->GetProperty()->HasMetaData(META_ShowOnlyInnerProperties);
39 if (!bShowOnlyInnerProperties)
40 {
41 HeaderRow.NameContent()
42 [
43 StructPropertyHandle->CreatePropertyNameWidget()
44 ];
45 }
46}
47
48void FDialogueTextArgument_Details::CustomizeChildren(TSharedRef<IPropertyHandle> InStructPropertyHandle,
49 IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
50{
51 const bool bHasDialogue = Dialogue != nullptr;
52
53 // DisplayString
54 StructBuilder.AddProperty(StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgTextArgument, DisplayString)).ToSharedRef());
55
56 // 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 // ArgumentType
73 StructBuilder.AddProperty(ArgumentTypePropertyHandle.ToSharedRef());
74
75 // VariableName
76 {
77 const TSharedPtr<IPropertyHandle> VariableNamePropertyHandle = StructPropertyHandle->GetChildHandle(
78 GET_MEMBER_NAME_CHECKED(FDlgTextArgument, VariableName)
79 );
80 FDetailWidgetRow* DetailWidgetRow = &StructBuilder.AddCustomRow(LOCTEXT("VariableNameSearchKey", "Variable Name"));
81
82 VariableNamePropertyRow = MakeShared<FDialogueTextPropertyPickList_CustomRowHelper>(DetailWidgetRow, VariableNamePropertyHandle);
83 VariableNamePropertyRow->SetTextPropertyPickListWidget(
85 .AvailableSuggestions(this, &Self::GetAllDialoguesVariableNames)
86 .OnTextCommitted(this, &Self::HandleTextCommitted)
87 .HasContextCheckbox(bHasDialogue)
88 .IsContextCheckBoxChecked(false)
89 .CurrentContextAvailableSuggestions(this, &Self::GetCurrentDialogueVariableNames)
90 );
93 }
94
95 // CustomTextArgument
96 {
97 CustomTextArgumentPropertyRow = &StructBuilder.AddProperty(
98 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgTextArgument, CustomTextArgument)).ToSharedRef()
99 );
101
102 // Add Custom buttons
103 CustomTextArgumentPropertyRow_CustomDisplay = MakeShared<FDialogueObject_CustomRowHelper>(CustomTextArgumentPropertyRow);
105 CustomTextArgumentPropertyRow_CustomDisplay->SetFunctionNameToOpen(
107 GET_FUNCTION_NAME_CHECKED(UDlgTextArgumentCustom, GetText)
108 );
109 }
110
111 // Cache the initial event type
113}
114
116{
117 // Update to the new type
118 uint8 Value = 0;
119 if (ArgumentTypePropertyHandle->GetValue(Value) != FPropertyAccess::Success)
120 {
121 return;
122 }
123 ArgumentType = static_cast<EDlgTextArgumentType>(Value);
124
125 // Refresh the view, without this some names/tooltips won't get refreshed
126 if (bForceRefresh && PropertyUtils.IsValid())
127 {
128 PropertyUtils->ForceRefresh();
129 }
130}
131
133{
134 TArray<FName> Suggestions;
136
137 switch (ArgumentType)
138 {
140 if (bCurrentOnly && Dialogue)
141 {
142 TSet<FName> SuggestionsSet;
143 Dialogue->GetIntNames(ParticipantName, SuggestionsSet);
144 Suggestions = SuggestionsSet.Array();
145 }
146 else
147 {
148 UDlgManager::GetAllDialoguesIntNames(ParticipantName, Suggestions);
149 }
150 break;
151
154 Dialogue->GetParticipantClass(ParticipantName),
155 FNYIntProperty::StaticClass(),
156 Suggestions,
157 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
158 );
159 break;
160
162 if (bCurrentOnly && Dialogue)
163 {
164 TSet<FName> SuggestionsSet;
165 Dialogue->GetFloatNames(ParticipantName, SuggestionsSet);
166 Suggestions = SuggestionsSet.Array();
167 }
168 else
169 {
170 UDlgManager::GetAllDialoguesFloatNames(ParticipantName, Suggestions);
171 }
172 break;
173
175 if (Dialogue)
176 {
178 Dialogue->GetParticipantClass(ParticipantName),
179 FNYFloatProperty::StaticClass(),
180 Suggestions,
181 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
182 );
183 }
184 break;
185
187 if (Dialogue)
188 {
190 Dialogue->GetParticipantClass(ParticipantName),
191 FNYTextProperty::StaticClass(),
192 Suggestions,
193 GetDefault<UDlgSystemSettings>()->BlacklistedReflectionClasses
194 );
195 }
196 break;
197
199 default:
200 break;
201 }
202 FDlgHelper::SortDefault(Suggestions);
203 return Suggestions;
204}
205
206#undef LOCTEXT_NAMESPACE
static const TCHAR * META_ShowOnlyInnerProperties
#define CREATE_VISIBILITY_CALLBACK(_SelfMethod)
EDlgTextArgumentType
UENUM(BlueprintType)
TSharedPtr< IPropertyHandle > ParticipantNamePropertyHandle
TSharedPtr< FDialogueObject_CustomRowHelper > CustomTextArgumentPropertyRow_CustomDisplay
void HandleTextCommitted(const FText &InSearchText, ETextCommit::Type CommitInfo) const
TArray< FName > GetCurrentDialogueVariableNames() const
TArray< FName > GetCurrentDialogueParticipantNames() const
TArray< FName > GetDialogueVariableNames(bool bCurrentOnly) const
TArray< FName > GetAllDialoguesParticipantNames() const
TSharedPtr< FDialogueTextPropertyPickList_CustomRowHelper > VariableNamePropertyRow
TSharedPtr< IPropertyUtilities > PropertyUtils
void CustomizeChildren(TSharedRef< IPropertyHandle > StructPropertyHandle, IDetailChildrenBuilder &StructBuilder, IPropertyTypeCustomizationUtils &StructCustomizationUtils) override
void CustomizeHeader(TSharedRef< IPropertyHandle > StructPropertyHandle, FDetailWidgetRow &HeaderRow, IPropertyTypeCustomizationUtils &StructCustomizationUtils) override
TSharedPtr< IPropertyHandle > ArgumentTypePropertyHandle
TSharedPtr< FDialogueTextPropertyPickList_CustomRowHelper > ParticipantNamePropertyRow
TSharedPtr< IPropertyHandle > StructPropertyHandle
TArray< FName > GetAllDialoguesVariableNames() const
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 GetFloatNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetIntNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
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")
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)
static FName GetParticipantNameFromPropertyHandle(const TSharedRef< IPropertyHandle > &ParticipantNamePropertyHandle)
static UDlgDialogue * GetDialogueFromPropertyHandle(const TSharedRef< IPropertyHandle > &PropertyHandle)
USTRUCT(BlueprintType)