Files
UnrealEngineUWP/Engine/Source/Editor/PhysicsAssetEditor/Private/PhysicsAssetEditorToolsSummoner.cpp
aditya ravichandran b2cf02aedd Physics Asset Profiles Reskin
#jira UE-133594
#rb louise.rasmussen
#preflight 619ba9fd664cbb92c7c7883d

[CL 18261201 by aditya ravichandran in ue5-main branch]
2021-11-22 13:47:00 -05:00

75 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "PhysicsAssetEditorToolsSummoner.h"
#include "IDocumentation.h"
#include "PropertyEditorModule.h"
#include "IDetailsView.h"
#include "PhysicsAssetGenerationSettings.h"
#include "PhysicsAssetEditorSharedData.h"
#include "PhysicsAssetEditor.h"
#include "ISkeletonTree.h"
#include "ISkeletonTreeItem.h"
#include "SkeletonTreeSelection.h"
#define LOCTEXT_NAMESPACE "PhysicsAssetProfilesSummoner"
FPhysicsAssetEditorToolsSummoner::FPhysicsAssetEditorToolsSummoner(TSharedPtr<FAssetEditorToolkit> InHostingApp)
: FWorkflowTabFactory("PhysicsAssetTools", InHostingApp)
{
TabLabel = LOCTEXT("PhysicsAssetToolsTabTitle", "Tools");
TabIcon = FSlateIcon(FAppStyle::GetAppStyleSetName(), "Icons.Tools");
bIsSingleton = true;
ViewMenuDescription = LOCTEXT("PhysicsAssetTools", "Tools");
ViewMenuTooltip = LOCTEXT("PhysicsAssetTools_ToolTip", "Shows the Tools tab");
}
TSharedPtr<SToolTip> FPhysicsAssetEditorToolsSummoner::CreateTabToolTipWidget(const FWorkflowTabSpawnInfo& Info) const
{
return IDocumentation::Get()->CreateToolTip(LOCTEXT("PhysicsAssetToolsTooltip", "The Physics Asset Tools tab lets you peform batch edits to your physics asset."), NULL, TEXT("Shared/Editors/PhysicsAssetEditor"), TEXT("PhysicsAssetTools_Window"));
}
TSharedRef<SWidget> FPhysicsAssetEditorToolsSummoner::CreateTabBody(const FWorkflowTabSpawnInfo& Info) const
{
return FPhysicsAssetEditorSharedData::CreateGenerateBodiesWidget(
FSimpleDelegate::CreateLambda([this]()
{
TSharedRef<FPhysicsAssetEditor> PhysicsAssetEditor = StaticCastSharedRef<FPhysicsAssetEditor>(HostingApp.Pin().ToSharedRef());
PhysicsAssetEditor->ResetBoneCollision();
}),
FSimpleDelegate(),
TAttribute<bool>::Create(TAttribute<bool>::FGetter::CreateLambda([this]()
{
TSharedRef<FPhysicsAssetEditor> PhysicsAssetEditor = StaticCastSharedRef<FPhysicsAssetEditor>(HostingApp.Pin().ToSharedRef());
return !PhysicsAssetEditor->GetSharedData()->bRunningSimulation;
})),
TAttribute<FText>::Create(TAttribute<FText>::FGetter::CreateLambda([this]()
{
TSharedRef<FPhysicsAssetEditor> PhysicsAssetEditor = StaticCastSharedRef<FPhysicsAssetEditor>(HostingApp.Pin().ToSharedRef());
if(PhysicsAssetEditor->GetSharedData()->GetSelectedBody())
{
// If we have bodies selected, we regenerate only the selected bodies
return LOCTEXT("RegenerateBodies", "Re-generate Bodies");
}
else
{
TArray<TSharedPtr<ISkeletonTreeItem>> Items = PhysicsAssetEditor->GetSkeletonTree()->GetSelectedItems();
FSkeletonTreeSelection Selection(Items);
TArray<TSharedPtr<ISkeletonTreeItem>> BoneItems = Selection.GetSelectedItemsByTypeId("FSkeletonTreeBoneItem");
// If we have bones selected, we make new bodies for them
if(BoneItems.Num() > 0)
{
return LOCTEXT("AddBodies", "Add Bodies");
}
else
{
return LOCTEXT("GenerateAllBodies", "Generate All Bodies");
}
}
}))
);
}
#undef LOCTEXT_NAMESPACE