1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
#include "Style/VSM_Style.h" #include "Styling/ISlateStyle.h" #include "Styling/SlateStyle.h" #include "Interfaces/IPluginManager.h" #include "Styling/SlateStyleRegistry.h" #include "SlateOptMacros.h" #include "Slate/SlateGameResources.h"
#define IMAGE_BRUSH(RelativePath, ... ) FSlateImageBrush( FVSM_Style::InResources( RelativePath, ".png" ), __VA_ARGS__ ) #define BOX_BRUSH(RelativePath, ... ) FSlateBoxBrush( FVSM_Style::InResources( RelativePath, ".png" ), __VA_ARGS__ )
TSharedPtr< FSlateStyleSet > FVSM_Style::StyleSet = nullptr; TSharedPtr< FSlateStyleSet > FVSM_Style::BlueprintStyleSet = nullptr;
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION void FVSM_Style::Initialize() { const FVector2D Icon8x8(8.0f, 8.0f); const FVector2D Icon16x16(16.0f, 16.0f); const FVector2D Icon20x20(20.0f, 20.0f); const FVector2D Icon40x40(40.0f, 40.0f); const FVector2D Generic10x10(10.0f, 10.0f); const FVector2D NodeBody64x64(64.0f, 64.0f); const FVector2D Icon128x128(64.0f, 64.0f);
if (!BlueprintStyleSet) { FString styleDir = TEXT("/VSM/Style/");
BlueprintStyleSet = FSlateGameResources::New(FVSM_Style::GetBPStyleSetName(),*styleDir, *styleDir); if (BlueprintStyleSet) { FSlateStyleRegistry::RegisterSlateStyle(*BlueprintStyleSet); } }
if (StyleSet.IsValid()) return;
StyleSet = MakeShareable(new FSlateStyleSet(GetStyleSetName())); StyleSet->SetContentRoot(FPaths::EngineContentDir() / TEXT("Editor/Slate")); StyleSet->SetCoreContentRoot(FPaths::EngineContentDir() / TEXT("Slate"));
StyleSet->Set("ClassIcon.VSM_Blueprint", new IMAGE_BRUSH(TEXT("Icons/StateMachine_16"), Icon16x16)); StyleSet->Set("ClassThumbnail.VSM_Blueprint", new IMAGE_BRUSH(TEXT("Icons/StateMachine_128"), Icon128x128));
StyleSet->Set("ClassIcon.VSM_StateMachine", new IMAGE_BRUSH(TEXT("Icons/StateMachine_16"), Icon16x16)); StyleSet->Set("ClassThumbnail.VSM_StateMachine", new IMAGE_BRUSH(TEXT("Icons/StateMachine_128"), Icon128x128));
StyleSet->Set("ClassIcon.VSM_Blueprint_Task", new IMAGE_BRUSH(TEXT("Icons/Task_16"), Icon16x16)); StyleSet->Set("ClassThumbnail.VSM_Blueprint_Task", new IMAGE_BRUSH(TEXT("Icons/Task_128"), Icon128x128));
StyleSet->Set("ClassIcon.VSM_Task_Base", new IMAGE_BRUSH(TEXT("Icons/Task_16"), Icon16x16)); StyleSet->Set("ClassThumbnail.VSM_Task_Base", new IMAGE_BRUSH(TEXT("Icons/Task_128"), Icon128x128));
StyleSet->Set("VSM.StateMachine", new IMAGE_BRUSH("Icons/StateMachine", Icon40x40)); StyleSet->Set("VSM.StateMachineSmall", new IMAGE_BRUSH("Icons/StateMachine", Icon20x20)); StyleSet->Set("VSM.StateMachineGraphSmall", new IMAGE_BRUSH("Icons/GraphIconSmall", Icon20x20)); StyleSet->Set("VSM.Task", new IMAGE_BRUSH("Icons/Task", Icon40x40));
StyleSet->Set("VSM.NodeBody", new BOX_BRUSH(TEXT("Graph/NodeBody"), FMargin(4.f / 64.f, 4.f / 64.f, 4.f / 64.f, 4.f / 64.f))); StyleSet->Set("VSM.NodePinHoverCue", new IMAGE_BRUSH(TEXT("Graph/NodePinHoverCue"), Generic10x10)); StyleSet->Set("VSM.RegularNodeShadow", new BOX_BRUSH(TEXT("Graph/RegularNodeShadow"), FMargin(18.0f / 64.0f)));
StyleSet->Set("VSM.StateMachine.NodeBody", new BOX_BRUSH(TEXT("Graph/StateMachine/NodeBody"), FMargin(16.f / 64.f, 25.f / 64.f, 16.f / 64.f, 16.f / 64.f))); StyleSet->Set("VSM.StateMachine.NodeBodySelected", new BOX_BRUSH(TEXT("Graph/StateMachine/NodeBodySelected"), FMargin(18.0f / 64.0f))); StyleSet->Set("VSM.StateMachine.NodeBodyColorSpill", new BOX_BRUSH(TEXT("Graph/StateMachine/NodeBodyColorSpill"), FMargin(4.0f / 64.0f, 4.0f / 32.0f))); StyleSet->Set("VSM.StateMachine.NodePinHoverCue", new BOX_BRUSH(TEXT("Graph/StateMachine/NodePinHoverCue"), FMargin(12.0f / 64.0f, 12.0f / 64.0f, 12.0f / 64.0f, 12.0f / 64.0f))); StyleSet->Set("VSM.StateMachine.Icon", new IMAGE_BRUSH("Graph/StateMachine/NodeIcon", Icon16x16)); StyleSet->Set("vsm.StateMachine.TransitionNodeBody", new BOX_BRUSH("Graph/StateMachine/TransNodeBody", FMargin(16.f / 64.f, 12.f / 28.f))); StyleSet->Set("VSM.StateMachine.TransitionNodeColorSpill", new BOX_BRUSH("Graph/StateMachine/TransNodeColorSpill", FMargin(0.25f, 0.25f, 0.25f, 0.25f))); StyleSet->Set("VSM.StateMachine.TransitionNodeIcon", new IMAGE_BRUSH("Graph/StateMachine/TransNodeIcon", FVector2D(25, 25)));
FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
}
const FSlateBrush* FVSM_Style::GetBrush(FName PropertyName, const ANSICHAR* Specifier ) { return FVSM_Style::Get()->GetBrush(PropertyName, Specifier); }
ISlateStyle& FVSM_Style::GetBPStyle() { return *BlueprintStyleSet; }
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
FLinearColor FVSM_Style::TransitionNodeHorverColor(0.22f, 1.0f, 1.0f, 1.0f); FLinearColor FVSM_Style::TransitionNodeBaseColor(0.8f, 0.8f, 0.8f, 0.8f); FLinearColor FVSM_Style::NodeBodyBaseColor(0.8f, 0.8f, 0.8f, 0.8f);
#undef IMAGE_BRUSH #undef BOX_BRUSH
void FVSM_Style::Shutdown() { if (StyleSet.IsValid()) { FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get()); ensure(StyleSet.IsUnique()); StyleSet.Reset(); } if (BlueprintStyleSet.IsValid()) { FSlateStyleRegistry::UnRegisterSlateStyle(*BlueprintStyleSet.Get()); ensure(BlueprintStyleSet.IsUnique()); BlueprintStyleSet.Reset(); } }
TSharedPtr< class ISlateStyle > FVSM_Style::Get() { return StyleSet; }
FName FVSM_Style::GetStyleSetName() { static FName StyleName(TEXT("FVSM_Style")); return StyleName; }
FName FVSM_Style::GetBPStyleSetName() {
FName BPStyleName(TEXT("FVSM_BlueprintStyle")); return BPStyleName; }
FString FVSM_Style::InResources(const FString& RelativePath, const ANSICHAR* Extension) { static FString ContentDir = IPluginManager::Get().FindPlugin(TEXT("VSM"))->GetBaseDir() / TEXT("Resources"); return (ContentDir / RelativePath) + Extension; }
|