2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-08-30 21:53:15 +00:00

refactor: streamline stringtable dumper

This commit is contained in:
Jan Laupetin
2025-07-30 22:59:57 +01:00
parent 0eb14890ab
commit e26c66ed60
20 changed files with 226 additions and 211 deletions

View File

@@ -9,7 +9,7 @@
#include "ObjWriting.h"
#include "RawFile/RawFileDumperIW3.h"
#include "Sound/AssetDumperLoadedSound.h"
#include "StringTable/AssetDumperStringTable.h"
#include "StringTable/StringTableDumperIW3.h"
#include "Weapon/AssetDumperWeapon.h"
using namespace IW3;
@@ -50,7 +50,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// 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::Dumper, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE)
return true;

View File

@@ -1,31 +0,0 @@
#include "AssetDumperStringTable.h"
#include "Csv/CsvStream.h"
using namespace IW3;
bool AssetDumperStringTable::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
csv.WriteColumn(stringTable->values[column + row * stringTable->columnCount]);
}
csv.NextRow();
}
}

View File

@@ -0,0 +1,34 @@
#include "StringTableDumperIW3.h"
#include "Csv/CsvStream.h"
using namespace IW3;
namespace IW3::string_table
{
bool Dumper::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
csv.WriteColumn(stringTable->values[column + row * stringTable->columnCount]);
}
csv.NextRow();
}
}
} // namespace IW3::string_table

View File

@@ -3,9 +3,9 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3
namespace IW3::string_table
{
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
class Dumper final : public AbstractAssetDumper<StringTable>
{
protected:
bool ShouldDump(XAssetInfo<StringTable>* asset) override;

View File

@@ -19,7 +19,7 @@
#include "Shader/AssetDumperVertexShader.h"
#include "Sound/AssetDumperLoadedSound.h"
#include "Sound/AssetDumperSndCurve.h"
#include "StringTable/AssetDumperStringTable.h"
#include "StringTable/StringTableDumperIW4.h"
#include "StructuredDataDef/AssetDumperStructuredDataDefSet.h"
#include "Techset/AssetDumperTechniqueSet.h"
#include "Tracer/AssetDumperTracer.h"
@@ -71,7 +71,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// 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::Dumper, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD)
DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER)

View File

@@ -1,39 +0,0 @@
#include "AssetDumperStringTable.h"
#include "Csv/CsvStream.h"
using namespace IW4;
bool AssetDumperStringTable::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}

View File

@@ -0,0 +1,42 @@
#include "StringTableDumperIW4.h"
#include "Csv/CsvStream.h"
using namespace IW4;
namespace IW4::string_table
{
bool Dumper::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}
} // namespace IW4::string_table

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
namespace IW4::string_table
{
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
class Dumper final : public AbstractAssetDumper<StringTable>
{
protected:
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset) override;
};
} // namespace IW4
} // namespace IW4::string_table

View File

@@ -13,7 +13,7 @@
#include "RawFile/RawFileDumperIW5.h"
#include "Script/ScriptDumperIW5.h"
#include "Sound/AssetDumperLoadedSound.h"
#include "StringTable/AssetDumperStringTable.h"
#include "StringTable/StringTableDumperIW5.h"
#include "Weapon/AssetDumperWeapon.h"
#include "Weapon/AssetDumperWeaponAttachment.h"
@@ -63,7 +63,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX)
DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(script::Dumper, m_script_file, ASSET_TYPE_SCRIPTFILE)
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD)
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
// DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER)

View File

@@ -1,39 +0,0 @@
#include "AssetDumperStringTable.h"
#include "Csv/CsvStream.h"
using namespace IW5;
bool AssetDumperStringTable::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}

View File

@@ -0,0 +1,42 @@
#include "StringTableDumperIW5.h"
#include "Csv/CsvStream.h"
using namespace IW5;
namespace IW5::string_table
{
bool Dumper::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}
} // namespace IW5::string_table

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW5/IW5.h"
namespace IW5
namespace IW5::string_table
{
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
class Dumper final : public AbstractAssetDumper<StringTable>
{
protected:
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset) override;
};
} // namespace IW5
} // namespace IW5::string_table

View File

@@ -8,7 +8,7 @@
#include "ObjWriting.h"
#include "RawFile/RawFileDumperT5.h"
#include "Sound/AssetDumperSndBank.h"
#include "StringTable/AssetDumperStringTable.h"
#include "StringTable/StringTableDumperT5.h"
#include "Weapon/AssetDumperWeapon.h"
using namespace T5;
@@ -50,7 +50,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// 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::Dumper, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE)
// DUMP_ASSET_POOL(AssetDumperPackIndex, m_pack_index, ASSET_TYPE_PACK_INDEX)
// DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS)
// DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL)

View File

@@ -1,39 +0,0 @@
#include "AssetDumperStringTable.h"
#include "Csv/CsvStream.h"
using namespace T5;
bool AssetDumperStringTable::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}

View File

@@ -0,0 +1,42 @@
#include "StringTableDumperT5.h"
#include "Csv/CsvStream.h"
using namespace T5;
namespace T5::string_table
{
bool Dumper::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}
} // namespace T5::string_table

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T5/T5.h"
namespace T5
namespace T5::string_table
{
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
class Dumper final : public AbstractAssetDumper<StringTable>
{
protected:
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset) override;
};
} // namespace T5
} // namespace T5::string_table

View File

@@ -17,7 +17,7 @@
#include "Slug/SlugDumperT6.h"
#include "Sound/AssetDumperSndBank.h"
#include "Sound/AssetDumperSndDriverGlobals.h"
#include "StringTable/AssetDumperStringTable.h"
#include "StringTable/StringTableDumperT6.h"
#include "Techset/AssetDumperTechniqueSet.h"
#include "Tracer/AssetDumperTracer.h"
#include "Vehicle/AssetDumperVehicle.h"
@@ -76,7 +76,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// 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::Dumper, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD)
// DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS)
// DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL)

View File

@@ -1,39 +0,0 @@
#include "AssetDumperStringTable.h"
#include "Csv/CsvStream.h"
using namespace T6;
bool AssetDumperStringTable::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}

View File

@@ -0,0 +1,42 @@
#include "StringTableDumperT6.h"
#include "Csv/CsvStream.h"
using namespace T6;
namespace T6::string_table
{
bool Dumper::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
CsvOutputStream csv(*assetFile);
for (auto row = 0; row < stringTable->rowCount; row++)
{
for (auto column = 0; column < stringTable->columnCount; column++)
{
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
if (cell->string != nullptr)
{
csv.WriteColumn(cell->string);
}
else
{
csv.WriteColumn("");
}
}
csv.NextRow();
}
}
} // namespace T6::string_table

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T6/T6.h"
namespace T6
namespace T6::string_table
{
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
class Dumper final : public AbstractAssetDumper<StringTable>
{
protected:
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset) override;
};
} // namespace T6
} // namespace T6::string_table