2014-11-19 07:43:07 -05:00
|
|
|
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "LogVisualizer.h"
|
|
|
|
|
#include "LogVisualizerModule.h"
|
|
|
|
|
#include "LogVisualizerStyle.h"
|
|
|
|
|
#include "SDockTab.h"
|
2014-11-25 10:26:44 -05:00
|
|
|
#include "VisualLoggerRenderingActor.h"
|
2014-11-25 17:52:12 -05:00
|
|
|
#include "Editor/EditorEngine.h"
|
2014-11-19 07:43:07 -05:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "FLogVisualizerModule"
|
|
|
|
|
|
|
|
|
|
static const FName VisualLoggerTabName("VisualLogger");
|
|
|
|
|
|
|
|
|
|
//DEFINE_LOG_CATEGORY(LogLogVisualizer);
|
|
|
|
|
|
|
|
|
|
void FNewLogVisualizerModule::StartupModule()
|
|
|
|
|
{
|
|
|
|
|
FLogVisualizerStyle::Initialize();
|
|
|
|
|
|
|
|
|
|
FVisualLoggerCommands::Register();
|
|
|
|
|
IModularFeatures::Get().RegisterModularFeature(VisualLoggerTabName, this);
|
|
|
|
|
|
|
|
|
|
// This is still experimental in the editor, so it'll be invoked specifically in FMainMenu if the experimental settings flag is set.
|
|
|
|
|
// When no longer experimental, switch to the nomad spawner registration below
|
|
|
|
|
FGlobalTabmanager::Get()->RegisterTabSpawner(VisualLoggerTabName, FOnSpawnTab::CreateRaw(this, &FNewLogVisualizerModule::SpawnLogVisualizerTab));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FNewLogVisualizerModule::ShutdownModule()
|
|
|
|
|
{
|
|
|
|
|
FGlobalTabmanager::Get()->UnregisterTabSpawner(VisualLoggerTabName);
|
|
|
|
|
FVisualLoggerCommands::Unregister();
|
|
|
|
|
IModularFeatures::Get().UnregisterModularFeature(VisualLoggerTabName, this);
|
|
|
|
|
|
|
|
|
|
FLogVisualizerStyle::Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SDockTab> FNewLogVisualizerModule::SpawnLogVisualizerTab(const FSpawnTabArgs& SpawnTabArgs)
|
|
|
|
|
{
|
|
|
|
|
const TSharedRef<SDockTab> MajorTab = SNew(SDockTab)
|
2014-11-25 10:26:44 -05:00
|
|
|
.TabRole(ETabRole::MajorTab).OnTabClosed(SDockTab::FOnTabClosedCallback::CreateRaw(this, &FNewLogVisualizerModule::OnTabClosed));
|
2014-11-19 07:43:07 -05:00
|
|
|
|
|
|
|
|
TSharedPtr<SWidget> TabContent;
|
|
|
|
|
|
|
|
|
|
TabContent = SNew(SVisualLogger, MajorTab, SpawnTabArgs.GetOwnerWindow());
|
|
|
|
|
|
|
|
|
|
MajorTab->SetContent(TabContent.ToSharedRef());
|
|
|
|
|
|
|
|
|
|
return MajorTab;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-25 10:26:44 -05:00
|
|
|
void FNewLogVisualizerModule::OnTabClosed(TSharedRef<SDockTab>)
|
|
|
|
|
{
|
|
|
|
|
UWorld* World = NULL;
|
|
|
|
|
#if WITH_EDITOR
|
|
|
|
|
UEditorEngine *EEngine = Cast<UEditorEngine>(GEngine);
|
|
|
|
|
if (GIsEditor && EEngine != NULL)
|
|
|
|
|
{
|
|
|
|
|
// lets use PlayWorld during PIE/Simulate and regular world from editor otherwise, to draw debug information
|
|
|
|
|
World = EEngine->PlayWorld != NULL ? EEngine->PlayWorld : EEngine->GetEditorWorldContext().World();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
if (!GIsEditor)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
World = GEngine->GetWorld();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (World == NULL)
|
|
|
|
|
{
|
|
|
|
|
World = GWorld;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (World)
|
|
|
|
|
{
|
|
|
|
|
for (TActorIterator<AVisualLoggerRenderingActor> It(World); It; ++It)
|
|
|
|
|
{
|
|
|
|
|
World->DestroyActor(*It);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 07:43:07 -05:00
|
|
|
IMPLEMENT_MODULE(FNewLogVisualizerModule, LogVisualizer);
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|