4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file ship_gui.cpp GUI for ships. */
13 #include "vehicle_base.h"
14 #include "window_gui.h"
16 #include "vehicle_gui.h"
17 #include "strings_func.h"
18 #include "vehicle_func.h"
19 #include "spritecache.h"
21 #include "table/strings.h"
24 * Draws an image of a ship
25 * @param v Front vehicle
26 * @param left The minimum horizontal position
27 * @param right The maximum horizontal position
28 * @param y Vertical position to draw at
29 * @param selection Selected vehicle to draw a frame around
31 void DrawShipImage(const Vehicle
*v
, int left
, int right
, int y
, VehicleID selection
)
33 bool rtl
= _current_text_dir
== TD_RTL
;
35 SpriteID sprite
= v
->GetImage(rtl
? DIR_E
: DIR_W
);
36 const Sprite
*real_sprite
= GetSprite(sprite
, ST_NORMAL
);
38 int x
= rtl
? right
- real_sprite
->width
- real_sprite
->x_offs
: left
- real_sprite
->x_offs
;
40 DrawSprite(sprite
, GetVehiclePalette(v
), x
, y
+ 10);
42 if (v
->index
== selection
) {
43 x
+= real_sprite
->x_offs
;
44 y
+= real_sprite
->y_offs
+ 10;
45 DrawFrameRect(x
- 1, y
- 1, x
+ real_sprite
->width
+ 1, y
+ real_sprite
->height
+ 1, COLOUR_WHITE
, FR_BORDERONLY
);
50 * Draw the details for the given vehicle at the given position
52 * @param v current vehicle
53 * @param left The left most coordinate to draw
54 * @param right The right most coordinate to draw
55 * @param y The y coordinate
57 void DrawShipDetails(const Vehicle
*v
, int left
, int right
, int y
)
59 SetDParam(0, v
->engine_type
);
60 SetDParam(1, v
->build_year
);
61 SetDParam(2, v
->value
);
62 DrawString(left
, right
, y
, STR_VEHICLE_INFO_BUILT_VALUE
, TC_FROMSTRING
, SA_LEFT
| SA_STRIP
);
64 SetDParam(0, v
->cargo_type
);
65 SetDParam(1, v
->cargo_cap
);
66 SetDParam(4, GetCargoSubtypeText(v
));
67 DrawString(left
, right
, y
+ FONT_HEIGHT_NORMAL
, STR_VEHICLE_INFO_CAPACITY
);
69 StringID str
= STR_VEHICLE_DETAILS_CARGO_EMPTY
;
70 if (!v
->cargo
.Empty()) {
71 SetDParam(0, v
->cargo_type
);
72 SetDParam(1, v
->cargo
.Count());
73 SetDParam(2, v
->cargo
.Source());
74 str
= STR_VEHICLE_DETAILS_CARGO_FROM
;
76 DrawString(left
, right
, y
+ 2 * FONT_HEIGHT_NORMAL
+ 1, str
);
78 /* Draw Transfer credits text */
79 SetDParam(0, v
->cargo
.FeederShare());
80 DrawString(left
, right
, y
+ 3 * FONT_HEIGHT_NORMAL
+ 3, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE
);