A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DlgNodeDataFactory.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4
6#include "DlgNodeData.h"
7#include "Kismet2/KismetEditorUtilities.h"
8#include "Misc/MessageDialog.h"
9
10#define LOCTEXT_NAMESPACE "DlgSystem"
11
13// UDlgNodeDataFactory
14UDlgNodeDataFactory::UDlgNodeDataFactory(const FObjectInitializer& ObjectInitializer)
15 : Super(ObjectInitializer)
16{
17 bCreateNew = true;
18
19 // true if the associated editor should be opened after creating a new object.
20 bEditAfterNew = false;
21 SupportedClass = UDlgNodeData::StaticClass();
22
23 // Default class
24 ParentClass = SupportedClass;
25}
26
28{
29 static const FText TitleText = FText::FromString(TEXT("Pick Parent Class for Node Data"));
30 ParentClass = nullptr;
31
32 UClass* ChosenClass = nullptr;
33 const bool bPressedOk = FDialogueEditorUtilities::PickChildrenOfClass(TitleText, ChosenClass, SupportedClass);
34 if (bPressedOk)
35 {
36 ParentClass = ChosenClass;
37 }
38
39 return bPressedOk;
40}
41
43 UClass* Class,
44 UObject* InParent,
45 FName Name,
46 EObjectFlags Flags,
47 UObject* Context,
48 FFeedbackContext* Warn
49)
50{
51 // Something wrong happened
52 if (ParentClass == nullptr || !FKismetEditorUtilities::CanCreateBlueprintOfClass(ParentClass))
53 {
54 FFormatNamedArguments Args;
55 Args.Add(TEXT("ClassName"), ParentClass ? FText::FromString(ParentClass->GetName()) : NSLOCTEXT("UnrealEd", "Null", "(null)"));
56 FMessageDialog::Open(EAppMsgType::Ok, FText::Format(NSLOCTEXT("UnrealEd", "CannotCreateBlueprintFromClass", "Cannot create a blueprint based on the class '{0}'."), Args));
57 return nullptr;
58 }
59
60 // Create
61 return FKismetEditorUtilities::CreateBlueprint(
63 InParent,
64 Name,
65 BPTYPE_Normal,
66 UBlueprint::StaticClass(),
67 UBlueprintGeneratedClass::StaticClass(),
68 NAME_None
69 );
70}
71
72#undef LOCTEXT_NAMESPACE
static bool PickChildrenOfClass(const FText &TitleText, UClass *&OutChosenClass, UClass *Class)
UDlgNodeDataFactory(const FObjectInitializer &ObjectInitializer)
TSubclassOf< UDlgNodeData > ParentClass
UPROPERTY()
UObject * FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override
bool ConfigureProperties() override