summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-17 16:03:51 +0000
committerrubidium <rubidium@openttd.org>2009-11-17 16:03:51 +0000
commit9e84075db5085bcadf0d034770ec2be260a7c9ad (patch)
tree5931ee79dbd4c8e0a60a42cea3a155785b305ceb
parentddffeb791e13e1b1a9b9b7f4c5e8ae12705bbc03 (diff)
downloadopenttd-9e84075db5085bcadf0d034770ec2be260a7c9ad.tar.xz
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
-rw-r--r--src/depot_gui.cpp33
-rw-r--r--src/roadveh_gui.cpp1
2 files changed, 20 insertions, 14 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 1259f7429..b3b21cdd1 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -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.
* @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 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;
int sprite_y = y + this->resize.step_height - GetVehicleHeight(v->type);
+ int x = left + 2;
switch (v->type) {
case VEH_TRAIN: {
@@ -263,7 +263,7 @@ struct DepotWindow : Window {
free_wagon = u->IsFreeWagon();
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) */
SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
@@ -271,8 +271,8 @@ struct DepotWindow : Window {
break;
}
- case VEH_ROAD: DrawRoadVehImage( v, x + 24, x + 24 + ROADVEHINFO_DEFAULT_VEHICLE_WIDTH - 1, sprite_y, this->sel); break;
- case VEH_SHIP: DrawShipImage( v, x + 19, right, sprite_y - 1, this->sel); break;
+ case VEH_ROAD: DrawRoadVehImage( v, x + 24, right, sprite_y, this->sel); break;
+ case VEH_SHIP: DrawShipImage( v, x + 12, right, sprite_y - 1, this->sel); break;
case VEH_AIRCRAFT: {
const Sprite *spr = GetSprite(v->GetImage(DIR_W), ST_NORMAL);
DrawAircraftImage(v, x + 12, right,
@@ -313,12 +313,13 @@ struct DepotWindow : Window {
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 x, y;
- for (x = r.left + 2, y = r.top + 1; num < maxval; y += this->resize.step_height, x = r.left + 2) { // Draw the rows
+ int y;
+ 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) {
/* Draw all vehicles in the current row */
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 */
for (; num < maxval; num++, y += 14) {
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()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_y / (int)this->resize.step_height);
- 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->type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START);
+ 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->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (this->hscroll.GetCapacity() << MAT_COL_START);
+ }
}
virtual EventState OnCTRLStateChange()
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 7e874e108..941036ce4 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -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);
pos += rtl ? -width : width;
+ spent_width += max_width;
}
if (v->index == selection) {