* Draws an image of a ship * @param v Front vehicle * @param r Rect to draw at * @param selection Selected vehicle to draw a frame around */
| 27 | * @param selection Selected vehicle to draw a frame around |
| 28 | */ |
| 29 | void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type) |
| 30 | { |
| 31 | bool rtl = _current_text_dir == TD_RTL; |
| 32 | |
| 33 | VehicleSpriteSeq seq; |
| 34 | v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq); |
| 35 | |
| 36 | Rect rect; |
| 37 | seq.GetBounds(&rect); |
| 38 | |
| 39 | int width = UnScaleGUI(rect.Width()); |
| 40 | int x_offs = UnScaleGUI(rect.left); |
| 41 | int x = rtl ? r.right - width - x_offs : r.left - x_offs; |
| 42 | /* This magic -1 offset is related to the sprite_y_offsets in build_vehicle_gui.cpp */ |
| 43 | int y = ScaleSpriteTrad(-1) + CentreBounds(r.top, r.bottom, 0); |
| 44 | |
| 45 | seq.Draw(x, y, GetVehiclePalette(v), false); |
| 46 | if (v->cargo_cap > 0) DrawCargoIconOverlay(x, y, v->cargo_type); |
| 47 | |
| 48 | if (v->index == selection) { |
| 49 | x += x_offs; |
| 50 | y += UnScaleGUI(rect.top); |
| 51 | Rect hr = {x, y, x + width - 1, y + UnScaleGUI(rect.Height()) - 1}; |
| 52 | DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FrameFlag::BorderOnly); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Draw the details for the given vehicle at the given position |
no test coverage detected