1
0
Fork 0

(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot

release/1.0
rubidium 2009-11-17 16:03:51 +00:00
parent ddffeb791e
commit 9e84075db5
2 changed files with 20 additions and 14 deletions

View File

@ -247,15 +247,15 @@ struct DepotWindow : Window {
/** Draw a vehicle in the depot window in the box with the top left corner at x,y. /** Draw a vehicle in the depot window in the box with the top left corner at x,y.
* @param v Vehicle to draw. * @param v Vehicle to draw.
* @param x Left side of the box to draw in. * @param left Left side of the box to draw in.
* @param right Right side of the box to draw in.
* @param y Top of the box to draw in. * @param y Top of the box to draw in.
* @param left Left edge of the widget.
* @param right Right edge of the widget.
*/ */
void DrawVehicleInDepot(const Vehicle *v, int x, int y, int left, int right) const void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
{ {
bool free_wagon = false; bool free_wagon = false;
int sprite_y = y + this->resize.step_height - GetVehicleHeight(v->type); int sprite_y = y + this->resize.step_height - GetVehicleHeight(v->type);
int x = left + 2;
switch (v->type) { switch (v->type) {
case VEH_TRAIN: { case VEH_TRAIN: {
@ -263,7 +263,7 @@ struct DepotWindow : Window {
free_wagon = u->IsFreeWagon(); free_wagon = u->IsFreeWagon();
uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0; uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
DrawTrainImage(u, x + 24 + x_space, x + 24 + this->hscroll.GetCapacity() - 1, sprite_y - 1, this->sel, this->hscroll.GetPosition()); DrawTrainImage(u, x + 24 + x_space, right - 10, sprite_y - 1, this->sel, this->hscroll.GetPosition());
/* Number of wagons relative to a standard length wagon (rounded up) */ /* Number of wagons relative to a standard length wagon (rounded up) */
SetDParam(0, (u->tcache.cached_total_length + 7) / 8); SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
@ -271,8 +271,8 @@ struct DepotWindow : Window {
break; break;
} }
case VEH_ROAD: DrawRoadVehImage( v, x + 24, x + 24 + ROADVEHINFO_DEFAULT_VEHICLE_WIDTH - 1, sprite_y, this->sel); break; case VEH_ROAD: DrawRoadVehImage( v, x + 24, right, sprite_y, this->sel); break;
case VEH_SHIP: DrawShipImage( v, x + 19, right, sprite_y - 1, this->sel); break; case VEH_SHIP: DrawShipImage( v, x + 12, right, sprite_y - 1, this->sel); break;
case VEH_AIRCRAFT: { case VEH_AIRCRAFT: {
const Sprite *spr = GetSprite(v->GetImage(DIR_W), ST_NORMAL); const Sprite *spr = GetSprite(v->GetImage(DIR_W), ST_NORMAL);
DrawAircraftImage(v, x + 12, right, DrawAircraftImage(v, x + 12, right,
@ -313,12 +313,13 @@ struct DepotWindow : Window {
uint16 num = this->vscroll.GetPosition() * boxes_in_each_row; uint16 num = this->vscroll.GetPosition() * boxes_in_each_row;
int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * boxes_in_each_row)); int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * boxes_in_each_row));
int x, y; int y;
for (x = r.left + 2, y = r.top + 1; num < maxval; y += this->resize.step_height, x = r.left + 2) { // Draw the rows for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
int x = r.left;
for (byte i = 0; i < boxes_in_each_row && num < maxval; i++, num++, x += this->resize.step_width) { for (byte i = 0; i < boxes_in_each_row && num < maxval; i++, num++, x += this->resize.step_width) {
/* Draw all vehicles in the current row */ /* Draw all vehicles in the current row */
const Vehicle *v = this->vehicle_list[num]; const Vehicle *v = this->vehicle_list[num];
this->DrawVehicleInDepot(v, x, y, r.left, r.right); this->DrawVehicleInDepot(v, x, (boxes_in_each_row == 1) ? r.right : x + this->resize.step_width - 1, y);
} }
} }
@ -327,7 +328,7 @@ struct DepotWindow : Window {
/* draw the train wagons, that do not have an engine in front */ /* draw the train wagons, that do not have an engine in front */
for (; num < maxval; num++, y += 14) { for (; num < maxval; num++, y += 14) {
const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()]; const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
this->DrawVehicleInDepot(v, x, y, r.left, r.right); this->DrawVehicleInDepot(v, r.left, r.right, y);
} }
} }
@ -898,9 +899,13 @@ struct DepotWindow : Window {
virtual void OnResize() virtual void OnResize()
{ {
this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_y / (int)this->resize.step_height); this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_y / (int)this->resize.step_height);
if (this->type == VEH_TRAIN) {
this->hscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_x - 36);
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
} else {
this->hscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_x / (int)this->resize.step_width); this->hscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_x / (int)this->resize.step_width);
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (this->hscroll.GetCapacity() << MAT_COL_START);
((this->type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START); }
} }
virtual EventState OnCTRLStateChange() virtual EventState OnCTRLStateChange()

View File

@ -147,6 +147,7 @@ void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID se
DrawSprite(u->GetImage(dir), pal, pos + (rtl ? -offset.x : offset.x), y + 6 + offset.y); DrawSprite(u->GetImage(dir), pal, pos + (rtl ? -offset.x : offset.x), y + 6 + offset.y);
pos += rtl ? -width : width; pos += rtl ? -width : width;
spent_width += max_width;
} }
if (v->index == selection) { if (v->index == selection) {