A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DlgSystemSettings.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#include "DlgSystemSettings.h"
3
4#include "GameFramework/Character.h"
5
6#include "DlgManager.h"
7#include "Logging/DlgLogger.h"
8
9#define LOCTEXT_NAMESPACE "DlgSystem"
10
12// UDlgSystemSettings
14{
15 BlacklistedReflectionClasses = {AActor::StaticClass(), APawn::StaticClass(), ACharacter::StaticClass()};
16 // AdditionalTextFormatFileExtensionsToLookFor = {""};
17
18 DefaultTextEdgeToEndNode = LOCTEXT("edge_finish", "Finish");
19 DefaultTextEdgeToNormalNode = LOCTEXT("edge_next", "Next");
20}
21
22#if WITH_EDITOR
23FText UDlgSystemSettings::GetSectionText() const
24{
25 return LOCTEXT("SectionText", "Dialogue");
26}
27
28FText UDlgSystemSettings::GetSectionDescription() const
29{
30 return LOCTEXT("SectionDescription", "Configure how the Dialogue Editor behaves + Runtime behaviour");
31}
32
33
34#if ENGINE_MINOR_VERSION >= 25
35bool UDlgSystemSettings::CanEditChange(const FProperty* InProperty) const
36#else
37bool UDlgSystemSettings::CanEditChange(const UProperty* InProperty) const
38#endif
39{
40 const bool bIsEditable = Super::CanEditChange(InProperty);
41 if (bIsEditable && InProperty)
42 {
43 const FName PropertyName = InProperty->GetFName();
44
45 // Do now allow to change the bDrawPrimaryEdges, bDrawSecondaryEdges if we aren't even showing them
46 if (!bShowPrimarySecondaryEdges &&
47 (PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, bDrawPrimaryEdges) ||
48 PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, bDrawSecondaryEdges)))
49 {
50 return false;
51 }
52
53 // Only useful for GlobalNamespace
54 if (DialogueTextNamespaceLocalization != EDlgTextNamespaceLocalization::Global &&
55 PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, DialogueTextGlobalNamespaceName))
56 {
57 return false;
58 }
59
60 // Only useful for WithPrefixPerDialogue
61 if (DialogueTextNamespaceLocalization != EDlgTextNamespaceLocalization::WithPrefixPerDialogue &&
62 PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, DialogueTextPrefixNamespaceName))
63 {
64 return false;
65 }
66
67 if (DialogueTextNamespaceLocalization == EDlgTextNamespaceLocalization::Ignore &&
68 (PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, LocalizationIgnoredStrings)))
69 {
70 return false;
71 }
72
73 // Can't edit because they are not used
74 if (!bSetDefaultEdgeTexts &&
75 (PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, DefaultTextEdgeToEndNode) ||
76 PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, DefaultTextEdgeToNormalNode) ||
77 PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, bSetDefaultEdgeTextOnFirstChildOnly)))
78 {
79 return false;
80 }
81 }
82
83 return bIsEditable;
84}
85
86void UDlgSystemSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
87{
88 Super::PostEditChangeProperty(PropertyChangedEvent);
89
90 const FName PropertyName = PropertyChangedEvent.Property != nullptr ? PropertyChangedEvent.Property->GetFName() : NAME_None;
91 if (PropertyName == GET_MEMBER_NAME_CHECKED(ThisClass, bEnableMessageLog))
92 {
93 // Prevent no logging at all
95 }
96
97 // Check category
98 if (PropertyChangedEvent.Property != nullptr && PropertyChangedEvent.Property->HasMetaData(TEXT("Category")))
99 {
100 const FString& Category = PropertyChangedEvent.Property->GetMetaData(TEXT("Category"));
101
102 // Sync logger settings
103 if (Category.Equals(TEXT("Logger"), ESearchCase::IgnoreCase))
104 {
106 }
107 }
108}
109#endif // WITH_EDITOR
110
112{
113 // Ignored texts
114 // for (const FText& Ignored : LocalizationIgnoredTexts)
115 // {
116 // if (Text.EqualTo(Ignored))
117 // {
118 // return false;
119 // }
120 // }
121
122 // Ignore strings
123 const FString& TextSourceString = *FTextInspector::GetSourceString(Text);
124 if (LocalizationIgnoredStrings.Contains(TextSourceString))
125 {
126 return false;
127 }
128 // for (const FString& Ignored : LocalizationIgnoredStrings)
129 // {
130 // if (TextSourceString.Equals(Ignored))
131 // {
132 // return false;
133 // }
134 // }
135
136 return true;
137}
138
140{
141 switch (TextFormat)
142 {
143 // JSON has the .json added at the end
145 return TEXT(".dlg.json");
146
148 return TEXT(".dlg");
149
150 // Empty
152 default:
153 return FString();
154 }
155}
156
158{
159 static TSet<FString> Extensions;
160 if (Extensions.Num() == 0)
161 {
162 // Iterate over all possible text formats
163 const int32 TextFormatsNum = static_cast<int32>(EDlgDialogueTextFormat::NumTextFormats);
164 for (int32 TextFormatIndex = static_cast<int32>(EDlgDialogueTextFormat::StartTextFormats);
165 TextFormatIndex < TextFormatsNum; TextFormatIndex++)
166 {
167 const EDlgDialogueTextFormat CurrentTextFormat = static_cast<EDlgDialogueTextFormat>(TextFormatIndex);
168 Extensions.Add(GetTextFileExtension(CurrentTextFormat));
169 }
170 }
171
172 return Extensions;
173}
174
176{
177 TSet<FString> CurrentFileExtensions = GetAllCurrentTextFileExtensions();
178
179 // Look for additional file extensions
180 for (const FString& Ext : AdditionalTextFormatFileExtensionsToLookFor)
181 {
182 // Only allow file extension that start with dot, also ignore uasset
183 if (Ext.StartsWith(".") && Ext != ".uasset")
184 {
185 CurrentFileExtensions.Add(Ext);
186 }
187 }
188
189 return CurrentFileExtensions;
190}
191
192#undef LOCTEXT_NAMESPACE
EDlgDialogueTextFormat
UENUM()
Self & SyncWithSettings()
Definition DlgLogger.cpp:29
static FDlgLogger & Get()
Definition DlgLogger.h:24
TSet< FString > GetAllTextFileExtensions() const
TSet< FString > LocalizationIgnoredStrings
UPROPERTY(Category = "Localization", Config, EditAnywhere, AdvancedDisplay, DisplayName = "Ignored St...
bool bEnableMessageLog
UPROPERTY(Category = "Logger", Config, EditAnywhere)
TArray< UClass * > BlacklistedReflectionClasses
UPROPERTY(Category = "Dialogue", Config, EditAnywhere)
TSet< FString > AdditionalTextFormatFileExtensionsToLookFor
UPROPERTY(Category = "Batch", Config, EditAnywhere)
static const TSet< FString > & GetAllCurrentTextFileExtensions()
static FString GetTextFileExtension(EDlgDialogueTextFormat TextFormat)
bool IsIgnoredTextForLocalization(const FText &Text) const
FText DefaultTextEdgeToNormalNode
UPROPERTY(Category = "Default Texts", Config, EditAnywhere, DisplayName = "Edge Text To Normal Node")
bool bEnableOutputLog
UPROPERTY(Config)
FText DefaultTextEdgeToEndNode
UPROPERTY(Category = "Default Texts", Config, EditAnywhere, DisplayName = "Edge Text To End Node")