Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/SLevelEditorModeContent.cpp
Andrew Rodham 8ff0d8b98b Added config migration path for newer versions of the engine.
Newly installed versions of the engine will now attempt to copy the project-agnostic config settings from a previous engine installation. This happens by way of a versioned manifest that copies old versions when the manifest does not exist, or is a different version. This code path is benign for non-installed versions of the engine (or FPaths::ShouldSaveToUserDir() is false).

EditorGameAgnosticSettings and EditorUserSettings ini paths have been renamed to EditorSettings and EditorPerProjectUserSettings respectively to better convey their purpose. In general, most settings should be saved in EditorSettings (project-agnostic) so that they apply regardless of which project is open. We have some way to go migrating existing settings for this to be the case, however.

Some previously per-project configuration files are now project-agnostic (such as Editor.ini, EditorKeyBindings.ini, and EditorLayout.ini)

GEditor->Access...Settings and GEditor->Get...Settings have been removed in favor of direct access of the CDO through GetMutableDefault<> and GetDefault<> respectively. Global config ini filenames that are not set up are now neither loaded nor saved on build machines, to handle the problem of indeterminate state more generically.

This addresses UETOOL-270 (Most editor preferences should be project-agnostic)

[CL 2517558 by Andrew Rodham in Main branch]
2015-04-20 10:12:55 -04:00

135 lines
4.0 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "LevelEditor.h"
#include "LevelEditorActions.h"
#include "SLevelEditorModeContent.h"
#include "LevelEditorActions.h"
#include "SToolkitDisplay.h"
#include "Editor/PropertyEditor/Public/PropertyEditorModule.h"
#include "Editor/PropertyEditor/Public/IDetailsView.h"
#include "SDockTab.h"
#define LOCTEXT_NAMESPACE "SLevelEditorModeContent"
SLevelEditorModeContent::~SLevelEditorModeContent()
{
GLevelEditorModeTools().OnEditorModeChanged().RemoveAll( this );
GetMutableDefault<UEditorPerProjectUserSettings>()->OnUserSettingChanged().RemoveAll( this );
}
void SLevelEditorModeContent::Construct( const FArguments& InArgs, const TSharedRef< class ILevelEditor >& InOwningLevelEditor, const TSharedRef< class SDockTab >& InOwningDocTab, FEdMode* InEditorMode )
{
LevelEditor = InOwningLevelEditor;
DocTab = InOwningDocTab;
EditorMode = InEditorMode;
InOwningDocTab->SetOnTabClosed( SDockTab::FOnTabClosedCallback::CreateSP(this, &SLevelEditorModeContent::HandleParentClosed ) );
GLevelEditorModeTools().OnEditorModeChanged().AddSP( this, &SLevelEditorModeContent::HandleEditorModeChanged );
GetMutableDefault<UEditorPerProjectUserSettings>()->OnUserSettingChanged().AddSP( this, &SLevelEditorModeContent::HandleUserSettingsChange );
ChildSlot
[
SNew( SHorizontalBox )
// The Current Creation Tool
+ SHorizontalBox::Slot()
.FillWidth( 1.0 )
.Padding( 2, 0, 0, 0 )
[
SNew( SVerticalBox )
+ SVerticalBox::Slot()
[
SAssignNew(InlineContentHolder, SBorder)
.BorderImage( FEditorStyle::GetBrush("NoBorder") )
.Padding(0.f)
.Visibility( this, &SLevelEditorModeContent::GetInlineContentHolderVisibility )
]
]
];
UpdateModeToolBar();
}
void SLevelEditorModeContent::HandleEditorModeChanged( FEdMode* Mode, bool IsEnabled )
{
if ( Mode == EditorMode && !IsEnabled )
{
DocTab.Pin()->SetOnTabClosed( SDockTab::FOnTabClosedCallback() );
DocTab.Pin()->RequestCloseTab();
}
}
void SLevelEditorModeContent::HandleUserSettingsChange( FName PropertyName )
{
UpdateModeToolBar();
}
void SLevelEditorModeContent::UpdateModeToolBar()
{
const TArray< TSharedPtr< IToolkit > >& HostedToolkits = LevelEditor.Pin()->GetHostedToolkits();
for( auto HostedToolkitIt = HostedToolkits.CreateConstIterator(); HostedToolkitIt; ++HostedToolkitIt )
{
UpdateInlineContent( ( *HostedToolkitIt )->GetInlineContent() );
break;
}
}
EVisibility SLevelEditorModeContent::GetInlineContentHolderVisibility() const
{
return InlineContentHolder->GetContent() == SNullWidget::NullWidget ? EVisibility::Collapsed : EVisibility::Visible;
}
void SLevelEditorModeContent::UpdateInlineContent(TSharedPtr<SWidget> InlineContent) const
{
if (InlineContent.IsValid() && InlineContentHolder.IsValid())
{
InlineContentHolder->SetContent(InlineContent.ToSharedRef());
}
}
void SLevelEditorModeContent::OnToolkitHostingStarted( const TSharedRef< class IToolkit >& Toolkit )
{
if( ToolkitArea.IsValid() )
{
ToolkitArea->OnToolkitHostingStarted( Toolkit );
}
UpdateInlineContent( Toolkit->GetInlineContent() );
}
void SLevelEditorModeContent::OnToolkitHostingFinished( const TSharedRef< class IToolkit >& Toolkit )
{
if( ToolkitArea.IsValid() )
{
ToolkitArea->OnToolkitHostingFinished( Toolkit );
}
bool FoundAnotherToolkit = false;
const TArray< TSharedPtr< IToolkit > >& HostedToolkits = LevelEditor.Pin()->GetHostedToolkits();
for( auto HostedToolkitIt = HostedToolkits.CreateConstIterator(); HostedToolkitIt; ++HostedToolkitIt )
{
if ( ( *HostedToolkitIt ) != Toolkit )
{
UpdateInlineContent( ( *HostedToolkitIt )->GetInlineContent() );
FoundAnotherToolkit = true;
break;
}
}
if ( !FoundAnotherToolkit )
{
UpdateInlineContent( SNullWidget::NullWidget );
}
}
void SLevelEditorModeContent::HandleParentClosed( TSharedRef<SDockTab> TabBeingClosed )
{
if ( GLevelEditorModeTools().IsModeActive(EditorMode->GetID()) )
{
GLevelEditorModeTools().DeactivateMode(EditorMode->GetID());
}
}
#undef LOCTEXT_NAMESPACE