2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-08-30 21:53:15 +00:00

refactor: streamline T5 asset loading

This commit is contained in:
Jan Laupetin
2025-08-04 23:53:51 +02:00
parent a5024d40b0
commit b5c9567389
11 changed files with 34 additions and 32 deletions

View File

@@ -35,10 +35,10 @@ namespace
};
} // namespace
namespace T5
namespace T5::localize
{
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
{
return std::make_unique<LocalizeLoader>(memory, searchPath, zone);
}
} // namespace T5
} // namespace T5::localize

View File

@@ -8,7 +8,7 @@
#include <memory>
namespace T5
namespace T5::localize
{
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
} // namespace T5
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
} // namespace T5::localize

View File

@@ -8,6 +8,7 @@
#include <iostream>
using namespace T5;
using namespace ::material;
namespace
{
@@ -22,7 +23,7 @@ namespace
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName));
const auto file = m_search_path.Open(GetFileNameForAssetName(assetName));
if (!file.IsOpen())
return AssetCreationResult::NoAction();
@@ -45,10 +46,10 @@ namespace
};
} // namespace
namespace T5
namespace T5::material
{
std::unique_ptr<AssetCreator<AssetMaterial>> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<MaterialLoader>(memory, searchPath);
}
} // namespace T5
} // namespace T5::material

View File

@@ -6,7 +6,7 @@
#include "SearchPath/ISearchPath.h"
#include "Utils/MemoryManager.h"
namespace T5
namespace T5::material
{
std::unique_ptr<AssetCreator<AssetMaterial>> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace T5
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace T5::material

View File

@@ -105,7 +105,7 @@ namespace
// collection.AddAssetCreator(std::make_unique<AssetLoaderDestructibleDef>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone));
collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath));
collection.AddAssetCreator(material::CreateLoader(memory, searchPath));
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderImage>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundBank>(memory));
@@ -120,13 +120,13 @@ namespace
// collection.AddAssetCreator(std::make_unique<AssetLoaderFont>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenuList>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenu>(memory));
collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone));
collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone));
// collection.AddAssetCreator(std::make_unique<AssetLoaderWeapon>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundDriverGlobals>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderFx>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderImpactFx>(memory));
collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath));
collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath));
collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath));
collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath));
// collection.AddAssetCreator(std::make_unique<AssetLoaderPackIndex>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderXGlobals>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderDDL>(memory));

View File

@@ -114,10 +114,10 @@ namespace
};
} // namespace
namespace T5
namespace T5::raw_file
{
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<RawFileLoader>(memory, searchPath);
}
} // namespace T5
} // namespace T5::raw_file

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace T5
namespace T5::raw_file
{
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace T5
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace T5::raw_file

View File

@@ -7,6 +7,7 @@
#include <cstring>
using namespace T5;
using namespace ::string_table;
namespace
{
@@ -25,7 +26,7 @@ namespace
if (!file.IsOpen())
return AssetCreationResult::NoAction();
string_table::StringTableLoaderV3<StringTable, Common::Com_HashString> loader;
StringTableLoaderV3<StringTable, Common::Com_HashString> loader;
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
@@ -37,10 +38,10 @@ namespace
};
} // namespace
namespace T5
namespace T5::string_table
{
std::unique_ptr<AssetCreator<AssetStringTable>> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<StringTableLoader>(memory, searchPath);
}
} // namespace T5
} // namespace T5::string_table

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace T5
namespace T5::string_table
{
std::unique_ptr<AssetCreator<AssetStringTable>> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace T5
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace T5::string_table

View File

@@ -26,7 +26,7 @@ namespace
IgnoredAssetLookup ignoredAssetLookup;
AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup);
auto loader = CreateStringTableLoader(memory, searchPath);
auto loader = string_table::CreateLoader(memory, searchPath);
auto result = loader->CreateAsset("mp/cooltable.csv", context);
REQUIRE(result.HasBeenSuccessful());

View File

@@ -370,7 +370,7 @@ namespace
GivenImage("~-gjun_art_brick_foundation_c", context, memory);
GivenTechset("mc_l_sm_r0c0n0s0", context, memory);
auto loader = CreateMaterialLoader(memory, searchPath);
auto loader = material::CreateLoader(memory, searchPath);
auto result = loader->CreateAsset("mc/jun_art_brick_foundation", context);
REQUIRE(result.HasBeenSuccessful());