mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-01 22:47:26 +00:00
refactor: streamline stringtable dumper
This commit is contained in:
@@ -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;
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
34
src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp
Normal file
34
src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp
Normal 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
|
@@ -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;
|
Reference in New Issue
Block a user