aboutsummaryrefslogtreecommitdiff
path: root/Plugins/SimpleUGC/Source/SimpleUGCEditor/Private/SimpleUGCEditorStyle.cpp
diff options
context:
space:
mode:
authorivey <[email protected]>2020-06-15 15:54:16 -0400
committerivey <[email protected]>2020-06-15 15:54:16 -0400
commitd5310c3455f9849243b7b950deb4e910aa1f24dd (patch)
tree994a81eec10538d2a1efd9ed78469a249ff086f2 /Plugins/SimpleUGC/Source/SimpleUGCEditor/Private/SimpleUGCEditorStyle.cpp
parentUpdated image paths. (diff)
downloadugcexample-d5310c3455f9849243b7b950deb4e910aa1f24dd.tar.xz
ugcexample-d5310c3455f9849243b7b950deb4e910aa1f24dd.zip
Initial commit of the UGCExample Project
Diffstat (limited to 'Plugins/SimpleUGC/Source/SimpleUGCEditor/Private/SimpleUGCEditorStyle.cpp')
-rw-r--r--Plugins/SimpleUGC/Source/SimpleUGCEditor/Private/SimpleUGCEditorStyle.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/Plugins/SimpleUGC/Source/SimpleUGCEditor/Private/SimpleUGCEditorStyle.cpp b/Plugins/SimpleUGC/Source/SimpleUGCEditor/Private/SimpleUGCEditorStyle.cpp
new file mode 100644
index 0000000..309261a
--- /dev/null
+++ b/Plugins/SimpleUGC/Source/SimpleUGCEditor/Private/SimpleUGCEditorStyle.cpp
@@ -0,0 +1,72 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "SimpleUGCEditorStyle.h"
+#include "SimpleUGCEditor.h"
+#include "Framework/Application/SlateApplication.h"
+#include "Styling/SlateStyleRegistry.h"
+#include "Slate/SlateGameResources.h"
+#include "Interfaces/IPluginManager.h"
+
+TSharedPtr< FSlateStyleSet > FSimpleUGCEditorStyle::StyleInstance = NULL;
+
+void FSimpleUGCEditorStyle::Initialize()
+{
+ if (!StyleInstance.IsValid())
+ {
+ StyleInstance = Create();
+ FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
+ }
+}
+
+void FSimpleUGCEditorStyle::Shutdown()
+{
+ FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
+ ensure(StyleInstance.IsUnique());
+ StyleInstance.Reset();
+}
+
+FName FSimpleUGCEditorStyle::GetStyleSetName()
+{
+ static FName StyleSetName(TEXT("SimpleUGCEditorStyle"));
+ return StyleSetName;
+}
+
+#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
+#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
+#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
+#define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ )
+#define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ )
+
+const FVector2D Icon16x16(16.0f, 16.0f);
+const FVector2D Icon20x20(20.0f, 20.0f);
+const FVector2D Icon40x40(40.0f, 40.0f);
+
+TSharedRef< FSlateStyleSet > FSimpleUGCEditorStyle::Create()
+{
+ TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("SimpleUGCEditorStyle"));
+ Style->SetContentRoot(IPluginManager::Get().FindPlugin("SimpleUGC")->GetBaseDir() / TEXT("Resources"));
+
+ Style->Set("SimpleUGCEditor.PackageUGCAction", new IMAGE_BRUSH(TEXT("PackageUGC_64x"), Icon40x40));
+ Style->Set("SimpleUGCEditor.CreateUGCAction", new IMAGE_BRUSH(TEXT("CreateUGC_64x"), Icon40x40));
+
+ return Style;
+}
+
+#undef IMAGE_BRUSH
+#undef BOX_BRUSH
+#undef BORDER_BRUSH
+#undef TTF_FONT
+#undef OTF_FONT
+
+void FSimpleUGCEditorStyle::ReloadTextures()
+{
+ if (FSlateApplication::IsInitialized())
+ {
+ FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
+ }
+}
+
+const ISlateStyle& FSimpleUGCEditorStyle::Get()
+{
+ return *StyleInstance;
+}