2023-06-17 22:52:42 +02:00
|
|
|
/*
|
2023-06-18 11:18:25 +02:00
|
|
|
* MetaString.cpp, part of VCMI engine
|
2023-06-17 22:52:42 +02:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "MetaString.h"
|
|
|
|
|
|
|
|
#include "CArtHandler.h"
|
|
|
|
#include "CCreatureHandler.h"
|
|
|
|
#include "CCreatureSet.h"
|
2024-10-25 22:41:19 +02:00
|
|
|
#include "entities/faction/CFaction.h"
|
2024-07-20 14:55:17 +02:00
|
|
|
#include "texts/CGeneralTextHandler.h"
|
2023-06-17 22:52:42 +02:00
|
|
|
#include "CSkillHandler.h"
|
|
|
|
#include "GameConstants.h"
|
|
|
|
#include "VCMI_Lib.h"
|
|
|
|
#include "mapObjectConstructors/CObjectClassesHandler.h"
|
|
|
|
#include "spells/CSpellHandler.h"
|
2023-09-15 10:06:06 +02:00
|
|
|
#include "serializer/JsonSerializeFormat.h"
|
2023-06-17 22:52:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-06-18 12:51:11 +02:00
|
|
|
MetaString MetaString::createFromRawString(const std::string & value)
|
|
|
|
{
|
|
|
|
MetaString result;
|
|
|
|
result.appendRawString(value);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaString MetaString::createFromTextID(const std::string & value)
|
|
|
|
{
|
|
|
|
MetaString result;
|
|
|
|
result.appendTextID(value);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-06-18 11:18:25 +02:00
|
|
|
void MetaString::appendLocalString(EMetaText type, ui32 serial)
|
2023-06-17 22:52:42 +02:00
|
|
|
{
|
2023-06-18 11:18:25 +02:00
|
|
|
message.push_back(EMessage::APPEND_LOCAL_STRING);
|
|
|
|
localStrings.emplace_back(type, serial);
|
|
|
|
}
|
|
|
|
|
2023-06-18 12:51:11 +02:00
|
|
|
void MetaString::appendRawString(const std::string & value)
|
2023-06-18 11:18:25 +02:00
|
|
|
{
|
|
|
|
message.push_back(EMessage::APPEND_RAW_STRING);
|
|
|
|
exactStrings.push_back(value);
|
|
|
|
}
|
|
|
|
|
2023-06-18 12:51:11 +02:00
|
|
|
void MetaString::appendTextID(const std::string & value)
|
|
|
|
{
|
2023-11-26 18:53:34 +02:00
|
|
|
if (!value.empty())
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::APPEND_TEXTID_STRING);
|
|
|
|
stringsTextID.push_back(value);
|
|
|
|
}
|
2023-06-18 12:51:11 +02:00
|
|
|
}
|
|
|
|
|
2023-06-18 11:18:25 +02:00
|
|
|
void MetaString::appendNumber(int64_t value)
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::APPEND_NUMBER);
|
|
|
|
numbers.push_back(value);
|
|
|
|
}
|
|
|
|
|
2024-05-21 19:00:13 +02:00
|
|
|
void MetaString::appendEOL()
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::APPEND_EOL);
|
|
|
|
}
|
|
|
|
|
2023-06-18 11:18:25 +02:00
|
|
|
void MetaString::replaceLocalString(EMetaText type, ui32 serial)
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::REPLACE_LOCAL_STRING);
|
|
|
|
localStrings.emplace_back(type, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replaceRawString(const std::string &txt)
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::REPLACE_RAW_STRING);
|
|
|
|
exactStrings.push_back(txt);
|
|
|
|
}
|
|
|
|
|
2023-06-18 12:51:11 +02:00
|
|
|
void MetaString::replaceTextID(const std::string & value)
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::REPLACE_TEXTID_STRING);
|
|
|
|
stringsTextID.push_back(value);
|
|
|
|
}
|
|
|
|
|
2023-06-18 11:18:25 +02:00
|
|
|
void MetaString::replaceNumber(int64_t txt)
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::REPLACE_NUMBER);
|
|
|
|
numbers.push_back(txt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replacePositiveNumber(int64_t txt)
|
|
|
|
{
|
|
|
|
message.push_back(EMessage::REPLACE_POSITIVE_NUMBER);
|
|
|
|
numbers.push_back(txt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::clear()
|
|
|
|
{
|
|
|
|
exactStrings.clear();
|
|
|
|
localStrings.clear();
|
2023-06-18 12:51:11 +02:00
|
|
|
stringsTextID.clear();
|
2023-06-18 11:18:25 +02:00
|
|
|
message.clear();
|
|
|
|
numbers.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MetaString::empty() const
|
|
|
|
{
|
2023-09-27 23:11:11 +02:00
|
|
|
return message.empty() || toString().empty();
|
2023-06-18 11:18:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string MetaString::getLocalString(const std::pair<EMetaText, ui32> & txt) const
|
|
|
|
{
|
|
|
|
EMetaText type = txt.first;
|
2023-06-17 22:52:42 +02:00
|
|
|
int ser = txt.second;
|
|
|
|
|
2023-06-18 11:18:25 +02:00
|
|
|
switch(type)
|
2023-06-17 22:52:42 +02:00
|
|
|
{
|
2023-06-18 11:18:25 +02:00
|
|
|
case EMetaText::GENERAL_TXT:
|
|
|
|
return VLC->generaltexth->translate("core.genrltxt", ser);
|
|
|
|
case EMetaText::ARRAY_TXT:
|
|
|
|
return VLC->generaltexth->translate("core.arraytxt", ser);
|
|
|
|
case EMetaText::ADVOB_TXT:
|
|
|
|
return VLC->generaltexth->translate("core.advevent", ser);
|
|
|
|
case EMetaText::JK_TXT:
|
|
|
|
return VLC->generaltexth->translate("core.jktext", ser);
|
|
|
|
default:
|
|
|
|
logGlobal->error("Failed string substitution because type is %d", static_cast<int>(type));
|
|
|
|
return "#@#";
|
2023-06-17 22:52:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-18 11:18:25 +02:00
|
|
|
DLL_LINKAGE std::string MetaString::toString() const
|
2023-06-17 22:52:42 +02:00
|
|
|
{
|
2023-06-18 11:18:25 +02:00
|
|
|
std::string dst;
|
|
|
|
|
2023-06-17 22:52:42 +02:00
|
|
|
size_t exSt = 0;
|
|
|
|
size_t loSt = 0;
|
|
|
|
size_t nums = 0;
|
2023-06-18 12:51:11 +02:00
|
|
|
size_t textID = 0;
|
2023-06-17 22:52:42 +02:00
|
|
|
dst.clear();
|
|
|
|
|
|
|
|
for(const auto & elem : message)
|
2023-06-18 11:18:25 +02:00
|
|
|
{
|
2023-06-17 22:52:42 +02:00
|
|
|
switch(elem)
|
|
|
|
{
|
2023-06-18 12:51:11 +02:00
|
|
|
case EMessage::APPEND_RAW_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
dst += exactStrings.at(exSt++);
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::APPEND_LOCAL_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
dst += getLocalString(localStrings.at(loSt++));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::APPEND_TEXTID_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
dst += VLC->generaltexth->translate(stringsTextID.at(textID++));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::APPEND_NUMBER:
|
2024-05-14 11:44:40 +02:00
|
|
|
dst += std::to_string(numbers.at(nums++));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
2024-05-21 19:00:13 +02:00
|
|
|
case EMessage::APPEND_EOL:
|
|
|
|
dst += '\n';
|
|
|
|
break;
|
2023-06-18 12:51:11 +02:00
|
|
|
case EMessage::REPLACE_RAW_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
boost::replace_first(dst, "%s", exactStrings.at(exSt++));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::REPLACE_LOCAL_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
boost::replace_first(dst, "%s", getLocalString(localStrings.at(loSt++)));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::REPLACE_TEXTID_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
boost::replace_first(dst, "%s", VLC->generaltexth->translate(stringsTextID.at(textID++)));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::REPLACE_NUMBER:
|
2024-05-14 11:44:40 +02:00
|
|
|
boost::replace_first(dst, "%d", std::to_string(numbers.at(nums++)));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::REPLACE_POSITIVE_NUMBER:
|
2023-12-10 16:33:22 +02:00
|
|
|
if (dst.find("%+d") != std::string::npos)
|
2024-04-08 17:21:24 +02:00
|
|
|
{
|
2024-05-14 11:44:40 +02:00
|
|
|
int64_t value = numbers.at(nums);
|
2024-04-09 17:56:28 +02:00
|
|
|
if (value > 0)
|
|
|
|
boost::replace_first(dst, "%+d", '+' + std::to_string(value));
|
2024-04-08 17:21:24 +02:00
|
|
|
else
|
2024-04-09 17:56:28 +02:00
|
|
|
boost::replace_first(dst, "%+d", std::to_string(value));
|
|
|
|
|
|
|
|
nums++;
|
2024-04-08 17:21:24 +02:00
|
|
|
}
|
2023-12-10 16:33:22 +02:00
|
|
|
else
|
2024-05-14 11:44:40 +02:00
|
|
|
boost::replace_first(dst, "%d", std::to_string(numbers.at(nums++)));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logGlobal->error("MetaString processing error! Received message of type %d", static_cast<int>(elem));
|
|
|
|
assert(0);
|
|
|
|
break;
|
2023-06-17 22:52:42 +02:00
|
|
|
}
|
|
|
|
}
|
2023-06-18 11:18:25 +02:00
|
|
|
return dst;
|
2023-06-17 22:52:42 +02:00
|
|
|
}
|
|
|
|
|
2023-06-18 12:51:11 +02:00
|
|
|
DLL_LINKAGE std::string MetaString::buildList() const
|
2023-06-17 22:52:42 +02:00
|
|
|
{
|
|
|
|
size_t exSt = 0;
|
|
|
|
size_t loSt = 0;
|
|
|
|
size_t nums = 0;
|
2023-06-18 12:51:11 +02:00
|
|
|
size_t textID = 0;
|
2023-06-17 22:52:42 +02:00
|
|
|
std::string lista;
|
2023-06-18 12:51:11 +02:00
|
|
|
for(int i = 0; i < message.size(); ++i)
|
2023-06-17 22:52:42 +02:00
|
|
|
{
|
2024-05-14 11:44:40 +02:00
|
|
|
if(i > 0 && (message.at(i) == EMessage::APPEND_RAW_STRING || message.at(i) == EMessage::APPEND_LOCAL_STRING))
|
2023-06-17 22:52:42 +02:00
|
|
|
{
|
2023-06-18 12:51:11 +02:00
|
|
|
if(exSt == exactStrings.size() - 1)
|
2023-06-17 22:52:42 +02:00
|
|
|
lista += VLC->generaltexth->allTexts[141]; //" and "
|
|
|
|
else
|
|
|
|
lista += ", ";
|
|
|
|
}
|
2024-05-14 11:44:40 +02:00
|
|
|
switch(message.at(i))
|
2023-06-17 22:52:42 +02:00
|
|
|
{
|
2023-06-18 11:18:25 +02:00
|
|
|
case EMessage::APPEND_RAW_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista += exactStrings.at(exSt++);
|
2023-06-17 22:52:42 +02:00
|
|
|
break;
|
2023-06-18 11:18:25 +02:00
|
|
|
case EMessage::APPEND_LOCAL_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista += getLocalString(localStrings.at(loSt++));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::APPEND_TEXTID_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista += VLC->generaltexth->translate(stringsTextID.at(textID++));
|
2023-06-17 22:52:42 +02:00
|
|
|
break;
|
2023-06-18 11:18:25 +02:00
|
|
|
case EMessage::APPEND_NUMBER:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista += std::to_string(numbers.at(nums++));
|
2023-06-17 22:52:42 +02:00
|
|
|
break;
|
2024-05-21 19:00:13 +02:00
|
|
|
case EMessage::APPEND_EOL:
|
|
|
|
lista += '\n';
|
|
|
|
break;
|
2023-06-18 11:18:25 +02:00
|
|
|
case EMessage::REPLACE_RAW_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista.replace(lista.find("%s"), 2, exactStrings.at(exSt++));
|
2023-06-17 22:52:42 +02:00
|
|
|
break;
|
2023-06-18 11:18:25 +02:00
|
|
|
case EMessage::REPLACE_LOCAL_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista.replace(lista.find("%s"), 2, getLocalString(localStrings.at(loSt++)));
|
2023-06-18 12:51:11 +02:00
|
|
|
break;
|
|
|
|
case EMessage::REPLACE_TEXTID_STRING:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista.replace(lista.find("%s"), 2, VLC->generaltexth->translate(stringsTextID.at(textID++)));
|
2023-06-17 22:52:42 +02:00
|
|
|
break;
|
2023-06-18 11:18:25 +02:00
|
|
|
case EMessage::REPLACE_NUMBER:
|
2024-05-14 11:44:40 +02:00
|
|
|
lista.replace(lista.find("%d"), 2, std::to_string(numbers.at(nums++)));
|
2023-06-17 22:52:42 +02:00
|
|
|
break;
|
|
|
|
default:
|
2024-05-14 11:44:40 +02:00
|
|
|
logGlobal->error("MetaString processing error! Received message of type %d", int(message.at(i)));
|
2023-06-17 22:52:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return lista;
|
|
|
|
}
|
|
|
|
|
2023-06-18 23:25:21 +02:00
|
|
|
bool MetaString::operator == (const MetaString & other) const
|
|
|
|
{
|
|
|
|
return message == other.message && localStrings == other.localStrings && exactStrings == other.exactStrings && stringsTextID == other.stringsTextID && numbers == other.numbers;
|
|
|
|
}
|
|
|
|
|
2023-06-18 17:59:04 +02:00
|
|
|
void MetaString::jsonSerialize(JsonNode & dest) const
|
|
|
|
{
|
|
|
|
JsonNode jsonMessage;
|
|
|
|
JsonNode jsonLocalStrings;
|
|
|
|
JsonNode jsonExactStrings;
|
|
|
|
JsonNode jsonStringsTextID;
|
|
|
|
JsonNode jsonNumbers;
|
|
|
|
|
|
|
|
for (const auto & entry : message )
|
|
|
|
{
|
|
|
|
JsonNode value;
|
|
|
|
value.Float() = static_cast<int>(entry);
|
|
|
|
jsonMessage.Vector().push_back(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto & entry : localStrings )
|
|
|
|
{
|
|
|
|
JsonNode value;
|
2023-06-19 21:01:18 +02:00
|
|
|
value.Integer() = static_cast<int>(entry.first) * 10000 + entry.second;
|
2023-06-18 17:59:04 +02:00
|
|
|
jsonLocalStrings.Vector().push_back(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto & entry : exactStrings )
|
|
|
|
{
|
|
|
|
JsonNode value;
|
|
|
|
value.String() = entry;
|
|
|
|
jsonExactStrings.Vector().push_back(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto & entry : stringsTextID )
|
|
|
|
{
|
|
|
|
JsonNode value;
|
|
|
|
value.String() = entry;
|
|
|
|
jsonStringsTextID.Vector().push_back(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto & entry : numbers )
|
|
|
|
{
|
|
|
|
JsonNode value;
|
2023-06-19 21:01:18 +02:00
|
|
|
value.Integer() = entry;
|
2023-06-18 17:59:04 +02:00
|
|
|
jsonNumbers.Vector().push_back(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
dest["message"] = jsonMessage;
|
|
|
|
dest["localStrings"] = jsonLocalStrings;
|
|
|
|
dest["exactStrings"] = jsonExactStrings;
|
|
|
|
dest["stringsTextID"] = jsonStringsTextID;
|
|
|
|
dest["numbers"] = jsonNumbers;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::jsonDeserialize(const JsonNode & source)
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
|
|
|
|
if (source.isString())
|
|
|
|
{
|
|
|
|
// compatibility with fields that were converted from string to MetaString
|
|
|
|
if(boost::starts_with(source.String(), "core.") || boost::starts_with(source.String(), "vcmi."))
|
|
|
|
appendTextID(source.String());
|
|
|
|
else
|
|
|
|
appendRawString(source.String());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto & entry : source["message"].Vector() )
|
|
|
|
message.push_back(static_cast<EMessage>(entry.Integer()));
|
|
|
|
|
|
|
|
for (const auto & entry : source["localStrings"].Vector() )
|
|
|
|
localStrings.push_back({ static_cast<EMetaText>(entry.Integer() / 10000), entry.Integer() % 10000 });
|
|
|
|
|
|
|
|
for (const auto & entry : source["exactStrings"].Vector() )
|
|
|
|
exactStrings.push_back(entry.String());
|
|
|
|
|
|
|
|
for (const auto & entry : source["stringsTextID"].Vector() )
|
|
|
|
stringsTextID.push_back(entry.String());
|
|
|
|
|
|
|
|
for (const auto & entry : source["numbers"].Vector() )
|
|
|
|
numbers.push_back(entry.Integer());
|
|
|
|
}
|
|
|
|
|
2023-09-15 10:06:06 +02:00
|
|
|
void MetaString::serializeJson(JsonSerializeFormat & handler)
|
|
|
|
{
|
|
|
|
if(handler.saving)
|
2023-09-20 20:58:47 +02:00
|
|
|
jsonSerialize(const_cast<JsonNode&>(handler.getCurrent()));
|
|
|
|
|
2023-09-15 10:06:06 +02:00
|
|
|
if(!handler.saving)
|
2023-09-20 20:58:47 +02:00
|
|
|
jsonDeserialize(handler.getCurrent());
|
2023-09-15 10:06:06 +02:00
|
|
|
}
|
|
|
|
|
2024-02-01 18:22:11 +02:00
|
|
|
void MetaString::appendName(const ArtifactID & id)
|
|
|
|
{
|
|
|
|
appendTextID(id.toEntity(VLC)->getNameTextID());
|
|
|
|
}
|
|
|
|
|
2023-11-02 22:01:49 +02:00
|
|
|
void MetaString::appendName(const SpellID & id)
|
|
|
|
{
|
2023-11-06 21:09:19 +02:00
|
|
|
appendTextID(id.toEntity(VLC)->getNameTextID());
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::appendName(const PlayerColor & id)
|
|
|
|
{
|
|
|
|
appendTextID(TextIdentifier("vcmi.capitalColors", id.getNum()).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::appendName(const CreatureID & id, TQuantity count)
|
|
|
|
{
|
|
|
|
if(count == 1)
|
|
|
|
appendNameSingular(id);
|
|
|
|
else
|
|
|
|
appendNamePlural(id);
|
|
|
|
}
|
|
|
|
|
2024-07-16 02:01:55 +02:00
|
|
|
void MetaString::appendName(const GameResID& id)
|
|
|
|
{
|
|
|
|
appendTextID(TextIdentifier("core.restypes", id.getNum()).get());
|
|
|
|
}
|
|
|
|
|
2023-11-02 22:01:49 +02:00
|
|
|
void MetaString::appendNameSingular(const CreatureID & id)
|
|
|
|
{
|
2023-11-06 21:09:19 +02:00
|
|
|
appendTextID(id.toEntity(VLC)->getNameSingularTextID());
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::appendNamePlural(const CreatureID & id)
|
|
|
|
{
|
2023-11-06 21:09:19 +02:00
|
|
|
appendTextID(id.toEntity(VLC)->getNamePluralTextID());
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replaceName(const ArtifactID & id)
|
|
|
|
{
|
2023-11-06 21:09:19 +02:00
|
|
|
replaceTextID(id.toEntity(VLC)->getNameTextID());
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
2024-10-25 22:41:19 +02:00
|
|
|
void MetaString::replaceName(const FactionID & id)
|
|
|
|
{
|
|
|
|
replaceTextID(id.toEntity(VLC)->getNameTextID());
|
|
|
|
}
|
|
|
|
|
2024-11-15 01:58:35 +02:00
|
|
|
void MetaString::replaceName(const MapObjectID & id)
|
2023-11-02 22:01:49 +02:00
|
|
|
{
|
|
|
|
replaceTextID(VLC->objtypeh->getObjectName(id, 0));
|
|
|
|
}
|
|
|
|
|
2024-11-15 01:58:35 +02:00
|
|
|
void MetaString::replaceName(const MapObjectID & id, const MapObjectSubID & subId)
|
|
|
|
{
|
|
|
|
replaceTextID(VLC->objtypeh->getObjectName(id, subId));
|
|
|
|
}
|
|
|
|
|
2023-11-02 22:01:49 +02:00
|
|
|
void MetaString::replaceName(const PlayerColor & id)
|
|
|
|
{
|
|
|
|
replaceTextID(TextIdentifier("vcmi.capitalColors", id.getNum()).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replaceName(const SecondarySkill & id)
|
|
|
|
{
|
|
|
|
replaceTextID(VLC->skillh->getById(id)->getNameTextID());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replaceName(const SpellID & id)
|
|
|
|
{
|
2023-11-06 21:09:19 +02:00
|
|
|
replaceTextID(id.toEntity(VLC)->getNameTextID());
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
2023-11-08 16:13:08 +02:00
|
|
|
void MetaString::replaceName(const GameResID& id)
|
|
|
|
{
|
|
|
|
replaceTextID(TextIdentifier("core.restypes", id.getNum()).get());
|
|
|
|
}
|
|
|
|
|
2023-11-02 22:01:49 +02:00
|
|
|
void MetaString::replaceNameSingular(const CreatureID & id)
|
|
|
|
{
|
2023-11-06 21:09:19 +02:00
|
|
|
replaceTextID(id.toEntity(VLC)->getNameSingularTextID());
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replaceNamePlural(const CreatureID & id)
|
|
|
|
{
|
2023-11-06 21:09:19 +02:00
|
|
|
replaceTextID(id.toEntity(VLC)->getNamePluralTextID());
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replaceName(const CreatureID & id, TQuantity count) //adds sing or plural name;
|
|
|
|
{
|
|
|
|
if(count == 1)
|
|
|
|
replaceNameSingular(id);
|
|
|
|
else
|
|
|
|
replaceNamePlural(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MetaString::replaceName(const CStackBasicDescriptor & stack)
|
|
|
|
{
|
2024-10-12 18:02:35 +02:00
|
|
|
replaceName(stack.getId(), stack.count);
|
2023-11-02 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
2023-06-17 22:52:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|