Files
UnrealEngineUWP/Engine/Source/Developer/MessageLog/Private/MessageLogModule.cpp

115 lines
3.8 KiB
C++
Raw Normal View History

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "MessageLogPrivatePCH.h"
#include "MessageLogModule.h"
#include "Editor/WorkspaceMenuStructure/Public/WorkspaceMenuStructureModule.h"
#include "TokenizedMessage.h"
#include "SDockTab.h"
#include "SMessageLog.h"
#include "SMessageLogListing.h"
#include "MessageLogModel.h"
#include "MessageLogViewModel.h"
#include "MessageLogListingModel.h"
#include "MessageLogListingViewModel.h"
#include "MessageLog.h"
IMPLEMENT_MODULE( FMessageLogModule, MessageLog );
TSharedRef<SDockTab> SpawnMessageLog( const FSpawnTabArgs& Args, TSharedRef<FMessageLogViewModel> MessageLogViewModel )
{
return SNew(SDockTab)
.TabRole(ETabRole::NomadTab)
[
SNew(SMessageLog, MessageLogViewModel)
];
}
static TSharedRef<IMessageLog> GetLog(const FName& LogName)
{
FMessageLogModule& MessageLogModule = FModuleManager::LoadModuleChecked<FMessageLogModule>("MessageLog");
return MessageLogModule.GetLogListing(LogName);
}
FMessageLogModule::FMessageLogModule()
: bCanDisplayMessageLog(false)
{
}
void FMessageLogModule::StartupModule()
{
MessageLogViewModel = MakeShareable(new FMessageLogViewModel(MakeShareable(new FMessageLogModel())));
MessageLogViewModel->Initialize();
#if WITH_EDITOR
FGlobalTabmanager::Get()->RegisterNomadTabSpawner("MessageLog", FOnSpawnTab::CreateStatic( &SpawnMessageLog, MessageLogViewModel.ToSharedRef() ))
.SetDisplayName(NSLOCTEXT("UnrealEditor", "MessageLogTab", "Message Log"))
.SetTooltipText(NSLOCTEXT("UnrealEditor", "MessageLogTooltipText", "Open the Message Log tab."))
Window menu refactor & polish - Window menu is now sectioned and labeled based on the current editor. There's now a local workspace root member in FTabManager and a workspace category in FAssetEditorToolkit (both are FWorkspaceItem objects). Individual editors attach their local category to the tab manager's local root. Workflow app modes have their own category members that are swapped out when the mode changes. - Finally, the AssetEditorCategory of FWorkspaceMenuStructure has been removed entirely. - Replaced the AddMenuSeparator() call in FTabManager::PopulateSpawnerMenu_Helper() with a section of the same title as the workspace category. - Tab spawner menu entries for the local editor now properly show the icon of the associated tab. To accomplish this it was necessary to change FWorkflowTabFactory::TabIcon to be an FSlateIcon instead of an FSlateBrush*. All factory instances have been updated accordingly. - Added & updated lots of icons! (those missing will be TTP'd) - The nomad tab spawner section (named "General" in the menu) has been largely compressed into the Developer Tools submenu, which has also been organized into sections for readability. - Unreal frontend options were also moved into a context menu within the General section - Moved all experimental tools to their own section of the Window menu. When they're no longer experimental they should register as nomads in the appropriate category - Undo history now under Edit menu [CL 2324285 by Dan Hertzka in Main branch]
2014-10-09 12:34:55 -04:00
.SetGroup( WorkspaceMenu::GetMenuStructure().GetDeveloperToolsLogCategory() )
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "MessageLog.TabIcon"));
#endif
Window menu refactor & polish - Window menu is now sectioned and labeled based on the current editor. There's now a local workspace root member in FTabManager and a workspace category in FAssetEditorToolkit (both are FWorkspaceItem objects). Individual editors attach their local category to the tab manager's local root. Workflow app modes have their own category members that are swapped out when the mode changes. - Finally, the AssetEditorCategory of FWorkspaceMenuStructure has been removed entirely. - Replaced the AddMenuSeparator() call in FTabManager::PopulateSpawnerMenu_Helper() with a section of the same title as the workspace category. - Tab spawner menu entries for the local editor now properly show the icon of the associated tab. To accomplish this it was necessary to change FWorkflowTabFactory::TabIcon to be an FSlateIcon instead of an FSlateBrush*. All factory instances have been updated accordingly. - Added & updated lots of icons! (those missing will be TTP'd) - The nomad tab spawner section (named "General" in the menu) has been largely compressed into the Developer Tools submenu, which has also been organized into sections for readability. - Unreal frontend options were also moved into a context menu within the General section - Moved all experimental tools to their own section of the Window menu. When they're no longer experimental they should register as nomads in the appropriate category - Undo history now under Edit menu [CL 2324285 by Dan Hertzka in Main branch]
2014-10-09 12:34:55 -04:00
// Bind us so message log output is routed via this module
FMessageLog::OnGetLog().BindStatic(&GetLog);
}
void FMessageLogModule::ShutdownModule()
{
#if WITH_EDITOR
if (FSlateApplication::IsInitialized())
{
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner("MessageLog");
}
#endif
FMessageLog::OnGetLog().Unbind();
}
TSharedRef<IMessageLogListing> FMessageLogModule::GetLogListing(const FName& LogName)
{
return MessageLogViewModel->GetLogListingViewModel(LogName);
}
void FMessageLogModule::RegisterLogListing(const FName& LogName, const FText& LogLabel, const FMessageLogInitializationOptions& InitializationOptions)
{
MessageLogViewModel->RegisterLogListingViewModel(LogName, LogLabel, InitializationOptions);
}
bool FMessageLogModule::UnregisterLogListing(const FName& LogName)
{
return MessageLogViewModel->UnregisterLogListingViewModel(LogName);
}
bool FMessageLogModule::IsRegisteredLogListing(const FName& LogName) const
{
return MessageLogViewModel->IsRegisteredLogListingViewModel(LogName);
}
TSharedRef<IMessageLogListing> FMessageLogModule::CreateLogListing(const FName& InLogName, const FMessageLogInitializationOptions& InitializationOptions)
{
TSharedRef<FMessageLogListingModel> MessageLogListingModel = FMessageLogListingModel::Create( InLogName );
return FMessageLogListingViewModel::Create( MessageLogListingModel, FText(), InitializationOptions );
}
TSharedRef<SWidget> FMessageLogModule::CreateLogListingWidget(const TSharedRef<IMessageLogListing>& InMessageLogListing)
{
return SNew(SMessageLogListing, InMessageLogListing);
}
void FMessageLogModule::OpenMessageLog(const FName& LogName)
{
// only open the message log if we have a window created for the tab manager & our delegate allows it
if(bCanDisplayMessageLog
#if !PLATFORM_MAC
&& FGlobalTabmanager::Get()->GetRootWindow().IsValid()
#endif
)
{
FGlobalTabmanager::Get()->InvokeTab(FName("MessageLog"));
MessageLogViewModel->ChangeCurrentListingViewModel(LogName);
}
}
void FMessageLogModule::EnableMessageLogDisplay(bool bInCanDisplayMessageLog)
{
bCanDisplayMessageLog = bInCanDisplayMessageLog;
}