* Get the size of the sprite of a train sprite heading west, or both heads (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
| 580 | * @param image_type Context the sprite is used in. |
| 581 | */ |
| 582 | void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type) |
| 583 | { |
| 584 | int y = 0; |
| 585 | |
| 586 | VehicleSpriteSeq seq; |
| 587 | GetRailIcon(engine, false, y, image_type, &seq); |
| 588 | |
| 589 | Rect rect; |
| 590 | seq.GetBounds(&rect); |
| 591 | |
| 592 | width = UnScaleGUI(rect.Width()); |
| 593 | height = UnScaleGUI(rect.Height()); |
| 594 | xoffs = UnScaleGUI(rect.left); |
| 595 | yoffs = UnScaleGUI(rect.top); |
| 596 | |
| 597 | if (RailVehInfo(engine)->railveh_type == RAILVEH_MULTIHEAD) { |
| 598 | GetRailIcon(engine, true, y, image_type, &seq); |
| 599 | seq.GetBounds(&rect); |
| 600 | |
| 601 | /* Calculate values relative to an imaginary center between the two sprites. */ |
| 602 | width = ScaleSpriteTrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) + UnScaleGUI(rect.right) - xoffs; |
| 603 | height = std::max<uint>(height, UnScaleGUI(rect.Height())); |
| 604 | xoffs = xoffs - ScaleSpriteTrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) / 2; |
| 605 | yoffs = std::min(yoffs, UnScaleGUI(rect.top)); |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * Get a list of free wagons in a depot. |
no test coverage detected