2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-03-16 18:03:03 +00:00

refactor: move asset type names to IGame implementations

This commit is contained in:
Jan Laupetin
2026-02-04 22:35:33 +00:00
parent e5784d09ed
commit 3b1e65e8cc
39 changed files with 72 additions and 607 deletions

View File

@@ -4,7 +4,6 @@
#include <cassert>
#include <format>
#include <iostream>
IgnoredAssetLookup::IgnoredAssetLookup() = default;
@@ -89,7 +88,7 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio
addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
if (addedAsset == nullptr)
con::error("Failed to add asset of type \"{}\" to pool: \"{}\"", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName);
con::error(R"(Failed to add asset of type "{}" to pool: "{}")", *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType), pAssetName);
return addedAsset;
}
@@ -99,7 +98,7 @@ XAssetInfoGeneric* AssetCreationContext::LoadDefaultAssetDependency(const asset_
if (result.HasTakenAction() && !result.HasFailed())
return result.GetAssetInfo();
con::error("Failed to create default asset of type {}", *m_zone.m_pools->GetAssetTypeName(assetType));
con::error("Failed to create default asset of type {}", *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType));
return nullptr;
}
@@ -129,11 +128,11 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
if (!result.HasFailed())
return result.GetAssetInfo();
con::error("Could not load asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
con::error(R"(Could not load asset "{}" of type "{}")", assetName, *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType));
}
else if (required)
{
con::error("Missing asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
con::error(R"(Missing asset "{}" of type "{}")", assetName, *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType));
}
return nullptr;
@@ -151,7 +150,8 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(c
const auto result = m_creators->CreateAsset(assetType, assetName, *this);
if (!result.HasTakenAction() && !result.HasFailed())
{
con::warn("Could not load indirectly referenced asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
con::warn(
R"(Could not load indirectly referenced asset "{}" of type "{}")", assetName, *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType));
}
return IndirectAssetReference(assetType, assetName);
}
@@ -187,11 +187,11 @@ XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_
if (!result.HasFailed())
return result.GetAssetInfo();
con::error("Could not load asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
con::error(R"(Could not load asset "{}" of type "{}")", assetName, *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType));
}
else
{
con::error("Missing asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
con::error(R"(Missing asset "{}" of type "{}")", assetName, *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType));
}
return nullptr;

View File

@@ -11,7 +11,6 @@
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
class AssetCreatorCollection;

View File

@@ -4,9 +4,10 @@
AssetCreatorCollection::AssetCreatorCollection(const Zone& zone)
{
m_asset_creators_by_type.resize(zone.m_pools->GetAssetTypeCount());
m_asset_post_processors_by_type.resize(zone.m_pools->GetAssetTypeCount());
m_default_asset_creators_by_type.resize(zone.m_pools->GetAssetTypeCount());
const auto* game = IGame::GetGameById(zone.m_game_id);
m_asset_creators_by_type.resize(game->GetAssetTypeCount());
m_asset_post_processors_by_type.resize(game->GetAssetTypeCount());
m_default_asset_creators_by_type.resize(game->GetAssetTypeCount());
}
void AssetCreatorCollection::AddAssetCreator(std::unique_ptr<IAssetCreator> creator)