89 lines
3.1 KiB
C++
89 lines
3.1 KiB
C++
// Copyright 2016 Mookie. All Rights Reserved.
|
|
|
|
#include "EasyBallisticsEditor.h"
|
|
#include "AssetToolsModule.h"
|
|
#include "PropertyEditorModule.h"
|
|
#include "EBMaterialResponseMapFactory.h"
|
|
#include "EBBulletPropertiesFactory.h"
|
|
#include "EBBulletActorFactory.h"
|
|
#include "EBBarrelComponentFactory.h"
|
|
#include "EBMathematicalBallisticsFactory.h"
|
|
#include "EBPhysicalMaterialCustomization.h"
|
|
#include "EBJsonImportExportTool.h"
|
|
#include "PhysicalMaterials/PhysicalMaterial.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "FEasyBallisticsEditorModule"
|
|
|
|
EAssetTypeCategories::Type FEasyBallisticsEditorModule::BallisticsAssetCategory;
|
|
|
|
void FEasyBallisticsEditorModule::StartupModule()
|
|
{
|
|
// Register asset factories
|
|
IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
|
|
|
// Register the Ballistics category
|
|
BallisticsAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("Ballistics")), LOCTEXT("BallisticsCategory", "Ballistics"));
|
|
|
|
// Store references to our asset type actions for cleanup
|
|
RegisteredAssetTypeActions.Empty();
|
|
|
|
// Register Material Response Map factory
|
|
{
|
|
TSharedRef<IAssetTypeActions> MaterialResponseMapActions = MakeShareable(new FEBMaterialResponseMapFactory());
|
|
AssetTools.RegisterAssetTypeActions(MaterialResponseMapActions);
|
|
RegisteredAssetTypeActions.Add(MaterialResponseMapActions);
|
|
}
|
|
|
|
// Register Bullet Properties Asset factory
|
|
{
|
|
TSharedRef<IAssetTypeActions> BulletPropertiesActions = MakeShareable(new FEBBulletPropertiesAssetFactory());
|
|
AssetTools.RegisterAssetTypeActions(BulletPropertiesActions);
|
|
RegisteredAssetTypeActions.Add(BulletPropertiesActions);
|
|
}
|
|
|
|
// Register Physical Material customization
|
|
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
|
PropertyModule.RegisterCustomClassLayout(
|
|
UPhysicalMaterial::StaticClass()->GetFName(),
|
|
FOnGetDetailCustomizationInstance::CreateStatic(&FEBPhysicalMaterialCustomization::MakeInstance)
|
|
);
|
|
|
|
// Register JSON Import/Export tool - delay this until after editor is fully loaded
|
|
FCoreDelegates::OnFEngineLoopInitComplete.AddLambda([]()
|
|
{
|
|
FEBJsonImportExportTool::RegisterMenus();
|
|
});
|
|
}
|
|
|
|
void FEasyBallisticsEditorModule::ShutdownModule()
|
|
{
|
|
// Unregister JSON Import/Export tool
|
|
FEBJsonImportExportTool::UnregisterMenus();
|
|
|
|
// Unregister Physical Material customization
|
|
if (FModuleManager::Get().IsModuleLoaded("PropertyEditor"))
|
|
{
|
|
FPropertyEditorModule& PropertyModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
|
PropertyModule.UnregisterCustomClassLayout(UPhysicalMaterial::StaticClass()->GetFName());
|
|
}
|
|
|
|
// Unregister asset type actions
|
|
if (FModuleManager::Get().IsModuleLoaded("AssetTools"))
|
|
{
|
|
IAssetTools& AssetTools = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
|
|
|
for (auto& AssetTypeAction : RegisteredAssetTypeActions)
|
|
{
|
|
if (AssetTypeAction.IsValid())
|
|
{
|
|
AssetTools.UnregisterAssetTypeActions(AssetTypeAction.ToSharedRef());
|
|
}
|
|
}
|
|
}
|
|
|
|
RegisteredAssetTypeActions.Empty();
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|
|
|
|
IMPLEMENT_MODULE(FEasyBallisticsEditorModule, EasyBallisticsEditor) |