A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueIntTextBox_CustomRowHelper.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4#include "PropertyHandle.h"
5#include "DetailWidgetRow.h"
6#include "Widgets/Input/SButton.h"
7#include "Widgets/Images/SImage.h"
8#include "Widgets/Input/SComboButton.h"
9#include "Widgets/Layout/SUniformGridPanel.h"
10#include "Internationalization/TextNamespaceUtil.h"
11#include "IPropertyUtilities.h"
14
15#define LOCTEXT_NAMESPACE "DialogueIntTextBox_CustomRowHelper"
16#define DEFAULT_FONT(...) FCoreStyle::GetDefaultFontStyle(__VA_ARGS__)
17
19// FDialogueMultiLineEditableTextBox_CustomRowHelper
21{
22 check(PropertyHandle.IsValid());
23
24 TSharedPtr<SHorizontalBox> HorizontalBox;
26 ->NameContent()
27 [
28 NameContentWidget.ToSharedRef()
29 ]
30 .ValueContent()
31 // Similar to TextProperty, see FTextCustomization
32 .MinDesiredWidth(200.f)
33 // .MaxDesiredWidth(300.f)
34 [
35 SAssignNew(HorizontalBox, SHorizontalBox)
36 +SHorizontalBox::Slot()
37 .Padding(0.f, 0.f, 4.f, 0.f)
38 .FillWidth(1.f)
39 [
40 PropertyHandle->CreatePropertyValueWidget()
41 ]
42 ];
43
44 // Add Reset to default
46 {
47 PropertyHandle->MarkResetToDefaultCustomized(true);
48 HorizontalBox->AddSlot()
49 .AutoWidth()
50 .VAlign(VAlign_Center)
51 .Padding(4.f, 2.f)
52 [
53 SNew(SButton)
54 .IsFocusable(false)
55 .ToolTipText(this, &Self::GetResetToolTip)
56 .ButtonStyle(FEditorStyle::Get(), "NoBorder")
57 .ContentPadding(0)
59 .OnClicked(this, &Self::OnResetClicked)
60 .Content()
61 [
62 SNew(SImage)
63 .Image(FEditorStyle::GetBrush("PropertyWindow.DiffersFromDefault"))
64 ]
65 ];
66 }
67
68 // Jump to Node
69 HorizontalBox->AddSlot()
70 .AutoWidth()
71 .VAlign(VAlign_Center)
72 .Padding(4.f, 2.f)
73 [
74 SNew(SButton)
75 .Visibility(JumpToNodeVisibility)
76 .ToolTipText(LOCTEXT("JumpToNodeTooltipKey", "Jump to Node"))
77 .OnClicked(this, &Self::OnJumpToNodeClicked)
78 [
79 SNew(STextBlock)
80 .Text(LOCTEXT("JumpToNodeKey", "Jump to Node"))
81 .Font(DEFAULT_FONT("Regular", 10))
82 ]
83 ];
84}
85
87{
88 FString Tooltip = NSLOCTEXT("PropertyEditor", "ResetToDefaultToolTip", "Reset to Default").ToString();
89 if (PropertyHandle.IsValid() && !PropertyHandle->IsEditConst() && PropertyHandle->DiffersFromDefault())
90 {
91 const FString DefaultLabel = PropertyHandle->GetResetToDefaultLabel().ToString();
92 if (DefaultLabel.Len() > 0)
93 {
94 Tooltip += "\n";
95 Tooltip += DefaultLabel;
96 }
97 }
98
99 return FText::FromString(Tooltip);
100}
101
103{
104 if (PropertyHandle.IsValid())
105 {
106 return PropertyHandle->DiffersFromDefault() ? EVisibility::Visible : EVisibility::Hidden;
107 }
108
109 return EVisibility::Visible;
110}
111
113{
114 if (PropertyHandle.IsValid())
115 {
116 PropertyHandle->ResetToDefault();
117 }
118 return FReply::Handled();
119}
120
122{
123 int32 NodeIndex = 0;
124 if (PropertyHandle->GetValue(NodeIndex) == FPropertyAccess::Success)
125 {
127 }
128
129 return FReply::Handled();
130}
131
132#undef LOCTEXT_NAMESPACE
133#undef DEFAULT_FONT
#define DEFAULT_FONT(...)
TSharedPtr< IPropertyHandle > PropertyHandle
static bool JumpToGraphNodeIndex(const UDlgDialogue *Dialogue, int32 NodeIndex)
TWeakObjectPtr< const UDlgDialogue > Dialogue