mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
PlayerColor: add getStr and getStrCap functions with optional L10n
This commit is contained in:
@ -17,6 +17,8 @@
|
||||
#include "CArtHandler.h"
|
||||
#include "CCreatureHandler.h"
|
||||
#include "spells/CSpellHandler.h"
|
||||
#include "StringConstants.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
|
||||
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER = SlotID(-2);
|
||||
const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER = SlotID(-3);
|
||||
@ -57,6 +59,32 @@ bool PlayerColor::isValidPlayer() const
|
||||
return num < PLAYER_LIMIT_I;
|
||||
}
|
||||
|
||||
std::string PlayerColor::getStr(bool L10n) const
|
||||
{
|
||||
std::string ret = "unnamed";
|
||||
if(isValidPlayer())
|
||||
{
|
||||
if(L10n)
|
||||
ret = VLC->generaltexth->colors[num];
|
||||
else
|
||||
ret = GameConstants::PLAYER_COLOR_NAMES[num];
|
||||
}
|
||||
else if(L10n)
|
||||
{
|
||||
ret = VLC->generaltexth->allTexts[508];
|
||||
ret[0] = std::tolower(ret[0]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string PlayerColor::getStrCap(bool L10n) const
|
||||
{
|
||||
std::string ret = getStr(L10n);
|
||||
ret[0] = std::toupper(ret[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, const Battle::ActionType actionType)
|
||||
{
|
||||
static const std::map<Battle::ActionType, std::string> actionTypeToString =
|
||||
|
Reference in New Issue
Block a user