Files
UnrealEngineUWP/Engine/Source/Editor/AnimationBlueprintEditor/Private/AnimationBlueprintEditorMode.cpp
lucas dower 7ba1366473 Misc pose watch manager changes.
- Pose watch manager now in default anim bp layout
- Fix for being unable to make pose watches created from 'Automatically create pose watch on selection' setting a permanent pose watch and vice versa
- Cleaned up drag-and-drop validation
- Updated context menus
- Improved resolving name clashes

#jira UE-136746
#jira UE-136745
#rb Thomas.Sarkanen
#preflight 61b33ae1ee0de9822e3a62cc

#ROBOMERGE-AUTHOR: lucas.dower
#ROBOMERGE-SOURCE: CL 18430031 in //UE5/Release-5.0/... via CL 18435283
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)

[CL 18435504 by lucas dower in ue5-release-engine-test branch]
2021-12-10 17:45:09 -05:00

190 lines
8.5 KiB
C++

// 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<FAnimationBlueprintEditor>& InAnimationBlueprintEditor)
: FBlueprintEditorApplicationMode(InAnimationBlueprintEditor, FAnimationBlueprintEditorModes::AnimationBlueprintEditorMode, FAnimationBlueprintEditorModes::GetLocalizedMode, false, false)
{
PreviewScenePtr = InAnimationBlueprintEditor->GetPreviewScene();
AnimBlueprintPtr = CastChecked<UAnimBlueprint>(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<ISkeletonEditorModule>("SkeletonEditor");
TabFactories.RegisterFactory(SkeletonEditorModule.CreateSkeletonTreeTabFactory(InAnimationBlueprintEditor, InAnimationBlueprintEditor->GetSkeletonTree()));
FPersonaModule& PersonaModule = FModuleManager::LoadModuleChecked<FPersonaModule>("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<FLayoutExtender>();
PersonaModule.OnRegisterLayoutExtensions().Broadcast(*LayoutExtender.Get());
TabLayout->ProcessExtensions(*LayoutExtender.Get());
}
void FAnimationBlueprintEditorMode::RegisterTabFactories(TSharedPtr<FTabManager> InTabManager)
{
TSharedPtr<FBlueprintEditor> 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();
}