TSharedRef<SWidget> TLevelViewportLayoutTwoPanes<TOrientation>::MakeViewportLayout(const FString& LayoutString) { FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString); FString ViewportKey0, ViewportKey1; FString ViewportType0, ViewportType1; float SplitterPercentage = ViewportLayoutTwoPanesDefs::DefaultSplitterPercentage; if (!SpecificLayoutString.IsEmpty()) { // The Layout String only holds the unique ID of the Additional Layout Configs to use const FString& IniSection = FLayoutSaveRestore::GetAdditionalLayoutConfigIni(); ViewportKey0 = SpecificLayoutString + TEXT(".Viewport0"); ViewportKey1 = SpecificLayoutString + TEXT(".Viewport1"); GConfig->GetString(*IniSection, *(ViewportKey0 + TEXT(".TypeWithinLayout")), ViewportType0, GEditorPerProjectIni); GConfig->GetString(*IniSection, *(ViewportKey1 + TEXT(".TypeWithinLayout")), ViewportType1, GEditorPerProjectIni); FString PercentageString; if(GConfig->GetString(*IniSection, *(SpecificLayoutString + TEXT(".Percentage")), PercentageString, GEditorPerProjectIni)) { TTypeFromString<float>::FromString(SplitterPercentage, *PercentageString); } } FLevelEditorModule& LevelEditor = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor"); // Set up the viewports FViewportConstructionArgs Args; Args.ParentLayout = AsShared(); Args.ParentLevelEditor = ParentLevelEditor; Args.IsEnabled = FSlateApplication::Get().GetNormalExecutionAttribute(); Args.bRealtime = false; Args.ConfigKey = ViewportKey0; Args.ViewportType = LVT_OrthoXY; TSharedRef<IViewportLayoutEntity> Viewport0 = LevelEditor.FactoryViewport(*ViewportType0, Args); Args.bRealtime = true; Args.ConfigKey = ViewportKey1; Args.ViewportType = LVT_Perspective; TSharedRef<IViewportLayoutEntity> Viewport1 = LevelEditor.FactoryViewport(*ViewportType1, Args); Viewports.Add( *ViewportKey0, Viewport0 ); Viewports.Add( *ViewportKey1, Viewport1 ); // Make newly-created perspective viewports active by default GCurrentLevelEditingViewportClient = &Viewport0->GetLevelViewportClient(); SplitterWidget = SNew( SSplitter ) .Orientation(TOrientation) +SSplitter::Slot() .Value(SplitterPercentage) [ Viewport0->AsWidget() ] +SSplitter::Slot() .Value(1.0f - SplitterPercentage) [ Viewport1->AsWidget() ]; InitCommonLayoutFromString(SpecificLayoutString, *ViewportKey1); return SplitterWidget.ToSharedRef(); }
TSharedRef<SWidget> FLevelViewportLayout2x2::MakeViewportLayout(const FString& LayoutString) { FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString); TSharedPtr< SLevelViewport > ViewportWidgetTL; TSharedPtr< SLevelViewport > ViewportWidgetTR; TSharedPtr< SLevelViewport > ViewportWidgetBL; TSharedPtr< SLevelViewport > ViewportWidgetBR; FString TopLeftKey, BottomLeftKey, TopRightKey, BottomRightKey; TArray<FVector2D> SplitterPercentages; if (!SpecificLayoutString.IsEmpty()) { // The Layout String only holds the unique ID of the Additional Layout Configs to use const FString& IniSection = FLayoutSaveRestore::GetAdditionalLayoutConfigIni(); TopLeftKey = SpecificLayoutString + TEXT(".Viewport0"); BottomLeftKey = SpecificLayoutString + TEXT(".Viewport1"); TopRightKey = SpecificLayoutString + TEXT(".Viewport2"); BottomRightKey = SpecificLayoutString + TEXT(".Viewport3"); for (int32 i = 0; i < 4; ++i) { FString PercentageString; FVector2D NewPercentage = ViewportLayout2x2Defs::DefaultSplitterPercentages; if(GConfig->GetString(*IniSection, *(SpecificLayoutString + FString::Printf(TEXT(".Percentages%i"), i)), PercentageString, GEditorUserSettingsIni)) { NewPercentage.InitFromString(PercentageString); } SplitterPercentages.Add(NewPercentage); } } SplitterWidget = SNew( SSplitter2x2 ) .TopLeft() [ SAssignNew( ViewportWidgetTL, SLevelViewport ) .ViewportType( LVT_OrthoYZ ) // Side .ParentLayout( AsShared() ) .ParentLevelEditor( ParentLevelEditor ) .ConfigKey( TopLeftKey ) ] .BottomLeft() [ SAssignNew( ViewportWidgetBL, SLevelViewport ) .ViewportType( LVT_Perspective ) // Persp .Realtime( true ) .ParentLayout( AsShared() ) .ParentLevelEditor( ParentLevelEditor ) .ConfigKey( BottomLeftKey ) ] .TopRight() [ SAssignNew( ViewportWidgetTR, SLevelViewport ) .ViewportType( LVT_OrthoXZ ) // Front .ParentLayout( AsShared() ) .ParentLevelEditor( ParentLevelEditor ) .ConfigKey( TopRightKey ) ] .BottomRight() [ SAssignNew( ViewportWidgetBR, SLevelViewport ) .ViewportType( LVT_OrthoXY ) // Top .ParentLayout( AsShared() ) .ParentLevelEditor( ParentLevelEditor ) .ConfigKey( BottomRightKey ) ]; Viewports.Add( ViewportWidgetTL ); Viewports.Add( ViewportWidgetBL ); Viewports.Add( ViewportWidgetTR ); Viewports.Add( ViewportWidgetBR ); // Make newly-created perspective viewports active by default GCurrentLevelEditingViewportClient = &ViewportWidgetBL->GetLevelViewportClient(); if (SplitterPercentages.Num() > 0) { SplitterWidget->SetSplitterPercentages(SplitterPercentages); } InitCommonLayoutFromString(SpecificLayoutString); return SplitterWidget.ToSharedRef(); }