summaryrefslogtreecommitdiff
path: root/src/roadveh_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-04-05 11:27:50 +0000
committersmatz <smatz@openttd.org>2008-04-05 11:27:50 +0000
commitb2e4adc2b8e3a06c25f0ad988a3826b6f4ddfc85 (patch)
tree8cac13d3ae9840f5708a9bc585b873cf5bf60343 /src/roadveh_gui.cpp
parentbdd64495cd7af3fa064ed58a5419845eb78def46 (diff)
downloadopenttd-b2e4adc2b8e3a06c25f0ad988a3826b6f4ddfc85.tar.xz
(svn r12576) -Feature(tte) [FS#337]: highlight vehicle chain when dragging in the group and depot GUI if appropriate
Diffstat (limited to 'src/roadveh_gui.cpp')
-rw-r--r--src/roadveh_gui.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 160a5874a..ba383c8bf 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -109,15 +109,29 @@ void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int c
* 0, we draw enough vehicles for 10 standard vehicle lengths. */
int max_length = (count == 0) ? 80 : count * 8;
- for (int dx = 0 ; v != NULL && dx < max_length ; dx += v->u.road.cached_veh_length, v = v->Next()) {
- if (dx + v->u.road.cached_veh_length > 0 && dx <= max_length) {
+ /* Width of highlight box */
+ int highlight_w = 0;
+
+ for (int dx = 0; v != NULL && dx < max_length ; v = v->Next()) {
+ int width = v->u.road.cached_veh_length;
+
+ if (dx + width > 0 && dx <= max_length) {
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
DrawSprite(v->GetImage(DIR_W), pal, x + 14 + RoadVehLengthToPixels(dx), y + 6);
if (v->index == selection) {
- DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY);
+ /* Set the highlight position */
+ highlight_w = RoadVehLengthToPixels(width);
+ } else if (_cursor.vehchain && highlight_w != 0) {
+ highlight_w += RoadVehLengthToPixels(width);
}
}
+
+ dx += width;
+ }
+
+ if (highlight_w != 0) {
+ DrawFrameRect(x - 1, y - 1, x - 1 + highlight_w, y + 12, 15, FR_BORDERONLY);
}
}