// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Input/Reply.h" #include "Layout/Visibility.h" #include "Widgets/SWidget.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "IPersonaViewport.h" #include "Toolkits/AssetEditorToolkit.h" #include "WorkflowOrientedApp/WorkflowTabFactory.h" #include "WorkflowOrientedApp/WorkflowTabManager.h" #include "BlueprintEditor.h" #include "WorkflowOrientedApp/ApplicationMode.h" #include "IDocumentation.h" #include "PersonaModule.h" #include "IPersonaPreviewScene.h" #include "AnimationEditorViewportClient.h" #include "SSingleObjectDetailsPanel.h" #include "PersonaTabs.h" #define LOCTEXT_NAMESPACE "PersonaMode" class IEditableSkeleton; class IPersonaToolkit; class ISkeletonTree; class SPersonaDetails; class SToolTip; ///////////////////////////////////////////////////// // This is the list of IDs for persona modes struct FPersonaModes { // Mode constants static const FName SkeletonDisplayMode; static const FName MeshEditMode; static const FName PhysicsEditMode; static const FName AnimationEditMode; static const FName AnimBlueprintEditMode; static FText GetLocalizedMode( const FName InMode ) { static TMap< FName, FText > LocModes; if (LocModes.Num() == 0) { LocModes.Add( SkeletonDisplayMode, NSLOCTEXT("PersonaModes", "SkeletonDisplayMode", "Skeleton") ); LocModes.Add( MeshEditMode, NSLOCTEXT("PersonaModes", "MeshEditMode", "Mesh") ); LocModes.Add( PhysicsEditMode, NSLOCTEXT("PersonaModes", "PhysicsEditMode", "Physics") ); LocModes.Add( AnimationEditMode, NSLOCTEXT("PersonaModes", "AnimationEditMode", "Animation") ); LocModes.Add( AnimBlueprintEditMode, NSLOCTEXT("PersonaModes", "AnimBlueprintEditMode", "Graph") ); } check( InMode != NAME_None ); const FText* OutDesc = LocModes.Find( InMode ); check( OutDesc ); return *OutDesc; } private: FPersonaModes() {} }; ///////////////////////////////////////////////////// // FPersonaModeSharedData struct FPersonaModeSharedData : public IPersonaViewportState { FPersonaModeSharedData(); void Save(const TSharedRef& InFromViewport); void Restore(const TSharedRef& InToViewport); // camera setup FVector ViewLocation; FRotator ViewRotation; float OrthoZoom; // orbit setup FVector OrbitZoom; FVector LookAtLocation; bool bCameraLock; EAnimationViewportCameraFollowMode CameraFollowMode; FName CameraFollowBoneName; // show flags bool bShowReferencePose; bool bShowBones; bool bShowBoneNames; bool bShowSockets; bool bShowBound; // viewport setup int32 ViewportType; EAnimationPlaybackSpeeds::Type PlaybackSpeedMode; int32 LocalAxesMode; }; ///////////////////////////////////////////////////// // FPersonaAppMode class FPersonaAppMode : public FApplicationMode { protected: FPersonaAppMode(TSharedPtr InPersona, FName InModeName); public: // FApplicationMode interface virtual void RegisterTabFactories(TSharedPtr InTabManager) override; virtual void PostActivateMode() override; // End of FApplicationMode interface protected: TWeakPtr MyPersona; // Set of spawnable tabs in persona mode (@TODO: Multiple lists!) FWorkflowAllowedTabSet PersonaTabFactories; }; ///////////////////////////////////////////////////// // FMorphTargetTabSummoner struct FMorphTargetTabSummoner : public FWorkflowTabFactory { public: FMorphTargetTabSummoner(TSharedPtr InHostingApp, TSharedRef InViewerWidget); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; // Create a tooltip widget for the tab virtual TSharedPtr CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const override { return IDocumentation::Get()->CreateToolTip(LOCTEXT("MorphTargetTooltip", "The Morph Target tab lets you preview any morph targets (aka blend shapes) available for the current mesh."), NULL, TEXT("Shared/Editors/Persona"), TEXT("MorphTarget_Window")); } private: TSharedRef ViewerWidget; }; ///////////////////////////////////////////////////// // FAnimCurveViewerTabSummoner struct FAnimCurveViewerTabSummoner : public FWorkflowTabFactory { public: FAnimCurveViewerTabSummoner(TSharedPtr InHostingApp, const TSharedPtr& InEditableSkeleton, const TSharedRef& InPreviewScene, FOnObjectsSelected InOnObjectsSelected); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; // Create a tooltip widget for the tab virtual TSharedPtr CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const override { return IDocumentation::Get()->CreateToolTip(LOCTEXT("AnimCurveViewTooltip", "The Anim Curve Viewer tab lets you preview any animation curves available for the current mesh from preview asset."), NULL, TEXT("Shared/Editors/Persona"), TEXT("AnimCurveView_Window")); } private: TWeakPtr EditableSkeleton; TWeakPtr PreviewScene; FOnObjectsSelected OnObjectsSelected; }; ///////////////////////////////////////////////////// // FAnimCurveViewerTabSummoner struct FAnimCurveMetadataEditorTabSummoner : public FWorkflowTabFactory { public: FAnimCurveMetadataEditorTabSummoner(TSharedPtr InHostingApp, UObject* InMetadataHost, const TSharedRef& InPreviewScene, FOnObjectsSelected InOnObjectsSelected); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; virtual TSharedPtr CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const override { return IDocumentation::Get()->CreateToolTip(LOCTEXT("AnimCurveMetadataEditorTooltip", "The Anim Curve Metadata Editor tab lets you add, remove, rename and edit curve metadata."), NULL, TEXT("Shared/Editors/Persona"), TEXT("AnimCurveMetadataEditor_Window")); } virtual FText GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const { return LOCTEXT("AnimCurveTabView_ToolTip", "Shows the animation curve debugger. This shows the state of animation curves."); } private: TWeakObjectPtr MetadataHost; TWeakPtr PreviewScene; FOnObjectsSelected OnObjectsSelected; }; ///////////////////////////////////////////////////// // FAnimationAssetBrowserSummoner struct FAnimationAssetBrowserSummoner : public FWorkflowTabFactory { FAnimationAssetBrowserSummoner(TSharedPtr InHostingApp, const TSharedRef& InPersonaToolkit, FOnOpenNewAsset InOnOpenNewAsset, FOnAnimationSequenceBrowserCreated InOnAnimationSequenceBrowserCreated, bool bInShowHistory); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; // Create a tooltip widget for the tab virtual TSharedPtr CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const override { return IDocumentation::Get()->CreateToolTip(LOCTEXT("AnimAssetBrowserTooltip", "The Asset Browser lets you browse all animation-related assets (animations, blend spaces etc)."), NULL, TEXT("Shared/Editors/Persona"), TEXT("AssetBrowser_Window")); } private: TWeakPtr PersonaToolkit; FOnOpenNewAsset OnOpenNewAsset; FOnAnimationSequenceBrowserCreated OnAnimationSequenceBrowserCreated; bool bShowHistory; }; ///////////////////////////////////////////////////// // FPreviewViewportSummoner struct FPreviewViewportSummoner : public FWorkflowTabFactory { FPreviewViewportSummoner(TSharedPtr InHostingApp, const FPersonaViewportArgs& InArgs, int32 InViewportIndex); virtual FTabSpawnerEntry& RegisterTabSpawner(TSharedRef TabManager, const FApplicationMode* CurrentApplicationMode) const; virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; TWeakPtr SkeletonTree; TWeakPtr PreviewScene; TWeakPtr BlueprintEditor; FOnViewportCreated OnViewportCreated; FOnGetViewportText OnGetViewportText; TArray> Extenders; FName ContextName; int32 ViewportIndex; bool bShowShowMenu; bool bShowLODMenu; bool bShowPlaySpeedMenu; bool bShowTimeline; bool bShowStats; bool bAlwaysShowTransformToolbar; bool bShowFloorOptions; bool bShowTurnTable; bool bShowPhysicsMenu; FAnimationScrubPanelDelegates TimelineDelegates; }; ///////////////////////////////////////////////////// // FRetargetManagerTabSummoner struct FRetargetSourcesTabSummoner : public FWorkflowTabFactory { public: FRetargetSourcesTabSummoner( TSharedPtr InHostingApp, const TSharedRef& InEditableSkeleton, FSimpleMulticastDelegate& InOnPostUndo); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; // Create a tooltip widget for the tab virtual TSharedPtr CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const override { return IDocumentation::Get()->CreateToolTip(LOCTEXT("RetargetSourceTooltip", "In this panel, you can manage Retarget Sources (for playing animations authored with varying proportions) and Compatible Skeletons (for playing animations from other skeletal meshes)."), NULL, TEXT("Shared/Editors/Persona"), TEXT("RetargetSources")); } private: TWeakPtr EditableSkeleton; FSimpleMulticastDelegate& OnPostUndo; }; ///////////////////////////////////////////////////// // SPersonaPreviewPropertyEditor class SPersonaPreviewPropertyEditor : public SSingleObjectDetailsPanel { public: SLATE_BEGIN_ARGS(SPersonaPreviewPropertyEditor) {} SLATE_END_ARGS() private: // Pointer to preview scene TWeakPtr PreviewScene; TWeakPtr BPEditor; public: void Construct(const FArguments& InArgs, TSharedRef InPreviewScene, TSharedRef InBPEditor); // SSingleObjectDetailsPanel interface virtual UObject* GetObjectToObserve() const override; virtual TSharedRef PopulateSlot(TSharedRef PropertyEditorWidget) override; // End of SSingleObjectDetailsPanel interface private: void HandlePropertyChanged(const FPropertyChangedEvent& InPropertyChangedEvent); FReply HandleApplyChanges(); private: bool bPropertyEdited; }; ///////////////////////////////////////////////////// // FAnimBlueprintPreviewEditorSummoner namespace EAnimBlueprintEditorMode { enum Type { PreviewMode, DefaultsMode }; } struct FAnimBlueprintPreviewEditorSummoner : public FWorkflowTabFactory { public: FAnimBlueprintPreviewEditorSummoner(TSharedPtr InBlueprintEditor, const TSharedRef& InPreviewScene); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; virtual FText GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const override; private: /** Delegates to customize tab look based on selected mode */ EVisibility IsEditorVisible(EAnimBlueprintEditorMode::Type Mode) const; ECheckBoxState IsChecked(EAnimBlueprintEditorMode::Type Mode) const; /** Handle changing of editor mode */ void OnCheckedChanged(ECheckBoxState NewType, EAnimBlueprintEditorMode::Type Mode); EAnimBlueprintEditorMode::Type CurrentMode; TWeakPtr BlueprintEditor; TWeakPtr PreviewScene; }; ////////////////////////////////////////////////////////////////////////// // FAnimBlueprintParentPlayerEditorSummoner class FAnimBlueprintParentPlayerEditorSummoner : public FWorkflowTabFactory { public: FAnimBlueprintParentPlayerEditorSummoner(TSharedPtr InBlueprintEditor, FSimpleMulticastDelegate& InOnPostUndo); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; virtual FText GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const override; private: TWeakPtr BlueprintEditor; FSimpleMulticastDelegate& OnPostUndo; }; ///////////////////////////////////////////////////// // FPoseWatchManagerSummoner class FPoseWatchManagerSummoner : public FWorkflowTabFactory { public: FPoseWatchManagerSummoner(TSharedPtr InBlueprintEditor); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; virtual FText GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const override; private: TWeakPtr BlueprintEditor; }; ///////////////////////////////////////////////////// // FAdvancedPreviewSceneTabSummoner struct FAdvancedPreviewSceneTabSummoner : public FWorkflowTabFactory { public: FAdvancedPreviewSceneTabSummoner(TSharedPtr InHostingApp, const TSharedRef& InPreviewScene); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; virtual FText GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const override; private: /** Customize the details of the scene setup object */ TSharedRef CustomizePreviewSceneDescription(); /** Customize a preview mesh collection entry */ TSharedRef CustomizePreviewMeshCollectionEntry(); private: TWeakPtr PreviewScene; }; ///////////////////////////////////////////////////// // FPersonaDetailsTabSummoner struct FPersonaDetailsTabSummoner : public FWorkflowTabFactory { public: FPersonaDetailsTabSummoner(TSharedPtr InHostingApp, FOnDetailsCreated InOnDetailsCreated); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; virtual FText GetTabToolTipText(const FWorkflowTabSpawnInfo& Info) const override; private: FOnDetailsCreated OnDetailsCreated; TSharedPtr PersonaDetails; }; ///////////////////////////////////////////////////// // FAssetPropertiesSummoner struct FAssetPropertiesSummoner : public FWorkflowTabFactory { FAssetPropertiesSummoner(TSharedPtr InHostingApp, FOnGetAsset InOnGetAsset, FOnDetailsCreated InOnDetailsCreated); // FWorkflowTabFactory interface virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; virtual TSharedPtr CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const override; // FWorkflowTabFactory interface private: FOnGetAsset OnGetAsset; FOnDetailsCreated OnDetailsCreated; }; ///////////////////////////////////////////////////// // FAnimAttributeViewerTabSummoner struct FAnimAttributeViewerTabSummoner : public FWorkflowTabFactory { public: FAnimAttributeViewerTabSummoner(TSharedPtr InHostingApp, const TSharedRef& InPreviewScene); virtual TSharedRef CreateTabBody(const FWorkflowTabSpawnInfo& Info) const override; // Create a tooltip widget for the tab virtual TSharedPtr CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const override { return IDocumentation::Get()->CreateToolTip(LOCTEXT("AnimAttributeViewTooltip", "The Animation Attribute Viewer tab lets you preview any Animation Attributes resulting from evaluating the current preview asset."), NULL, TEXT("Shared/Editors/Persona"), TEXT("AnimAttributeView_Window")); } private: TWeakPtr EditableSkeleton; TWeakPtr PreviewScene; }; #undef LOCTEXT_NAMESPACE