Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/LevelViewportLayoutOnePane.cpp
Matt Kuhlenschmidt 2046b738cd Fixed 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.

Added realtime and scalability indicators in the editor viewports so that users understand when realtime is off and non-default scalability is affecting their scene.

#rb none
#jira UE-88878

[CL 11537095 by Matt Kuhlenschmidt in 4.25 branch]
2020-02-19 09:48:23 -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
];
}