mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +02:00
PlayerColor: add getStr and getStrCap functions with optional L10n
This commit is contained in:
parent
ca0fe8fdc4
commit
fdca75b4b0
@ -17,6 +17,8 @@
|
|||||||
#include "CArtHandler.h"
|
#include "CArtHandler.h"
|
||||||
#include "CCreatureHandler.h"
|
#include "CCreatureHandler.h"
|
||||||
#include "spells/CSpellHandler.h"
|
#include "spells/CSpellHandler.h"
|
||||||
|
#include "StringConstants.h"
|
||||||
|
#include "CGeneralTextHandler.h"
|
||||||
|
|
||||||
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER = SlotID(-2);
|
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER = SlotID(-2);
|
||||||
const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER = SlotID(-3);
|
const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER = SlotID(-3);
|
||||||
@ -57,6 +59,32 @@ bool PlayerColor::isValidPlayer() const
|
|||||||
return num < PLAYER_LIMIT_I;
|
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)
|
std::ostream & operator<<(std::ostream & os, const Battle::ActionType actionType)
|
||||||
{
|
{
|
||||||
static const std::map<Battle::ActionType, std::string> actionTypeToString =
|
static const std::map<Battle::ActionType, std::string> actionTypeToString =
|
||||||
|
@ -262,6 +262,9 @@ class PlayerColor : public BaseForID<PlayerColor, ui8>
|
|||||||
|
|
||||||
DLL_LINKAGE bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral)
|
DLL_LINKAGE bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral)
|
||||||
|
|
||||||
|
std::string getStr(bool L10n = false) const;
|
||||||
|
std::string getStrCap(bool L10n = false) const;
|
||||||
|
|
||||||
friend class CGameInfoCallback;
|
friend class CGameInfoCallback;
|
||||||
friend class CNonConstInfoCallback;
|
friend class CNonConstInfoCallback;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user