Change: Separate ground sprite from foundation sprite offsets.

This commit is contained in:
Peter Nelson 2022-12-18 12:35:08 +00:00 committed by PeterN
parent 002fe67bef
commit 138198e971
3 changed files with 17 additions and 13 deletions

View File

@ -516,26 +516,27 @@ void DrawFoundation(TileInfo *ti, Foundation f)
f == FOUNDATION_INCLINED_Y ? 16 : 1,
TILE_HEIGHT, ti->z
);
OffsetGroundSprite(31, 9);
OffsetGroundSprite(0, 0);
} else if (IsLeveledFoundation(f)) {
AddSortableSpriteToDraw(leveled_base + SlopeWithOneCornerRaised(highest_corner), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z - TILE_HEIGHT);
OffsetGroundSprite(31, 1);
OffsetGroundSprite(0, -8);
} else if (f == FOUNDATION_STEEP_LOWER) {
/* one corner raised */
OffsetGroundSprite(31, 1);
OffsetGroundSprite(0, -8);
} else {
/* halftile foundation */
int x_bb = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? 8 : 0);
int y_bb = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? 8 : 0);
AddSortableSpriteToDraw(halftile_base + highest_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z + TILE_HEIGHT);
OffsetGroundSprite(31, 9);
Point pt = {(y_bb - x_bb) * 2, y_bb + x_bb};
OffsetGroundSprite(-pt.x, -pt.y);
}
} else {
if (IsLeveledFoundation(f)) {
/* leveled foundation */
AddSortableSpriteToDraw(leveled_base + ti->tileh, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
OffsetGroundSprite(31, 1);
OffsetGroundSprite(0, -8);
} else if (IsNonContinuousFoundation(f)) {
/* halftile foundation */
Corner halftile_corner = GetHalftileFoundationCorner(f);
@ -543,7 +544,8 @@ void DrawFoundation(TileInfo *ti, Foundation f)
int y_bb = (((halftile_corner == CORNER_S) || (halftile_corner == CORNER_E)) ? 8 : 0);
AddSortableSpriteToDraw(halftile_base + halftile_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z);
OffsetGroundSprite(31, 9);
Point pt = {(y_bb - x_bb) * 2, y_bb + x_bb};
OffsetGroundSprite(-pt.x, -pt.y);
} else if (IsSpecialRailFoundation(f)) {
/* anti-zig-zag foundation */
SpriteID spr;
@ -555,7 +557,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
spr = inclined_base + 2 * GetRailFoundationCorner(f) + ((ti->tileh == SLOPE_SW || ti->tileh == SLOPE_NE) ? 1 : 0);
}
AddSortableSpriteToDraw(spr, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
OffsetGroundSprite(31, 9);
OffsetGroundSprite(0, 0);
} else {
/* inclined foundation */
byte inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
@ -565,7 +567,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
f == FOUNDATION_INCLINED_Y ? 16 : 1,
TILE_HEIGHT, ti->z
);
OffsetGroundSprite(31, 9);
OffsetGroundSprite(0, 0);
}
ti->z += ApplyPixelFoundationToSlope(f, &ti->tileh);
}

View File

@ -2921,7 +2921,7 @@ static void DrawTile_Station(TileInfo *ti)
EndSpriteCombine();
}
OffsetGroundSprite(31, 1);
OffsetGroundSprite(0, -8);
ti->z += ApplyPixelFoundationToSlope(FOUNDATION_LEVELED, &ti->tileh);
} else {
draw_default_foundation:

View File

@ -538,7 +538,7 @@ static void AddChildSpriteToFoundation(SpriteID image, PaletteID pal, const SubS
int *old_child = _vd.last_child;
_vd.last_child = _vd.last_foundation_child[foundation_part];
AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub, false);
AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub, false, false);
/* Switch back to last ChildSprite list */
_vd.last_child = old_child;
@ -876,16 +876,18 @@ static void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint
* @param ti TileInfo Tile that is being drawn
* @param z_offset Z offset relative to the groundsprite. Only used for the sprite position, not for sprite sorting.
* @param foundation_part Foundation part the sprite belongs to.
* @param extra_offs_x Pixel X offset for the sprite position.
* @param extra_offs_y Pixel Y offset for the sprite position.
*/
static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part)
static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part, int extra_offs_x = 0, int extra_offs_y = 0)
{
/* FIXME: This is not totally valid for some autorail highlights that extend over the edges of the tile. */
if (_vd.foundation[foundation_part] == -1) {
/* draw on real ground */
AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset);
AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset, nullptr, extra_offs_x, extra_offs_y);
} else {
/* draw on top of foundation */
AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, 0, -z_offset * ZOOM_LVL_BASE);
AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, extra_offs_x, extra_offs_y - z_offset * ZOOM_LVL_BASE);
}
}