mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-25 02:51:43 +00:00
refactor: introduce subasset loading
This commit is contained in:
@@ -61,8 +61,7 @@ namespace
|
||||
|
||||
namespace image
|
||||
{
|
||||
DumperT5::DumperT5(const AssetPool<AssetImage::Type>& pool)
|
||||
: AbstractAssetDumper(pool)
|
||||
DumperT5::DumperT5()
|
||||
{
|
||||
switch (ObjWriting::Configuration.ImageOutputFormat)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace image
|
||||
class DumperT5 final : public AbstractAssetDumper<T5::AssetImage>
|
||||
{
|
||||
public:
|
||||
explicit DumperT5(const AssetPool<T5::AssetImage::Type>& pool);
|
||||
DumperT5();
|
||||
|
||||
protected:
|
||||
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T5::AssetImage::Type>& asset) override;
|
||||
|
||||
@@ -5,20 +5,15 @@
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T5;
|
||||
|
||||
namespace localize
|
||||
{
|
||||
DumperT5::DumperT5(const AssetPool<AssetLocalize::Type>& pool)
|
||||
: AbstractSingleProgressAssetDumper(pool)
|
||||
{
|
||||
}
|
||||
|
||||
void DumperT5::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);
|
||||
@@ -35,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);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace localize
|
||||
class DumperT5 final : public AbstractSingleProgressAssetDumper<T5::AssetLocalize>
|
||||
{
|
||||
public:
|
||||
explicit DumperT5(const AssetPool<T5::AssetLocalize::Type>& pool);
|
||||
|
||||
void Dump(AssetDumpingContext& context) override;
|
||||
};
|
||||
} // namespace localize
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "MaterialConstantZoneStateT5.h"
|
||||
|
||||
#include "Game/T5/CommonT5.h"
|
||||
#include "Game/T5/GameAssetPoolT5.h"
|
||||
#include "Game/T5/GameT5.h"
|
||||
#include "ObjWriting.h"
|
||||
#include "Zone/ZoneRegistry.h"
|
||||
@@ -479,11 +478,7 @@ namespace T5
|
||||
{
|
||||
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::T5)->Zones())
|
||||
{
|
||||
const auto* assetPools = dynamic_cast<const GameAssetPoolT5*>(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();
|
||||
|
||||
|
||||
@@ -1,36 +1,25 @@
|
||||
#include "ObjWriterT5.h"
|
||||
|
||||
#include "Game/T5/GameAssetPoolT5.h"
|
||||
#include "Game/T5/Material/MaterialJsonDumperT5.h"
|
||||
#include "Game/T5/Techset/TechsetDumperT5.h"
|
||||
#include "Game/T5/XModel/XModelDumperT5.h"
|
||||
#include "Image/ImageDumperT5.h"
|
||||
#include "Localize/LocalizeDumperT5.h"
|
||||
#include "ObjWriting.h"
|
||||
#include "RawFile/RawFileDumperT5.h"
|
||||
#include "StringTable/StringTableDumperT5.h"
|
||||
|
||||
using namespace T5;
|
||||
|
||||
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<GameAssetPoolT5*>(context.m_zone.m_pools.get());
|
||||
std::vector<std::unique_ptr<IAssetDumper>> dumpers;
|
||||
|
||||
// REGISTER_DUMPER(AssetDumperPhysPreset, m_phys_preset)
|
||||
// REGISTER_DUMPER(AssetDumperPhysConstraints, m_phys_constraints)
|
||||
// REGISTER_DUMPER(AssetDumperDestructibleDef, m_destructible_def)
|
||||
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
|
||||
REGISTER_DUMPER(xmodel::DumperT5, m_xmodel)
|
||||
REGISTER_DUMPER(material::JsonDumperT5, m_material)
|
||||
REGISTER_DUMPER(techset::DumperT5, m_technique_set)
|
||||
REGISTER_DUMPER(image::DumperT5, m_image)
|
||||
RegisterAssetDumper(std::make_unique<xmodel::DumperT5>());
|
||||
RegisterAssetDumper(std::make_unique<material::JsonDumperT5>());
|
||||
RegisterAssetDumper(std::make_unique<techset::DumperT5>());
|
||||
RegisterAssetDumper(std::make_unique<image::DumperT5>());
|
||||
// REGISTER_DUMPER(AssetDumperSndBank, m_sound_bank)
|
||||
// REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch)
|
||||
// REGISTER_DUMPER(AssetDumperClipMap, m_clip_map)
|
||||
@@ -43,32 +32,16 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// REGISTER_DUMPER(AssetDumperFont, m_font)
|
||||
// REGISTER_DUMPER(AssetDumperMenuList, m_menu_list)
|
||||
// REGISTER_DUMPER(AssetDumperMenuDef, m_menu_def)
|
||||
REGISTER_DUMPER(localize::DumperT5, m_localize)
|
||||
RegisterAssetDumper(std::make_unique<localize::DumperT5>());
|
||||
// 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::DumperT5, m_raw_file)
|
||||
REGISTER_DUMPER(string_table::DumperT5, m_string_table)
|
||||
RegisterAssetDumper(std::make_unique<raw_file::DumperT5>());
|
||||
RegisterAssetDumper(std::make_unique<string_table::DumperT5>());
|
||||
// REGISTER_DUMPER(AssetDumperPackIndex, m_pack_index)
|
||||
// REGISTER_DUMPER(AssetDumperXGlobals, m_xglobals)
|
||||
// REGISTER_DUMPER(AssetDumperDDLRoot, m_ddl)
|
||||
// REGISTER_DUMPER(AssetDumperGlasses, m_glasses)
|
||||
// REGISTER_DUMPER(AssetDumperEmblemSet, m_emblem_set)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
#include "IObjWriter.h"
|
||||
|
||||
#include "ObjWriter.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
class ObjWriter final : public IObjWriter
|
||||
{
|
||||
public:
|
||||
bool DumpZone(AssetDumpingContext& context) const override;
|
||||
void RegisterAssetDumpers(AssetDumpingContext& context) override;
|
||||
};
|
||||
} // namespace T5
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr static size_t GSC_MAX_SIZE = 0xC000000;
|
||||
constexpr size_t GSC_MAX_SIZE = 0xC000000;
|
||||
|
||||
void DumpGsc(AssetDumpingContext& context, const XAssetInfo<RawFile>& asset, std::ostream& stream)
|
||||
{
|
||||
@@ -96,11 +96,6 @@ namespace
|
||||
|
||||
namespace raw_file
|
||||
{
|
||||
DumperT5::DumperT5(const AssetPool<AssetRawFile::Type>& pool)
|
||||
: AbstractAssetDumper(pool)
|
||||
{
|
||||
}
|
||||
|
||||
void DumperT5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetRawFile::Type>& asset)
|
||||
{
|
||||
const auto* rawFile = asset.Asset();
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace raw_file
|
||||
{
|
||||
class DumperT5 final : public AbstractAssetDumper<T5::AssetRawFile>
|
||||
{
|
||||
public:
|
||||
explicit DumperT5(const AssetPool<T5::AssetRawFile::Type>& pool);
|
||||
|
||||
protected:
|
||||
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T5::AssetRawFile::Type>& asset) override;
|
||||
};
|
||||
|
||||
@@ -6,11 +6,6 @@ using namespace T5;
|
||||
|
||||
namespace string_table
|
||||
{
|
||||
DumperT5::DumperT5(const AssetPool<AssetStringTable::Type>& pool)
|
||||
: AbstractAssetDumper(pool)
|
||||
{
|
||||
}
|
||||
|
||||
void DumperT5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetStringTable::Type>& asset)
|
||||
{
|
||||
const auto* stringTable = asset.Asset();
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace string_table
|
||||
{
|
||||
class DumperT5 final : public AbstractAssetDumper<T5::AssetStringTable>
|
||||
{
|
||||
public:
|
||||
explicit DumperT5(const AssetPool<T5::AssetStringTable::Type>& pool);
|
||||
|
||||
protected:
|
||||
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T5::AssetStringTable::Type>& asset) override;
|
||||
};
|
||||
|
||||
@@ -318,11 +318,6 @@ namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
DumperT5::DumperT5(const AssetPool<AssetTechniqueSet::Type>& pool)
|
||||
: AbstractAssetDumper(pool)
|
||||
{
|
||||
}
|
||||
|
||||
void DumperT5::Dump(AssetDumpingContext& context)
|
||||
{
|
||||
context.GetZoneAssetDumperState<MaterialConstantZoneState>()->EnsureInitialized();
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace techset
|
||||
class DumperT5 final : public AbstractAssetDumper<T5::AssetTechniqueSet>
|
||||
{
|
||||
public:
|
||||
explicit DumperT5(const AssetPool<T5::AssetTechniqueSet::Type>& pool);
|
||||
|
||||
void Dump(AssetDumpingContext& context) override;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user