76 lines
2.3 KiB
C++
Raw Permalink Normal View History

2025-08-31 14:51:48 +08:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "AssetEditor/BagConfigAssetEditor.h"
#include "ProjectFish/DataAsset/BagConfigAsset.h"
2025-08-31 15:14:48 +08:00
#include "Widgets/BagConfigEditorWidget.h"
2025-08-31 14:51:48 +08:00
const FName FBagConfigAssetEditor::BagConfigEditorTabId(TEXT("BagConfigEditor"));
void FBagConfigAssetEditor::Initialize(const EToolkitMode::Type Mode,
const TSharedPtr<class IToolkitHost>& InitToolkitHost, class UBagConfigAsset* InBagConfigAsset)
{
BagConfigAsset = InBagConfigAsset;
const TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_BagConfigAssetEditor_Layout_v1")
->AddArea
(
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(1.0f)
->AddTab(BagConfigEditorTabId, ETabState::OpenedTab)
)
);
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, TEXT("BagShapeAssetEditorApp"), StandaloneDefaultLayout, true, true, InBagConfigAsset);
}
FName FBagConfigAssetEditor::GetToolkitFName() const
{
return FName("BagConfigEditor");
}
FText FBagConfigAssetEditor::GetBaseToolkitName() const
{
return FText::FromString("BagConfig");
}
FString FBagConfigAssetEditor::GetWorldCentricTabPrefix() const
{
return TEXT("BagConfig");
}
FLinearColor FBagConfigAssetEditor::GetWorldCentricTabColorScale() const
{
return FLinearColor::White;
}
void FBagConfigAssetEditor::RegisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
{
WorkspaceMenuCategory = tabManager->AddLocalWorkspaceMenuCategory( FText::FromString("BagShape"));
tabManager->RegisterTabSpawner(BagConfigEditorTabId, FOnSpawnTab::CreateSP(this, &FBagConfigAssetEditor::SpawnBagConfigEditorTab))
.SetDisplayName( FText::FromString("BagShapeEditor"))
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
}
void FBagConfigAssetEditor::UnregisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
{
tabManager->UnregisterTabSpawner(BagConfigEditorTabId);
}
TSharedRef<SDockTab> FBagConfigAssetEditor::SpawnBagConfigEditorTab(const FSpawnTabArgs& Args)
{
2025-08-31 15:14:48 +08:00
return SNew(SDockTab)
.TabRole(ETabRole::NomadTab)
.Label(FText::FromString(FString::Printf(TEXT("Bag Class Editor - %s"), *BagConfigAsset->GetName())))
[
SNew(SBagConfigEditorWidget)
.BagConfigAsset(BagConfigAsset)
];
2025-08-31 14:51:48 +08:00
}