diff options
-rw-r--r-- | src/gfx.cpp | 15 | ||||
-rw-r--r-- | src/gfx_func.h | 2 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 8 | ||||
-rw-r--r-- | src/station_gui.cpp | 33 | ||||
-rw-r--r-- | src/timetable_gui.cpp | 6 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 40 |
6 files changed, 44 insertions, 60 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index be008c1c0..6d6a7342e 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -425,21 +425,6 @@ static int DrawString(int left, int right, int top, char *str, const char *last, } /** - * Draw string starting at position (x,y). - * - * @param x X position to start drawing - * @param y Y position to start drawing - * @param str String to draw - * @param colour Colour used for drawing the string, see DoDrawString() for details - * - * @return Horizontal coordinate after drawing the string - */ -int DrawString(int x, int y, StringID str, TextColour colour) -{ - return DrawString(x, INT32_MAX, y, str, colour); -} - -/** * Draw string, possibly truncated to make it fit in its allocated space * * @param left The left most position to draw on. diff --git a/src/gfx_func.h b/src/gfx_func.h index c54509f3d..88aebc07b 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -96,8 +96,6 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour, int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false); int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, StringAlignment align = SA_LEFT); -int DrawString(int x, int y, StringID str, TextColour colour); - void DrawCharCentered(uint32 c, int x, int y, TextColour colour); void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE); diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 1d5c2baca..3efade6c6 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -738,7 +738,7 @@ public: y < dpi->top + dpi->height) { /* And draw it. */ SetDParam(0, t->index); - DrawString(x, y, STR_2056, TC_WHITE); + DrawString(x, x + t->sign.width_2, y, STR_2056, TC_WHITE); } } } @@ -857,15 +857,15 @@ public: if (!tbl->show_on_map) { /* Simply draw the string, not the black border of the legend colour. * This will enforce the idea of the disabled item */ - DrawString(x + 11, y, STR_SMALLMAP_INDUSTRY, TC_GREY); + DrawString(x + 11, x + COLUMN_WIDTH - 1, y, STR_SMALLMAP_INDUSTRY, TC_GREY); } else { - DrawString(x + 11, y, STR_SMALLMAP_INDUSTRY, TC_BLACK); + DrawString(x + 11, x + COLUMN_WIDTH - 1, y, STR_SMALLMAP_INDUSTRY, TC_BLACK); GfxFillRect(x, y + 1, x + 8, y + 5, 0); // outer border of the legend colour } } else { /* Anything that is not an industry is using normal process */ GfxFillRect(x, y + 1, x + 8, y + 5, 0); - DrawString(x + 11, y, tbl->legend, TC_FROMSTRING); + DrawString(x + 11, x + COLUMN_WIDTH - 1, y, tbl->legend, TC_FROMSTRING); } GfxFillRect(x + 1, y + 2, x + 7, y + 4, tbl->colour); // legend colour diff --git a/src/station_gui.cpp b/src/station_gui.cpp index a5d5360aa..9028d3ec6 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -34,16 +34,17 @@ * coordinates. If amount exceeds 576 units, it is shown 'full', same * goes for the rating: at above 90% orso (224) it is also 'full' * - * @param x coordinate to draw the box at - * @param y coordinate to draw the box at - * @param type Cargo type + * @param left left most coordinate to draw the box at + * @param right right most coordinate to draw the box at + * @param y coordinate to draw the box at + * @param type Cargo type * @param amount Cargo amount * @param rating ratings data for that particular cargo * * @note Each cargo-bar is 16 pixels wide and 6 pixels high * @note Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar */ -static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) +static void StationsWndShowStationRating(int left, int right, int y, CargoID type, uint amount, byte rating) { static const uint units_full = 576; ///< number of units to show station as 'full' static const uint rating_full = 224; ///< rating needed so it is shown as 'full' @@ -55,25 +56,25 @@ static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount uint w = (minu(amount, units_full) + 5) / 36; /* Draw total cargo (limited) on station (fits into 16 pixels) */ - if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour); + if (w != 0) GfxFillRect(left, y, left + w - 1, y + 6, colour); /* Draw a one pixel-wide bar of additional cargo meter, useful * for stations with only a small amount (<=30) */ if (w == 0) { uint rest = amount / 5; if (rest != 0) { - w += x; + w += left; GfxFillRect(w, y + 6 - rest, w, y + 6, colour); } } - DrawString(x + 1, y, cs->abbrev, TC_BLACK); + DrawString(left + 1, right, y, cs->abbrev, TC_BLACK); /* Draw green/red ratings bar (fits into 14 pixels) */ y += 8; - GfxFillRect(x + 1, y, x + 14, y, 0xB8); + GfxFillRect(left + 1, y, left + 14, y, 0xB8); rating = minu(rating, rating_full) / 16; - if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0); + if (rating != 0) GfxFillRect(left + 1, y, left + rating, y, 0xD0); } typedef GUIList<const Station*> GUIStationList; @@ -346,10 +347,10 @@ public: DrawString(x + cg_ofst, x + cg_ofst + 12, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_CENTER); cg_ofst = this->IsWidgetLowered(SLW_FACILALL) ? 2 : 1; - DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK); + DrawString(71 + cg_ofst, 71 + cg_ofst + 12, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK); if (this->vscroll.count == 0) { // company has no stations - DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING); + DrawString(xb, this->width, 40, STR_304A_NONE, TC_FROMSTRING); return; } @@ -368,12 +369,12 @@ public: SetDParam(0, st->index); SetDParam(1, st->facilities); - x = DrawString(xb, y, STR_3049_0, TC_FROMSTRING) + 5; + x = DrawString(xb, this->widget[SLW_LIST].right, y, STR_3049_0, TC_FROMSTRING) + 5; /* show cargo waiting and station ratings */ for (CargoID j = 0; j < NUM_CARGO; j++) { if (!st->goods[j].cargo.Empty()) { - StationsWndShowStationRating(x, y, j, st->goods[j].cargo.Count(), st->goods[j].rating); + StationsWndShowStationRating(x, this->widget[SLW_LIST].right, y, j, st->goods[j].cargo.Count(), st->goods[j].rating); x += 20; } } @@ -802,7 +803,7 @@ struct StationViewWindow : public Window { if (!st->goods[i].cargo.Empty()) str = STR_EMPTY; } SetDParam(0, str); - DrawString(x, y, STR_0008_WAITING, TC_FROMSTRING); + DrawString(x, this->widget[SVW_WAITING].right - 2, y, STR_0008_WAITING, TC_FROMSTRING); y += 10; } @@ -867,7 +868,7 @@ struct StationViewWindow : public Window { } else { // extended window with list of cargo ratings y = this->widget[SVW_RATINGLIST].top + 1; - DrawString(2, y, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING); + DrawString(this->widget[SVW_ACCEPTLIST].left + 2, this->widget[SVW_ACCEPTLIST].right - 2, y, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING); y += 10; for (CargoID i = 0; i < NUM_CARGO; i++) { @@ -880,7 +881,7 @@ struct StationViewWindow : public Window { SetDParam(0, cs->name); SetDParam(2, ge->rating * 101 >> 8); SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5)); - DrawString(8, y, STR_303D, TC_FROMSTRING); + DrawString(this->widget[SVW_ACCEPTLIST].left + 8, this->widget[SVW_ACCEPTLIST].right - 2, y, STR_303D, TC_FROMSTRING); y += 10; } } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 2391b3f55..ad20c38f9 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -228,16 +228,16 @@ struct TimetableWindow : Window { if (total_time != 0) { SetTimetableParams(0, 1, total_time); - DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK); + DrawString(this->widget[TTV_SUMMARY_PANEL].left + 2, this->widget[TTV_SUMMARY_PANEL].right - 2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK); } } y += 10; if (v->lateness_counter == 0 || (!_settings_client.gui.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) { - DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK); + DrawString(this->widget[TTV_SUMMARY_PANEL].left + 2, this->widget[TTV_SUMMARY_PANEL].right - 2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK); } else { SetTimetableParams(0, 1, abs(v->lateness_counter)); - DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK); + DrawString(this->widget[TTV_SUMMARY_PANEL].left + 2, this->widget[TTV_SUMMARY_PANEL].right - 2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK); } } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index d7aa74f4f..946f82dcb 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -230,7 +230,7 @@ static RefitList *BuildRefitList(const Vehicle *v) * @param delta step height in caller window * @return the refit option that is hightlighted, NULL if none */ -static RefitOption *DrawVehicleRefitWindow(const RefitList *list, int sel, uint pos, uint rows, uint delta) +static RefitOption *DrawVehicleRefitWindow(const RefitList *list, int sel, uint pos, uint rows, uint delta, uint right) { RefitOption *refit = list->items; RefitOption *selected = NULL; @@ -248,11 +248,11 @@ static RefitOption *DrawVehicleRefitWindow(const RefitList *list, int sel, uint if (i >= pos && i < pos + rows) { /* Draw the cargo name */ - int last_x = DrawString(2, y, GetCargo(refit[i].cargo)->name, colour); + int last_x = DrawString(2, right, y, GetCargo(refit[i].cargo)->name, colour); /* If the callback succeeded, draw the cargo suffix */ if (refit[i].value != CALLBACK_FAILED) { - DrawString(last_x + 1, y, GetGRFStringID(GetEngineGRFID(refit[i].engine), 0xD000 + refit[i].value), colour); + DrawString(last_x + 1, right, y, GetGRFStringID(GetEngineGRFID(refit[i].engine), 0xD000 + refit[i].value), colour); } y += delta; } @@ -340,7 +340,7 @@ struct RefitWindow : public Window { SetDParam(0, v->index); this->DrawWidgets(); - this->cargo = DrawVehicleRefitWindow(this->list, this->sel, this->vscroll.pos, this->vscroll.cap, this->resize.step_height); + this->cargo = DrawVehicleRefitWindow(this->list, this->sel, this->vscroll.pos, this->vscroll.cap, this->resize.step_height, this->width - 2); if (this->cargo != NULL) { CommandCost cost; @@ -352,7 +352,7 @@ struct RefitWindow : public Window { SetDParam(0, this->cargo->cargo); SetDParam(1, _returned_refit_capacity); SetDParam(2, cost.GetCost()); - DrawString(2, this->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, TC_FROMSTRING); + DrawString(2, this->width - 2, this->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, TC_FROMSTRING); } } } @@ -716,7 +716,7 @@ static const Widget _vehicle_list_widgets[] = { { WIDGETS_END}, }; -static void DrawSmallOrderList(const Vehicle *v, int x, int y) +static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y) { const Order *order; int sel, i = 0; @@ -724,14 +724,14 @@ static void DrawSmallOrderList(const Vehicle *v, int x, int y) sel = v->cur_order_index; FOR_VEHICLE_ORDERS(v, order) { - if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, TC_BLACK); + if (sel == 0) DrawString(left - 6, left, y, STR_SMALL_RIGHT_ARROW, TC_BLACK); sel--; if (order->IsType(OT_GOTO_STATION)) { if (v->type == VEH_SHIP && GetStation(order->GetDestination())->IsBuoy()) continue; SetDParam(0, order->GetDestination()); - DrawString(x, y, STR_A036, TC_FROMSTRING); + DrawString(left, right, y, STR_A036, TC_FROMSTRING); y += 6; if (++i == 4) break; @@ -767,19 +767,19 @@ void BaseVehicleListWindow::DrawVehicleListItems(int x, VehicleID selected_vehic SetDParam(1, v->GetDisplayProfitLastYear()); DrawVehicleImage(v, x + 19, y + 6, selected_vehicle, this->widget[VLW_WIDGET_LIST].right - this->widget[VLW_WIDGET_LIST].left - 20, 0); - DrawString(x + 19, y + this->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING); + DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y + this->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING); if (v->name != NULL) { /* The vehicle got a name so we will print it */ SetDParam(0, v->index); - DrawString(x + 19, y, STR_01AB, TC_FROMSTRING); + DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y, STR_01AB, TC_FROMSTRING); } else if (v->group_id != DEFAULT_GROUP) { /* The vehicle has no name, but is member of a group, so print group name */ SetDParam(0, v->group_id); - DrawString(x + 19, y, STR_GROUP_TINY_NAME, TC_BLACK); + DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y, STR_GROUP_TINY_NAME, TC_BLACK); } - if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, x + 138, y); + if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, x + 138, this->widget[VLW_WIDGET_LIST].right, y); if (v->IsInDepot()) { str = STR_021F; @@ -788,7 +788,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(int x, VehicleID selected_vehic } SetDParam(0, v->unitnumber); - DrawString(x, y + 2, str, TC_FROMSTRING); + DrawString(x, this->widget[VLW_WIDGET_LIST].right, y + 2, str, TC_FROMSTRING); DrawVehicleProfitButton(v, x, y + 13); @@ -1005,7 +1005,7 @@ struct VehicleListWindow : public BaseVehicleListWindow { this->DrawWidgets(); /* draw sorting criteria string */ - DrawString(85, 15, this->vehicle_sorter_names[this->vehicles.SortType()], TC_BLACK); + DrawString(85, this->widget[VLW_WIDGET_SORT_ORDER].right, 15, this->vehicle_sorter_names[this->vehicles.SortType()], TC_BLACK); /* draw arrow pointing up/down for ascending/descending sorting */ this->DrawSortButtonState(VLW_WIDGET_SORT_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP); @@ -1417,7 +1417,7 @@ struct VehicleDetailsWindow : Window { SetDParam(0, (v->age + DAYS_IN_YEAR < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / DAYS_IN_LEAP_YEAR); SetDParam(3, v->GetDisplayRunningCost()); - DrawString(2, 15, _vehicle_translation_table[VST_VEHICLE_AGE_RUNNING_COST_YR][v->type], TC_FROMSTRING); + DrawString(2, this->width - 2, 15, _vehicle_translation_table[VST_VEHICLE_AGE_RUNNING_COST_YR][v->type], TC_FROMSTRING); /* Draw max speed */ switch (v->type) { @@ -1426,7 +1426,7 @@ struct VehicleDetailsWindow : Window { SetDParam(1, v->u.rail.cached_power); SetDParam(0, v->u.rail.cached_weight); SetDParam(3, v->u.rail.cached_max_te / 1000); - DrawString(2, 25, (_settings_game.vehicle.train_acceleration_model != TAM_ORIGINAL && v->u.rail.railtype != RAILTYPE_MAGLEV) ? + DrawString(2, this->width - 2, 25, (_settings_game.vehicle.train_acceleration_model != TAM_ORIGINAL && v->u.rail.railtype != RAILTYPE_MAGLEV) ? STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE : STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, TC_FROMSTRING); break; @@ -1435,7 +1435,7 @@ struct VehicleDetailsWindow : Window { case VEH_SHIP: case VEH_AIRCRAFT: SetDParam(0, v->GetDisplayMaxSpeed()); - DrawString(2, 25, _vehicle_translation_table[VST_VEHICLE_MAX_SPEED][v->type], TC_FROMSTRING); + DrawString(2, this->width - 2, 25, _vehicle_translation_table[VST_VEHICLE_MAX_SPEED][v->type], TC_FROMSTRING); break; default: NOT_REACHED(); @@ -1444,17 +1444,17 @@ struct VehicleDetailsWindow : Window { /* Draw profit */ SetDParam(0, v->GetDisplayProfitThisYear()); SetDParam(1, v->GetDisplayProfitLastYear()); - DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING); + DrawString(2, this->width - 2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING); /* Draw breakdown & reliability */ SetDParam(0, v->reliability * 100 >> 16); SetDParam(1, v->breakdowns_since_last_service); - DrawString(2, 45, _vehicle_translation_table[VST_VEHICLE_RELIABILITY_BREAKDOWNS][v->type], TC_FROMSTRING); + DrawString(2, this->width - 2, 45, _vehicle_translation_table[VST_VEHICLE_RELIABILITY_BREAKDOWNS][v->type], TC_FROMSTRING); /* Draw service interval text */ SetDParam(0, v->service_interval); SetDParam(1, v->date_of_last_service); - DrawString(13, this->height - (v->type != VEH_TRAIN ? 11 : 23), _settings_game.vehicle.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, TC_FROMSTRING); + DrawString(13, this->width - 2, this->height - (v->type != VEH_TRAIN ? 11 : 23), _settings_game.vehicle.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, TC_FROMSTRING); switch (v->type) { case VEH_TRAIN: |