* Add a child sprite to a parent sprite. * * @param image the image to draw. * @param pal the provided palette. * @param x sprite x-offset (screen coordinates) relative to parent sprite. * @param y sprite y-offset (screen coordinates) relative to parent sprite. * @param transparent if true, switch the palette between the provided palette and the transparent palette, * @param sub Only draw a
| 822 | * @param relative if true, draw sprite relative to parent sprite offsets. |
| 823 | */ |
| 824 | void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub, bool scale, bool relative) |
| 825 | { |
| 826 | assert((image & SPRITE_MASK) < MAX_SPRITES); |
| 827 | |
| 828 | /* If the ParentSprite was clipped by the viewport bounds, do not draw the ChildSprites either */ |
| 829 | if (_vd.last_child == LAST_CHILD_NONE) return; |
| 830 | |
| 831 | /* make the sprites transparent with the right palette */ |
| 832 | if (transparent) { |
| 833 | SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
| 834 | pal = PALETTE_TO_TRANSPARENT; |
| 835 | } |
| 836 | |
| 837 | int32_t child_id = static_cast<int32_t>(_vd.child_screen_sprites_to_draw.size()); |
| 838 | if (_vd.last_child != LAST_CHILD_PARENT) { |
| 839 | _vd.child_screen_sprites_to_draw[_vd.last_child].next = child_id; |
| 840 | } else { |
| 841 | _vd.parent_sprites_to_draw.back().first_child = child_id; |
| 842 | } |
| 843 | |
| 844 | ChildScreenSpriteToDraw &cs = _vd.child_screen_sprites_to_draw.emplace_back(); |
| 845 | cs.image = image; |
| 846 | cs.pal = pal; |
| 847 | cs.sub = sub; |
| 848 | cs.x = scale ? x * ZOOM_BASE : x; |
| 849 | cs.y = scale ? y * ZOOM_BASE : y; |
| 850 | cs.relative = relative; |
| 851 | cs.next = LAST_CHILD_NONE; |
| 852 | |
| 853 | /* Append the sprite to the active ChildSprite list. |
| 854 | * If the active ParentSprite is a foundation, update last_foundation_child as well. |
| 855 | * Note: ChildSprites of foundations are NOT sequential in the vector, as selection sprites are added at last. */ |
| 856 | if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = child_id; |
| 857 | if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = child_id; |
| 858 | _vd.last_child = child_id; |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * Add a string to draw to a viewport. |
no test coverage detected