77 lines
2.6 KiB
C++
77 lines
2.6 KiB
C++
/*
|
|
* Tencent is pleased to support the open source community by making Puerts available.
|
|
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
|
|
* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may
|
|
* be subject to their corresponding license terms. This file is subject to the terms and conditions defined in file 'LICENSE',
|
|
* which is part of this source code package.
|
|
*/
|
|
|
|
#include "GenDTSStyle.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
#include "Styling/SlateStyleRegistry.h"
|
|
#include "Slate/SlateGameResources.h"
|
|
#include "Interfaces/IPluginManager.h"
|
|
|
|
TSharedPtr<FSlateStyleSet> FGenDTSStyle::StyleInstance = NULL;
|
|
|
|
void FGenDTSStyle::Initialize()
|
|
{
|
|
if (!StyleInstance.IsValid())
|
|
{
|
|
StyleInstance = Create();
|
|
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
|
|
}
|
|
}
|
|
|
|
void FGenDTSStyle::Shutdown()
|
|
{
|
|
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
|
|
ensure(StyleInstance.IsUnique());
|
|
StyleInstance.Reset();
|
|
}
|
|
|
|
FName FGenDTSStyle::GetStyleSetName()
|
|
{
|
|
static FName StyleSetName(TEXT("GenDTSStyle"));
|
|
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> FGenDTSStyle::Create()
|
|
{
|
|
TSharedRef<FSlateStyleSet> Style = MakeShareable(new FSlateStyleSet("GenDTSStyle"));
|
|
Style->SetContentRoot(IPluginManager::Get().FindPlugin("Puerts")->GetBaseDir() / TEXT("Resources"));
|
|
|
|
Style->Set("GenDTS.PluginAction", new IMAGE_BRUSH(TEXT("ButtonIcon_40x"), Icon40x40));
|
|
|
|
return Style;
|
|
}
|
|
|
|
#undef IMAGE_BRUSH
|
|
#undef BOX_BRUSH
|
|
#undef BORDER_BRUSH
|
|
#undef TTF_FONT
|
|
#undef OTF_FONT
|
|
|
|
void FGenDTSStyle::ReloadTextures()
|
|
{
|
|
if (FSlateApplication::IsInitialized())
|
|
{
|
|
FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
|
|
}
|
|
}
|
|
|
|
const ISlateStyle& FGenDTSStyle::Get()
|
|
{
|
|
return *StyleInstance;
|
|
}
|