// Copyright Epic Games, Inc. All Rights Reserved. #include "AnimationBlueprintEditorMode.h" #include "Animation/DebugSkelMeshComponent.h" #include "Animation/AnimInstance.h" #include "IPersonaToolkit.h" #include "BlueprintEditorTabs.h" #include "ISkeletonEditorModule.h" #include "PersonaModule.h" #include "SBlueprintEditorToolbar.h" #include "IPersonaPreviewScene.h" #include "PersonaUtils.h" #include "ToolMenus.h" ///////////////////////////////////////////////////// // FAnimationBlueprintEditorMode FAnimationBlueprintEditorMode::FAnimationBlueprintEditorMode(const TSharedRef& InAnimationBlueprintEditor) : FBlueprintEditorApplicationMode(InAnimationBlueprintEditor, FAnimationBlueprintEditorModes::AnimationBlueprintEditorMode, FAnimationBlueprintEditorModes::GetLocalizedMode, false, false) { PreviewScenePtr = InAnimationBlueprintEditor->GetPreviewScene(); AnimBlueprintPtr = CastChecked(InAnimationBlueprintEditor->GetBlueprintObj()); TabLayout = FTabManager::NewLayout( "Stanalone_AnimationBlueprintEditMode_Layout_v1.4" ) ->AddArea ( FTabManager::NewPrimaryArea() ->SetOrientation(Orient_Vertical) ->Split ( // Main application area FTabManager::NewSplitter() ->SetOrientation(Orient_Horizontal) ->Split ( // Left side FTabManager::NewSplitter() ->SetSizeCoefficient(0.25f) ->SetOrientation(Orient_Vertical) ->Split ( // Left top - viewport FTabManager::NewStack() ->SetSizeCoefficient(0.5f) ->SetHideTabWell(true) ->AddTab(AnimationBlueprintEditorTabs::ViewportTab, ETabState::OpenedTab) ) ->Split ( // Left bottom - preview settings FTabManager::NewStack() ->SetSizeCoefficient(0.5f) ->AddTab(AnimationBlueprintEditorTabs::CurveNamesTab, ETabState::ClosedTab) ->AddTab(AnimationBlueprintEditorTabs::SkeletonTreeTab, ETabState::ClosedTab) ->AddTab(AnimationBlueprintEditorTabs::PoseWatchTab, ETabState::OpenedTab) ->AddTab(FBlueprintEditorTabs::MyBlueprintID, ETabState::OpenedTab) ) ) ->Split ( // Middle FTabManager::NewSplitter() ->SetOrientation(Orient_Vertical) ->SetSizeCoefficient(0.55f) ->Split ( // Middle top - document edit area FTabManager::NewStack() ->SetSizeCoefficient(0.8f) ->AddTab("Document", ETabState::ClosedTab) ) ->Split ( // Middle bottom - compiler results & find FTabManager::NewStack() ->SetSizeCoefficient(0.2f) ->AddTab(FBlueprintEditorTabs::CompilerResultsID, ETabState::ClosedTab) ->AddTab(FBlueprintEditorTabs::FindResultsID, ETabState::ClosedTab) ) ) ->Split ( // Right side FTabManager::NewSplitter() ->SetSizeCoefficient(0.2f) ->SetOrientation(Orient_Vertical) ->Split ( // Right top - selection details panel & overrides FTabManager::NewStack() ->SetHideTabWell(false) ->SetSizeCoefficient(0.5f) ->AddTab(FBlueprintEditorTabs::DetailsID, ETabState::OpenedTab) ->AddTab(AnimationBlueprintEditorTabs::AdvancedPreviewTab, ETabState::OpenedTab) ->AddTab(AnimationBlueprintEditorTabs::AssetOverridesTab, ETabState::ClosedTab) ->SetForegroundTab(FBlueprintEditorTabs::DetailsID) ) ->Split ( // Right bottom - Asset browser & advanced preview settings FTabManager::NewStack() ->SetHideTabWell(false) ->SetSizeCoefficient(0.5f) ->AddTab(AnimationBlueprintEditorTabs::AnimBlueprintPreviewEditorTab, ETabState::OpenedTab) ->AddTab(AnimationBlueprintEditorTabs::AssetBrowserTab, ETabState::OpenedTab) ->AddTab(AnimationBlueprintEditorTabs::SlotNamesTab, ETabState::ClosedTab) ->SetForegroundTab(AnimationBlueprintEditorTabs::AnimBlueprintPreviewEditorTab) ) ) ) ); ISkeletonEditorModule& SkeletonEditorModule = FModuleManager::LoadModuleChecked("SkeletonEditor"); TabFactories.RegisterFactory(SkeletonEditorModule.CreateSkeletonTreeTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetSkeletonTree())); FPersonaModule& PersonaModule = FModuleManager::LoadModuleChecked("Persona"); FPersonaViewportArgs ViewportArgs(InAnimationBlueprintEditor->GetPersonaToolkit()->GetPreviewScene()); ViewportArgs.OnViewportCreated = FOnViewportCreated::CreateSP(&InAnimationBlueprintEditor.Get(), &FAnimationBlueprintEditor::HandleViewportCreated); ViewportArgs.BlueprintEditor = InAnimationBlueprintEditor; ViewportArgs.bShowStats = false; ViewportArgs.ContextName = TEXT("AnimationBlueprintEditor.Viewport"); PersonaModule.RegisterPersonaViewportTabFactories(TabFactories, InAnimationBlueprintEditor, ViewportArgs); TabFactories.RegisterFactory(PersonaModule.CreateAdvancedPreviewSceneTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetPersonaToolkit()->GetPreviewScene())); TabFactories.RegisterFactory(PersonaModule.CreateAnimationAssetBrowserTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetPersonaToolkit(), FOnOpenNewAsset::CreateSP(&InAnimationBlueprintEditor.Get(), &FAnimationBlueprintEditor::HandleOpenNewAsset), FOnAnimationSequenceBrowserCreated(), true)); TabFactories.RegisterFactory(PersonaModule.CreateAnimBlueprintPreviewTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetPersonaToolkit()->GetPreviewScene())); TabFactories.RegisterFactory(PersonaModule.CreateAnimBlueprintAssetOverridesTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetPersonaToolkit()->GetAnimBlueprint(), InAnimationBlueprintEditor->OnPostUndo)); TabFactories.RegisterFactory(PersonaModule.CreateSkeletonSlotNamesTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetSkeletonTree()->GetEditableSkeleton(), FOnObjectSelected::CreateSP(&InAnimationBlueprintEditor.Get(), &FAnimationBlueprintEditor::HandleObjectSelected))); TabFactories.RegisterFactory(PersonaModule.CreateCurveViewerTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetSkeletonTree()->GetEditableSkeleton(), InAnimationBlueprintEditor->GetPersonaToolkit()->GetPreviewScene(), FOnObjectsSelected::CreateSP(&InAnimationBlueprintEditor.Get(), &FAnimationBlueprintEditor::HandleObjectsSelected))); TabFactories.RegisterFactory(PersonaModule.CreatePoseWatchTabFactory(InAnimationBlueprintEditor)); // setup toolbar - clear existing toolbar extender from the BP mode //@TODO: Keep this in sync with BlueprintEditorModes.cpp ToolbarExtender = MakeShareable(new FExtender); if (UToolMenu* Toolbar = InAnimationBlueprintEditor->RegisterModeToolbarIfUnregistered(GetModeName())) { InAnimationBlueprintEditor->GetToolbarBuilder()->AddCompileToolbar(Toolbar); InAnimationBlueprintEditor->GetToolbarBuilder()->AddScriptingToolbar(Toolbar); InAnimationBlueprintEditor->GetToolbarBuilder()->AddBlueprintGlobalOptionsToolbar(Toolbar); InAnimationBlueprintEditor->GetToolbarBuilder()->AddDebuggingToolbar(Toolbar); } PersonaModule.OnRegisterTabs().Broadcast(TabFactories, InAnimationBlueprintEditor); LayoutExtender = MakeShared(); PersonaModule.OnRegisterLayoutExtensions().Broadcast(*LayoutExtender.Get()); TabLayout->ProcessExtensions(*LayoutExtender.Get()); } void FAnimationBlueprintEditorMode::RegisterTabFactories(TSharedPtr InTabManager) { TSharedPtr BP = MyBlueprintEditor.Pin(); BP->RegisterToolbarTab(InTabManager.ToSharedRef()); // Mode-specific setup BP->PushTabFactories(CoreTabFactories); BP->PushTabFactories(BlueprintEditorTabFactories); BP->PushTabFactories(TabFactories); } void FAnimationBlueprintEditorMode::PostActivateMode() { if (UAnimBlueprint* AnimBlueprint = AnimBlueprintPtr.Get()) { // Switch off any active preview when going to graph editing mode PreviewScenePtr.Pin()->SetPreviewAnimationAsset(NULL, false); // When switching to anim blueprint mode, make sure the object being debugged is either a valid world object or the preview instance UDebugSkelMeshComponent* PreviewComponent = PreviewScenePtr.Pin()->GetPreviewMeshComponent(); if ((AnimBlueprint->GetObjectBeingDebugged() == NULL) && (PreviewComponent->IsAnimBlueprintInstanced())) { PersonaUtils::SetObjectBeingDebugged(AnimBlueprint, PreviewComponent->GetAnimInstance()); } // If we are a derived anim blueprint always show the overrides tab if(UAnimBlueprint::FindRootAnimBlueprint(AnimBlueprint)) { MyBlueprintEditor.Pin()->GetTabManager()->TryInvokeTab(AnimationBlueprintEditorTabs::AssetOverridesTab); } } FBlueprintEditorApplicationMode::PostActivateMode(); }