74 lines
2.1 KiB
C++
Raw Permalink Normal View History

2025-10-15 18:25:31 +08:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "AssetEditor/ShapeAssetEditor.h"
#include "ProjectFish/DataAsset/ShapeAsset.h"
#include "Widgets/BagShapeEditorWidget.h"
const FName FShapeAssetEditor::ShapeEditorTabId(TEXT("BagShapeEditor"));
void FShapeAssetEditor::Initialize(const EToolkitMode::Type Mode,
const TSharedPtr<class IToolkitHost>& InitToolkitHost, UShapeAsset* InBagShapeAsset)
{
ShapeAsset = InBagShapeAsset;
const TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_BagShapeAssetEditor_Layout_v1")
->AddArea
(
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(1.0f)
->AddTab(ShapeEditorTabId, ETabState::OpenedTab)
)
);
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, TEXT("BagShapeAssetEditorApp"), StandaloneDefaultLayout, true, true, InBagShapeAsset);
}
FName FShapeAssetEditor::GetToolkitFName() const
{
return FName("ShapeEditor");
}
FText FShapeAssetEditor::GetBaseToolkitName() const
{
return FText::FromString("Base ShapeEditor");
}
FString FShapeAssetEditor::GetWorldCentricTabPrefix() const
{
return TEXT("ShapeTab");
}
FLinearColor FShapeAssetEditor::GetWorldCentricTabColorScale() const
{
//return FLinearColor::White;
return FLinearColor(1.f, 0.8f, 0.45f, 0.5f);
}
void FShapeAssetEditor::RegisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
{
WorkspaceMenuCategory = tabManager->AddLocalWorkspaceMenuCategory( FText::FromString("BagShape"));
tabManager->RegisterTabSpawner(ShapeEditorTabId, FOnSpawnTab::CreateSP(this, &FShapeAssetEditor::SpawnBagShapeEditorTab))
.SetDisplayName( FText::FromString("BagShapeEditor"))
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
}
void FShapeAssetEditor::UnregisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
{
tabManager->UnregisterTabSpawner(ShapeEditorTabId);
}
TSharedRef<SDockTab> FShapeAssetEditor::SpawnBagShapeEditorTab(const FSpawnTabArgs& Args)
{
return SNew(SDockTab)
.TabRole(ETabRole::PanelTab)
[
SNew(SShapeEditorWidget)
.BagShapeAsset(ShapeAsset)
];
}