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