summaryrefslogtreecommitdiff
path: root/src/elrail.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-04-05 07:49:04 +0000
committerpeter1138 <peter1138@openttd.org>2007-04-05 07:49:04 +0000
commita2cec54c9d880243617b16972528e305d743014d (patch)
tree56e95f5fe598d9097484013307aecd3c2c9821d0 /src/elrail.cpp
parentabf88b687ccbc7e344b3eacf8a84c1f71cac73a3 (diff)
downloadopenttd-a2cec54c9d880243617b16972528e305d743014d.tar.xz
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
Diffstat (limited to 'src/elrail.cpp')
-rw-r--r--src/elrail.cpp54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 4330bdb37..fcf8bedfe 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -269,7 +269,14 @@ static void DrawCatenaryRailway(const TileInfo *ti)
continue; /* No neighbour, go looking for a better position */
}
- AddSortableSpriteToDraw(pylons_normal[temp], PAL_NONE, x, y, 1, 1, 10,
+ SpriteID img = pylons_normal[temp];
+ SpriteID pal = PAL_NONE;
+ if (_transparent_opt & TO_BUILDINGS) {
+ SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ pal = PALETTE_TO_TRANSPARENT;
+ }
+
+ AddSortableSpriteToDraw(img, pal, x, y, 1, 1, 10,
GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]));
break; /* We already have drawn a pylon, bail out */
}
@@ -278,7 +285,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
}
/* Don't draw a wire under a low bridge */
- if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !(_display_opt & DO_TRANS_BUILDINGS)) {
+ if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !(_transparent_opt & TO_BUILDINGS)) {
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
if (height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) return;
@@ -307,7 +314,14 @@ static void DrawCatenaryRailway(const TileInfo *ti)
assert(!IsSteepSlope(tileh[TS_HOME]));
sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
- AddSortableSpriteToDraw( sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
+ SpriteID img = sss->image;
+ SpriteID pal = PAL_NONE;
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
+ SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ pal = PALETTE_TO_TRANSPARENT;
+ }
+
+ AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset);
}
}
@@ -339,7 +353,14 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
height = GetBridgeHeight(end);
- AddSortableSpriteToDraw( sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
+ SpriteID img = sss->image;
+ SpriteID pal = PAL_NONE;
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
+ SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ pal = PALETTE_TO_TRANSPARENT;
+ }
+
+ AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset
);
@@ -347,18 +368,26 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
/* every other tile needs a pylon on the northern end */
if (num % 2) {
if (axis == AXIS_X) {
- AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
+ img = pylons_bridge[0 + HASBIT(tlg, 0)];
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ AddSortableSpriteToDraw(img, pal, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
} else {
- AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height);
+ img = pylons_bridge[2 + HASBIT(tlg, 1)];
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height);
}
}
/* need a pylon on the southern end of the bridge */
if (DistanceMax(ti->tile, start) == length) {
if (axis == AXIS_X) {
- AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
+ img = pylons_bridge[0 + HASBIT(tlg, 0)];
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ AddSortableSpriteToDraw(img, pal, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
} else {
- AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height);
+ img = pylons_bridge[2 + HASBIT(tlg, 1)];
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height);
}
}
}
@@ -379,8 +408,15 @@ void DrawCatenary(const TileInfo *ti)
if (IsRailDepot(ti->tile)) {
const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
+ SpriteID img = sss->image;
+ SpriteID pal = PAL_NONE;
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
+ SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
+ pal = PALETTE_TO_TRANSPARENT;
+ }
+
AddSortableSpriteToDraw(
- sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
+ img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
sss->x_size, sss->y_size, sss->z_size,
GetTileMaxZ(ti->tile) + sss->z_offset
);