mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-28 17:09:10 +00:00
(svn r23952) -Feature: [NewGRF] Customisable tunnel portals for rail types (sprites by Snail).
This commit is contained in:
@@ -5458,6 +5458,7 @@ static const Action5Type _action5_types[] = {
|
||||
/* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "Flag graphics" },
|
||||
/* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" },
|
||||
/* 0x16 */ { A5BLOCK_ALLOW_OFFSET, SPR_AIRPORT_PREVIEW_BASE, 1, SPR_AIRPORT_PREVIEW_COUNT, "Airport preview graphics" },
|
||||
/* 0x17 */ { A5BLOCK_ALLOW_OFFSET, SPR_RAILTYPE_TUNNEL_BASE, 1, RAILTYPE_TUNNEL_BASE_COUNT, "Railtype tunnel base" },
|
||||
};
|
||||
|
||||
/* Action 0x05 */
|
||||
|
@@ -46,6 +46,7 @@ enum RailTypeSpriteGroup {
|
||||
RTSG_CROSSING, ///< Level crossing overlay images
|
||||
RTSG_DEPOT, ///< Depot images
|
||||
RTSG_FENCES, ///< Fence images
|
||||
RTSG_TUNNEL_PORTAL, ///< Tunnel portal overlay
|
||||
RTSG_END,
|
||||
};
|
||||
|
||||
|
@@ -270,8 +270,12 @@ static const uint16 ONEWAY_SPRITE_COUNT = 6;
|
||||
static const SpriteID SPR_FLAGS_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT;
|
||||
static const uint16 FLAGS_SPRITE_COUNT = 36;
|
||||
|
||||
/** Tunnel sprites with grass only for custom railtype tunnel. */
|
||||
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_FLAGS_BASE + FLAGS_SPRITE_COUNT;
|
||||
static const uint16 RAILTYPE_TUNNEL_BASE_COUNT = 16;
|
||||
|
||||
/* Not really a sprite, but an empty bounding box. Used to construct bounding boxes that help sorting the sprites, but do not have a sprite associated. */
|
||||
static const SpriteID SPR_EMPTY_BOUNDING_BOX = SPR_FLAGS_BASE + FLAGS_SPRITE_COUNT;
|
||||
static const SpriteID SPR_EMPTY_BOUNDING_BOX = SPR_RAILTYPE_TUNNEL_BASE + RAILTYPE_TUNNEL_BASE_COUNT;
|
||||
static const uint16 EMPTY_BOUNDING_BOX_SPRITE_COUNT = 1;
|
||||
|
||||
/* From where can we start putting NewGRFs? */
|
||||
|
@@ -1115,13 +1115,20 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||
bool catenary = false;
|
||||
|
||||
SpriteID image;
|
||||
SpriteID railtype_overlay = 0;
|
||||
if (transport_type == TRANSPORT_RAIL) {
|
||||
image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
|
||||
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
|
||||
image = rti->base_sprites.tunnel;
|
||||
if (rti->UsesOverlay()) {
|
||||
/* Check if the railtype has custom tunnel portals. */
|
||||
railtype_overlay = GetCustomRailSprite(rti, ti->tile, RTSG_TUNNEL_PORTAL);
|
||||
if (railtype_overlay != 0) image = SPR_RAILTYPE_TUNNEL_BASE; // Draw blank grass tunnel base.
|
||||
}
|
||||
} else {
|
||||
image = SPR_TUNNEL_ENTRY_REAR_ROAD;
|
||||
}
|
||||
|
||||
if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32;
|
||||
if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += railtype_overlay != 0 ? 8 : 32;
|
||||
|
||||
image += tunnelbridge_direction * 2;
|
||||
DrawGroundSprite(image, PAL_NONE);
|
||||
@@ -1164,9 +1171,13 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||
}
|
||||
}
|
||||
|
||||
AddSortableSpriteToDraw(image + 1, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, BB_data[0], BB_data[1], TILE_HEIGHT, ti->z, false, BB_data[2], BB_data[3], BB_Z_SEPARATOR);
|
||||
if (railtype_overlay != 0 && !catenary) StartSpriteCombine();
|
||||
|
||||
if (catenary) EndSpriteCombine();
|
||||
AddSortableSpriteToDraw(image + 1, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, BB_data[0], BB_data[1], TILE_HEIGHT, ti->z, false, BB_data[2], BB_data[3], BB_Z_SEPARATOR);
|
||||
/* Draw railtype tunnel portal overlay if defined. */
|
||||
if (railtype_overlay != 0) AddSortableSpriteToDraw(railtype_overlay + tunnelbridge_direction, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, BB_data[0], BB_data[1], TILE_HEIGHT, ti->z, false, BB_data[2], BB_data[3], BB_Z_SEPARATOR);
|
||||
|
||||
if (catenary || railtype_overlay != 0) EndSpriteCombine();
|
||||
|
||||
/* Add helper BB for sprite sorting that separates the tunnel from things beside of it. */
|
||||
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x, ti->y, BB_data[6], BB_data[7], TILE_HEIGHT, ti->z);
|
||||
|
Reference in New Issue
Block a user