2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-06-06 16:52:35 +00:00

refactor: introduce subasset loading

This commit is contained in:
Jan Laupetin
2026-02-05 16:25:00 +00:00
parent 1be411b371
commit aa47ffa629
255 changed files with 1668 additions and 3132 deletions
@@ -64,8 +64,8 @@ namespace
namespace image
{
DumperIW3::DumperIW3(const AssetPool<AssetImage::Type>& pool)
: AbstractAssetDumper(pool)
DumperIW3::DumperIW3()
: AbstractAssetDumper()
{
switch (ObjWriting::Configuration.ImageOutputFormat)
{
@@ -11,7 +11,7 @@ namespace image
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetImage>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetImage::Type>& pool);
DumperIW3();
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::AssetImage::Type>& asset) override;
@@ -5,25 +5,15 @@
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
using namespace IW3;
namespace localize
{
DumperIW3::DumperIW3(const AssetPool<IW3::AssetLocalize::Type>& pool)
: AbstractSingleProgressAssetDumper(pool)
{
}
size_t DumperIW3::GetProgressTotalCount() const
{
return m_pool.m_asset_lookup.empty() ? 0uz : 1uz;
}
void DumperIW3::Dump(AssetDumpingContext& context)
{
if (m_pool.m_asset_lookup.empty())
auto localizeAssets = context.m_zone.m_pools.PoolAssets<AssetLocalize>();
if (localizeAssets.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
@@ -40,7 +30,7 @@ namespace localize
stringFileDumper.SetNotes("");
for (const auto* localizeEntry : m_pool)
for (const auto* localizeEntry : localizeAssets)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
@@ -2,16 +2,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
#include "Pool/AssetPool.h"
namespace localize
{
class DumperIW3 final : public AbstractSingleProgressAssetDumper<IW3::AssetLocalize>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetLocalize::Type>& pool);
[[nodiscard]] size_t GetProgressTotalCount() const override;
void Dump(AssetDumpingContext& context) override;
};
} // namespace localize
@@ -4,11 +4,6 @@ using namespace IW3;
namespace map_ents
{
DumperIW3::DumperIW3(const AssetPool<IW3::AssetMapEnts::Type>& pool)
: AbstractAssetDumper(pool)
{
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<MapEnts>& asset)
{
const auto* mapEnts = asset.Asset();
@@ -7,9 +7,6 @@ namespace map_ents
{
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetMapEnts>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetMapEnts::Type>& pool);
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::MapEnts>& asset) override;
};
@@ -1,7 +1,6 @@
#include "MaterialConstantZoneStateIW3.h"
#include "Game/IW3/CommonIW3.h"
#include "Game/IW3/GameAssetPoolIW3.h"
#include "Game/IW3/GameIW3.h"
#include "ObjWriting.h"
#include "Zone/ZoneRegistry.h"
@@ -205,11 +204,7 @@ namespace IW3
{
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::IW3)->Zones())
{
const auto* assetPools = dynamic_cast<const GameAssetPoolIW3*>(zone->m_pools.get());
if (!assetPools)
return;
for (const auto* techniqueSetInfo : *assetPools->m_technique_set)
for (const auto* techniqueSetInfo : zone->m_pools.PoolAssets<AssetTechniqueSet>())
{
const auto* techniqueSet = techniqueSetInfo->Asset();
+27 -54
View File
@@ -1,69 +1,42 @@
#include "ObjWriterIW3.h"
#include "Game/IW3/GameAssetPoolIW3.h"
#include "Game/IW3/Material/MaterialJsonDumperIW3.h"
#include "Game/IW3/XModel/XModelDumperIW3.h"
#include "Image/ImageDumperIW3.h"
#include "Localize/LocalizeDumperIW3.h"
#include "Maps/MapEntsDumperIW3.h"
#include "ObjWriting.h"
#include "RawFile/RawFileDumperIW3.h"
#include "Sound/LoadedSoundDumperIW3.h"
#include "StringTable/StringTableDumperIW3.h"
using namespace IW3;
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context)
{
#define REGISTER_DUMPER(dumperType, poolName) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \
{ \
dumpers.emplace_back(std::make_unique<dumperType>(*assetPools->poolName)); \
}
const auto* assetPools = dynamic_cast<GameAssetPoolIW3*>(context.m_zone.m_pools.get());
std::vector<std::unique_ptr<IAssetDumper>> dumpers;
// REGISTER_DUMPER(AssetDumperPhysPreset, m_phys_preset)
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
REGISTER_DUMPER(xmodel::DumperIW3, m_xmodel)
REGISTER_DUMPER(material::JsonDumperIW3, m_material)
// REGISTER_DUMPER(AssetDumperMaterialTechniqueSet, m_technique_set)
REGISTER_DUMPER(image::DumperIW3, m_image)
// REGISTER_DUMPER(AssetDumpersnd_alias_list_t, m_sound)
// REGISTER_DUMPER(AssetDumperSndCurve, m_sound_curve)
REGISTER_DUMPER(sound::LoadedSoundDumperIW3, m_loaded_sound)
// 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::DumperIW3, m_map_ents)
// REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world)
// REGISTER_DUMPER(AssetDumperGfxLightDef, m_gfx_light_def)
// REGISTER_DUMPER(AssetDumperFont_s, m_font)
// REGISTER_DUMPER(AssetDumperMenuList, m_menu_list)
// REGISTER_DUMPER(AssetDumpermenuDef_t, m_menu_def)
REGISTER_DUMPER(localize::DumperIW3, m_localize)
// REGISTER_DUMPER(AssetDumperWeapon, m_weapon)
// REGISTER_DUMPER(AssetDumperSndDriverGlobals, m_snd_driver_globals)
// REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx)
// REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table)
REGISTER_DUMPER(raw_file::DumperIW3, m_raw_file)
REGISTER_DUMPER(string_table::DumperIW3, m_string_table)
if (context.ShouldTrackProgress())
{
size_t totalProgress = 0uz;
for (const auto& dumper : dumpers)
totalProgress += dumper->GetProgressTotalCount();
context.SetTotalProgress(totalProgress);
}
for (const auto& dumper : dumpers)
dumper->Dump(context);
return true;
#undef REGISTER_DUMPER
// REGISTER_DUMPER(AssetDumperPhysPreset)
// REGISTER_DUMPER(AssetDumperXAnimParts)
RegisterAssetDumper(std::make_unique<xmodel::DumperIW3>());
RegisterAssetDumper(std::make_unique<material::JsonDumperIW3>());
// REGISTER_DUMPER(AssetDumperMaterialTechniqueSet)
RegisterAssetDumper(std::make_unique<image::DumperIW3>());
// REGISTER_DUMPER(AssetDumpersnd_alias_list_t)
// REGISTER_DUMPER(AssetDumperSndCurve)
RegisterAssetDumper(std::make_unique<sound::LoadedSoundDumperIW3>());
// REGISTER_DUMPER(AssetDumperClipMap)
// REGISTER_DUMPER(AssetDumperComWorld)
// REGISTER_DUMPER(AssetDumperGameWorldSp)
// REGISTER_DUMPER(AssetDumperGameWorldMp)
RegisterAssetDumper(std::make_unique<map_ents::DumperIW3>());
// REGISTER_DUMPER(AssetDumperGfxWorld)
// REGISTER_DUMPER(AssetDumperGfxLightDef)
// REGISTER_DUMPER(AssetDumperFont_s)
// REGISTER_DUMPER(AssetDumperMenuList)
// REGISTER_DUMPER(AssetDumpermenuDef_t)
RegisterAssetDumper(std::make_unique<localize::DumperIW3>());
// REGISTER_DUMPER(AssetDumperWeapon)
// REGISTER_DUMPER(AssetDumperSndDriverGlobals)
// REGISTER_DUMPER(AssetDumperFxEffectDef)
// REGISTER_DUMPER(AssetDumperFxImpactTable)
RegisterAssetDumper(std::make_unique<raw_file::DumperIW3>());
RegisterAssetDumper(std::make_unique<string_table::DumperIW3>());
}
+3 -3
View File
@@ -1,12 +1,12 @@
#pragma once
#include "IObjWriter.h"
#include "ObjWriter.h"
namespace IW3
{
class ObjWriter final : public IObjWriter
{
public:
bool DumpZone(AssetDumpingContext& context) const override;
protected:
void RegisterAssetDumpers(AssetDumpingContext& context) override;
};
} // namespace IW3
@@ -4,11 +4,6 @@ using namespace IW3;
namespace raw_file
{
DumperIW3::DumperIW3(const AssetPool<AssetRawFile::Type>& pool)
: AbstractAssetDumper(pool)
{
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<RawFile>& asset)
{
const auto* rawFile = asset.Asset();
@@ -7,9 +7,6 @@ namespace raw_file
{
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetRawFile>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetRawFile::Type>& pool);
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::RawFile>& asset) override;
};
@@ -25,11 +25,6 @@ namespace
namespace sound
{
LoadedSoundDumperIW3::LoadedSoundDumperIW3(const AssetPool<AssetLoadedSound::Type>& pool)
: AbstractAssetDumper(pool)
{
}
void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<LoadedSound>& asset)
{
const auto* loadedSound = asset.Asset();
@@ -7,9 +7,6 @@ namespace sound
{
class LoadedSoundDumperIW3 final : public AbstractAssetDumper<IW3::AssetLoadedSound>
{
public:
explicit LoadedSoundDumperIW3(const AssetPool<IW3::AssetLoadedSound::Type>& pool);
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::AssetLoadedSound::Type>& asset) override;
};
@@ -6,11 +6,6 @@ using namespace IW3;
namespace string_table
{
DumperIW3::DumperIW3(const AssetPool<AssetStringTable::Type>& pool)
: AbstractAssetDumper(pool)
{
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<StringTable>& asset)
{
const auto* stringTable = asset.Asset();
@@ -7,9 +7,6 @@ namespace string_table
{
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetStringTable>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetStringTable::Type>& pool);
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::StringTable>& asset) override;
};