mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-10-23 06:46:00 +00:00
refactor: streamline localize dumper
This commit is contained in:
44
src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp
Normal file
44
src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp
Normal 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
|
Reference in New Issue
Block a user