You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Added a global event for when some package are migrated. This can be used for hotfixes and as extension point for systems to react or add stuff to the migration. Other changes that were required for the new migration: Level streaming is now aware that the world might be part of a instanced package. When it validate that file for the streamed world exist it will use the path from the package linker of the world package. The level postload function now prefer to use the Instancing Context package remapping from its linker to determine where it should load some of its external UActorFolder. The StringTableEditorModule was modified to be able to properly react to the migration. This change will still require some change in a future release to reduce its memory usage. #rb Francis.Hurteau #jira UE-162943, UE-161367, UE-161364, UE-161359, UE-161357, UE-161355, UE-161354, UE-145342 #preflight 6358419f2e6690262abbce83 #lockdown jeanmichel.dignard [CL 22798574 by julien stjean in ue5-main branch]
75 lines
3.0 KiB
C++
75 lines
3.0 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "StringTableEditorModule.h"
|
|
#include "Modules/ModuleManager.h"
|
|
#include "IStringTableEditor.h"
|
|
#include "Internationalization/StringTableRegistry.h"
|
|
#include "StringTableEditor.h"
|
|
#include "AssetTypeActions_StringTable.h"
|
|
#include "PackageMigrationContext.h"
|
|
|
|
IMPLEMENT_MODULE(FStringTableEditorModule, StringTableEditor);
|
|
|
|
const FName FStringTableEditorModule::StringTableEditorAppIdentifier("StringTableEditorApp");
|
|
|
|
void FStringTableEditorModule::StartupModule()
|
|
{
|
|
MenuExtensibilityManager = MakeShareable(new FExtensibilityManager);
|
|
ToolBarExtensibilityManager = MakeShareable(new FExtensibilityManager);
|
|
|
|
IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
|
AssetTools.RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_StringTable()));
|
|
|
|
AssetTools.GetOnPackageMigration().AddRaw(this, &FStringTableEditorModule::OnPackageMigration);
|
|
}
|
|
|
|
void FStringTableEditorModule::ShutdownModule()
|
|
{
|
|
if (FAssetToolsModule* AssetToolsModule = FModuleManager::GetModulePtr<FAssetToolsModule>("AssetTools"))
|
|
{
|
|
AssetToolsModule->Get().GetOnPackageMigration().RemoveAll(this);
|
|
}
|
|
|
|
MenuExtensibilityManager.Reset();
|
|
ToolBarExtensibilityManager.Reset();
|
|
}
|
|
|
|
TSharedRef<IStringTableEditor> FStringTableEditorModule::CreateStringTableEditor(const EToolkitMode::Type Mode, const TSharedPtr<IToolkitHost>& InitToolkitHost, UStringTable* StringTable)
|
|
{
|
|
TSharedRef<FStringTableEditor> NewStringTableEditor(new FStringTableEditor());
|
|
NewStringTableEditor->InitStringTableEditor(Mode, InitToolkitHost, StringTable);
|
|
return NewStringTableEditor;
|
|
}
|
|
|
|
void FStringTableEditorModule::OnPackageMigration(UE::AssetTools::FPackageMigrationContext& MigrationContext)
|
|
{
|
|
constexpr auto ForEachStringTableInTheWay = [](UE::AssetTools::FPackageMigrationContext& MigrationContext, TFunctionRef<void(UStringTable*)> Callback)
|
|
{
|
|
const TArray<UPackage*>& MovedPackages = MigrationContext.GetMovedOutOfTheWayPackages();
|
|
for (UPackage* Package : MovedPackages)
|
|
{
|
|
UObject* MainAsset = Package->FindAssetInPackage();
|
|
if (UStringTable* StringTableAsset = Cast<UStringTable>(MainAsset))
|
|
{
|
|
Callback(StringTableAsset);
|
|
}
|
|
}
|
|
};
|
|
|
|
// The migration can create temporally new packages that will use the same name as the asset migrated. So we need to unregister the migrated asset for the duration of the migration
|
|
if (MigrationContext.GetCurrentStep() == UE::AssetTools::FPackageMigrationContext::EPackageMigrationStep::InTheWayPackagesMoved)
|
|
{
|
|
ForEachStringTableInTheWay(MigrationContext, [](UStringTable* StringTableAsset)
|
|
{
|
|
FStringTableRegistry::Get().UnregisterStringTable(StringTableAsset->GetStringTableId());
|
|
});
|
|
}
|
|
else if (MigrationContext.GetCurrentStep() == UE::AssetTools::FPackageMigrationContext::EPackageMigrationStep::EndMigration)
|
|
{
|
|
ForEachStringTableInTheWay(MigrationContext, [](UStringTable* StringTableAsset)
|
|
{
|
|
FStringTableRegistry::Get().RegisterStringTable(StringTableAsset->GetStringTableId(), StringTableAsset->GetMutableStringTable());
|
|
});
|
|
}
|
|
}
|