A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueStyle.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#include "DialogueStyle.h"
3
4#include "Styling/SlateStyle.h"
5#include "Interfaces/IPluginManager.h"
6#include "Styling/SlateStyleRegistry.h"
7
9#include "DlgSystemModule.h"
10
11// Const icon sizes
12static const FVector2D Icon16x16(16.0f, 16.0f);
13static const FVector2D Icon20x20(20.0f, 20.0f);
14static const FVector2D Icon24x24(24.0f, 24.0f);
15static const FVector2D Icon40x40(40.0f, 40.0f);
16static const FVector2D Icon64x64(64.0f, 64.0f);
17static const FVector2D Icon96x96(96.0f, 96.0f);
18
19
20// What is displayed in the Content Browser
21const FName FDialogueStyle::PROPERTY_DlgDialogueClassIcon(TEXT("ClassIcon.DlgDialogue"));
22const FName FDialogueStyle::PROPERTY_DlgDialogueClassThumbnail(TEXT("ClassThumbnail.DlgDialogue"));
23const FName FDialogueStyle::PROPERTY_DlgEventCustomClassIcon(TEXT("ClassIcon.DlgEventCustom"));
24const FName FDialogueStyle::PROPERTY_DlgEventCustomClassThumbnail(TEXT("ClassThumbnail.DlgEventCustom"));
25const FName FDialogueStyle::PROPERTY_DlgConditionCustomClassIcon(TEXT("ClassIcon.DlgConditionCustom"));
26const FName FDialogueStyle::PROPERTY_DlgConditionCustomClassThumbnail(TEXT("ClassThumbnail.DlgConditionCustom"));
27const FName FDialogueStyle::PROPERTY_DlgTextArgumentCustomClassIcon(TEXT("ClassIcon.DlgTextArgumentCustom"));
28const FName FDialogueStyle::PROPERTY_DlgTextArgumentCustomClassThumbnail(TEXT("ClassThumbnail.DlgTextArgumentCustom"));
29const FName FDialogueStyle::PROPERTY_DlgNodeDataClassIcon(TEXT("ClassIcon.DlgNodeData"));
30const FName FDialogueStyle::PROPERTY_DlgNodeDataClassThumbnail(TEXT("ClassThumbnail.DlgNodeData"));
31
32
33// Inside the Dialogue Editor Window
34const FName FDialogueStyle::PROPERTY_GraphNodeCircleBox(TEXT("DlgSystemEditor.Graph.Node.Circle"));
35const FName FDialogueStyle::PROPERTY_ConditionIcon(TEXT("DlgSystemEditor.Condition"));
36const FName FDialogueStyle::PROPERTY_EventIcon(TEXT("DlgSystemEditor.Event"));
37const FName FDialogueStyle::PROPERTY_VoiceIcon(TEXT("DlgSystemEditor.Voice"));
38const FName FDialogueStyle::PROPERTY_GenericIcon(TEXT("DlgSystemEditor.Generic"));
39const FName FDialogueStyle::PROPERTY_QuestionMarkIcon(TEXT("DlgSystemEditor.QuestionMark"));
40
41// Tied with FDialogueCommands::DialogueReloadData
42const FName FDialogueStyle::PROPERTY_ReloadAssetIcon(TEXT("DlgSystemEditor.DialogueReloadData"));
43
44// Tied with FDialogueCommands::ToggleShowPrimarySecondaryEdges
45const FName FDialogueStyle::PROPERTY_ShowPrimarySecondaryEdgesIcon(TEXT("DlgSystemEditor.ToggleShowPrimarySecondaryEdges"));
46
47// For the Dialogue Browser
48const FName FDialogueStyle::PROPERTY_OpenAssetIcon(TEXT("DlgSystemEditor.OpenAsset"));
49const FName FDialogueStyle::PROPERTY_FindAssetIcon(TEXT("DlgSystemEditor.FindAsset"));
50const FName FDialogueStyle::PROPERTY_DialogueBrowser_TabIcon(TEXT("DlgSystemEditor.DialogueBrowser.TabIcon"));
51
52// Tied with FDialogueCommands::SaveAllDialogues
53const FName FDialogueStyle::PROPERTY_SaveAllDialoguesIcon(TEXT("DlgSystemEditor.SaveAllDialogues"));
54
55// Tied with FDialogueCommands::DeleteAllDialoguesTextFiles
56const FName FDialogueStyle::PROPERTY_DeleteAllDialoguesTextFilesIcon(TEXT("DlgSystemEditor.DeleteAllDialoguesTextFiles"));
57
58// Tied with FDialogueCommands::DeleteCurrentDialogueTextFiles
59const FName FDialogueStyle::PROPERTY_DeleteCurrentDialogueTextFilesIcon(TEXT("DlgSystemEditor.DeleteCurrentDialogueTextFiles"));
60
61// For the Dialogue Search Browser
62const FName FDialogueStyle::PROPERTY_DialogueSearch_TabIcon(TEXT("DlgSystemEditor.DialogueSearch.TabIcon"));
63
64// For the Dialogue Data Display Window
65const FName FDialogueStyle::PROPERTY_DialogueDataDisplay_TabIcon(TEXT("DlgSystemEditor.DialogueDataDisplay.TabIcon"));
66
67// Tied with FDialogueCommands::FindInDialogue
68const FName FDialogueStyle::PROPERTY_FindInDialogueEditorIcon(TEXT("DlgSystemEditor.FindInDialogue"));
69
70// Tied with FDialogueCommands::FindInAllDialogues
71const FName FDialogueStyle::PROPERTY_FindInAllDialogueEditorIcon(TEXT("DlgSystemEditor.FindInAllDialogues"));
72
73// Tied with FDialogueCommands::OpenDiscord
74const FName FDialogueStyle::PROPERTY_OpenDiscordIcon(TEXT("DlgSystemEditor.OpenDiscord"));
75
76// Tied with FDialogueCommands::OpenForum
77const FName FDialogueStyle::PROPERTY_OpenForumIcon(TEXT("DlgSystemEditor.OpenForum"));
78
79// Tied with FDialogueCommands::OpenNotYetPlugins
80const FName FDialogueStyle::PROPERTY_OpenNotYetPluginsIcon(TEXT("DlgSystemEditor.OpenNotYetPlugins"));
81
82// Tied with FDialogueCommands::OpenMarketplace
83const FName FDialogueStyle::PROPERTY_OpenMarketplaceIcon(TEXT("DlgSystemEditor.OpenMarketplace"));
84
85// Tied with FDialogueCommands::OpenWiki
86const FName FDialogueStyle::PROPERTY_OpenWikiIcon(TEXT("DlgSystemEditor.OpenWiki"));
87
88// For FDialogueSearchResult_CommentNode
89const FName FDialogueStyle::PROPERTY_CommentBubbleOn(TEXT("DlgSystemEditor.CommentBubbleOn"));
90
91const FName FDialogueStyle::PROPERTY_NotYetLogoIcon(TEXT("DlgSystemEditor.NotYetLogo.Icon"));
92
93// The private ones
94TSharedPtr<FSlateStyleSet> FDialogueStyle::StyleSet = nullptr;
95FString FDialogueStyle::EngineContentRoot = FString();
96FString FDialogueStyle::PluginContentRoot = FString();
97
99{
100 // Only register once
101 if (StyleSet.IsValid())
102 {
103 return;
104 }
105
106 StyleSet = MakeShared<FSlateStyleSet>(GetStyleSetName());
107 EngineContentRoot = FPaths::EngineContentDir() / TEXT("Editor/Slate");
108 TSharedPtr<IPlugin> CurrentPlugin = IPluginManager::Get().FindPlugin(DIALOGUE_SYSTEM_PLUGIN_NAME.ToString());
109 if (CurrentPlugin.IsValid())
110 {
111 // Replaces the Engine Content Root (Engine/Editor/Slate) with the plugin content root
112 StyleSet->SetContentRoot(CurrentPlugin->GetContentDir());
113 PluginContentRoot = CurrentPlugin->GetContentDir();
114 }
115 else
116 {
117 UE_LOG(LogDlgSystemEditor, Fatal, TEXT("Could not find the Dialogue System Plugin :("));
118 return;
119 }
120
121 // Content Browser icons for asset types
122 StyleSet->Set(
124 new FSlateImageBrush(GetPluginContentPath("Icons/DlgDialogue_16x.png"), Icon16x16)
125 );
126 StyleSet->Set(
128 new FSlateImageBrush(GetPluginContentPath("Icons/DlgDialogue_64x.png"), Icon64x64)
129 );
130 StyleSet->Set(
132 new FSlateImageBrush(GetPluginContentPath("Icons/DlgEventCustom_16x.png"), Icon16x16)
133 );
134 StyleSet->Set(
136 new FSlateImageBrush(GetPluginContentPath("Icons/DlgEventCustom_64x.png"), Icon64x64)
137 );
138 StyleSet->Set(
140 new FSlateImageBrush(GetPluginContentPath("Icons/DlgConditionCustom_16x.png"), Icon16x16)
141 );
142 StyleSet->Set(
144 new FSlateImageBrush(GetPluginContentPath("Icons/DlgConditionCustom_64x.png"), Icon64x64)
145 );
146 StyleSet->Set(
148 new FSlateImageBrush(GetPluginContentPath("Icons/DlgTextArgumentCustom_16x.png"), Icon16x16)
149 );
150 StyleSet->Set(
152 new FSlateImageBrush(GetPluginContentPath("Icons/DlgTextArgumentCustom_64x.png"), Icon64x64)
153 );
154 StyleSet->Set(
156 new FSlateImageBrush(GetPluginContentPath("Icons/DlgNodeData_16x.png"), Icon16x16)
157 );
158 StyleSet->Set(
160 new FSlateImageBrush(GetPluginContentPath("Icons/DlgNodeData_64x.png"), Icon64x64)
161 );
162
163 // Dialogue Search
164 StyleSet->Set(
166 new FSlateImageBrush(GetEngineContentPath("Icons/icon_Blueprint_Find_40px.png"), Icon40x40)
167 );
168 StyleSet->Set(
170 new FSlateImageBrush(GetEngineContentPath("Icons/icon_Blueprint_Find_40px.png"), Icon20x20)
171 );
172
173 StyleSet->Set(
175 new FSlateImageBrush(GetEngineContentPath("Icons/icon_FindInAnyBlueprint_40px.png"), Icon40x40)
176 );
177 StyleSet->Set(
179 new FSlateImageBrush(GetEngineContentPath("Icons/icon_FindInAnyBlueprint_40px.png"), Icon20x20)
180 );
181
182 StyleSet->Set(
184 new FSlateImageBrush(GetEngineContentPath("Icons/icon_Genericfinder_16x.png"), Icon16x16)
185 );
186
187 // Level Editor File
188 StyleSet->Set(
190 new FSlateImageBrush(GetEngineContentPath("Icons/icon_file_saveall_40x.png"), Icon40x40)
191 );
192 StyleSet->Set(
194 new FSlateImageBrush(GetEngineContentPath("Icons/Edit/icon_Edit_Delete_40x.png"), Icon40x40)
195 );
196 StyleSet->Set(
198 new FSlateImageBrush(GetEngineContentPath("Icons/Edit/icon_Edit_Delete_40x.png"), Icon40x40)
199 );
200
201 // Level Editor Help
202 StyleSet->Set(
204 new FSlateImageBrush(GetPluginContentPath("Icons/Discord_96x.png"), Icon96x96)
205 );
206 StyleSet->Set(
208 new FSlateImageBrush(GetPluginContentPath("Icons/NotYet_96x.png"), Icon96x96)
209 );
210 StyleSet->Set(
212 new FSlateImageBrush(GetPluginContentPath("Icons/Forum_96x.png"), Icon96x96)
213 );
214 StyleSet->Set(
216 new FSlateImageBrush(GetPluginContentPath("Icons/Wiki_96x.png"), Icon96x96)
217 );
218 StyleSet->Set(
220 new FSlateImageBrush(GetPluginContentPath("Icons/Marketplace_96x.png"), Icon96x96)
221 );
222
223 // Dialogue Browser
224 StyleSet->Set(
226 new FSlateImageBrush(GetEngineContentPath("Icons/icon_tab_ContentBrowser_16x.png"), Icon16x16)
227 );
228
229 // Dialogue Data Display
230 StyleSet->Set(
232 new FSlateImageBrush(GetEngineContentPath("Icons/icon_tab_DebugTools_40x.png"), Icon16x16)
233 );
234
235 // Dialogue Editor Window
236 StyleSet->Set(
238 new FSlateImageBrush(GetEngineContentPath("Icons/icon_Cascade_RestartInLevel_40x.png"), Icon40x40)
239 );
240 StyleSet->Set(
242 new FSlateImageBrush(GetEngineContentPath("Icons/icon_Refresh_16x.png"), Icon16x16)
243 );
244
245 StyleSet->Set(
247 new FSlateImageBrush(GetPluginContentPath("Icons/Dialogue_ShowPrimarySecondaryEdges_40x.png"), Icon40x40)
248 );
249 StyleSet->Set(
251 new FSlateImageBrush(GetPluginContentPath("Icons/Dialogue_ShowPrimarySecondaryEdges_40x.png"), Icon16x16)
252 );
253
254 // Custom Icon sizes, original image is 128x64, we divide by 1.4
255 StyleSet->Set(
257 new FSlateImageBrush(GetPluginContentPath("Icons/NotYet_128x_64x.png"), FVector2D{91.42f, 45.8f})
258 );
259 StyleSet->Set(
261 new FSlateImageBrush(GetPluginContentPath("Icons/NotYet_96x.png"), Icon16x16)
262 );
263
264 StyleSet->Set(
266 new FSlateImageBrush(GetPluginContentPath("Icons/Condition_96x.png"), Icon96x96)
267 );
268 StyleSet->Set(
270 new FSlateImageBrush(GetPluginContentPath("Icons/Event_96x.png"), Icon96x96)
271 );
272 StyleSet->Set(
274 new FSlateImageBrush(GetPluginContentPath("Icons/Speaker_96x.png"), Icon96x96)
275 );
276 StyleSet->Set(
278 new FSlateImageBrush(GetPluginContentPath("Icons/Generic_96x.png"), Icon96x96)
279 );
280 StyleSet->Set(
282 new FSlateImageBrush(GetPluginContentPath("Icons/QuestionMark_16x.png"), Icon16x16)
283 );
284 StyleSet->Set(
286 new FSlateImageBrush(GetEngineContentPath("Icons/icon_asset_open_16px.png"), Icon16x16)
287 );
288 StyleSet->Set(
290 new FSlateImageBrush(GetEngineContentPath("Icons/icon_Genericfinder_16x.png"), Icon16x16)
291 );
292 StyleSet->Set(
294 new FSlateBoxBrush(
295 GetEngineContentPath("BehaviorTree/IndexCircle.png"),
296 Icon20x20,
297 FMargin(8.0f / 20.0f)
298 )
299 );
300 StyleSet->Set(
302 new FSlateImageBrush(
303 GetEngineContentPath("Icons/icon_Blueprint_CommentBubbleOn_16x.png"),
304 Icon16x16,
305 FLinearColor(1.f, 1.f, 1.f, 1.f)
306 )
307 );
308
309 // Register the current style
310 FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
311}
312
314{
315 // unregister the style
316 if (!StyleSet.IsValid())
317 {
318 return;
319 }
320
321 FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get());
322 ensure(StyleSet.IsUnique());
323 StyleSet.Reset();
324}
static const FVector2D Icon64x64(64.0f, 64.0f)
static const FVector2D Icon16x16(16.0f, 16.0f)
static const FVector2D Icon20x20(20.0f, 20.0f)
static const FVector2D Icon24x24(24.0f, 24.0f)
static const FVector2D Icon96x96(96.0f, 96.0f)
static const FVector2D Icon40x40(40.0f, 40.0f)
const FName DIALOGUE_SYSTEM_PLUGIN_NAME(TEXT("DlgSystem"))
static const FName PROPERTY_DialogueSearch_TabIcon
static const FName PROPERTY_GraphNodeCircleBox
static const FName PROPERTY_DlgTextArgumentCustomClassThumbnail
static const FName PROPERTY_DlgConditionCustomClassIcon
static const FName PROPERTY_SaveAllDialoguesIcon
static const FName PROPERTY_ReloadAssetIcon
static const FName PROPERTY_OpenAssetIcon
static const FName PROPERTY_OpenWikiIcon
static const FName PROPERTY_OpenMarketplaceIcon
static const FName PROPERTY_DlgNodeDataClassThumbnail
static const FName PROPERTY_CommentBubbleOn
static const FName PROPERTY_VoiceIcon
static FString PluginContentRoot
static const FName PROPERTY_DlgTextArgumentCustomClassIcon
static FName GetStyleSetName()
static const FName PROPERTY_DlgEventCustomClassThumbnail
static FString GetEngineContentPath(const FString &RelativePath)
static void Initialize()
static const FName PROPERTY_DialogueBrowser_TabIcon
static const FName PROPERTY_DialogueDataDisplay_TabIcon
static const FName PROPERTY_DlgNodeDataClassIcon
static const FName PROPERTY_OpenNotYetPluginsIcon
static TSharedPtr< FSlateStyleSet > StyleSet
static void Shutdown()
static const FName PROPERTY_DlgDialogueClassIcon
static const FName PROPERTY_NotYetLogoIcon
static const FName PROPERTY_GenericIcon
static FString EngineContentRoot
static const FName PROPERTY_FindAssetIcon
static const FName PROPERTY_ConditionIcon
static const FName PROPERTY_FindInDialogueEditorIcon
static const FName PROPERTY_DeleteAllDialoguesTextFilesIcon
static const FName PROPERTY_DlgEventCustomClassIcon
static const FName PROPERTY_ShowPrimarySecondaryEdgesIcon
static const FName PROPERTY_DeleteCurrentDialogueTextFilesIcon
static const FName PROPERTY_DlgConditionCustomClassThumbnail
static const FName PROPERTY_FindInAllDialogueEditorIcon
static const FName PROPERTY_QuestionMarkIcon
static FName GetSmallProperty(FName PropertyName)
static const FName PROPERTY_DlgDialogueClassThumbnail
static const FName PROPERTY_OpenDiscordIcon
static const FName PROPERTY_EventIcon
static FString GetPluginContentPath(const FString &RelativePath)
static const FName PROPERTY_OpenForumIcon