mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Added h3m strings generation to 'convert txt' command
This commit is contained in:
parent
6c693f2920
commit
a4ef9fd0b8
@ -23,6 +23,9 @@
|
||||
#include "../lib/CGameState.h"
|
||||
#include "../lib/CPlayerState.h"
|
||||
#include "../lib/StringConstants.h"
|
||||
#include "../lib/mapping/CMapService.h"
|
||||
#include "../lib/mapping/CMap.h"
|
||||
#include "../lib/mapping/CCampaignHandler.h"
|
||||
#include "windows/CCastleInterface.h"
|
||||
#include "render/CAnimation.h"
|
||||
#include "../CCallback.h"
|
||||
@ -153,6 +156,29 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle
|
||||
// }
|
||||
else if(message=="convert txt")
|
||||
{
|
||||
std::unordered_set<ResourceID> mapList = CResourceHandler::get()->getFilteredFiles([&](const ResourceID & ident)
|
||||
{
|
||||
return ident.getType() == EResType::MAP;
|
||||
});
|
||||
|
||||
//std::unordered_set<ResourceID> campaignList = CResourceHandler::get()->getFilteredFiles([&](const ResourceID & ident)
|
||||
//{
|
||||
// return ident.getType() == EResType::CAMPAIGN;
|
||||
//});
|
||||
|
||||
CMapService mapService;
|
||||
|
||||
for (auto const & mapName : mapList)
|
||||
mapService.loadMap(mapName); // load and drop loaded map - we only need loader to run over all maps
|
||||
|
||||
// TODO:
|
||||
//for (auto const & campaignName : campaignList)
|
||||
//{
|
||||
// CCampaignState state(CCampaignHandler::getCampaign(campaignName.getName()));
|
||||
// for (auto const & part : state.camp->mapPieces)
|
||||
// delete state.getMap(part.first);
|
||||
//}
|
||||
|
||||
VLC->generaltexth->dumpAllTexts();
|
||||
}
|
||||
else if(message=="get config")
|
||||
|
@ -35,11 +35,24 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
const bool CMapLoaderH3M::IS_PROFILING_ENABLED = false;
|
||||
|
||||
static std::string convertMapName(std::string input)
|
||||
{
|
||||
boost::algorithm::to_lower(input);
|
||||
boost::algorithm::trim(input);
|
||||
|
||||
size_t slashPos = input.find_last_of("/");
|
||||
|
||||
if (slashPos != std::string::npos)
|
||||
return input.substr(slashPos + 1);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
CMapLoaderH3M::CMapLoaderH3M(const std::string & mapName, const std::string & modName, const std::string & encodingName, CInputStream * stream)
|
||||
: map(nullptr)
|
||||
, reader(new CBinaryReader(stream))
|
||||
, inputStream(stream)
|
||||
, mapName(boost::algorithm::to_lower_copy(mapName))
|
||||
, mapName(convertMapName(mapName))
|
||||
, modName(modName)
|
||||
, fileEncoding(encodingName)
|
||||
{
|
||||
@ -2252,7 +2265,7 @@ std::string CMapLoaderH3M::readBasicString()
|
||||
std::string CMapLoaderH3M::readLocalizedString(const TextIdentifier & stringIdentifier)
|
||||
{
|
||||
std::string mapString = TextOperations::toUnicode(reader->readBaseString(), fileEncoding);
|
||||
TextIdentifier fullIdentifier(mapName, stringIdentifier.get());
|
||||
TextIdentifier fullIdentifier("map", mapName, stringIdentifier.get());
|
||||
|
||||
if (mapString.empty())
|
||||
return "";
|
||||
|
Loading…
Reference in New Issue
Block a user