diff --git a/Source/ComboInputEditor/Private/ComboInputEditor.cpp b/Source/ComboInputEditor/Private/ComboInputEditor.cpp index 89eb08f..6d72cbb 100644 --- a/Source/ComboInputEditor/Private/ComboInputEditor.cpp +++ b/Source/ComboInputEditor/Private/ComboInputEditor.cpp @@ -234,7 +234,6 @@ FComboInputSlateStyle::FComboInputSlateStyle() : FSlateStyleSet("ComboInputEdito this->Set("MDSStyleSet.Node.Icon.small", new IMAGE_BRUSH(TEXT("DialogueNodeIcon"), Icon12)); this->Set("MDSStyleSet.Icon.Close", new IMAGE_BRUSH(TEXT("CloseIcon"), Icon12)); - this->Set("MDSStyleSet.Icon.SupportDiscord", new IMAGE_BRUSH(TEXT("DiscordIcon"), Icon12)); this->Set("MDSStyleSet.Icon.HeartIcon", new IMAGE_BRUSH(TEXT("HeartIcon"), Icon12)); this->Set("MDSStyleSet.Icon.UBIcon", new IMAGE_BRUSH(TEXT("UnrealBucketIcon"), Icon12)); this->Set("MDSStyleSet.Icon.MoneyIcon", new IMAGE_BRUSH(TEXT("MoneyIcon"), Icon12)); diff --git a/Source/ComboInputEditor/Private/Popups/ComboInputPopup_GraphValidation.cpp b/Source/ComboInputEditor/Private/Popups/ComboInputPopup_GraphValidation.cpp new file mode 100644 index 0000000..4c6cfa1 --- /dev/null +++ b/Source/ComboInputEditor/Private/Popups/ComboInputPopup_GraphValidation.cpp @@ -0,0 +1,147 @@ +#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 ComboInputPopup_GraphValidation::Open(const TArray ValidationMessages) +{ + if (!FSlateApplication::Get().CanDisplayWindows()) + { + return nullptr; + } + + const FComboInputEditorModule &Module = FModuleManager::GetModuleChecked("ComboInputEditor"); + const TSharedPtr &EditorStyle = Module.Get().GetComboInputEditorStyleSet(); + + const TSharedRef WindowContent = SNew(SBorder) + .BorderImage(EditorStyle->GetBrush("MDSStyleSet.Node.TextSoftEdges")) + .BorderBackgroundColor + ( + ComboActionGraphColors::ValidationGraph::DarkTheme + ) + .Padding(FMargin(8.0f, 8.0f)); + + TSharedPtr 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 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 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 diff --git a/Source/ComboInputEditor/Private/Popups/ComboInputPopup_GraphValidation.h b/Source/ComboInputEditor/Private/Popups/ComboInputPopup_GraphValidation.h new file mode 100644 index 0000000..2f72535 --- /dev/null +++ b/Source/ComboInputEditor/Private/Popups/ComboInputPopup_GraphValidation.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Framework/Text/SlateHyperlinkRun.h" + + +class SScrollBox; + +class ComboInputPopup_GraphValidation +{ +public: + static TSharedPtr Open(const TArray ValidationMessages); + static void OnBrowserLinkClicked(const FSlateHyperlinkRun::FMetadata &Metadata); +}; diff --git a/Source/ComboInputEditor/Public/ComboInputEditor.h b/Source/ComboInputEditor/Public/ComboInputEditor.h index 3876702..8b6ed56 100644 --- a/Source/ComboInputEditor/Public/ComboInputEditor.h +++ b/Source/ComboInputEditor/Public/ComboInputEditor.h @@ -95,7 +95,6 @@ private: TArray> CreatedAssetTypeActions; TSharedPtr ComboInputEditorStyleSet; - TSharedPtr ComboActionGraphEditorStyleSet; TSharedPtr ComboActionGraphPanelNodeFactory; TSharedPtr ComboActionGraphAssetActions; };