2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-11 11:11:50 +00:00

feat: report on unlinking progress

This commit is contained in:
Jan Laupetin
2025-10-14 23:20:56 +01:00
parent 9fa41ca0d3
commit c6e9cbedda
159 changed files with 686 additions and 802 deletions

View File

@@ -79,19 +79,14 @@ namespace image
}
}
bool DumperIW3::ShouldDump(XAssetInfo<GfxImage>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<GfxImage>& asset)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
const auto* image = asset.Asset();
const auto texture = LoadImageData(context.m_obj_search_path, *image);
if (!texture)
return;
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension()));
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name, m_writer->GetFileExtension()));
if (!assetFile)
return;

View File

@@ -14,8 +14,7 @@ namespace image
DumperIW3();
protected:
bool ShouldDump(XAssetInfo<IW3::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::GfxImage>& asset) override;
private:
std::unique_ptr<IImageWriter> m_writer;

View File

@@ -11,9 +11,14 @@ using namespace IW3;
namespace localize
{
void DumperIW3::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
size_t DumperIW3::GetProgressTotalCount(const AssetPool<IW3::LocalizeEntry>& pool) const
{
if (pool->m_asset_lookup.empty())
return pool.m_asset_lookup.empty() ? 0uz : 1uz;
}
void DumperIW3::DumpPool(AssetDumpingContext& context, const AssetPool<LocalizeEntry>& pool)
{
if (pool.m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
@@ -30,7 +35,7 @@ namespace localize
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
for (const auto* localizeEntry : pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
@@ -41,5 +46,7 @@ namespace localize
{
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
context.IncrementProgress();
}
} // namespace localize

View File

@@ -8,6 +8,7 @@ namespace localize
class DumperIW3 final : public IAssetDumper<IW3::LocalizeEntry>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<IW3::LocalizeEntry>* pool) override;
[[nodiscard]] size_t GetProgressTotalCount(const AssetPool<IW3::LocalizeEntry>& pool) const override;
void DumpPool(AssetDumpingContext& context, const AssetPool<IW3::LocalizeEntry>& pool) override;
};
} // namespace localize

View File

@@ -4,15 +4,10 @@ using namespace IW3;
namespace map_ents
{
bool DumperIW3::ShouldDump(XAssetInfo<MapEnts>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<MapEnts>& asset)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
{
const auto* mapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name + ".ents");
const auto* mapEnts = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name + ".ents");
if (!assetFile)
return;

View File

@@ -8,7 +8,6 @@ namespace map_ents
class DumperIW3 final : public AbstractAssetDumper<IW3::MapEnts>
{
protected:
bool ShouldDump(XAssetInfo<IW3::MapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::MapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::MapEnts>& asset) override;
};
} // namespace map_ents

View File

@@ -19,11 +19,20 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
{ \
dumperType dumper; \
dumper.DumpPool(context, assetPools->poolName.get()); \
totalProgress += dumper.GetProgressTotalCount(*assetPools->poolName); \
dumpingFunctions.emplace_back( \
[](AssetDumpingContext& funcContext, const GameAssetPoolIW3* funcPools) \
{ \
dumperType dumper; \
dumper.DumpPool(funcContext, *funcPools->poolName); \
}); \
}
const auto* assetPools = dynamic_cast<GameAssetPoolIW3*>(context.m_zone.m_pools.get());
size_t totalProgress = 0uz;
std::vector<std::function<void(AssetDumpingContext & context, const GameAssetPoolIW3*)>> dumpingFunctions;
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET)
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
DUMP_ASSET_POOL(xmodel::DumperIW3, m_xmodel, ASSET_TYPE_XMODEL)
@@ -51,6 +60,10 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
DUMP_ASSET_POOL(raw_file::DumperIW3, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(string_table::DumperIW3, m_string_table, ASSET_TYPE_STRINGTABLE)
context.SetTotalProgress(totalProgress);
for (const auto& func : dumpingFunctions)
func(context, assetPools);
return true;
#undef DUMP_ASSET_POOL

View File

@@ -4,15 +4,10 @@ using namespace IW3;
namespace raw_file
{
bool DumperIW3::ShouldDump(XAssetInfo<RawFile>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<RawFile>& asset)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
{
const auto* rawFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* rawFile = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -8,7 +8,6 @@ namespace raw_file
class DumperIW3 final : public AbstractAssetDumper<IW3::RawFile>
{
protected:
bool ShouldDump(XAssetInfo<IW3::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::RawFile>& asset) override;
};
} // namespace raw_file

View File

@@ -25,15 +25,10 @@ namespace
namespace sound
{
bool LoadedSoundDumperIW3::ShouldDump(XAssetInfo<LoadedSound>* asset)
void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<LoadedSound>& asset)
{
return true;
}
void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset)
{
const auto* loadedSound = asset->Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name));
const auto* loadedSound = asset.Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset.m_name));
if (!assetFile)
return;

View File

@@ -8,7 +8,6 @@ namespace sound
class LoadedSoundDumperIW3 final : public AbstractAssetDumper<IW3::LoadedSound>
{
protected:
bool ShouldDump(XAssetInfo<IW3::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::LoadedSound>& asset) override;
};
} // namespace sound

View File

@@ -6,15 +6,10 @@ using namespace IW3;
namespace string_table
{
bool DumperIW3::ShouldDump(XAssetInfo<StringTable>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<StringTable>& asset)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* stringTable = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -8,7 +8,6 @@ namespace string_table
class DumperIW3 final : public AbstractAssetDumper<IW3::StringTable>
{
protected:
bool ShouldDump(XAssetInfo<IW3::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::StringTable>& asset) override;
};
} // namespace string_table