chore: generalize default asset creators

This commit is contained in:
Jan
2024-12-24 00:58:53 +01:00
parent c524cb007a
commit 9ebea5034a
18 changed files with 193 additions and 182 deletions

View File

@ -1,8 +1,9 @@
#include "Game/IW3/AssetLoaders/AssetLoaderStringTable.h"
#include "Game/IW3/StringTable/AssetLoaderStringTableIW3.h"
#include "Game/IW3/GameIW3.h"
#include "Mock/MockAssetLoadingManager.h"
#include "Mock/MockSearchPath.h"
#include "Pool/ZoneAssetPools.h"
#include "Utils/MemoryManager.h"
#include <catch2/catch_test_macros.hpp>
@ -21,16 +22,23 @@ namespace
"lorem,ipsum");
Zone zone("MockZone", 0, IGame::GetGameById(GameId::IW3));
MockAssetLoadingManager assetLoadingManager(zone, searchPath);
zone.m_pools = ZoneAssetPools::CreateForGame(GameId::IW3, &zone, 1);
const auto assetTypeCount = zone.m_pools->GetAssetTypeCount();
for (auto i = 0; i < assetTypeCount; i++)
zone.m_pools->InitPoolDynamic(i);
AssetLoaderStringTable assetLoader;
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
AssetLoaderStringTable assetLoader(memory, searchPath);
IgnoredAssetLookup ignoredAssetLookup;
assetLoader.LoadFromRaw("mp/cooltable.csv", &searchPath, &memory, &assetLoadingManager, &zone);
AssetCreationContext context(&zone, &creatorCollection, &ignoredAssetLookup);
auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(assetLoadingManager.MockGetAddedAsset("mp/cooltable.csv"));
REQUIRE(assetInfo != nullptr);
const auto result = assetLoader.CreateAsset("mp/cooltable.csv", context);
REQUIRE(result.HasBeenSuccessful());
const auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(result.GetAssetInfo());
const auto* stringTable = assetInfo->Asset();
REQUIRE(stringTable->name == "mp/cooltable.csv"s);
REQUIRE(stringTable->columnCount == 3);