/** * Get the size of the sprite of a ship sprite heading west (used for lists). * @param engine The engine to get the sprite from. * @param[out] width The width of the sprite. * @param[out] height The height of the sprite. * @param[out] xoffs Number of pixels to shift the sprite to the right. * @param[out] yoffs Number of pixels to shift the sprite downwards. * @param image_type Context the sprite is used in. */ void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type) { VehicleSpriteSeq seq; GetShipIcon(engine, image_type, &seq); Rect rect; seq.GetBounds(&rect); width = UnScaleGUI(rect.right - rect.left + 1); height = UnScaleGUI(rect.bottom - rect.top + 1); xoffs = UnScaleGUI(rect.left); yoffs = UnScaleGUI(rect.top); }
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type) { VehicleSpriteSeq seq; GetShipIcon(engine, image_type, &seq); Rect rect; seq.GetBounds(&rect); preferred_x = Clamp(preferred_x, left - UnScaleGUI(rect.left), right - UnScaleGUI(rect.right)); seq.Draw(preferred_x, y, pal, pal == PALETTE_CRASH); }
/** * Draws an image of a ship * @param v Front vehicle * @param left The minimum horizontal position * @param right The maximum horizontal position * @param y Vertical position to draw at * @param selection Selected vehicle to draw a frame around */ void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type) { bool rtl = _current_text_dir == TD_RTL; SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type); const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL); int width = UnScaleGUI(real_sprite->width); int x_offs = UnScaleGUI(real_sprite->x_offs); int x = rtl ? right - width - x_offs : left - x_offs; y += ScaleGUITrad(10); DrawSprite(sprite, GetVehiclePalette(v), x, y); if (v->index == selection) { x += x_offs; y += UnScaleGUI(real_sprite->y_offs); DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(real_sprite->height) + 1, COLOUR_WHITE, FR_BORDERONLY); } }