* Draws a tile sprite sequence in the GUI * @param x X position to draw to * @param y Y position to draw to * @param dts Sprite and subsprites to draw * @param orig_offset Sprite-Offset for original sprites * @param newgrf_offset Sprite-Offset for NewGRF defined sprites * @param default_palette The default recolour sprite to use (typically company colour) * @param child_offset_is_unsigned W
| 84 | * @param child_offset_is_unsigned Whether child sprite offsets are interpreted signed or unsigned |
| 85 | */ |
| 86 | void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned) |
| 87 | { |
| 88 | Point child_offset = {0, 0}; |
| 89 | |
| 90 | bool skip_childs = false; |
| 91 | for (const DrawTileSeqStruct &dtss : dts->GetSequence()) { |
| 92 | SpriteID image = dtss.image.sprite; |
| 93 | PaletteID pal = dtss.image.pal; |
| 94 | |
| 95 | if (skip_childs) { |
| 96 | if (!dtss.IsParentSprite()) continue; |
| 97 | skip_childs = false; |
| 98 | } |
| 99 | |
| 100 | /* TTD sprite 0 means no sprite */ |
| 101 | if (GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { |
| 102 | skip_childs = dtss.IsParentSprite(); |
| 103 | continue; |
| 104 | } |
| 105 | |
| 106 | image += (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? newgrf_offset : orig_offset); |
| 107 | if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += newgrf_offset; |
| 108 | |
| 109 | pal = SpriteLayoutPaletteTransform(image, pal, default_palette); |
| 110 | |
| 111 | if (dtss.IsParentSprite()) { |
| 112 | Point pt = RemapCoords(dtss.origin.x, dtss.origin.y, dtss.origin.z); |
| 113 | DrawSprite(image, pal, x + UnScaleGUI(pt.x), y + UnScaleGUI(pt.y)); |
| 114 | |
| 115 | const Sprite *spr = GetSprite(image & SPRITE_MASK, SpriteType::Normal); |
| 116 | child_offset.x = UnScaleGUI(pt.x + spr->x_offs); |
| 117 | child_offset.y = UnScaleGUI(pt.y + spr->y_offs); |
| 118 | } else { |
| 119 | int offs_x = child_offset_is_unsigned ? static_cast<uint8_t>(dtss.origin.x) : dtss.origin.x; |
| 120 | int offs_y = child_offset_is_unsigned ? static_cast<uint8_t>(dtss.origin.y) : dtss.origin.y; |
| 121 | DrawSprite(image, pal, x + child_offset.x + ScaleSpriteTrad(offs_x), y + child_offset.y + ScaleSpriteTrad(offs_y)); |
| 122 | } |
| 123 | } |
| 124 | } |
no test coverage detected