summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorPeterN <peter@fuzzle.org>2018-04-19 19:33:21 +0100
committerGitHub <noreply@github.com>2018-04-19 19:33:21 +0100
commit3b32075e8a3440c9bca8764289c0b1e3c2f4c28d (patch)
treecc5dde691f49ec264e0f932bb2ad56a689dc3c80 /src/strings.cpp
parentf4f9e18790b23862239164721dba831756ae24d7 (diff)
downloadopenttd-3b32075e8a3440c9bca8764289c0b1e3c2f4c28d.tar.xz
Add: {PUSH_COLOUR} and {POP_COLOUR} control codes to handle switching colours. (#6737)
This replaces the internal SCC_PREVIOUS_COLOUR swap.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 82669ddb2..e1e352f5d 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -449,6 +449,8 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
/* convert from negative */
if (number < 0) {
+ if (buff + Utf8CharLen(SCC_PUSH_COLOUR) > last) return buff;
+ buff += Utf8Encode(buff, SCC_PUSH_COLOUR);
if (buff + Utf8CharLen(SCC_RED) > last) return buff;
buff += Utf8Encode(buff, SCC_RED);
buff = strecpy(buff, "-", last);
@@ -485,8 +487,8 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last);
if (negative) {
- if (buff + Utf8CharLen(SCC_PREVIOUS_COLOUR) > last) return buff;
- buff += Utf8Encode(buff, SCC_PREVIOUS_COLOUR);
+ if (buff + Utf8CharLen(SCC_POP_COLOUR) > last) return buff;
+ buff += Utf8Encode(buff, SCC_POP_COLOUR);
*buff = '\0';
}