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

refactor: streamline localize dumper

This commit is contained in:
Jan Laupetin
2025-07-29 20:44:24 +01:00
parent 22dbf57269
commit 934ba7f95a
20 changed files with 245 additions and 230 deletions

View File

@@ -1,41 +0,0 @@
#include "AssetDumperLocalizeEntry.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace IW3;
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}

View File

@@ -0,0 +1,44 @@
#include "LocalizeDumperIW3.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace IW3;
namespace IW3::localize
{
void Dumper::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}
} // namespace IW3::localize

View File

@@ -3,11 +3,11 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3
namespace IW3::localize
{
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
class Dumper final : public IAssetDumper<LocalizeEntry>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
};
} // namespace IW3
} // namespace IW3::localize

View File

@@ -3,7 +3,7 @@
#include "Game/IW3/GameAssetPoolIW3.h"
#include "Game/IW3/XModel/XModelDumperIW3.h"
#include "Image/ImageDumperIW3.h"
#include "Localize/AssetDumperLocalizeEntry.h"
#include "Localize/LocalizeDumperIW3.h"
#include "Maps/AssetDumperMapEnts.h"
#include "Material/DumperMaterialIW3.h"
#include "ObjWriting.h"
@@ -44,7 +44,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
// DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
// DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)

View File

@@ -1,41 +0,0 @@
#include "AssetDumperLocalizeEntry.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <sstream>
using namespace IW4;
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}

View File

@@ -0,0 +1,44 @@
#include "LocalizeDumperIW4.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <sstream>
using namespace IW4;
namespace IW4::localize
{
void Dumper::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}
} // namespace IW4::localize

View File

@@ -3,11 +3,11 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
namespace IW4::localize
{
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
class Dumper final : public IAssetDumper<LocalizeEntry>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
};
} // namespace IW4
} // namespace IW4::localize

View File

@@ -5,7 +5,7 @@
#include "Image/ImageDumperIW4.h"
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
#include "LightDef/LightDefDumperIW4.h"
#include "Localize/AssetDumperLocalizeEntry.h"
#include "Localize/LocalizeDumperIW4.h"
#include "Maps/AssetDumperAddonMapEnts.h"
#include "Material/DumperMaterialIW4.h"
#include "Menu/AssetDumperMenuDef.h"
@@ -61,7 +61,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)

View File

@@ -1,41 +0,0 @@
#include "AssetDumperLocalizeEntry.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace IW5;
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}

View File

@@ -0,0 +1,44 @@
#include "LocalizeDumperIW5.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace IW5;
namespace IW5::localize
{
void Dumper::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}
} // namespace IW5::localize

View File

@@ -3,11 +3,11 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW5/IW5.h"
namespace IW5
namespace IW5::localize
{
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
class Dumper final : public IAssetDumper<LocalizeEntry>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
};
} // namespace IW5
} // namespace IW5::localize

View File

@@ -4,7 +4,7 @@
#include "Game/IW5/XModel/XModelDumperIW5.h"
#include "Image/ImageDumperIW5.h"
#include "Leaderboard/LeaderboardJsonDumperIW5.h"
#include "Localize/AssetDumperLocalizeEntry.h"
#include "Localize/LocalizeDumperIW5.h"
#include "Maps/AssetDumperAddonMapEnts.h"
#include "Material/DumperMaterialIW5.h"
#include "Menu/AssetDumperMenuDef.h"
@@ -55,7 +55,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT)
DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)

View File

@@ -1,41 +0,0 @@
#include "AssetDumperLocalizeEntry.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace T5;
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/projects/cod/t5/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}

View File

@@ -0,0 +1,44 @@
#include "LocalizeDumperT5.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace T5;
namespace T5::localize
{
void Dumper::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/projects/cod/t5/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}
} // namespace T5::localize

View File

@@ -3,11 +3,11 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T5/T5.h"
namespace T5
namespace T5::localize
{
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
class Dumper final : public IAssetDumper<LocalizeEntry>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
};
} // namespace T5
} // namespace T5::localize

View File

@@ -3,7 +3,7 @@
#include "Game/T5/GameAssetPoolT5.h"
#include "Game/T5/XModel/XModelDumperT5.h"
#include "Image/ImageDumperT5.h"
#include "Localize/AssetDumperLocalizeEntry.h"
#include "Localize/LocalizeDumperT5.h"
#include "Material/DumperMaterialT5.h"
#include "ObjWriting.h"
#include "PhysConstraints/AssetDumperPhysConstraints.h"
@@ -46,7 +46,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
// DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
// DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)

View File

@@ -1,41 +0,0 @@
#include "AssetDumperLocalizeEntry.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace T6;
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/projects/cod/t6/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}

View File

@@ -0,0 +1,44 @@
#include "LocalizeDumperT6.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <format>
#include <iostream>
using namespace T6;
namespace T6::localize
{
void Dumper::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
StringFileDumper stringFileDumper(context.m_zone, *assetFile);
stringFileDumper.SetLanguageName(language);
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
stringFileDumper.SetConfigFile(R"(C:/projects/cod/t6/bin/StringEd.cfg)");
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
stringFileDumper.Finalize();
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}
} // namespace T6::localize

View File

@@ -3,11 +3,11 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T6/T6.h"
namespace T6
namespace T6::localize
{
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
class Dumper final : public IAssetDumper<LocalizeEntry>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
};
} // namespace T6
} // namespace T6::localize

View File

@@ -5,7 +5,7 @@
#include "Game/T6/XModel/XModelDumperT6.h"
#include "Image/ImageDumperT6.h"
#include "Leaderboard/LeaderboardJsonDumperT6.h"
#include "Localize/AssetDumperLocalizeEntry.h"
#include "Localize/LocalizeDumperT6.h"
#include "Maps/AssetDumperMapEnts.h"
#include "Material/DumperMaterialT6.h"
#include "ObjWriting.h"
@@ -67,7 +67,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
DUMP_ASSET_POOL_WITH_FACTORY(font_icon::CreateDumper(), m_font_icon, ASSET_TYPE_FONTICON)
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
// DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON)
DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT)
DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE)