summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-07 15:20:31 +0000
committerrubidium <rubidium@openttd.org>2007-08-07 15:20:31 +0000
commitc46e445e69f50d5b5a95e3e46fb3eed1efdb7656 (patch)
treed96722811d3b8b7cb54fe12d32dc41147a3a4159 /src/strings.cpp
parenta7e37d8592d702b06679eba14a386dd779b61786 (diff)
downloadopenttd-c46e445e69f50d5b5a95e3e46fb3eed1efdb7656.tar.xz
(svn r10820) -Codechange: make negative currencies red and restore the colour from before the currency was printed; this removes the need to make two strings for printing currencies (one for positive currencies and one for negative currencies).
-Fix [FS#1036]: do not use green for currencies as it is practically unreadable on CRT monitors.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 70e995ba2..ad902ead4 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -343,6 +343,8 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
/* convert from negative */
if (number < 0) {
+ if (buff + Utf8CharLen(SCC_RED) > last) return buff;
+ buff += Utf8Encode(buff, SCC_RED);
buff = strecpy(buff, "-", last);
number = -number;
}
@@ -383,6 +385,12 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
* The only remaining value is 1 (prefix), so everything that is not 0 */
if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last);
+ if (cs.GetCost() < 0) {
+ if (buff + Utf8CharLen(SCC_PREVIOUS_COLOUR) > last) return buff;
+ buff += Utf8Encode(buff, SCC_PREVIOUS_COLOUR);
+ *buff = '\0';
+ }
+
return buff;
}