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
commit34545a381a30b43098c03bd6fed6d71a3cc0c66c (patch)
treed96722811d3b8b7cb54fe12d32dc41147a3a4159 /src/strings.cpp
parent14e55dd4b9c152c3538b9855c68ee28c82a1ebc0 (diff)
downloadopenttd-34545a381a30b43098c03bd6fed6d71a3cc0c66c.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;
}