summaryrefslogtreecommitdiff
path: root/src/train_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-07-12 16:00:11 +0000
committerfrosch <frosch@openttd.org>2009-07-12 16:00:11 +0000
commit78eccd05befe40a006974daf0b29dfb1b2382b65 (patch)
treedfc209ba6db7b370111bda05a1b8649de8667821 /src/train_gui.cpp
parent9efd32d13ce11aedf020cd2ce9eddc2ccaa72d32 (diff)
downloadopenttd-78eccd05befe40a006974daf0b29dfb1b2382b65.tar.xz
(svn r16799) -Codechange: When drawing articulated road vehicles in the vehicle details window, draw as many parts as the window fits instead of always up to a vehicle length of 80/8.
Diffstat (limited to 'src/train_gui.cpp')
-rw-r--r--src/train_gui.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index fb4230fb7..9591da258 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -64,7 +64,16 @@ int WagonLengthToPixels(int len)
return (len * _traininfo_vehicle_width) / 8;
}
-void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip)
+/**
+ * Draws an image of a whole train
+ * @param v Front vehicle
+ + @param x x Position to start at
+ * @param y y Position to draw at
+ * @param seletion Selected vehicle to draw a frame around
+ * @param max_width Number of pixels space for drawing
+ * @param skip Number of pixels to skip at the front (for scrolling)
+ */
+void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int max_width, int skip)
{
DrawPixelInfo tmp_dpi, *old_dpi;
int dx = -(skip * 8) / _traininfo_vehicle_width;
@@ -72,9 +81,9 @@ void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int cou
int highlight_l = 0;
int highlight_r = 0;
- if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, count + 1, 14)) return;
+ if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, max_width + 1, 14)) return;
- count = (count * 8) / _traininfo_vehicle_width;
+ int count = (max_width * 8) / _traininfo_vehicle_width;
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;