mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
ZoneLoading: Dump localized strings as str files
This commit is contained in:
@ -1,8 +1,95 @@
|
||||
#include "AssetDumperLocalizeEntry.h"
|
||||
#include "Dumping/Localize/StringFileDumper.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
std::string AssetDumperLocalizeEntry::GetNameOfLanguage(ZoneLanguage language)
|
||||
{
|
||||
// TODO: Add a dumping method that dumps all localized strings to a .str file and not in separate files.
|
||||
switch(language)
|
||||
{
|
||||
case ZoneLanguage::LANGUAGE_NONE:
|
||||
case ZoneLanguage::LANGUAGE_ENGLISH:
|
||||
default:
|
||||
return "english";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_FRENCH:
|
||||
return "french";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_GERMAN:
|
||||
return "german";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_ITALIAN:
|
||||
return "italian";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_SPANISH:
|
||||
return "spanish";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_BRITISH:
|
||||
return "british";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_RUSSIAN:
|
||||
return "russian";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_POLISH:
|
||||
return "polish";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_KOREAN:
|
||||
return "korean";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_JAPANESE:
|
||||
return "japanese";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_CZECH:
|
||||
return "czech";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_FRENCH_CAN:
|
||||
return "frenchcan";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_AUSTRIAN:
|
||||
return "austrian";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_PORTUGUESE:
|
||||
return "portuguese";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_MEXICAN_SPANISH:
|
||||
return "mexicanspanish";
|
||||
|
||||
case ZoneLanguage::LANGUAGE_FULL_JAPANESE:
|
||||
return "fulljapanese";
|
||||
}
|
||||
}
|
||||
|
||||
void AssetDumperLocalizeEntry::DumpPool(Zone* zone, AssetPool<LocalizeEntry>* pool, const std::string& basePath)
|
||||
{
|
||||
const std::string language = GetNameOfLanguage(zone->m_language);
|
||||
const std::string stringsPath = utils::Path::Combine(basePath, language + "/localizedstrings");
|
||||
|
||||
FileAPI::DirectoryCreate(stringsPath);
|
||||
|
||||
FileAPI::File stringFile = FileAPI::Open(utils::Path::Combine(stringsPath, zone->m_name + ".str"), FileAPI::Mode::MODE_WRITE);
|
||||
|
||||
if(stringFile.IsOpen())
|
||||
{
|
||||
StringFileDumper stringFileDumper(zone, &stringFile);
|
||||
|
||||
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_asset->name, localizeEntry->m_asset->value);
|
||||
}
|
||||
|
||||
stringFileDumper.Finalize();
|
||||
|
||||
stringFile.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", zone->m_name.c_str());
|
||||
}
|
||||
}
|
@ -5,6 +5,8 @@
|
||||
|
||||
class AssetDumperLocalizeEntry final : public IAssetDumper<T6::LocalizeEntry>
|
||||
{
|
||||
static std::string GetNameOfLanguage(ZoneLanguage language);
|
||||
|
||||
public:
|
||||
void DumpPool(Zone* zone, AssetPool<T6::LocalizeEntry>* pool, const std::string& basePath) override;
|
||||
};
|
@ -7,6 +7,7 @@
|
||||
#include "AssetDumpers/AssetDumperQdb.h"
|
||||
#include "AssetDumpers/AssetDumperScriptParseTree.h"
|
||||
#include "AssetDumpers/AssetDumperStringTable.h"
|
||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||
|
||||
bool ZoneDumperT6::CanHandleZone(Zone* zone)
|
||||
{
|
||||
@ -45,7 +46,7 @@ bool ZoneDumperT6::DumpZone(Zone* zone, const std::string& basePath)
|
||||
// DUMP_ASSET_POOL(AssetDumperFontIcon, m_font_icon);
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list);
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def);
|
||||
// DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize);
|
||||
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize);
|
||||
// DUMP_ASSET_POOL(AssetDumperWeaponVariantDef, m_weapon);
|
||||
// DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment);
|
||||
// DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique);
|
||||
|
Reference in New Issue
Block a user