mirror of https://github.com/OpenTTD/OpenTTD.git
(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.
This commit is contained in:
parent
a7e37d8592
commit
c46e445e69
|
@ -495,10 +495,10 @@ int DoDrawString(const char *string, int x, int y, uint16 real_color)
|
|||
DrawPixelInfo *dpi = _cur_dpi;
|
||||
FontSize size = _cur_fontsize;
|
||||
WChar c;
|
||||
byte color;
|
||||
int xo = x, yo = y;
|
||||
|
||||
color = real_color & 0xFF;
|
||||
byte color = real_color & 0xFF;
|
||||
byte previous_color = color;
|
||||
|
||||
if (color != 0xFE) {
|
||||
if (x >= dpi->left + dpi->width ||
|
||||
|
@ -548,8 +548,12 @@ skip_cont:;
|
|||
y += GetCharacterHeight(size);
|
||||
goto check_bounds;
|
||||
} else if (c >= SCC_BLUE && c <= SCC_BLACK) { // change color?
|
||||
previous_color = color;
|
||||
color = (byte)(c - SCC_BLUE);
|
||||
goto switch_color;
|
||||
} else if (c == SCC_PREVIOUS_COLOUR) { // revert to the previous color
|
||||
Swap(color, previous_color);
|
||||
goto switch_color;
|
||||
} else if (c == SCC_SETX) { // {SETX}
|
||||
x = xo + (byte)*string++;
|
||||
} else if (c == SCC_SETXY) {// {SETXY}
|
||||
|
|
|
@ -451,36 +451,20 @@ static void GroupWndProc(Window *w, WindowEvent *e)
|
|||
max = min(w->vscroll2.pos + w->vscroll2.cap, gv->l.list_length);
|
||||
for (i = w->vscroll2.pos ; i < max ; ++i) {
|
||||
const Vehicle* v = gv->sort_list[i];
|
||||
StringID str;
|
||||
|
||||
assert(v->type == gv->vehicle_type && v->owner == owner);
|
||||
|
||||
DrawVehicleImage(v, x + 19, y2 + 6, w->hscroll.cap, 0, gv->vehicle_sel);
|
||||
DrawVehicleProfitButton(v, x, y2 + 13);
|
||||
|
||||
if (IsVehicleInDepot(v)) {
|
||||
str = STR_021F;
|
||||
} else {
|
||||
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
|
||||
}
|
||||
SetDParam(0, v->unitnumber);
|
||||
DrawString(x, y2 + 2, str, 0);
|
||||
DrawString(x, y2 + 2, IsVehicleInDepot(v) ? STR_021F : (v->age > v->max_age - 366 ? STR_00E3 : STR_00E2), 0);
|
||||
|
||||
if (w->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG2) DrawSmallOrderList(v, x + 138, y2);
|
||||
|
||||
if (v->profit_this_year < 0) {
|
||||
str = v->profit_last_year < 0 ?
|
||||
STR_PROFIT_BAD_THIS_YEAR_BAD_LAST_YEAR :
|
||||
STR_PROFIT_BAD_THIS_YEAR_GOOD_LAST_YEAR;
|
||||
} else {
|
||||
str = v->profit_last_year < 0 ?
|
||||
STR_PROFIT_GOOD_THIS_YEAR_BAD_LAST_YEAR :
|
||||
STR_PROFIT_GOOD_THIS_YEAR_GOOD_LAST_YEAR;
|
||||
}
|
||||
|
||||
SetDParam(0, v->profit_this_year);
|
||||
SetDParam(1, v->profit_last_year);
|
||||
DrawString(x + 19, y2 + w->resize.step_height - 8, str, 0);
|
||||
DrawString(x + 19, y2 + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
||||
|
||||
if (IsValidGroupID(v->group_id)) {
|
||||
SetDParam(0, v->group_id);
|
||||
|
|
|
@ -2068,7 +2068,7 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
|
|||
if (p != NULL) {
|
||||
/* Draw player money */
|
||||
SetDParam(0, p->player_money);
|
||||
DrawStringCentered(w->widget[2].left + 70, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0);
|
||||
DrawStringCentered(w->widget[2].left + 70, 1, STR_0004, 0);
|
||||
}
|
||||
|
||||
/* Draw status bar */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ enum {
|
|||
SCC_GRAY,
|
||||
SCC_DKBLUE,
|
||||
SCC_BLACK,
|
||||
SCC_PREVIOUS_COLOUR,
|
||||
|
||||
/* Special printable symbols.
|
||||
* These are mapped to the original glyphs */
|
||||
|
|
Loading…
Reference in New Issue