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

refactor: streamline IW3 asset loading

This commit is contained in:
Jan Laupetin
2025-08-05 01:22:39 +02:00
parent 6806337f46
commit 95a6a028ab
13 changed files with 41 additions and 39 deletions

View File

@@ -122,10 +122,10 @@ namespace
};
} // namespace
namespace IW3
namespace IW3::image
{
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetImage>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<ImageLoader>(memory, searchPath);
}
} // namespace IW3
} // namespace IW3::image

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW3
namespace IW3::image
{
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW3
std::unique_ptr<AssetCreator<AssetImage>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW3::image

View File

@@ -36,10 +36,10 @@ namespace
};
} // namespace
namespace IW3
namespace IW3::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 IW3
} // namespace IW3::localize

View File

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

View File

@@ -8,6 +8,7 @@
#include <iostream>
using namespace IW3;
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 IW3
namespace IW3::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 IW3
} // namespace IW3::material

View File

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

View File

@@ -92,9 +92,9 @@ namespace
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(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(CreateImageLoader(memory, searchPath));
collection.AddAssetCreator(image::CreateLoader(memory, searchPath));
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
@@ -108,13 +108,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));
}
} // namespace

View File

@@ -44,10 +44,10 @@ namespace
};
} // namespace
namespace IW3
namespace IW3::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 IW3
} // namespace IW3::raw_file

View File

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

View File

@@ -6,6 +6,7 @@
#include <cstring>
using namespace IW3;
using namespace ::string_table;
namespace
{
@@ -24,7 +25,7 @@ namespace
if (!file.IsOpen())
return AssetCreationResult::NoAction();
string_table::StringTableLoaderV1<StringTable> loader;
StringTableLoaderV1<StringTable> loader;
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
if (!stringTable)
return AssetCreationResult::Failure();
@@ -38,10 +39,10 @@ namespace
};
} // namespace
namespace IW3
namespace IW3::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 IW3
} // namespace IW3::string_table

View File

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

View File

@@ -286,7 +286,7 @@ namespace
GivenImage("ch_plasterwall_long_col", context, memory);
GivenTechset("wc_l_sm_r0c0n0s0", context, memory);
auto loader = CreateMaterialLoader(memory, searchPath);
auto loader = material::CreateLoader(memory, searchPath);
auto result = loader->CreateAsset("wc/ch_plasterwall_long", context);
REQUIRE(result.HasBeenSuccessful());

View File

@@ -27,7 +27,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());