A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueEdge_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 "IDetailChildrenBuilder.h"
6#include "IPropertyTypeCustomization.h"
7
8#include "Nodes/DlgNode.h"
14
15#define LOCTEXT_NAMESPACE "DialogueEdge_Details"
16
18// FDialogueEdge_Details
19void FDialogueEdge_Details::CustomizeHeader(TSharedRef<IPropertyHandle> InStructPropertyHandle,
20 FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
21{
22 StructPropertyHandle = InStructPropertyHandle;
24 bShowTextProperty = true;
25
26 // Should we show hide the Text property?
28 {
29 // Virtual parents do not handle direct children, only grand children
30 // And selector node do not even touch them
31 bShowTextProperty = FDlgEdge::IsTextVisible(GraphNode->GetDialogueNode());
32
33 // Special case
34 // Selector node but one of its parent is a virtual parent, allow text then
35 if (!bShowTextProperty && GraphNode->IsSelectorNode())
36 {
37 for (const UDialogueGraphNode* ParentNode : GraphNode->GetParentNodes())
38 {
39 if (ParentNode->IsVirtualParentNode())
40 {
41 bShowTextProperty = true;
42 break;
43 }
44 }
45 }
46 }
47
48 const bool bShowOnlyInnerProperties = StructPropertyHandle->GetProperty()->HasMetaData(META_ShowOnlyInnerProperties);
49 if (!bShowOnlyInnerProperties)
50 {
51 HeaderRow.NameContent()
52 [
53 StructPropertyHandle->CreatePropertyNameWidget()
54 ];
55 }
56}
57
58void FDialogueEdge_Details::CustomizeChildren(TSharedRef<IPropertyHandle> InStructPropertyHandle,
59 IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
60{
61 // TargetIndex
62 StructBuilder.AddProperty(StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEdge, TargetIndex)).ToSharedRef());
63
64 // Conditions
65 StructBuilder.AddProperty(StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEdge, Conditions)).ToSharedRef());
66
67 // Text
69 FDetailWidgetRow* TextDetailWidgetRow = &StructBuilder.AddCustomRow(LOCTEXT("TextSearchKey", "Text"));
70
71 TextPropertyRow = MakeShared<FDialogueMultiLineEditableTextBox_CustomRowHelper>(TextDetailWidgetRow, TextPropertyHandle);
72 TextPropertyRow->SetPropertyUtils(StructCustomizationUtils.GetPropertyUtilities())
74 .Update();
75 TextPropertyRow->OnTextCommittedEvent().AddRaw(this, &Self::HandleTextCommitted);
76 TextPropertyRow->OnTextChangedEvent().AddRaw(this, &Self::HandleTextChanged);
77
78 // Text Arguments
79 StructBuilder.AddProperty(StructPropertyHandle->GetChildHandle(FDlgEdge::GetMemberNameTextArguments()).ToSharedRef())
81
82 // Speaker State
83 {
84 const TSharedPtr<IPropertyHandle> SpeakerStatePropertyHandle =
85 StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDlgEdge, SpeakerState));
86
87 FDetailWidgetRow* SpeakerStateDetailWidgetRow = &StructBuilder.AddCustomRow(LOCTEXT("SpeakerStateSearchKey", "Speaker State"));
88
89 SpeakerStatePropertyRow = MakeShared<FDialogueTextPropertyPickList_CustomRowHelper>(SpeakerStateDetailWidgetRow, SpeakerStatePropertyHandle);
90 SpeakerStatePropertyRow->SetTextPropertyPickListWidget(
92 .IsEnabled(InStructPropertyHandle->IsEditable())
93 .AvailableSuggestions(this, &Self::GetAllDialoguesSpeakerStates)
94 .OnTextCommitted(this, &Self::HandleSpeakerStateCommitted)
95 .HasContextCheckbox(false)
96 )
98 .Update();
99 }
100
101 // bIncludeInAllOptionListIfUnsatisfied
102 IDetailPropertyRow& BoolPropertyRow = StructBuilder.AddProperty(StructPropertyHandle->GetChildHandle(
103 GET_MEMBER_NAME_CHECKED(FDlgEdge, bIncludeInAllOptionListIfUnsatisfied)).ToSharedRef()
104 );
105 BoolPropertyRow.Visibility(CREATE_VISIBILITY_CALLBACK(&Self::GetTextVisibility));
106}
107
108void FDialogueEdge_Details::HandleSpeakerStateCommitted(const FText& InSearchText, ETextCommit::Type CommitInfo)
109{
110 if (Dialogue)
111 {
113 }
114}
115
116void FDialogueEdge_Details::HandleTextCommitted(const FText& InText, ETextCommit::Type CommitInfo)
117{
119 {
120 if (Dialogue)
121 {
123 }
124
125 GraphEdge->GetDialogueEdge().RebuildTextArguments();
126 }
127}
128
130{
132 {
133 GraphEdge->GetDialogueEdge().RebuildTextArgumentsFromPreview(InText);
134 }
135}
136
137
138#undef LOCTEXT_NAMESPACE
static const TCHAR * META_ShowOnlyInnerProperties
#define CREATE_VISIBILITY_CALLBACK(_SelfMethod)
TArray< FName > GetAllDialoguesSpeakerStates() const
TSharedPtr< IPropertyHandle > TextPropertyHandle
void CustomizeChildren(TSharedRef< IPropertyHandle > StructPropertyHandle, IDetailChildrenBuilder &StructBuilder, IPropertyTypeCustomizationUtils &StructCustomizationUtils) override
TSharedPtr< FDialogueMultiLineEditableTextBox_CustomRowHelper > TextPropertyRow
EVisibility GetSpeakerStateVisibility() const
void HandleTextCommitted(const FText &InText, ETextCommit::Type CommitInfo)
void HandleSpeakerStateCommitted(const FText &InSearchText, ETextCommit::Type CommitInfo)
void HandleTextChanged(const FText &InText)
void CustomizeHeader(TSharedRef< IPropertyHandle > StructPropertyHandle, FDetailWidgetRow &HeaderRow, IPropertyTypeCustomizationUtils &StructCustomizationUtils) override
TSharedPtr< IPropertyHandle > StructPropertyHandle
TSharedPtr< FDialogueTextPropertyPickList_CustomRowHelper > SpeakerStatePropertyRow
EVisibility GetTextVisibility() const
void UpdateAndRefreshData(bool bUpdateTextsNamespacesAndKeys=false)
static UDlgDialogue * GetDialogueFromPropertyHandle(const TSharedRef< IPropertyHandle > &PropertyHandle)
static UDialogueGraphNode * GetClosestGraphNodeFromPropertyHandle(const TSharedRef< IPropertyHandle > &PropertyHandle)
static UDialogueGraphNode_Edge * GetAsGraphNodeEdgeFromPropertyHandle(const TSharedRef< IPropertyHandle > &PropertyHandle)
USTRUCT(BlueprintType)
Definition DlgEdge.h:25
static bool IsTextVisible(const UDlgNode &ParentNode)
Definition DlgEdge.cpp:10
static FName GetMemberNameTextArguments()
Definition DlgEdge.h:117
static FName GetMemberNameText()
Definition DlgEdge.h:116