mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-10-30 10:06:57 +00:00
refactor: streamline stringtable dumper
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
42
src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp
Normal file
42
src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp
Normal 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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user