mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Restored text export command
This commit is contained in:
@@ -664,36 +664,7 @@ void processCommand(const std::string &message)
|
|||||||
// }
|
// }
|
||||||
else if(message=="convert txt")
|
else if(message=="convert txt")
|
||||||
{
|
{
|
||||||
std::cout << "Command accepted.\t";
|
VLC->generaltexth->dumpAllTexts();
|
||||||
|
|
||||||
const bfs::path outPath =
|
|
||||||
VCMIDirs::get().userExtractedPath();
|
|
||||||
|
|
||||||
bfs::create_directories(outPath);
|
|
||||||
|
|
||||||
auto extractVector = [=](const std::vector<std::string> & source, const std::string & name)
|
|
||||||
{
|
|
||||||
JsonNode data(JsonNode::JsonType::DATA_VECTOR);
|
|
||||||
size_t index = 0;
|
|
||||||
for(auto & line : source)
|
|
||||||
{
|
|
||||||
JsonNode lineNode(JsonNode::JsonType::DATA_STRUCT);
|
|
||||||
lineNode["text"].String() = line;
|
|
||||||
lineNode["index"].Integer() = index++;
|
|
||||||
data.Vector().push_back(lineNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bfs::path filePath = outPath / (name + ".json");
|
|
||||||
bfs::ofstream file(filePath);
|
|
||||||
file << data.toJson();
|
|
||||||
};
|
|
||||||
|
|
||||||
//extractVector(VLC->generaltexth->allTexts, "generalTexts");
|
|
||||||
//extractVector(VLC->generaltexth->jktexts, "jkTexts");
|
|
||||||
//extractVector(VLC->generaltexth->arraytxt, "arrayTexts");
|
|
||||||
|
|
||||||
std::cout << "\rExtracting done :)\n";
|
|
||||||
std::cout << " Extracted files can be found in " << outPath << " directory\n";
|
|
||||||
}
|
}
|
||||||
else if(message=="get config")
|
else if(message=="get config")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -546,8 +546,6 @@ CGeneralTextHandler::CGeneralTextHandler():
|
|||||||
if (CResourceHandler::get()->existsResource(ResourceID("DATA/ZNPC00.TXT", EResType::TEXT)))
|
if (CResourceHandler::get()->existsResource(ResourceID("DATA/ZNPC00.TXT", EResType::TEXT)))
|
||||||
readToVector("vcmi.znpc00", "DATA/ZNPC00.TXT" );
|
readToVector("vcmi.znpc00", "DATA/ZNPC00.TXT" );
|
||||||
}
|
}
|
||||||
|
|
||||||
dumpAllTexts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CGeneralTextHandler::pluralText(const int32_t textIndex, const int32_t count) const
|
int32_t CGeneralTextHandler::pluralText(const int32_t textIndex, const int32_t count) const
|
||||||
@@ -564,7 +562,7 @@ int32_t CGeneralTextHandler::pluralText(const int32_t textIndex, const int32_t c
|
|||||||
|
|
||||||
void CGeneralTextHandler::dumpAllTexts()
|
void CGeneralTextHandler::dumpAllTexts()
|
||||||
{
|
{
|
||||||
logGlobal->trace("BEGIN TEXT EXPORT");
|
logGlobal->info("BEGIN TEXT EXPORT");
|
||||||
for ( auto const & entry : stringsLocalizations)
|
for ( auto const & entry : stringsLocalizations)
|
||||||
{
|
{
|
||||||
auto cleanString = entry.second;
|
auto cleanString = entry.second;
|
||||||
@@ -574,9 +572,9 @@ void CGeneralTextHandler::dumpAllTexts()
|
|||||||
boost::replace_all(cleanString, "\t", "\\t");
|
boost::replace_all(cleanString, "\t", "\\t");
|
||||||
boost::replace_all(cleanString, "\"", "\\\"");
|
boost::replace_all(cleanString, "\"", "\\\"");
|
||||||
|
|
||||||
logGlobal->trace("\"%s\" : \"%s\",", entry.first, cleanString);
|
logGlobal->info("\"%s\" : \"%s\",", entry.first, cleanString);
|
||||||
}
|
}
|
||||||
logGlobal->trace("END TEXT EXPORT");
|
logGlobal->info("END TEXT EXPORT");
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CGeneralTextHandler::getCampaignLength(size_t campaignID) const
|
size_t CGeneralTextHandler::getCampaignLength(size_t campaignID) const
|
||||||
|
|||||||
Reference in New Issue
Block a user