mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-02-14 19:33:02 +00:00
chore: generalize IAssetDumper interface
This commit is contained in:
@@ -27,96 +27,88 @@
|
||||
#include "Weapon/WeaponDumperT6.h"
|
||||
#include "ZBarrier/ZBarrierDumperT6.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
{
|
||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
||||
#define REGISTER_DUMPER(dumperType, poolName) \
|
||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
totalProgress += dumper.GetProgressTotalCount(*assetPools->poolName); \
|
||||
dumpingFunctions.emplace_back( \
|
||||
[](AssetDumpingContext& funcContext, const GameAssetPoolT6* funcPools) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(funcContext, *funcPools->poolName); \
|
||||
}); \
|
||||
dumpers.emplace_back(std::make_unique<dumperType>(*assetPools->poolName)); \
|
||||
}
|
||||
#define DUMP_ASSET_POOL_WITH_FACTORY(createDumper, poolName, assetType) \
|
||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
||||
#define REGISTER_DUMPER_WITH_FACTORY(createDumper, poolName, asset) \
|
||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(asset::EnumEntry)) \
|
||||
{ \
|
||||
auto dumper = createDumper; \
|
||||
totalProgress += dumper->GetProgressTotalCount(*assetPools->poolName); \
|
||||
dumpingFunctions.emplace_back( \
|
||||
[](AssetDumpingContext& funcContext, const GameAssetPoolT6* funcPools) \
|
||||
{ \
|
||||
auto dumper = createDumper; \
|
||||
dumper->DumpPool(funcContext, *funcPools->poolName); \
|
||||
}); \
|
||||
auto dumper = createDumper(*assetPools->poolName); \
|
||||
if (dumper) \
|
||||
dumpers.emplace_back(std::move(dumper)); \
|
||||
}
|
||||
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolT6*>(context.m_zone.m_pools.get());
|
||||
std::vector<std::unique_ptr<IAssetDumper>> dumpers;
|
||||
|
||||
size_t totalProgress = 0uz;
|
||||
std::vector<std::function<void(AssetDumpingContext & context, const GameAssetPoolT6*)>> dumpingFunctions;
|
||||
REGISTER_DUMPER(phys_preset::InfoStringDumperT6, m_phys_preset)
|
||||
REGISTER_DUMPER(phys_constraints::InfoStringDumperT6, m_phys_constraints)
|
||||
// REGISTER_DUMPER(AssetDumperDestructibleDef, m_destructible_def)
|
||||
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
|
||||
REGISTER_DUMPER(xmodel::DumperT6, m_xmodel)
|
||||
REGISTER_DUMPER(material::JsonDumperT6, m_material)
|
||||
REGISTER_DUMPER(techset::DumperT6, m_technique_set)
|
||||
REGISTER_DUMPER(image::DumperT6, m_image)
|
||||
REGISTER_DUMPER(sound::SndBankDumperT6, m_sound_bank)
|
||||
// REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch)
|
||||
// REGISTER_DUMPER(AssetDumperClipMap, m_clip_map)
|
||||
// REGISTER_DUMPER(AssetDumperComWorld, m_com_world)
|
||||
// REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp)
|
||||
// REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp)
|
||||
REGISTER_DUMPER(map_ents::DumperT6, m_map_ents)
|
||||
// REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world)
|
||||
// REGISTER_DUMPER(AssetDumperGfxLightDef, m_gfx_light_def)
|
||||
// REGISTER_DUMPER(AssetDumperFont, m_font)
|
||||
REGISTER_DUMPER_WITH_FACTORY(font_icon::CreateDumperT6, m_font_icon, AssetFontIcon)
|
||||
// REGISTER_DUMPER(AssetDumperMenuList, m_menu_list)
|
||||
// REGISTER_DUMPER(AssetDumperMenuDef, m_menu_def)
|
||||
REGISTER_DUMPER(localize::DumperT6, m_localize)
|
||||
REGISTER_DUMPER(weapon::DumperT6, m_weapon)
|
||||
REGISTER_DUMPER(attachment::DumperT6, m_attachment)
|
||||
REGISTER_DUMPER(attachment_unique::DumperT6, m_attachment_unique)
|
||||
REGISTER_DUMPER(camo::JsonDumperT6, m_camo)
|
||||
REGISTER_DUMPER(sound::SndDriverGlobalsDumperT6, m_snd_driver_globals)
|
||||
// REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx)
|
||||
// REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table)
|
||||
REGISTER_DUMPER(raw_file::DumperT6, m_raw_file)
|
||||
REGISTER_DUMPER(string_table::DumperT6, m_string_table)
|
||||
REGISTER_DUMPER(leaderboard::JsonDumperT6, m_leaderboard)
|
||||
// REGISTER_DUMPER(AssetDumperXGlobals, m_xglobals)
|
||||
// REGISTER_DUMPER(AssetDumperDDLRoot, m_ddl)
|
||||
// REGISTER_DUMPER(AssetDumperGlasses, m_glasses)
|
||||
// REGISTER_DUMPER(AssetDumperEmblemSet, m_emblem_set)
|
||||
REGISTER_DUMPER(script::DumperT6, m_script)
|
||||
// REGISTER_DUMPER(AssetDumperKeyValuePairs, m_key_value_pairs)
|
||||
REGISTER_DUMPER(vehicle::DumperT6, m_vehicle)
|
||||
// REGISTER_DUMPER(AssetDumperMemoryBlock, m_memory_block)
|
||||
// REGISTER_DUMPER(AssetDumperAddonMapEnts, m_addon_map_ents)
|
||||
REGISTER_DUMPER(tracer::DumperT6, m_tracer)
|
||||
// REGISTER_DUMPER(AssetDumperSkinnedVertsDef, m_skinned_verts)
|
||||
REGISTER_DUMPER(qdb::DumperT6, m_qdb)
|
||||
REGISTER_DUMPER(slug::DumperT6, m_slug)
|
||||
// REGISTER_DUMPER(AssetDumperFootstepTableDef, m_footstep_table)
|
||||
// REGISTER_DUMPER(AssetDumperFootstepFXTableDef, m_footstep_fx_table)
|
||||
REGISTER_DUMPER(z_barrier::DumperT6, m_zbarrier)
|
||||
|
||||
DUMP_ASSET_POOL(phys_preset::InfoStringDumperT6, m_phys_preset, ASSET_TYPE_PHYSPRESET)
|
||||
DUMP_ASSET_POOL(phys_constraints::InfoStringDumperT6, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS)
|
||||
// DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
||||
DUMP_ASSET_POOL(xmodel::DumperT6, m_xmodel, ASSET_TYPE_XMODEL)
|
||||
DUMP_ASSET_POOL(material::JsonDumperT6, m_material, ASSET_TYPE_MATERIAL)
|
||||
DUMP_ASSET_POOL(techset::DumperT6, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
||||
DUMP_ASSET_POOL(image::DumperT6, m_image, ASSET_TYPE_IMAGE)
|
||||
DUMP_ASSET_POOL(sound::SndBankDumperT6, m_sound_bank, ASSET_TYPE_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
DUMP_ASSET_POOL(map_ents::DumperT6, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)
|
||||
DUMP_ASSET_POOL_WITH_FACTORY(font_icon::CreateDumperT6(), m_font_icon, ASSET_TYPE_FONTICON)
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)
|
||||
DUMP_ASSET_POOL(localize::DumperT6, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
|
||||
DUMP_ASSET_POOL(weapon::DumperT6, m_weapon, ASSET_TYPE_WEAPON)
|
||||
DUMP_ASSET_POOL(attachment::DumperT6, m_attachment, ASSET_TYPE_ATTACHMENT)
|
||||
DUMP_ASSET_POOL(attachment_unique::DumperT6, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE)
|
||||
DUMP_ASSET_POOL(camo::JsonDumperT6, m_camo, ASSET_TYPE_WEAPON_CAMO)
|
||||
DUMP_ASSET_POOL(sound::SndDriverGlobalsDumperT6, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
|
||||
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)
|
||||
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
|
||||
DUMP_ASSET_POOL(raw_file::DumperT6, m_raw_file, ASSET_TYPE_RAWFILE)
|
||||
DUMP_ASSET_POOL(string_table::DumperT6, m_string_table, ASSET_TYPE_STRINGTABLE)
|
||||
DUMP_ASSET_POOL(leaderboard::JsonDumperT6, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
||||
// DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS)
|
||||
// DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL)
|
||||
// DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses, ASSET_TYPE_GLASSES)
|
||||
// DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set, ASSET_TYPE_EMBLEMSET)
|
||||
DUMP_ASSET_POOL(script::DumperT6, m_script, ASSET_TYPE_SCRIPTPARSETREE)
|
||||
// DUMP_ASSET_POOL(AssetDumperKeyValuePairs, m_key_value_pairs, ASSET_TYPE_KEYVALUEPAIRS)
|
||||
DUMP_ASSET_POOL(vehicle::DumperT6, m_vehicle, ASSET_TYPE_VEHICLEDEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block, ASSET_TYPE_MEMORYBLOCK)
|
||||
// DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
|
||||
DUMP_ASSET_POOL(tracer::DumperT6, m_tracer, ASSET_TYPE_TRACER)
|
||||
// DUMP_ASSET_POOL(AssetDumperSkinnedVertsDef, m_skinned_verts, ASSET_TYPE_SKINNEDVERTS)
|
||||
DUMP_ASSET_POOL(qdb::DumperT6, m_qdb, ASSET_TYPE_QDB)
|
||||
DUMP_ASSET_POOL(slug::DumperT6, m_slug, ASSET_TYPE_SLUG)
|
||||
// DUMP_ASSET_POOL(AssetDumperFootstepTableDef, m_footstep_table, ASSET_TYPE_FOOTSTEP_TABLE)
|
||||
// DUMP_ASSET_POOL(AssetDumperFootstepFXTableDef, m_footstep_fx_table, ASSET_TYPE_FOOTSTEPFX_TABLE)
|
||||
DUMP_ASSET_POOL(z_barrier::DumperT6, m_zbarrier, ASSET_TYPE_ZBARRIER)
|
||||
if (context.ShouldTrackProgress())
|
||||
{
|
||||
size_t totalProgress = 0uz;
|
||||
for (const auto& dumper : dumpers)
|
||||
totalProgress += dumper->GetProgressTotalCount();
|
||||
|
||||
context.SetTotalProgress(totalProgress);
|
||||
for (const auto& func : dumpingFunctions)
|
||||
func(context, assetPools);
|
||||
context.SetTotalProgress(totalProgress);
|
||||
}
|
||||
|
||||
for (const auto& dumper : dumpers)
|
||||
dumper->Dump(context);
|
||||
|
||||
return true;
|
||||
|
||||
#undef DUMP_ASSET_POOL
|
||||
#undef REGISTER_DUMPER
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user