15 #include "vehicle_gui.h" |
15 #include "vehicle_gui.h" |
16 #include "newgrf_engine.h" |
16 #include "newgrf_engine.h" |
17 #include "strings_func.h" |
17 #include "strings_func.h" |
18 #include "vehicle_func.h" |
18 #include "vehicle_func.h" |
19 #include "string_func.h" |
19 #include "string_func.h" |
|
20 #include "order_func.h" |
20 |
21 |
21 #include "table/sprites.h" |
22 #include "table/sprites.h" |
22 #include "table/strings.h" |
23 #include "table/strings.h" |
23 |
24 |
24 void DrawRoadVehDetails(const Vehicle *v, int x, int y) |
25 void DrawRoadVehDetails(const Vehicle *v, int x, int y) |
106 /* Road vehicle lengths are measured in eighths of the standard length, so |
107 /* Road vehicle lengths are measured in eighths of the standard length, so |
107 * count is the number of standard vehicles that should be drawn. If it is |
108 * count is the number of standard vehicles that should be drawn. If it is |
108 * 0, we draw enough vehicles for 10 standard vehicle lengths. */ |
109 * 0, we draw enough vehicles for 10 standard vehicle lengths. */ |
109 int max_length = (count == 0) ? 80 : count * 8; |
110 int max_length = (count == 0) ? 80 : count * 8; |
110 |
111 |
111 for (int dx = 0 ; v != NULL && dx < max_length ; dx += v->u.road.cached_veh_length, v = v->Next()) { |
112 /* Width of highlight box */ |
112 if (dx + v->u.road.cached_veh_length > 0 && dx <= max_length) { |
113 int highlight_w = 0; |
|
114 |
|
115 for (int dx = 0; v != NULL && dx < max_length ; v = v->Next()) { |
|
116 int width = v->u.road.cached_veh_length; |
|
117 |
|
118 if (dx + width > 0 && dx <= max_length) { |
113 SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
119 SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
114 DrawSprite(v->GetImage(DIR_W), pal, x + 14 + RoadVehLengthToPixels(dx), y + 6); |
120 DrawSprite(v->GetImage(DIR_W), pal, x + 14 + RoadVehLengthToPixels(dx), y + 6); |
115 |
121 |
116 if (v->index == selection) { |
122 if (v->index == selection) { |
117 DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY); |
123 /* Set the highlight position */ |
|
124 highlight_w = RoadVehLengthToPixels(width); |
|
125 } else if (_cursor.vehchain && highlight_w != 0) { |
|
126 highlight_w += RoadVehLengthToPixels(width); |
118 } |
127 } |
119 } |
128 } |
|
129 |
|
130 dx += width; |
|
131 } |
|
132 |
|
133 if (highlight_w != 0) { |
|
134 DrawFrameRect(x - 1, y - 1, x - 1 + highlight_w, y + 12, 15, FR_BORDERONLY); |
120 } |
135 } |
121 } |
136 } |
122 |
137 |
123 void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2) |
138 void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2) |
124 { |
139 { |