78 SpriteID image; |
78 SpriteID image; |
79 SpriteID pal; |
79 SpriteID pal; |
80 const SubSprite *sub; ///< only draw a rectangular part of the sprite |
80 const SubSprite *sub; ///< only draw a rectangular part of the sprite |
81 int32 x; |
81 int32 x; |
82 int32 y; |
82 int32 y; |
83 ChildScreenSpriteToDraw *next; |
83 int next; ///< next child to draw (-1 at the end) |
84 }; |
84 }; |
85 |
85 |
86 struct ParentSpriteToDraw { |
86 struct ParentSpriteToDraw { |
87 SpriteID image; ///< sprite to draw |
87 SpriteID image; ///< sprite to draw |
88 SpriteID pal; ///< palette to use |
88 SpriteID pal; ///< palette to use |
100 int32 ymax; ///< maximal world Y coordinate of bounding box |
100 int32 ymax; ///< maximal world Y coordinate of bounding box |
101 int zmin; ///< minimal world Z coordinate of bounding box |
101 int zmin; ///< minimal world Z coordinate of bounding box |
102 int zmax; ///< maximal world Z coordinate of bounding box |
102 int zmax; ///< maximal world Z coordinate of bounding box |
103 |
103 |
104 int first_child; ///< the first child to draw. |
104 int first_child; ///< the first child to draw. |
105 int last_child; ///< the last sprite to draw. |
|
106 bool comparison_done; ///< Used during sprite sorting: true if sprite has been compared with all other sprites |
105 bool comparison_done; ///< Used during sprite sorting: true if sprite has been compared with all other sprites |
107 }; |
106 }; |
108 |
107 |
109 /* Enumeration of multi-part foundations */ |
108 /* Enumeration of multi-part foundations */ |
110 enum FoundationPart { |
109 enum FoundationPart { |
674 |
673 |
675 ps->zmin = z + bb_offset_z; |
674 ps->zmin = z + bb_offset_z; |
676 ps->zmax = z + max(bb_offset_z, dz) - 1; |
675 ps->zmax = z + max(bb_offset_z, dz) - 1; |
677 |
676 |
678 ps->comparison_done = false; |
677 ps->comparison_done = false; |
679 ps->first_child = _vd.child_screen_sprites_to_draw.items; |
678 ps->first_child = -1; |
680 ps->last_child = _vd.child_screen_sprites_to_draw.items; |
679 |
681 |
680 _vd.last_child = &ps->first_child; |
682 _vd.last_child = &ps->last_child; |
|
683 |
681 |
684 if (_vd.combine_sprites == 1) _vd.combine_sprites = 2; |
682 if (_vd.combine_sprites == 1) _vd.combine_sprites = 2; |
685 } |
683 } |
686 |
684 |
687 void StartSpriteCombine() |
685 void StartSpriteCombine() |
715 if (transparent) { |
713 if (transparent) { |
716 SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
714 SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
717 pal = PALETTE_TO_TRANSPARENT; |
715 pal = PALETTE_TO_TRANSPARENT; |
718 } |
716 } |
719 |
717 |
720 /* Append the sprite to the active ChildSprite list. |
718 *_vd.last_child = _vd.child_screen_sprites_to_draw.items; |
721 * If the active ParentSprite is a foundation, update last_foundation_child as well. */ |
719 |
722 ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append(); |
720 ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append(); |
723 cs->image = image; |
721 cs->image = image; |
724 cs->pal = pal; |
722 cs->pal = pal; |
725 cs->sub = sub; |
723 cs->sub = sub; |
726 cs->x = x; |
724 cs->x = x; |
727 cs->y = y; |
725 cs->y = y; |
728 cs->next = NULL; |
726 cs->next = -1; |
729 |
727 |
730 *_vd.last_child = _vd.child_screen_sprites_to_draw.items; |
728 /* Append the sprite to the active ChildSprite list. |
|
729 * If the active ParentSprite is a foundation, update last_foundation_child as well. |
|
730 * Note: ChildSprites of foundations are NOT sequential in the vector, as selection sprites are added at last. */ |
|
731 if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = &cs->next; |
|
732 if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = &cs->next; |
|
733 _vd.last_child = &cs->next; |
731 } |
734 } |
732 |
735 |
733 /* Returns a StringSpriteToDraw */ |
736 /* Returns a StringSpriteToDraw */ |
734 void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, uint16 color, uint16 width) |
737 void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, uint16 color, uint16 width) |
735 { |
738 { |
1348 const ParentSpriteToDraw * const *psd_end = psd->End(); |
1351 const ParentSpriteToDraw * const *psd_end = psd->End(); |
1349 for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { |
1352 for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { |
1350 const ParentSpriteToDraw *ps = *it; |
1353 const ParentSpriteToDraw *ps = *it; |
1351 if (ps->image != SPR_EMPTY_BOUNDING_BOX) DrawSprite(ps->image, ps->pal, ps->x, ps->y, ps->sub); |
1354 if (ps->image != SPR_EMPTY_BOUNDING_BOX) DrawSprite(ps->image, ps->pal, ps->x, ps->y, ps->sub); |
1352 |
1355 |
1353 const ChildScreenSpriteToDraw *last = csstdv->Get(ps->last_child); |
1356 int child_idx = ps->first_child; |
1354 for (const ChildScreenSpriteToDraw *cs = csstdv->Get(ps->first_child); cs != last; cs++) { |
1357 while (child_idx >= 0) { |
|
1358 const ChildScreenSpriteToDraw *cs = csstdv->Get(child_idx); |
|
1359 child_idx = cs->next; |
1355 DrawSprite(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub); |
1360 DrawSprite(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub); |
1356 } |
1361 } |
1357 } |
1362 } |
1358 } |
1363 } |
1359 |
1364 |