1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 15:02:34 +02:00

Add constants for non alphanumeric symbols

This commit is contained in:
Daniel Evans 2016-08-21 18:02:13 +01:00
parent 398e184cd6
commit f82d48d52a
2 changed files with 19 additions and 6 deletions

View File

@ -28,6 +28,19 @@ namespace GameStringUtil
GameString fromString(const std::string& str);
}
/**
* Since the encoding of symbols is arbitrary, these constants should be used in
* hard-coded strings containing symbols outside of the ASCII-subset supported by
* all fonts
*/
namespace GameSymbols
{
static constexpr GameStringChar Money = '$';
static constexpr GameStringChar Heart = '{';
static constexpr GameStringChar Armour = '[';
static constexpr GameStringChar Star = ']';
}
class GameTexts
{
using StringTable = std::unordered_map<GameStringKey, GameString>;

View File

@ -88,7 +88,7 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world, GameRenderer* re
infoTextY += ui_textHeight;
ti.text = GameStringUtil::fromString("[") + GameStringUtil::fromString(std::to_string(world->state->playerInfo.money));
ti.text = GameSymbols::Money + GameStringUtil::fromString(std::to_string(world->state->playerInfo.money));
ti.baseColour = ui_shadowColour;
ti.screenPosition = glm::vec2(infoTextX + 1.f, infoTextY+1.f);
render->text.renderText(ti);
@ -101,9 +101,9 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world, GameRenderer* re
{
std::stringstream ss;
ss << "{" << std::setw(3) << std::setfill('0')
ss << std::setw(3) << std::setfill('0')
<< (int)player->getCharacter()->getCurrentState().health;
ti.text = GameStringUtil::fromString(ss.str());
ti.text = GameSymbols::Heart + GameStringUtil::fromString(ss.str());
}
ti.baseColour = ui_shadowColour;
ti.screenPosition = glm::vec2(infoTextX + 1.f, infoTextY+1.f);
@ -116,9 +116,9 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world, GameRenderer* re
if (player->getCharacter()->getCurrentState().armour > 0)
{
std::stringstream ss;
ss << "[" << std::setw(3) << std::setfill('0')
ss << std::setw(3) << std::setfill('0')
<< (int)player->getCharacter()->getCurrentState().armour;
ti.text = GameStringUtil::fromString(ss.str());
ti.text = GameSymbols::Armour + GameStringUtil::fromString(ss.str());
ti.baseColour = ui_shadowColour;
ti.screenPosition = glm::vec2(infoTextX + 1.f - ui_armourOffset, infoTextY+1.f);
render->text.renderText(ti);
@ -130,7 +130,7 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world, GameRenderer* re
GameString s;
for (size_t i = 0; i < ui_maxWantedLevel; ++i) {
s += GameStringUtil::fromString("]");
s += GameSymbols::Star;
}
ti.text = s;
ti.baseColour = ui_shadowColour;