5#include "Engine/BlueprintCore.h"
6#include "Templates/SharedPointer.h"
7#include "AssetRegistryModule.h"
8#include "Kismet2/BlueprintEditorUtils.h"
9#include "WorkspaceMenuStructureModule.h"
10#include "WorkspaceMenuStructure.h"
11#include "Widgets/Docking/SDockTab.h"
12#include "Framework/MultiBox/MultiBoxExtender.h"
13#include "LevelEditor.h"
14#include "GenericPlatform/GenericPlatformMisc.h"
16#include "Framework/MultiBox/MultiBoxBuilder.h"
17#include "Kismet2/KismetEditorUtilities.h"
18#include "K2Node_Event.h"
44#define LOCTEXT_NAMESPACE "DlgSystemEditor"
59#if ENGINE_MINOR_VERSION >= 24
61 const FString LongName = FPackageName::ConvertToLongScriptPackageName(TEXT(
"DlgSystemEditor"));
62 if (UPackage* Package = Cast<UPackage>(StaticFindObjectFast(UPackage::StaticClass(),
nullptr, *LongName,
false,
false)))
64 Package->SetPackageFlags(PKG_EditorOnly);
68 UE_LOG(LogDlgSystemEditor, Log, TEXT(
"DlgSystemEditorModule: StartupModule"));
78 FKismetEditorUtilities::RegisterOnBlueprintCreatedCallback(
80 UDlgConditionCustom::StaticClass(),
83 FKismetEditorUtilities::RegisterOnBlueprintCreatedCallback(
85 UDlgTextArgumentCustom::StaticClass(),
88 FKismetEditorUtilities::RegisterOnBlueprintCreatedCallback(
90 UDlgEventCustom::StaticClass(),
93 FKismetEditorUtilities::RegisterOnBlueprintCreatedCallback(
95 UDlgNodeData::StaticClass(),
103 FDialogueCommands::Register();
106 IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>(
NAME_MODULE_AssetTools).Get();
112 AssetTools.RegisterAssetTypeActions(Action);
117 AssetTools.RegisterAssetTypeActions(Action);
122 AssetTools.RegisterAssetTypeActions(Action);
127 AssetTools.RegisterAssetTypeActions(Action);
132 AssetTools.RegisterAssetTypeActions(Action);
147 TArray<FOnGetDetailCustomizationInstance> CustomClassLayouts = {
153 UDlgDialogue::StaticClass()->GetFName(),
154 UDialogueGraphNode::StaticClass()->GetFName(),
155 UDlgNode::StaticClass()->GetFName()
164 TArray<FOnGetPropertyTypeCustomizationInstance> CustomPropertyTypeLayouts = {
172 FDlgEdge::StaticStruct()->GetFName(),
173 FDlgCondition::StaticStruct()->GetFName(),
174 FDlgEvent::StaticStruct()->GetFName(),
175 FDlgSpeechSequenceEntry::StaticStruct()->GetFName(),
176 FDlgTextArgument::StaticStruct()->GetFName()
183 PropertyModule.NotifyCustomizationModuleChanged();
210 const FModuleManager& ModuleManger = FModuleManager::Get();
221 if (UObjectInitialized())
248 IAssetTools& AssetTools = FModuleManager::GetModuleChecked<FAssetToolsModule>(
NAME_MODULE_AssetTools).Get();
251 AssetTools.UnregisterAssetTypeActions(TypeAction.ToSharedRef());
257 FDialogueCommands::Unregister();
285 UE_LOG(LogDlgSystemEditor, Log, TEXT(
"DlgSystemEditorModule: ShutdownModule"));
290 const EAppReturnType::Type Response = FPlatformMisc::MessageBoxExt(EAppMsgType::YesNo,
291 TEXT(
"Save all Dialogue assets/files? This will save both the .uasset and the text files depending on the TextFormat from the Dialogue Settings."),
292 TEXT(
"Save Dialogues?")
294 if (Response == EAppReturnType::No)
301 UE_LOG(LogDlgSystemEditor,
Error, TEXT(
"Failed To save all Dialogues. An error occurred."));
307 const TSet<FString> AllFileExtensions = GetDefault<UDlgSystemSettings>()->GetAllTextFileExtensions();
308 const FString StringAllFileExtensions = FString::Join(AllFileExtensions, TEXT(
","));
309 const FString Text = FString::Printf(
310 TEXT(
"Delete all Dialogues text files? Delete all dialogues text files on the disk with the following extensions: %s"),
311 *StringAllFileExtensions
314 const EAppReturnType::Type Response = FPlatformMisc::MessageBoxExt(EAppMsgType::YesNo, *Text, TEXT(
"Delete All Dialogues text files?"));
315 if (Response == EAppReturnType::No)
322 UE_LOG(LogDlgSystemEditor,
Error, TEXT(
"Failed To delete all Dialogues text files. An error occurred."));
331 UE_LOG(LogDlgSystemEditor, Log, TEXT(
"DlgSystemEditorModule::HandleOnPostEngineInit"));
348 FDlgLogger::Get().
Debugf(TEXT(
"BeginPIE(bIsSimulating = %d). Clearing Dialogue History"), bIsSimulating);
354 FDlgLogger::Get().
Debugf(TEXT(
"BeginPIE(bIsSimulating = %d). Registering Console commands"), bIsSimulating);
369 FDlgLogger::Get().
Debugf(TEXT(
"EndPIE(bIsSimulating = %d). Unregistering Console commands"), bIsSimulating);
376 if (!Blueprint || Blueprint->BlueprintType != BPTYPE_Normal)
381 Blueprint->bForceFullEditor =
true;
385 UDlgConditionCustom::StaticClass()
389 Blueprint->LastEditedDocuments.Add(FunctionGraph);
395 if (!Blueprint || Blueprint->BlueprintType != BPTYPE_Normal)
400 Blueprint->bForceFullEditor =
true;
404 UDlgTextArgumentCustom::StaticClass()
408 Blueprint->LastEditedDocuments.Add(FunctionGraph);
414 if (!Blueprint || Blueprint->BlueprintType != BPTYPE_Normal)
419 Blueprint->bForceFullEditor =
true;
423 UDlgEventCustom::StaticClass()
427 Blueprint->LastEditedDocuments.Add(EventNode->GetGraph());
433 if (!Blueprint || Blueprint->BlueprintType != BPTYPE_Normal)
444 if (IsRunningGame() || IsRunningCommandlet() || IsRunningDedicatedServer())
455 FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>(
NAME_MODULE_LevelEditor);
456 LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(FileMenuExtender);
457 LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(HelpMenuExtender);
464 LOCTEXT(
"WorkspaceMenu_DialogueCategory",
"Dialogue" ),
474 FOnSpawnTab::CreateLambda([
this](
const FSpawnTabArgs& Args) -> TSharedRef<SDockTab>
476 const TSharedRef<SDockTab> DockTab = SNew(SDockTab)
477 .TabRole(ETabRole::NomadTab)
483 .SetDisplayName(LOCTEXT(
"DialogueBrowserTabTitle",
"Dialogue Browser"))
484 .SetTooltipText(LOCTEXT(
"DialogueBrowserTooltipText",
"Open the Dialogue Overview Browser tab."))
499 TSharedRef<FUICommandList> Commands,
500 const TArray<TSharedPtr<FUICommandInfo>>& AdditionalMenuEntries
504 TSharedRef<FExtender> FileMenuExtender(
new FExtender);
505 FileMenuExtender->AddMenuExtension(
507 EExtensionHook::After,
509 FMenuExtensionDelegate::CreateLambda([AdditionalMenuEntries](FMenuBuilder& MenuBuilder)
512 MenuBuilder.BeginSection(
"Dialogue", LOCTEXT(
"DialogueMenuKeyCategory",
"Dialogue"));
514 MenuBuilder.AddMenuEntry(FDialogueCommands::Get().SaveAllDialogues);
515 MenuBuilder.AddMenuEntry(FDialogueCommands::Get().DeleteAllDialoguesTextFiles);
516 MenuBuilder.AddMenuSeparator();
517 for (
auto& MenuEntry : AdditionalMenuEntries)
519 MenuBuilder.AddMenuEntry(MenuEntry);
522 MenuBuilder.EndSection();
526 return FileMenuExtender;
534 TSharedRef<FExtender> HelpMenuExtender(
new FExtender);
535 HelpMenuExtender->AddMenuExtension(
537 EExtensionHook::Before,
539 FMenuExtensionDelegate::CreateLambda([](FMenuBuilder& MenuBuilder)
542 MenuBuilder.BeginSection(
"Dialogue", LOCTEXT(
"DialogueMenuKeyCategory",
"Dialogue"));
544 MenuBuilder.AddMenuEntry(FDialogueCommands::Get().OpenNotYetPlugins);
545 MenuBuilder.AddMenuEntry(FDialogueCommands::Get().OpenMarketplace);
546 MenuBuilder.AddMenuEntry(FDialogueCommands::Get().OpenWiki);
547 MenuBuilder.AddMenuEntry(FDialogueCommands::Get().OpenDiscord);
548 MenuBuilder.AddMenuEntry(FDialogueCommands::Get().OpenForum);
550 MenuBuilder.EndSection();
554 return HelpMenuExtender;
560 FDialogueCommands::Get().SaveAllDialogues,
564 FDialogueCommands::Get().DeleteAllDialoguesTextFiles,
573 FDialogueCommands::Get().OpenNotYetPlugins,
574 FExecuteAction::CreateLambda([&Settings]()
580 FDialogueCommands::Get().OpenMarketplace,
581 FExecuteAction::CreateLambda([&Settings]()
583 FPlatformProcess::LaunchURL(*Settings.
URLMarketplace,
nullptr,
nullptr );
587 FDialogueCommands::Get().OpenDiscord,
588 FExecuteAction::CreateLambda([&Settings]()
590 FPlatformProcess::LaunchURL(*Settings.
URLDiscord,
nullptr,
nullptr );
594 FDialogueCommands::Get().OpenForum,
595 FExecuteAction::CreateLambda([&Settings]()
597 FPlatformProcess::LaunchURL(*Settings.
URLForum,
nullptr,
nullptr );
601 FDialogueCommands::Get().OpenWiki,
602 FExecuteAction::CreateLambda([&Settings]()
604 FPlatformProcess::LaunchURL(*Settings.
URLWiki,
nullptr,
nullptr );
609#undef LOCTEXT_NAMESPACE
static const FName DIALOGUE_SYSTEM_MENU_CATEGORY_KEY(TEXT("Dialogue System"))
static const FName NAME_MODULE_AssetTools(TEXT("AssetTools"))
static const FName NAME_MODULE_LevelEditor(TEXT("LevelEditor"))
static const FName NAME_MODULE_AssetRegistry(TEXT("AssetRegistry"))
static const FText DIALOGUE_SYSTEM_MENU_CATEGORY_KEY_TEXT(NSLOCTEXT("DlgSystemEditor", "DlgSystemAssetCategory", "Dialogue System"))
static const FName NAME_MODULE_PropertyEditor(TEXT("PropertyEditor"))
static const FName DIALOGUE_BROWSER_TAB_ID("DialogueBrowser")
IMPLEMENT_MODULE(FOpenXRExpansionEditorModule, OpenXRExpansionEditor)
DEFINE_LOG_CATEGORY(LogVaRest)
static TSharedRef< IDetailCustomization > MakeInstance()
static TSharedRef< IPropertyTypeCustomization > MakeInstance()
static void InstallHooks()
static void RemoveHooks()
static TSharedRef< IPropertyTypeCustomization > MakeInstance()
static bool DeleteAllDialoguesTextFiles()
static UK2Node_Event * BlueprintGetOrAddEvent(UBlueprint *Blueprint, FName EventName, UClass *EventClassSignature)
static bool SaveAllDialogues()
static UEdGraphNode_Comment * BlueprintAddComment(UBlueprint *Blueprint, const FString &CommentString, FVector2D Location=FVector2D::ZeroVector)
static UEdGraph * BlueprintGetOrAddFunction(UBlueprint *Blueprint, FName FunctionName, UClass *FunctionClassSignature)
static TSharedRef< IPropertyTypeCustomization > MakeInstance()
static TSharedRef< IDetailCustomization > MakeInstance()
static TSharedRef< IDetailCustomization > MakeInstance()
static TSharedRef< IPropertyTypeCustomization > MakeInstance()
static FName GetStyleSetName()
static const FName PROPERTY_DialogueBrowser_TabIcon
static const FName PROPERTY_DialogueDataDisplay_TabIcon
static const FName PROPERTY_DlgDialogueClassIcon
static TSharedRef< IPropertyTypeCustomization > MakeInstance()
static FDlgLogger & Get()
static TSharedRef< FExtender > CreateHelpMenuExtender(TSharedRef< FUICommandList > Commands)
void ShutdownModule() override
EAssetTypeCategories::Type DlgSystemAssetCategoryBit
TSharedPtr< FUICommandList > LevelMenuEditorCommands
void HandleOnEndPIEHandle(bool bIsSimulating)
static void HandleOnDeleteAllDialoguesTextFiles()
void StartupModule() override
TSharedPtr< FWorkspaceItem > ToolsDialogueCategory
static void MapActionsForFileMenuExtender(TSharedRef< FUICommandList > Commands)
FDelegateHandle OnPostEngineInitHandle
static void MapActionsForHelpMenuExtender(TSharedRef< FUICommandList > Commands)
static void HandleOnSaveAllDialogues()
void HandleOnPostPIEStarted(bool bIsSimulating)
TArray< FName > RegisteredCustomClassLayouts
TArray< TSharedPtr< IAssetTypeActions > > RegisteredAssetTypeActions
void HandleNewCustomConditionBlueprintCreated(UBlueprint *Blueprint)
FDelegateHandle OnPostPIEStartedHandle
void HandleNewNodeDataBlueprintCreated(UBlueprint *Blueprint)
TSharedPtr< FGraphPanelPinFactory > DialogueGraphPinFactory
void HandleNewCustomTextArgumentBlueprintCreated(UBlueprint *Blueprint)
static TSharedRef< FExtender > CreateFileMenuExtender(TSharedRef< FUICommandList > Commands, const TArray< TSharedPtr< FUICommandInfo > > &AdditionalMenuEntries={})
FDelegateHandle OnEndPIEHandle
TSharedPtr< FGraphPanelNodeFactory > DialogueGraphNodeFactory
bool bIsEngineInitialized
void HandleOnBeginPIE(bool bIsSimulating)
void HandleOnPostEngineInit()
void HandleNewCustomEventBlueprintCreated(UBlueprint *Blueprint)
FDelegateHandle OnBeginPIEHandle
TArray< FName > RegisteredCustomPropertyTypeLayout
static IDlgSystemModule & Get()
virtual FTabSpawnerEntry * GetDialogueDataDisplaySpawnEntry()=0
void Debugf(const FmtType &Fmt, Types... Args)
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)
static bool RegisterDialogueConsoleCommands()
UFUNCTION(BlueprintCallable, Category = "Dialogue|Console")
static void ClearDialogueHistory()
UFUNCTION(BlueprintCallable, Category = "Dialogue|Memory")
static bool UnregisterDialogueConsoleCommands()
UFUNCTION(BlueprintCallable, Category = "Dialogue|Console")
UCLASS(Config = Engine, DefaultConfig, meta = (DisplayName = "Dialogue System Settings"))
bool bClearDialogueHistoryAutomatically
UPROPERTY(Category = "Runtime", Config, EditAnywhere)
bool bRegisterDialogueConsoleCommandsAutomatically
UPROPERTY(Category = "Runtime", Config, EditAnywhere)
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)