summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--projects/openttd.vcproj3
-rw-r--r--projects/openttd_vs80.vcproj6
-rw-r--r--source.list1
-rw-r--r--src/elrail.cpp54
-rw-r--r--src/industry_cmd.cpp4
-rw-r--r--src/lang/english.txt10
-rw-r--r--src/main_gui.cpp44
-rw-r--r--src/newgrf_house.cpp2
-rw-r--r--src/news_gui.cpp7
-rw-r--r--src/openttd.cpp5
-rw-r--r--src/openttd.h13
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/road_cmd.cpp2
-rw-r--r--src/settings.cpp2
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/town_cmd.cpp4
-rw-r--r--src/transparency_gui.cpp68
-rw-r--r--src/tree_cmd.cpp4
-rw-r--r--src/tunnelbridge_cmd.cpp10
-rw-r--r--src/unmovable_cmd.cpp6
-rw-r--r--src/variables.h1
-rw-r--r--src/viewport.cpp9
-rw-r--r--src/water_cmd.cpp2
23 files changed, 212 insertions, 49 deletions
diff --git a/projects/openttd.vcproj b/projects/openttd.vcproj
index f95c9977b..4ee36a3f5 100644
--- a/projects/openttd.vcproj
+++ b/projects/openttd.vcproj
@@ -757,6 +757,9 @@
RelativePath=".\..\src\train_gui.cpp">
</File>
<File
+ RelativePath=".\..\src\transparency_gui.cpp">
+ </File>
+ <File
RelativePath=".\..\src\vehicle_gui.cpp">
</File>
</Filter>
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 1dce3d9be..4f1536637 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -784,7 +784,7 @@
>
</File>
<File
- RelativePath="..\src\direction.h"
+ RelativePath=".\..\src\direction.h"
>
</File>
<File
@@ -1236,6 +1236,10 @@
>
</File>
<File
+ RelativePath=".\..\src\transparency_gui.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\vehicle_gui.cpp"
>
</File>
diff --git a/source.list b/source.list
index a7bfb2ebf..b8fb9a0fe 100644
--- a/source.list
+++ b/source.list
@@ -220,6 +220,7 @@ subsidy_gui.cpp
terraform_gui.cpp
town_gui.cpp
train_gui.cpp
+transparency_gui.cpp
vehicle_gui.cpp
# Landscape
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
);
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 7187ffe28..a6a5c07aa 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -259,7 +259,7 @@ static void DrawTile_Industry(TileInfo *ti)
/* Add industry on top of the ground? */
image = dits->building.sprite;
if (image != 0) {
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_INDUSTRIES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -274,7 +274,7 @@ static void DrawTile_Industry(TileInfo *ti)
dits->dz,
z);
- if (_display_opt & DO_TRANS_BUILDINGS) return;
+ if (HASBIT(_transparent_opt, TO_INDUSTRIES)) return;
}
{
diff --git a/src/lang/english.txt b/src/lang/english.txt
index e34670cdb..20f1ae7d7 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -802,6 +802,7 @@ STR_02DD_SUBSIDIES :Subsidies
STR_02DE_MAP_OF_WORLD :Map of world
STR_EXTRA_VIEW_PORT :Extra viewport
STR_SIGN_LIST :Sign list
+STR_TRANSPARENCY_OPTIONS :Transparency options
STR_02DF_TOWN_DIRECTORY :Town directory
STR_TOWN_POPULATION :{BLACK}World population: {COMMA}
STR_EXTRA_VIEW_PORT_TITLE :{WHITE}Viewport {COMMA}
@@ -3154,3 +3155,12 @@ STR_DATE_LONG :{STRING} {STRIN
STR_FEEDER_CARGO_VALUE :{BLACK}Transfer Credits: {LTBLUE}{CURRENCY}
STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD :{WHITE}...this is a town owned road
STR_DRIVE_THROUGH_ERROR_DIRECTION :{WHITE}...road facing in the wrong direction
+
+STR_TRANSPARENCY_TOOLB :{WHITE}Transparency Options
+STR_TRANSPARENT_SIGNS_DESC :{BLACK}Toggle transparency for station signs
+STR_TRANSPARENT_TREES_DESC :{BLACK}Toggle transparency for trees
+STR_TRANSPARENT_HOUSES_DESC :{BLACK}Toggle transparency for houses
+STR_TRANSPARENT_INDUSTRIES_DESC :{BLACK}Toggle transparency for industries
+STR_TRANSPARENT_BUILDINGS_DESC :{BLACK}Toggle transparency for buildables like stations, depots, waypoints and catenary
+STR_TRANSPARENT_BRIDGES_DESC :{BLACK}Toggle transparency for bridges
+STR_TRANSPARENT_STRUCTURES_DESC :{BLACK}Toggle transparency for structures like lighthouses and antennas, maybe in future for eyecandy
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 6f3be6341..eb039bb95 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -37,6 +37,7 @@
#include "settings.h"
#include "date.h"
#include "vehicle_gui.h"
+#include "transparency_gui.h"
#include "newgrf_config.h"
#include "network/network_data.h"
@@ -160,8 +161,8 @@ static void MenuClickSettings(int index)
case 8: _display_opt ^= DO_WAYPOINTS; break;
case 9: _display_opt ^= DO_FULL_ANIMATION; break;
case 10: _display_opt ^= DO_FULL_DETAIL; break;
- case 11: _display_opt ^= DO_TRANS_BUILDINGS; break;
- case 12: _display_opt ^= DO_TRANS_SIGNS; break;
+ case 11: TOGGLEBIT(_transparent_opt, TO_BUILDINGS); break;
+ case 12: TOGGLEBIT(_transparent_opt, TO_SIGNS); break;
}
MarkWholeScreenDirty();
}
@@ -192,6 +193,7 @@ static void MenuClickMap(int index)
case 0: ShowSmallMap(); break;
case 1: ShowExtraViewPortWindow(); break;
case 2: ShowSignList(); break;
+ case 3: ShowTransparencyToolbar(); break;
}
}
@@ -206,7 +208,8 @@ static void MenuClickScenMap(int index)
case 0: ShowSmallMap(); break;
case 1: ShowExtraViewPortWindow(); break;
case 2: ShowSignList(); break;
- case 3: ShowTownDirectory(); break;
+ case 3: ShowTransparencyToolbar(); break;
+ case 4: ShowTownDirectory(); break;
}
}
@@ -762,7 +765,7 @@ static void ToolbarSaveClick(Window *w)
static void ToolbarMapClick(Window *w)
{
- PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0);
+ PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 4, 0);
}
static void ToolbarTownClick(Window *w)
@@ -961,8 +964,8 @@ static void ToolbarOptionsClick(Window *w)
if (_display_opt & DO_WAYPOINTS) SETBIT(x, 8);
if (_display_opt & DO_FULL_ANIMATION) SETBIT(x, 9);
if (_display_opt & DO_FULL_DETAIL) SETBIT(x, 10);
- if (_display_opt & DO_TRANS_BUILDINGS) SETBIT(x, 11);
- if (_display_opt & DO_TRANS_SIGNS) SETBIT(x, 12);
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(x, 11);
+ if (HASBIT(_transparent_opt, TO_SIGNS)) SETBIT(x, 12);
WP(w,menu_d).checked_items = x;
}
@@ -1001,7 +1004,7 @@ static void ToolbarScenDateForward(Window *w)
static void ToolbarScenMapTownDir(Window *w)
{
/* Scenario editor button, *hack*hack* use different button to activate */
- PopupMainToolbMenu(w, 8 | (17 << 8), STR_02DE_MAP_OF_WORLD, 4, 0);
+ PopupMainToolbMenu(w, 8 | (17 << 8), STR_02DE_MAP_OF_WORLD, 5, 0);
}
static void ToolbarScenZoomIn(Window *w)
@@ -2330,11 +2333,34 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
break;
#endif
- case 'X':
- _display_opt ^= DO_TRANS_BUILDINGS;
+ case '1' | WKC_CTRL:
+ case '2' | WKC_CTRL:
+ case '3' | WKC_CTRL:
+ case '4' | WKC_CTRL:
+ case '5' | WKC_CTRL:
+ case '6' | WKC_CTRL:
+ case '7' | WKC_CTRL:
+ /* Transparency toggle hot keys */
+ TOGGLEBIT(_transparent_opt, e->we.keypress.key - '1');
MarkWholeScreenDirty();
break;
+ case 'X' | WKC_CTRL:
+ ShowTransparencyToolbar();
+ break;
+
+ case 'X': {
+ static byte trans_opt = ~0;
+ if (_transparent_opt == 0) {
+ _transparent_opt = trans_opt;
+ } else {
+ trans_opt = _transparent_opt;
+ _transparent_opt = 0;
+ }
+ MarkWholeScreenDirty();
+ break;
+ }
+
#ifdef ENABLE_NETWORK
case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
if (_networking) {
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index e6ba75693..79ad7f3d5 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -406,7 +406,7 @@ void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, Ho
image = dtss->image + stage;
pal = dtss->pal;
- if (!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && ((_display_opt & DO_TRANS_BUILDINGS))) {
+ if (!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && HASBIT(_transparent_opt, TO_HOUSES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 32d7cdc57..a94461180 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -128,10 +128,11 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56,
ni->string_id, w->width - 4);
} else {
- byte bk = _display_opt;
- _display_opt &= ~DO_TRANS_BUILDINGS;
+ /* Back up transparency options to draw news view */
+ byte to_backup = _transparent_opt;
+ _transparent_opt = 0;
DrawWindowViewport(w);
- _display_opt = bk;
+ _transparent_opt = to_backup;
/* Shade the viewport into gray, or color*/
vp = w->viewport;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 84de7904e..7cc37f2f2 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -303,7 +303,10 @@ static void LoadIntroGame()
char filename[256];
_game_mode = GM_MENU;
- CLRBITS(_display_opt, DO_TRANS_BUILDINGS); // don't make buildings transparent in intro
+
+ /* Clear transparency options */
+ _transparent_opt = 0;
+
_opt_ptr = &_opt_newgame;
ResetGRFConfig(false);
diff --git a/src/openttd.h b/src/openttd.h
index 0b1f1649f..f4bd4813b 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -175,10 +175,18 @@ enum {
DO_SHOW_STATION_NAMES = 1 << 1,
DO_SHOW_SIGNS = 1 << 2,
DO_FULL_ANIMATION = 1 << 3,
- DO_TRANS_BUILDINGS = 1 << 4,
DO_FULL_DETAIL = 1 << 5,
DO_WAYPOINTS = 1 << 6,
- DO_TRANS_SIGNS = 1 << 7,
+};
+
+enum {
+ TO_SIGNS,
+ TO_TREES,
+ TO_HOUSES,
+ TO_INDUSTRIES,
+ TO_BUILDINGS,
+ TO_BRIDGES,
+ TO_STRUCTURES,
};
/* Landscape types */
@@ -461,6 +469,7 @@ enum WindowClass {
WC_GENERATE_LANDSCAPE,
WC_GENERATE_PROGRESS_WINDOW,
WC_CONFIRM_POPUP_QUERY,
+ WC_TRANSPARENCY_TOOLBAR,
};
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 05100a9ad..35a4e0030 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1373,7 +1373,7 @@ default_waypoint:
image += relocation;
}
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index c086d0c61..0ec31702f 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -765,7 +765,7 @@ static void DrawTile_Road(TileInfo *ti)
SpriteID image = dtss->image;
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
diff --git a/src/settings.cpp b/src/settings.cpp
index 08255a957..c9b1cdef9 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1205,7 +1205,7 @@ static const SettingDescGlobVarList _win32_settings[] = {
#endif /* WIN32 */
static const SettingDescGlobVarList _misc_settings[] = {
- SDTG_MMANY("display_opt", SLE_UINT8, S, 0, _display_opt, (DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_TRANS_BUILDINGS|DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|TRANS_BUILDINGS|FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
+ SDTG_MMANY("display_opt", SLE_UINT8, S, 0, _display_opt, (DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
SDTG_BOOL("news_ticker_sound", S, 0, _news_ticker_sound, true, STR_NULL, NULL),
SDTG_BOOL("fullscreen", S, 0, _fullscreen, false, STR_NULL, NULL),
SDTG_STR("videodriver", SLE_STRB,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL),
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 582a3e05e..740321b01 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1959,7 +1959,7 @@ static void DrawTile_Station(TileInfo *ti)
}
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 482e7e5aa..ba2166fe8 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -151,7 +151,7 @@ static void DrawTile_Town(TileInfo *ti)
/* Add a house on top of the ground? */
image = dcts->building.sprite;
if (image != 0) {
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_HOUSES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -167,7 +167,7 @@ static void DrawTile_Town(TileInfo *ti)
ti->z
);
- if (_display_opt & DO_TRANS_BUILDINGS) return;
+ if (HASBIT(_transparent_opt, TO_HOUSES)) return;
}
{
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
new file mode 100644
index 000000000..ab4f40554
--- /dev/null
+++ b/src/transparency_gui.cpp
@@ -0,0 +1,68 @@
+/* $Id$ */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "table/sprites.h"
+#include "table/strings.h"
+#include "functions.h"
+#include "window.h"
+#include "gui.h"
+#include "viewport.h"
+#include "gfx.h"
+#include "sound.h"
+#include "variables.h"
+
+static void Transparent_Click(byte widget)
+{
+ TOGGLEBIT(_transparent_opt, widget);
+ SndPlayFx(SND_15_BEEP);
+}
+
+static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
+{
+ switch (e->event) {
+ case WE_PAINT:
+ for (uint i = 0; i < 7; i++) {
+ SetWindowWidgetLoweredState(w, i + 3, HASBIT(_transparent_opt, i));
+ }
+ DrawWindowWidgets(w);
+ break;
+
+ case WE_CLICK:
+ if (e->we.click.widget >= 3) {
+ Transparent_Click(e->we.click.widget - 3);
+ MarkWholeScreenDirty();
+ }
+ break;
+ }
+}
+
+static const Widget _transparency_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 162, 0, 13, STR_TRANSPARENCY_TOOLB, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{WWT_STICKYBOX, RESIZE_NONE, 7, 163, 174, 0, 13, STR_NULL, STR_STICKY_BUTTON},
+
+/* transparency widgets: transparent signs, trees, houses, industries, player's buildings */
+{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_PLACE_SIGN, STR_TRANSPARENT_SIGNS_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 152, 14, 35, SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 153, 174, 14, 35, SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_DESC},
+
+{ WIDGETS_END},
+};
+
+static const WindowDesc _transparency_desc = {
+ WDP_ALIGN_TBR, 58+36, 175, 36,
+ WC_TRANSPARENCY_TOOLBAR, WC_NONE,
+ WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
+ _transparency_widgets,
+ TransparencyToolbWndProc
+};
+
+void ShowTransparencyToolbar(void)
+{
+ AllocateWindowDescFront(&_transparency_desc, 0);
+}
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 4168b73b1..74d3e5d02 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -368,7 +368,7 @@ static void DrawTile_Trees(TileInfo *ti)
StartSpriteCombine();
- if (!(_display_opt & DO_TRANS_BUILDINGS) || !_patches.invisible_trees) {
+ if (!HASBIT(_transparent_opt, TO_TREES) || !_patches.invisible_trees) {
TreeListEnt te[4];
uint i;
@@ -377,7 +377,7 @@ static void DrawTile_Trees(TileInfo *ti)
do {
SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_TREES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 55132b3f5..e7a4b5718 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -795,7 +795,7 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis
{ 2, 4, 8, 1, 2, 16, 9, 0 }
};
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -920,7 +920,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
image = psid->sprite;
/* draw ramp */
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -1012,7 +1012,7 @@ void DrawBridgeMiddle(const TileInfo* ti)
z = GetBridgeHeight(rampsouth) - 3;
image = psid->sprite;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -1027,7 +1027,7 @@ void DrawBridgeMiddle(const TileInfo* ti)
psid++;
image = psid->sprite;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -1050,7 +1050,7 @@ void DrawBridgeMiddle(const TileInfo* ti)
/* draw poles below for small bridges */
if (psid->sprite != 0) {
image = psid->sprite;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 23483f159..2549e51cc 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -125,7 +125,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
image = dtus->image;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -143,7 +143,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
image = SPR_STATUE_COMPANY;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -179,7 +179,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
foreach_draw_tile_seq(dtss, t->seq) {
image = dtss->image;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
diff --git a/src/variables.h b/src/variables.h
index fdbe131fa..97581628f 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -282,6 +282,7 @@ VARDEF bool _do_autosave;
VARDEF int _autosave_ctr;
VARDEF byte _display_opt;
+VARDEF byte _transparent_opt;
VARDEF int _caret_timer;
VARDEF uint32 _news_display_opt;
VARDEF bool _news_ticker_sound;
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 5c7a166c9..6986cc534 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1193,11 +1193,12 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss
/* Draw the rectangle if 'tranparent station signs' is off,
* or if we are drawing a general text sign (STR_2806) */
- if (!(_display_opt & DO_TRANS_SIGNS) || ss->string == STR_2806)
+ if (!HASBIT(_transparent_opt, TO_SIGNS) || ss->string == STR_2806) {
DrawFrameRect(
x, y, x + w, bottom, ss->color,
- (_display_opt & DO_TRANS_BUILDINGS) ? FR_TRANSPARENT : FR_NONE
+ HASBIT(_transparent_opt, TO_SIGNS) ? FR_TRANSPARENT : FR_NONE
);
+ }
}
SetDParam(0, ss->params[0]);
@@ -1205,8 +1206,8 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss
/* if we didn't draw a rectangle, or if transparant building is on,
* draw the text in the color the rectangle would have */
if ((
- (_display_opt & DO_TRANS_BUILDINGS) ||
- (_display_opt & DO_TRANS_SIGNS && ss->string != STR_2806)
+ HASBIT(_transparent_opt, TO_BUILDINGS) ||
+ (HASBIT(_transparent_opt, TO_SIGNS) && ss->string != STR_2806)
) && ss->width != 0) {
/* Real colors need the IS_PALETTE_COLOR flag
* otherwise colors from _string_colormap are assumed. */
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 87713d0b5..429583eac 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -421,7 +421,7 @@ static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
SpriteID image = wdts->image + base;
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {