148 lines
3.6 KiB
C++
148 lines
3.6 KiB
C++
#include "Popups/ComboInputPopup_GraphValidation.h"
|
|
|
|
#include "ComboInputEditor.h"
|
|
#include "Helpers/ComboActionGraphColors.h"
|
|
#include "Interfaces/IPluginManager.h"
|
|
#include "Settings/ComboActionGraphEditorSettings.h"
|
|
#include "Widgets/Layout/SScrollBox.h"
|
|
#include "Widgets/Text/SRichTextBlock.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "ComboInputPopup_GraphValidation"
|
|
|
|
|
|
void ComboInputPopup_GraphValidation::OnBrowserLinkClicked(const FSlateHyperlinkRun::FMetadata &Metadata)
|
|
{
|
|
const FString *URL = Metadata.Find(TEXT("href"));
|
|
|
|
if (URL)
|
|
{
|
|
FPlatformProcess::LaunchURL(**URL, nullptr, nullptr);
|
|
}
|
|
}
|
|
|
|
TSharedPtr<SWindow> ComboInputPopup_GraphValidation::Open(const TArray<FText> ValidationMessages)
|
|
{
|
|
if (!FSlateApplication::Get().CanDisplayWindows())
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
const FComboInputEditorModule &Module = FModuleManager::GetModuleChecked<FComboInputEditorModule>("ComboInputEditor");
|
|
const TSharedPtr<FSlateStyleSet> &EditorStyle = Module.Get().GetComboInputEditorStyleSet();
|
|
|
|
const TSharedRef<SBorder> WindowContent = SNew(SBorder)
|
|
.BorderImage(EditorStyle->GetBrush("MDSStyleSet.Node.TextSoftEdges"))
|
|
.BorderBackgroundColor
|
|
(
|
|
ComboActionGraphColors::ValidationGraph::DarkTheme
|
|
)
|
|
.Padding(FMargin(8.0f, 8.0f));
|
|
|
|
TSharedPtr<SWindow> Window = SNew(SWindow)
|
|
.AutoCenter(EAutoCenter::PreferredWorkArea)
|
|
.SupportsMaximize(false)
|
|
.SupportsMinimize(false)
|
|
.SizingRule(ESizingRule::FixedSize)
|
|
.ClientSize(FVector2D(650, 750))
|
|
.Title(FText::FromString("Combo Action Graph Validation"))
|
|
.IsTopmostWindow(true)
|
|
[
|
|
WindowContent
|
|
];
|
|
|
|
const FSlateFontInfo Heading1Font = FCoreStyle::GetDefaultFontStyle("Bold", 24);
|
|
const FSlateFontInfo Heading2Font = FCoreStyle::GetDefaultFontStyle("Bold", 18);
|
|
const FSlateFontInfo NormalFont = FCoreStyle::GetDefaultFontStyle("Regular", 12);
|
|
|
|
const TSharedRef<SScrollBox> ListOfMessages = SNew(SScrollBox);
|
|
for (auto Itr : ValidationMessages)
|
|
{
|
|
ListOfMessages->AddSlot()
|
|
[
|
|
SNew(SBox)
|
|
.Padding(FMargin(0.f, 3.5f, 0.f, 3.5f))
|
|
[
|
|
SNew(SRichTextBlock)
|
|
.Text(Itr)
|
|
.TextStyle(FAppStyle::Get(), "NormalText")
|
|
.DecoratorStyleSet(&FAppStyle::Get())
|
|
.AutoWrapText(true)
|
|
]
|
|
];
|
|
}
|
|
|
|
if (ValidationMessages.Num() == 0)
|
|
{
|
|
ListOfMessages->AddSlot()
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(FText::FromString("There are no issues with your graph. You can close this window."))
|
|
.TextStyle(FAppStyle::Get(), "NormalText")
|
|
.AutoWrapText(true)
|
|
];
|
|
}
|
|
|
|
const TSharedRef<SVerticalBox> InnerContent =
|
|
SNew(SVerticalBox)
|
|
+ SVerticalBox::Slot()
|
|
.FillHeight(1.0)
|
|
.Padding(10)
|
|
[
|
|
SNew(SBorder)
|
|
.Padding(10)
|
|
.BorderImage(FAppStyle::GetBrush("ToolPanel.DarkGroupBorder"))
|
|
[
|
|
ListOfMessages
|
|
]
|
|
]
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(10)
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+ SHorizontalBox::Slot().FillWidth(1.0f)
|
|
[
|
|
SNew(SButton)
|
|
.HAlign(HAlign_Center)
|
|
.OnClicked_Lambda([Window]()
|
|
{
|
|
Window->RequestDestroyWindow();
|
|
|
|
return FReply::Handled();
|
|
})
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+ SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(FText::FromString("Close window"))
|
|
]
|
|
|
|
+ SHorizontalBox::Slot()
|
|
[
|
|
SNew(SSpacer)
|
|
.Size(FVector2D(5, 0))
|
|
]
|
|
|
|
+ SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(SImage)
|
|
.ColorAndOpacity(FLinearColor::Red)
|
|
.Image(EditorStyle->GetBrush("MDSStyleSet.Icon.Close"))
|
|
]
|
|
]
|
|
]
|
|
];
|
|
|
|
const int32 A = InnerContent.Get().GetAllChildren()->Num();
|
|
|
|
WindowContent->SetContent(InnerContent);
|
|
Window = FSlateApplication::Get().AddWindow(Window.ToSharedRef());
|
|
|
|
return Window;
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|