4#include "Modules/ModuleManager.h"
5#include "AssetRegistryModule.h"
6#include "Framework/Docking/TabManager.h"
7#include "Widgets/Docking/SDockTab.h"
8#include "HAL/IConsoleManager.h"
9#include "HAL/FileManager.h"
10#include "GameFramework/Actor.h"
12#if WITH_GAMEPLAY_DEBUGGER
13#include "GameplayDebugger.h"
16#include "WorkspaceMenuStructureModule.h"
17#include "WorkspaceMenuStructure.h"
28#define LOCTEXT_NAMESPACE "FDlgSystemModule"
41 OnPreLoadMapHandle = FCoreUObjectDelegates::PreLoadMap.AddRaw(
this, &Self::HandleOnPreLoadMap);
42 OnPostLoadMapWithWorldHandle = FCoreUObjectDelegates::PostLoadMapWithWorld.AddRaw(
this, &Self::HandleOnPostLoadMapWithWorld);
47 OnInMemoryAssetDeletedHandle = AssetRegistry.OnInMemoryAssetDeleted().AddRaw(
this, &Self::HandleOnInMemoryAssetDeleted);
50 OnAssetRemovedHandle = AssetRegistry.OnAssetRemoved().AddRaw(
this, &Self::HandleOnAssetRemoved);
51 OnAssetRenamedHandle = AssetRegistry.OnAssetRenamed().AddRaw(
this, &Self::HandleOnAssetRenamed);
53#if WITH_GAMEPLAY_DEBUGGER
55 IGameplayDebugger& GameplayDebuggerModule = IGameplayDebugger::Get();
56 GameplayDebuggerModule.RegisterCategory(
58 IGameplayDebugger::FOnGetCategory::CreateStatic(&FDlgGameplayDebuggerCategory::MakeInstance),
59 EGameplayDebuggerCategoryState::EnabledInGameAndSimulate
61 GameplayDebuggerModule.NotifyCategoriesChanged();
65 bHasRegisteredTabSpawners =
true;
67 DialogueDataDisplayTabSpawnEntry = &FGlobalTabmanager::Get()->RegisterNomadTabSpawner(
69 FOnSpawnTab::CreateLambda([
this](
const FSpawnTabArgs& Args) -> TSharedRef<SDockTab>
71 TSharedRef<SDockTab> DialogueDataDisplayTab = SNew(SDockTab)
72 .TabRole(ETabRole::NomadTab)
74 GetDialogueDataDisplayWindow()
76 return DialogueDataDisplayTab;
78 .SetDisplayName(LOCTEXT(
"DialogueDataDisplayTitle",
"Dialogue Data Display"))
79 .SetTooltipText(LOCTEXT(
"DialogueDataDisplayTooltipText",
"Open the Dialogue Data Display tab.")
92#if WITH_GAMEPLAY_DEBUGGER
94 if (IGameplayDebugger::IsAvailable())
96 IGameplayDebugger& GameplayDebuggerModule = IGameplayDebugger::Get();
98 GameplayDebuggerModule.NotifyCategoriesChanged();
104 const FModuleManager& ModuleManger = FModuleManager::Get();
109 IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(
NAME_MODULE_AssetRegistry).Get();
140 if (!DialogueData.IsValid())
146 return DialogueData.ToSharedRef();
159 if (InWorldContextObjectPtr.IsValid())
164 IConsoleManager& ConsoleManager = IConsoleManager::Get();
166 ConsoleManager.RegisterConsoleCommand(
167 TEXT(
"Dlg.DataDisplay"),
168 TEXT(
"Displays the Dialogue Data Window"),
175 ConsoleManager.RegisterConsoleCommand(
176 TEXT(
"Dlg.LoadAllDialogues"),
177 TEXT(
"Load All Dialogues into memory"),
178 FConsoleCommandDelegate::CreateLambda([]()
195 IConsoleManager::Get().UnregisterConsoleObject(Command);
204 FDlgLogger::Get().
Error(TEXT(
"Did not Initialize the tab spawner for the DisplayDialogueDataWindow"));
217 const TSharedPtr<SDockTab> DlgDisplayDataTab =
219 if (DlgDisplayDataTab.IsValid())
222 TSharedRef<SDlgDataDisplay> Window = StaticCastSharedRef<SDlgDataDisplay>(DlgDisplayDataTab->GetContent());
226 Window->RefreshTree(
false);
232 FGlobalTabmanager::Get()->DrawAttention(DlgDisplayDataTab.ToSharedRef());
253 if (!RemovedAsset.IsAssetLoaded())
261 UObject* ObjectRenamed = AssetRenamed.GetAsset();
270 if (!IsValid(DeletedDialogue))
280 if (!IsValid(RenamedDialogue))
287 if (OldTextFilePathName.IsEmpty())
295 if (OldTextFilePathName == CurrentTextFilePathName)
298 TEXT(
"Dialogue was renamed but the paths before and after are equal :O | `%s` == `%s`"),
299 *OldTextFilePathName, *CurrentTextFilePathName
305 for (
const FString& FileExtension : GetDefault<UDlgSystemSettings>()->GetAllTextFileExtensions())
307 const FString OldFileName = OldTextFilePathName + FileExtension;
308 const FString NewFileName = CurrentTextFilePathName + FileExtension;
346 FDlgLogger::Get().
Debugf(TEXT(
"PostLoadMapWithWorld = %s. Registering Console commands"), *LoadedWorld->GetMapName());
351#undef LOCTEXT_NAMESPACE
static const FName NAME_MODULE_AssetRegistry(TEXT("AssetRegistry"))
static const FName DIALOGUE_DATA_DISPLAY_TAB_ID(TEXT("DlgDataDisplayWindow"))
const FName DIALOGUE_SYSTEM_PLUGIN_NAME(TEXT("DlgSystem"))
IMPLEMENT_MODULE(FOpenXRExpansionEditorModule, OpenXRExpansionEditor)
DEFINE_LOG_CATEGORY(LogVaRest)
static bool RenameFile(const FString &OldPathName, const FString &NewPathName, bool bOverWrite=false, bool bVerbose=true)
static TSharedPtr< SDockTab > InvokeTab(TSharedPtr< FTabManager > TabManager, const FTabId &TabID)
static FDlgLogger & Get()
void UnregisterConsoleCommands() override
TWeakPtr< SDlgDataDisplay > DialogueDataDisplayWidget
FDelegateHandle OnPostLoadMapWithWorldHandle
bool RefreshDisplayDialogueDataWindow(bool bFocus=true)
TSharedRef< SWidget > GetDialogueDataDisplayWindow() override
FDelegateHandle OnAssetRenamedHandle
void HandleDialogueDeleted(UDlgDialogue *DeletedDialogue)
void HandleOnInMemoryAssetDeleted(UObject *DeletedObject)
void ShutdownModule() override
void DisplayDialogueDataWindow() override
void HandleOnPostLoadMapWithWorld(UWorld *LoadedWorld)
FTabSpawnerEntry * DialogueDataDisplayTabSpawnEntry
void HandleDialogueRenamed(UDlgDialogue *RenamedDialogue, const FString &OldObjectPath)
void HandleOnAssetRemoved(const FAssetData &RemovedAsset)
TWeakObjectPtr< UWorld > LastLoadedWorld
void HandleOnPreLoadMap(const FString &MapName)
FDelegateHandle OnAssetRemovedHandle
bool bHasRegisteredTabSpawners
void HandleOnAssetRenamed(const FAssetData &AssetRenamed, const FString &OldObjectPath)
void RegisterConsoleCommands(const TWeakObjectPtr< const UObject > &InWorldContextObjectPtr) override
FDelegateHandle OnInMemoryAssetDeletedHandle
TArray< IConsoleCommand * > ConsoleCommands
FDelegateHandle OnPreLoadMapHandle
FTabSpawnerEntry * GetDialogueDataDisplaySpawnEntry() override
TWeakObjectPtr< const UObject > WorldContextObjectPtr
FORCEINLINE void Error(const FString &Message)
void Errorf(const FmtType &Fmt, Types... Args)
FORCEINLINE void Info(const FString &Message)
void Debugf(const FmtType &Fmt, Types... Args)
UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
static FString GetTextFilePathNameFromAssetPathName(const FString &AssetPathName)
bool DeleteAllTextFiles() const
FString GetTextFilePathName(bool bAddExtension=true) const
static void ClearDialogueHistory()
UFUNCTION(BlueprintCallable, Category = "Dialogue|Memory")
static int32 LoadAllDialoguesIntoMemory(bool bAsync=false)
UCLASS(Config = Engine, DefaultConfig, meta = (DisplayName = "Dialogue System Settings"))
bool bClearDialogueHistoryAutomatically
UPROPERTY(Category = "Runtime", Config, EditAnywhere)
bool bRegisterDialogueConsoleCommandsAutomatically
UPROPERTY(Category = "Runtime", Config, EditAnywhere)