Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/LevelViewportLayoutOnePane.cpp
matt kuhlenschmidt 0f072073f6 Reworked how realtime is overriden in the editor. This fixes issues where a temporarily set realtime state is saved between editor sessions causing users to be unaware that their viewport is not realtime. Shutting down the editor during PIE or remote desktop were two such cases.
Now there is a separate api on editor viewports to set and remove a temporary override state.  Deprecated existing methods and fixed up use cases.



#ROBOMERGE-OWNER: matt.kuhlenschmidt
#ROBOMERGE-AUTHOR: matt.kuhlenschmidt
#ROBOMERGE-SOURCE: CL 11498109 via CL 11498156 via CL 11498165
#ROBOMERGE-BOT: (v654-11333218)
#rb none

[CL 11498464 by matt kuhlenschmidt in Main branch]
2020-02-18 09:38:41 -05:00

89 lines
2.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "LevelViewportLayoutOnePane.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SBoxPanel.h"
#include "Framework/Docking/LayoutService.h"
#include "ShowFlags.h"
#include "Editor.h"
#include "Misc/ConfigCacheIni.h"
#include "Modules/ModuleManager.h"
#include "Framework/Application/SlateApplication.h"
#include "LevelEditor.h"
// FLevelViewportLayoutOnePane /////////////////////////////
void FLevelViewportLayoutOnePane::SaveLayoutString(const FString& LayoutString) const
{
if (!bIsTransitioning)
{
FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString);
SaveCommonLayoutString(SpecificLayoutString);
}
}
TSharedRef<SWidget> FLevelViewportLayoutOnePane::MakeViewportLayout(const FString& LayoutString)
{
// single viewport layout blocks maximize feature as it doesn't make sense
bIsMaximizeSupported = false;
FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString);
FEngineShowFlags OrthoShowFlags(ESFIM_Editor);
ApplyViewMode(VMI_BrushWireframe, false, OrthoShowFlags);
FEngineShowFlags PerspectiveShowFlags(ESFIM_Editor);
ApplyViewMode(VMI_Lit, true, PerspectiveShowFlags);
FString ViewportKey, ViewportType;
if (!SpecificLayoutString.IsEmpty())
{
const FString& IniSection = FLayoutSaveRestore::GetAdditionalLayoutConfigIni();
ViewportKey = SpecificLayoutString + TEXT(".Viewport0");
GConfig->GetString(*IniSection, *(ViewportKey + TEXT(".TypeWithinLayout")), ViewportType, GEditorPerProjectIni);
}
FLevelEditorModule& LevelEditor = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
// Set up the viewport
FViewportConstructionArgs Args;
Args.ParentLayout = AsShared();
Args.ParentLevelEditor = ParentLevelEditor;
Args.IsEnabled = FSlateApplication::Get().GetNormalExecutionAttribute();
Args.bRealtime = true;
Args.ConfigKey = *ViewportKey;
Args.ViewportType = LVT_Perspective;
TSharedRef<ILevelViewportLayoutEntity> Viewport = LevelEditor.FactoryViewport(*ViewportType, Args);
ViewportBox =
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
Viewport->AsWidget()
];
Viewports.Add( *ViewportKey, Viewport );
// Make newly-created perspective viewports active by default
GCurrentLevelEditingViewportClient = &Viewport->GetLevelViewportClient();
InitCommonLayoutFromString(SpecificLayoutString, NAME_None);
return ViewportBox.ToSharedRef();
}
void FLevelViewportLayoutOnePane::ReplaceWidget(TSharedRef<SWidget> Source, TSharedRef<SWidget> Replacement)
{
check(ViewportBox->GetChildren()->Num() == 1)
TSharedRef<SWidget> ViewportWidget = ViewportBox->GetChildren()->GetChildAt(0);
check(ViewportWidget == Source);
ViewportBox->RemoveSlot(Source);
ViewportBox->AddSlot()
[
Replacement
];
}