diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -978,7 +978,7 @@ struct AIDebugWindow : public QueryStrin /* Check if the current line should be highlighted */ if (pos == this->highlight_row) { - GfxFillRect(r.left + 1, r.top + y, r.right - 1, r.top + y + this->resize.step_height - WD_PAR_VSEP_NORMAL, 0); + GfxFillRect(r.left + 1, r.top + y, r.right - 1, r.top + y + this->resize.step_height - WD_PAR_VSEP_NORMAL, GREY_SCALE(0)); if (colour == TC_BLACK) colour = TC_WHITE; // Make black text readable by inverting it to white. } diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -356,7 +356,7 @@ public: for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < AirportClass::GetCount(_selected_airport_class); i++) { const AirportSpec *as = AirportClass::Get(_selected_airport_class, i); if (!as->IsAvailable()) { - GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, 0, FILLRECT_CHECKER); + GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, GREY_SCALE(0), FILLRECT_CHECKER); } DrawString(r.left + WD_MATRIX_LEFT, r.right + WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK); y += this->line_height; diff --git a/src/company_gui.cpp b/src/company_gui.cpp --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -209,7 +209,7 @@ static void DrawYearColumn(const Rect &r if (et == INVALID_EXPENSES) { Money cost = subtotal; subtotal = 0; - GfxFillRect(r.left, y, r.right, y, 215); + GfxFillRect(r.left, y, r.right, y, GREY_SCALE(1)); y += EXP_LINESPACE; DrawPrice(cost, r.left, r.right, y); y += FONT_HEIGHT_NORMAL + EXP_BLOCKSPACE; @@ -222,7 +222,7 @@ static void DrawYearColumn(const Rect &r } } - GfxFillRect(r.left, y, r.right, y, 215); + GfxFillRect(r.left, y, r.right, y, GREY_SCALE(1)); y += EXP_LINESPACE; DrawPrice(sum, r.left, r.right, y); } @@ -385,7 +385,7 @@ struct CompanyFinancesWindow : Window { } case CFW_LOAN_LINE: - GfxFillRect(r.left, r.top, r.right, r.top, 215); + GfxFillRect(r.left, r.top, r.right, r.top, GREY_SCALE(1)); break; } } diff --git a/src/console_gui.cpp b/src/console_gui.cpp --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -204,7 +204,7 @@ struct IConsoleWindow : Window { const int right = this->width - 5; - GfxFillRect(0, 0, this->width - 1, this->height - 1, 0); + GfxFillRect(0, 0, this->width - 1, this->height - 1, GREY_SCALE(0)); int ypos = this->height - this->line_height; for (const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll); print != NULL; print = print->previous) { SetDParamStr(0, print->buffer); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -351,7 +351,7 @@ public: } case SLWW_DRIVES_DIRECTORIES_LIST: { - GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, 0xD7); + GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, GREY_SCALE(1)); uint y = r.top + WD_FRAMERECT_TOP; for (uint pos = this->vscroll->GetPosition(); pos < _fios_items.Length(); pos++) { @@ -369,7 +369,7 @@ public: case SLWW_DETAILS: { GfxFillRect(r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, - r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL * 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, 0x0A); + r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL * 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, GREY_SCALE(10)); DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL / 2 + WD_FRAMERECT_TOP, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER); if (this->selected == NULL) break; diff --git a/src/gfx.cpp b/src/gfx.cpp --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -264,7 +264,7 @@ void DrawBox(int x, int y, int dx1, int * ....V. */ - static const byte colour = 15; + static const byte colour = GREY_SCALE(15); GfxDrawLineUnscaled(x, y, x + dx1, y + dy1, colour); GfxDrawLineUnscaled(x, y, x + dx2, y + dy2, colour); diff --git a/src/gfx_func.h b/src/gfx_func.h --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -182,4 +182,11 @@ extern byte _colour_gradient[COLOUR_END] extern bool _palette_remap_grf[]; +/** + * Return the colour for a particular greyscale level. + * @param level Intensity, 0 = black, 15 = white + * @return colour + */ +#define GREY_SCALE(level) (level) + #endif /* GFX_FUNC_H */ diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -177,7 +177,7 @@ enum CompanyValueWidgets { struct BaseGraphWindow : Window { protected: static const int GRAPH_MAX_DATASETS = 32; - static const int GRAPH_AXIS_LINE_COLOUR = 215; + static const int GRAPH_AXIS_LINE_COLOUR = GREY_SCALE(1); static const int GRAPH_NUM_MONTHS = 24; ///< Number of months displayed in the graph. static const int MIN_GRAPH_NUM_LINES_Y = 9; ///< Minimal number of horizontal lines to draw. @@ -977,7 +977,7 @@ struct PaymentRatesGraphWindow : BaseGra int rect_x = clk_dif + (rtl ? r.right - 12 : r.left + WD_FRAMERECT_LEFT); - GfxFillRect(rect_x, y + clk_dif, rect_x + 8, y + 5 + clk_dif, 0); + GfxFillRect(rect_x, y + clk_dif, rect_x + 8, y + 5 + clk_dif, GREY_SCALE(0)); GfxFillRect(rect_x + 1, y + 1 + clk_dif, rect_x + 7, y + 4 + clk_dif, cs->legend_colour); SetDParam(0, cs->name); DrawString(rtl ? r.left : x + 14 + clk_dif, (rtl ? r.right - 14 + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -396,7 +396,7 @@ public: /* Draw the name of the industry in white is selected, otherwise, in orange */ DrawString(x + MATRIX_TEXT_OFFSET, r.right - WD_MATRIX_RIGHT, y, indsp->name, selected ? TC_WHITE : TC_ORANGE); - GfxFillRect(x, y + 1, x + 10, y + 7, selected ? 15 : 0); + GfxFillRect(x, y + 1, x + 10, y + 7, selected ? GREY_SCALE(15) : GREY_SCALE(0)); GfxFillRect(x + 1, y + 2, x + 9, y + 6, indsp->map_colour); } break; @@ -1677,7 +1677,7 @@ struct CargoesField { blob_left = xpos + BLOB_DISTANCE; blob_right = blob_left + BLOB_WIDTH; } - GfxFillRect(blob_left, ypos2 - BLOB_DISTANCE - BLOB_HEIGHT, blob_right, ypos2 - BLOB_DISTANCE, 0); // Border + GfxFillRect(blob_left, ypos2 - BLOB_DISTANCE - BLOB_HEIGHT, blob_right, ypos2 - BLOB_DISTANCE, GREY_SCALE(0)); // Border GfxFillRect(blob_left + 1, ypos2 - BLOB_DISTANCE - BLOB_HEIGHT + 1, blob_right - 1, ypos2 - BLOB_DISTANCE - 1, indsp->map_colour); } else { DrawString(xpos, xpos2, ypos, STR_INDUSTRY_CARGOES_HOUSES, TC_FROMSTRING, SA_HOR_CENTER); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -930,7 +930,7 @@ struct TooltipsWindow : public Window virtual void DrawWidget(const Rect &r, int widget) const { /* There is only one widget. */ - GfxFillRect(r.left, r.top, r.right, r.bottom, 0); + GfxFillRect(r.left, r.top, r.right, r.bottom, GREY_SCALE(0)); GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0x44); for (uint arg = 0; arg < this->paramcount; arg++) { @@ -1303,7 +1303,7 @@ void QueryString::DrawEditBox(Window *w, int top = wi->pos_y; int bottom = wi->pos_y + wi->current_y - 1; - GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, 215); + GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, GREY_SCALE(1)); /* Limit the drawing of the string inside the widget boundaries */ DrawPixelInfo dpi; diff --git a/src/music_gui.cpp b/src/music_gui.cpp --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -370,7 +370,7 @@ struct MusicTrackSelectionWindow : publi { switch (widget) { case MTSW_LIST_LEFT: { - GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, GREY_SCALE(0)); int y = r.top + WD_FRAMERECT_TOP; for (uint i = 0; i < NUM_SONGS_AVAILABLE; i++) { @@ -387,7 +387,7 @@ struct MusicTrackSelectionWindow : publi } case MTSW_LIST_RIGHT: { - GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, GREY_SCALE(0)); int y = r.top + WD_FRAMERECT_TOP; for (const byte *p = _playlists[_settings_client.music.playlist]; *p != 0; p++) { @@ -592,7 +592,7 @@ struct MusicWindow : public Window { { switch (widget) { case MW_GAUGE: - GfxFillRect(r.left, r.top, r.right, r.bottom, 0); + GfxFillRect(r.left, r.top, r.right, r.bottom, GREY_SCALE(0)); for (uint i = 0; i != 8; i++) { int colour = 0xD0; @@ -607,7 +607,7 @@ struct MusicWindow : public Window { break; case MW_TRACK_NR: { - GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, 0); + GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, GREY_SCALE(0)); StringID str = STR_MUSIC_TRACK_NONE; if (_song_is_active != 0 && _music_wnd_cursong != 0) { SetDParam(0, GetTrackNumber(_music_wnd_cursong - 1)); @@ -619,7 +619,7 @@ struct MusicWindow : public Window { } case MW_TRACK_NAME: { - GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, 0); + GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, GREY_SCALE(0)); StringID str = STR_MUSIC_TITLE_NONE; if (_song_is_active != 0 && _music_wnd_cursong != 0) { str = STR_MUSIC_TITLE_NAME; diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -452,7 +452,7 @@ public: for (ConstContentIterator iter = this->content.Get(this->vscroll->GetPosition()); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) { const ContentInfo *ci = *iter; - if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, 10); + if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, GREY_SCALE(10)); SpriteID sprite; SpriteID pal = PAL_NONE; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -382,7 +382,7 @@ protected: const NWidgetBase *nwi_info = this->GetWidget(NGWW_INFO); /* show highlighted item with a different colour */ - if (highlight) GfxFillRect(nwi_name->pos_x + 1, y - 2, nwi_info->pos_x + nwi_info->current_x - 2, y + FONT_HEIGHT_NORMAL - 1, 10); + if (highlight) GfxFillRect(nwi_name->pos_x + 1, y - 2, nwi_info->pos_x + nwi_info->current_x - 2, y + FONT_HEIGHT_NORMAL - 1, GREY_SCALE(10)); DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y, cur_item->info.server_name, TC_BLACK); @@ -1490,7 +1490,7 @@ struct NetworkLobbyWindow : public Windo byte company = NetworkLobbyFindCompanyIndex(pos); bool income = false; if (this->company == company) { - GfxFillRect(r.left + 1, y - 2, r.right - 1, y + FONT_HEIGHT_NORMAL, 10); // show highlighted item with a different colour + GfxFillRect(r.left + 1, y - 2, r.right - 1, y + FONT_HEIGHT_NORMAL, GREY_SCALE(10)); // show highlighted item with a different colour } DrawString(text_left, text_right, y, this->company_info[company].company_name, TC_BLACK); @@ -1826,7 +1826,7 @@ struct NetworkClientListPopupWindow : Wi for (const ClientListAction *action = this->actions.Begin(); action != this->actions.End(); action++, y += FONT_HEIGHT_NORMAL) { TextColour colour; if (sel-- == 0) { // Selected item, highlight it - GfxFillRect(r.left + 1, y, r.right - 1, y + FONT_HEIGHT_NORMAL - 1, 0); + GfxFillRect(r.left + 1, y, r.right - 1, y + FONT_HEIGHT_NORMAL - 1, GREY_SCALE(0)); colour = TC_WHITE; } else { colour = TC_BLACK; @@ -1978,7 +1978,7 @@ struct NetworkClientListWindow : Window FOR_ALL_CLIENT_INFOS(ci) { TextColour colour; if (this->selected_item == i++) { // Selected item, highlight it - GfxFillRect(r.left + 1, y, r.right - 1, y + FONT_HEIGHT_NORMAL - 1, 0); + GfxFillRect(r.left + 1, y, r.right - 1, y + FONT_HEIGHT_NORMAL - 1, GREY_SCALE(0)); colour = TC_WHITE; } else { colour = TC_BLACK; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -695,7 +695,7 @@ struct NewGRFWindow : public QueryString { switch (widget) { case SNGRFS_FILE_LIST: { - GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0xD7); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, GREY_SCALE(1)); uint step_height = this->GetWidget(SNGRFS_FILE_LIST)->resize_y; uint y = r.top + WD_FRAMERECT_TOP; @@ -727,7 +727,7 @@ struct NewGRFWindow : public QueryString } case SNGRFS_AVAIL_LIST: { - GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0xD7); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, GREY_SCALE(1)); uint step_height = this->GetWidget(SNGRFS_AVAIL_LIST)->resize_y; int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2; diff --git a/src/news_gui.cpp b/src/news_gui.cpp --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -335,12 +335,12 @@ struct NewsWindow : Window { void DrawNewsBorder(const Rect &r) const { - GfxFillRect(r.left, r.top, r.right, r.bottom, 0xF); + GfxFillRect(r.left, r.top, r.right, r.bottom, GREY_SCALE(15)); - GfxFillRect(r.left, r.top, r.left, r.bottom, 0xD7); - GfxFillRect(r.right, r.top, r.right, r.bottom, 0xD7); - GfxFillRect(r.left, r.top, r.right, r.top, 0xD7); - GfxFillRect(r.left, r.bottom, r.right, r.bottom, 0xD7); + GfxFillRect(r.left, r.top, r.left, r.bottom, GREY_SCALE(1)); + GfxFillRect(r.right, r.top, r.right, r.bottom, GREY_SCALE(1)); + GfxFillRect(r.left, r.top, r.right, r.top, GREY_SCALE(1)); + GfxFillRect(r.left, r.bottom, r.right, r.bottom, GREY_SCALE(1)); } virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) @@ -425,7 +425,7 @@ struct NewsWindow : Window { break; case NTW_VEH_BKGND: - GfxFillRect(r.left, r.top, r.right, r.bottom, 10); + GfxFillRect(r.left, r.top, r.right, r.bottom, GREY_SCALE(10)); break; case NTW_VEH_NAME: diff --git a/src/object_gui.cpp b/src/object_gui.cpp --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -206,7 +206,7 @@ public: if (spec == NULL) break; if (!spec->IsAvailable()) { - GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0, FILLRECT_CHECKER); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, GREY_SCALE(0), FILLRECT_CHECKER); } DrawPixelInfo tmp_dpi; /* Set up a clipping area for the preview. */ diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1163,7 +1163,7 @@ public: const StationSpec *statspec = StationClass::Get(_railstation.station_class, type); if (statspec != NULL && HasBit(statspec->callback_mask, CBM_STATION_AVAIL) && GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) { - GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0, FILLRECT_CHECKER); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, GREY_SCALE(0), FILLRECT_CHECKER); } /* Set up a clipping area for the station preview. */ diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -952,7 +952,7 @@ class SmallMapWindow : public Window { _cur_dpi = dpi; /* Clear it */ - GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, 0); + GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, GREY_SCALE(0)); /* Which tile is displayed at (dpi->left, dpi->top)? */ int dx; @@ -1204,7 +1204,7 @@ public: DrawString(x + text_left, x + text_right, y, STR_SMALLMAP_INDUSTRY, TC_GREY); } else { DrawString(x + text_left, x + text_right, y, STR_SMALLMAP_INDUSTRY, TC_BLACK); - GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, 0); // Outer border of the legend colour + GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, GREY_SCALE(0)); // Outer border of the legend colour } } else if (this->map_type == SMT_OWNER && tbl->company != INVALID_COMPANY) { SetDParam(0, tbl->company); @@ -1214,13 +1214,13 @@ public: DrawString(x + text_left, x + text_right, y, STR_SMALLMAP_COMPANY, TC_GREY); } else { DrawString(x + text_left, x + text_right, y, STR_SMALLMAP_COMPANY, TC_BLACK); - GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, 0); // Outer border of the legend colour + GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, GREY_SCALE(0)); // Outer border of the legend colour } } else { if (this->map_type == SMT_CONTOUR) SetDParam(0, tbl->height * TILE_HEIGHT_STEP); /* Anything that is not an industry or a company is using normal process */ - GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, 0); + GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, GREY_SCALE(0)); DrawString(x + text_left, x + text_right, y, tbl->legend); } GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, tbl->colour); // Legend colour diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -248,7 +248,7 @@ struct DropdownWindow : Window { if (y + item_height < r.bottom) { bool selected = (this->selected_index == item->result); - if (selected) GfxFillRect(r.left + 2, y, r.right - 1, y + item_height - 1, 0); + if (selected) GfxFillRect(r.left + 2, y, r.right - 1, y + item_height - 1, GREY_SCALE(0)); item->Draw(r.left, r.right, y, r.bottom, selected, colour);