mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-02-10 17:43:03 +00:00
refactor: introduce subasset loading
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include "Game/IW3/CommonIW3.h"
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
#include "NormalizedJson.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "SearchPath/MockOutputPath.h"
|
||||
#include "SearchPath/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@@ -35,7 +34,7 @@ namespace
|
||||
return techset;
|
||||
}
|
||||
|
||||
void GivenMaterial(const std::string& name, AssetPool<Material>& pool, MemoryManager& memory)
|
||||
void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory)
|
||||
{
|
||||
auto* material = memory.Alloc<Material>();
|
||||
material->info.name = memory.Dup(name.c_str());
|
||||
@@ -310,7 +309,7 @@ namespace
|
||||
stateBits6.loadBits.structured.stencilBackZFail = 0;
|
||||
stateBits6.loadBits.structured.stencilBackFunc = 0;
|
||||
|
||||
pool.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
}
|
||||
|
||||
TEST_CASE("DumperMaterial(IW3): Can dump material", "[iw3][material][assetdumper]")
|
||||
@@ -558,11 +557,9 @@ namespace
|
||||
MockOutputPath mockOutput;
|
||||
AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt);
|
||||
|
||||
AssetPoolDynamic<Material> materialPool(0);
|
||||
GivenMaterial("wc/ch_plasterwall_long", zone, memory);
|
||||
|
||||
GivenMaterial("wc/ch_plasterwall_long", materialPool, memory);
|
||||
|
||||
material::JsonDumperIW3 dumper(materialPool);
|
||||
material::JsonDumperIW3 dumper;
|
||||
dumper.Dump(context);
|
||||
|
||||
const auto* file = mockOutput.GetMockedFile("materials/wc/ch_plasterwall_long.json");
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "NormalizedJson.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "SearchPath/MockOutputPath.h"
|
||||
#include "SearchPath/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@@ -35,7 +34,7 @@ namespace
|
||||
return techset;
|
||||
}
|
||||
|
||||
void GivenMaterial(const std::string& name, AssetPool<Material>& pool, MemoryManager& memory)
|
||||
void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory)
|
||||
{
|
||||
auto* material = memory.Alloc<Material>();
|
||||
material->info.name = memory.Dup(name.c_str());
|
||||
@@ -288,7 +287,7 @@ namespace
|
||||
stateBits5.loadBits.structured.stencilBackZFail = 0;
|
||||
stateBits5.loadBits.structured.stencilBackFunc = 0;
|
||||
|
||||
pool.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
}
|
||||
|
||||
TEST_CASE("DumperMaterial(IW4): Can dump material", "[iw4][material][assetdumper]")
|
||||
@@ -539,11 +538,9 @@ namespace
|
||||
MockOutputPath mockOutput;
|
||||
AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt);
|
||||
|
||||
AssetPoolDynamic<Material> materialPool(0);
|
||||
GivenMaterial("mc/ch_rubble01", zone, memory);
|
||||
|
||||
GivenMaterial("mc/ch_rubble01", materialPool, memory);
|
||||
|
||||
material::JsonDumperIW4 dumper(materialPool);
|
||||
material::JsonDumperIW4 dumper;
|
||||
dumper.Dump(context);
|
||||
|
||||
const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json");
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "Game/IW5/CommonIW5.h"
|
||||
#include "Game/IW5/GameIW5.h"
|
||||
#include "NormalizedJson.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "SearchPath/MockOutputPath.h"
|
||||
#include "SearchPath/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@@ -35,7 +34,7 @@ namespace
|
||||
return techset;
|
||||
}
|
||||
|
||||
void GivenMaterial(const std::string& name, AssetPool<Material>& pool, MemoryManager& memory)
|
||||
void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory)
|
||||
{
|
||||
auto* material = memory.Alloc<Material>();
|
||||
material->info.name = memory.Dup(name.c_str());
|
||||
@@ -317,7 +316,7 @@ namespace
|
||||
stateBits6.loadBits.structured.stencilBackZFail = 0;
|
||||
stateBits6.loadBits.structured.stencilBackFunc = 0;
|
||||
|
||||
pool.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
}
|
||||
|
||||
TEST_CASE("DumperMaterial(IW5): Can dump material", "[iw5][material][assetdumper]")
|
||||
@@ -592,11 +591,9 @@ namespace
|
||||
MockOutputPath mockOutput;
|
||||
AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt);
|
||||
|
||||
AssetPoolDynamic<Material> materialPool(0);
|
||||
GivenMaterial("wc/me_metal_rust_02", zone, memory);
|
||||
|
||||
GivenMaterial("wc/me_metal_rust_02", materialPool, memory);
|
||||
|
||||
material::JsonDumperIW5 dumper(materialPool);
|
||||
material::JsonDumperIW5 dumper;
|
||||
dumper.Dump(context);
|
||||
|
||||
const auto* file = mockOutput.GetMockedFile("materials/wc/me_metal_rust_02.json");
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "Game/T5/CommonT5.h"
|
||||
#include "Game/T5/GameT5.h"
|
||||
#include "NormalizedJson.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "SearchPath/MockOutputPath.h"
|
||||
#include "SearchPath/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@@ -35,7 +34,7 @@ namespace
|
||||
return techset;
|
||||
}
|
||||
|
||||
void GivenMaterial(const std::string& name, AssetPool<Material>& pool, MemoryManager& memory)
|
||||
void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory)
|
||||
{
|
||||
auto* material = memory.Alloc<Material>();
|
||||
material->info.name = memory.Dup(name.c_str());
|
||||
@@ -289,7 +288,7 @@ namespace
|
||||
stateBits5.loadBits.structured.stencilBackZFail = 0;
|
||||
stateBits5.loadBits.structured.stencilBackFunc = 0;
|
||||
|
||||
pool.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
zone.m_pools.AddAsset<AssetMaterial>(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
}
|
||||
|
||||
TEST_CASE("DumperMaterial(T5): Can dump material", "[t5][material][assetdumper]")
|
||||
@@ -621,11 +620,9 @@ namespace
|
||||
MockOutputPath mockOutput;
|
||||
AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt);
|
||||
|
||||
AssetPoolDynamic<Material> materialPool(0);
|
||||
GivenMaterial("mc/ch_rubble01", zone, memory);
|
||||
|
||||
GivenMaterial("mc/ch_rubble01", materialPool, memory);
|
||||
|
||||
material::JsonDumperT5 dumper(materialPool);
|
||||
material::JsonDumperT5 dumper;
|
||||
dumper.Dump(context);
|
||||
|
||||
const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json");
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "NormalizedJson.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "SearchPath/MockOutputPath.h"
|
||||
#include "SearchPath/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@@ -27,7 +26,7 @@ namespace
|
||||
return material;
|
||||
}
|
||||
|
||||
void GivenFontIcon(const std::string& name, AssetPool<FontIcon>& pool, MemoryManager& memory)
|
||||
void GivenFontIcon(const std::string& name, Zone& zone, MemoryManager& memory)
|
||||
{
|
||||
auto* fontIcon = memory.Alloc<FontIcon>();
|
||||
fontIcon->name = memory.Dup(name.c_str());
|
||||
@@ -86,7 +85,7 @@ namespace
|
||||
alias5.aliasHash = Common::Com_HashString("BUTTON_MOVESTICK");
|
||||
alias5.buttonHash = entry2.fontIconName.hash;
|
||||
|
||||
pool.AddAsset(std::make_unique<XAssetInfo<FontIcon>>(ASSET_TYPE_FONTICON, name, fontIcon));
|
||||
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<FontIcon>>(ASSET_TYPE_FONTICON, name, fontIcon));
|
||||
}
|
||||
|
||||
TEST_CASE("DumperFontIconJson(T6): Can dump font icon", "[t6][font-icon][assetdumper]")
|
||||
@@ -148,10 +147,9 @@ namespace
|
||||
MockOutputPath mockOutput;
|
||||
AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt);
|
||||
|
||||
AssetPoolDynamic<FontIcon> fontIconPool(0);
|
||||
GivenFontIcon("fonticon/test.csv", fontIconPool, memory);
|
||||
GivenFontIcon("fonticon/test.csv", zone, memory);
|
||||
|
||||
font_icon::JsonDumperT6 dumper(fontIconPool);
|
||||
font_icon::JsonDumperT6 dumper;
|
||||
dumper.Dump(context);
|
||||
|
||||
const auto* file = mockOutput.GetMockedFile("fonticon/test.json");
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "NormalizedJson.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "SearchPath/MockOutputPath.h"
|
||||
#include "SearchPath/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@@ -35,7 +34,7 @@ namespace
|
||||
return techset;
|
||||
}
|
||||
|
||||
void GivenMaterial(const std::string& name, AssetPool<Material>& pool, MemoryManager& memory)
|
||||
void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory)
|
||||
{
|
||||
auto* material = memory.Alloc<Material>();
|
||||
material->info.name = memory.Dup(name.c_str());
|
||||
@@ -254,7 +253,7 @@ namespace
|
||||
|
||||
material->thermalMaterial = nullptr;
|
||||
|
||||
pool.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<Material>>(ASSET_TYPE_MATERIAL, name, material));
|
||||
}
|
||||
|
||||
TEST_CASE("DumperMaterial(T6): Can dump material", "[t6][material][assetdumper]")
|
||||
@@ -469,10 +468,9 @@ namespace
|
||||
MockOutputPath mockOutput;
|
||||
AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt);
|
||||
|
||||
AssetPoolDynamic<Material> materialPool(0);
|
||||
GivenMaterial("wpc/metal_ac_duct", materialPool, memory);
|
||||
GivenMaterial("wpc/metal_ac_duct", zone, memory);
|
||||
|
||||
material::JsonDumperT6 dumper(materialPool);
|
||||
material::JsonDumperT6 dumper;
|
||||
dumper.Dump(context);
|
||||
|
||||
const auto* file = mockOutput.GetMockedFile("materials/wpc/metal_ac_duct.json");
|
||||
|
||||
Reference in New Issue
Block a user