summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-04-03 19:55:40 +0000
committersmatz <smatz@openttd.org>2008-04-03 19:55:40 +0000
commitfebc5150c9ee3f2df2a1cad8ef527d9541697b22 (patch)
tree6e5ae7f6b1b5f40dbc7a0e75f50db327a96a8b37
parent83f9e141e038d1564ca2ed9d2ff034afbc948dbc (diff)
downloadopenttd-febc5150c9ee3f2df2a1cad8ef527d9541697b22.tar.xz
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
-rw-r--r--src/elrail.cpp3
-rw-r--r--src/industry_cmd.cpp3
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/main_gui.cpp13
-rw-r--r--src/newgrf_house.cpp3
-rw-r--r--src/newgrf_industrytiles.cpp3
-rw-r--r--src/rail_cmd.cpp10
-rw-r--r--src/road_cmd.cpp6
-rw-r--r--src/settings.cpp2
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/station_cmd.cpp3
-rw-r--r--src/table/track_land.h6
-rw-r--r--src/town_cmd.cpp3
-rw-r--r--src/transparency.h40
-rw-r--r--src/transparency_gui.cpp36
-rw-r--r--src/tree_cmd.cpp2
-rw-r--r--src/tunnelbridge_cmd.cpp61
-rw-r--r--src/unmovable_cmd.cpp6
-rw-r--r--src/viewport.cpp13
-rw-r--r--src/water_cmd.cpp3
21 files changed, 189 insertions, 31 deletions
diff --git a/src/elrail.cpp b/src/elrail.cpp
index c126b80dc..3637f0ba5 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -434,6 +434,9 @@ void DrawCatenary(const TileInfo *ti)
{
if (_patches.disable_elrails) return;
+ /* Do not draw catenary if it is invisible */
+ if (IsInvisibilitySet(TO_CATENARY)) return;
+
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) {
TileIndex head = GetNorthernBridgeEnd(ti->tile);
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 3886ddc0e..b2247e565 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -303,6 +303,9 @@ static void DrawTile_Industry(TileInfo *ti)
DrawGroundSprite(image, pal);
+ /* If industries are transparent and invisible, do not draw the upper part */
+ if (IsInvisibilitySet(TO_INDUSTRIES)) return;
+
/* Add industry on top of the ground? */
image = dits->building.sprite;
if (image != 0) {
diff --git a/src/lang/english.txt b/src/lang/english.txt
index ffe0ec08c..b15148a57 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1068,7 +1068,6 @@ STR_CONFIG_PATCHES_AUTORENEW_MONTHS :{LTBLUE}Autoren
STR_CONFIG_PATCHES_AUTORENEW_MONEY :{LTBLUE}Autorenew minimum needed money for renew: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_ERRMSG_DURATION :{LTBLUE}Duration of error message: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_POPULATION_IN_LABEL :{LTBLUE}Show town population in the town name label: {ORANGE}{STRING1}
-STR_CONFIG_PATCHES_INVISIBLE_TREES :{LTBLUE}Invisible trees: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_LAND_GENERATOR :{LTBLUE}Land generator: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL :Original
@@ -3373,6 +3372,7 @@ STR_TRANSPARENT_BRIDGES_DESC :{BLACK}Toggle t
STR_TRANSPARENT_STRUCTURES_DESC :{BLACK}Toggle transparency for structures like lighthouses and antennas. CTRL+click to lock.
STR_TRANSPARENT_CATENARY_DESC :{BLACK}Toggle transparency for catenary. CTRL+click to lock.
STR_TRANSPARENT_LOADING_DESC :{BLACK}Toggle transparency for loading indicators. CTRL+click to lock.
+STR_TRANSPARENT_INVISIBLE_DESC :{BLACK}Set objects invisible instead of transparent
STR_PERCENT_UP_SMALL :{TINYFONT}{WHITE}{NUM}%{UPARROW}
STR_PERCENT_UP :{WHITE}{NUM}%{UPARROW}
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index e43bfd7ba..027f29130 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -1067,6 +1067,19 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
MarkWholeScreenDirty();
break;
+ case '1' | WKC_CTRL | WKC_SHIFT:
+ case '2' | WKC_CTRL | WKC_SHIFT:
+ case '3' | WKC_CTRL | WKC_SHIFT:
+ case '4' | WKC_CTRL | WKC_SHIFT:
+ case '5' | WKC_CTRL | WKC_SHIFT:
+ case '6' | WKC_CTRL | WKC_SHIFT:
+ case '7' | WKC_CTRL | WKC_SHIFT:
+ case '8' | WKC_CTRL | WKC_SHIFT:
+ /* Invisibility toggle hot keys */
+ ToggleInvisibilityWithTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL | WKC_SHIFT)));
+ MarkWholeScreenDirty();
+ break;
+
case 'X' | WKC_CTRL:
ShowTransparencyToolbar();
break;
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 3eab86df4..4c8fae368 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -322,6 +322,9 @@ void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, Ho
if (GB(image, 0, SPRITE_WIDTH) != 0) DrawGroundSprite(image, pal);
+ /* End now, if houses are invisible */
+ if (IsInvisibilitySet(TO_HOUSES)) return;
+
foreach_draw_tile_seq(dtss, dts->seq) {
if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue;
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 1303a6460..f79222e8e 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -185,6 +185,9 @@ void IndustryDrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte r
if (GB(image, 0, SPRITE_WIDTH) != 0) DrawGroundSprite(image, pal);
+ /* End now if industries are invisible */
+ if (IsInvisibilitySet(TO_INDUSTRIES)) return;
+
foreach_draw_tile_seq(dtss, dts->seq) {
if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue;
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 8e1e0ba5d..673ad404f 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1772,7 +1772,12 @@ static void DrawTile_Track(TileInfo *ti)
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
if (IsRailDepot(ti->tile)) {
- dts = &_depot_gfx_table[GetRailDepotDirection(ti->tile)];
+ if (IsInvisibilitySet(TO_BUILDINGS)) {
+ /* Draw rail instead of depot */
+ dts = &_depot_invisible_gfx_table[GetRailDepotDirection(ti->tile)];
+ } else {
+ dts = &_depot_gfx_table[GetRailDepotDirection(ti->tile)];
+ }
relocation = rti->total_offset;
@@ -1836,6 +1841,9 @@ default_waypoint:
if (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti);
+ /* End now if buildings are invisible */
+ if (IsInvisibilitySet(TO_BUILDINGS)) return;
+
foreach_draw_tile_seq(dtss, dts->seq) {
SpriteID image = dtss->image.sprite;
SpriteID pal;
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 7906650ab..29168db7f 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -970,6 +970,9 @@ static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
*/
void DrawTramCatenary(TileInfo *ti, RoadBits tram)
{
+ /* Do not draw catenary if it is invisible */
+ if (IsInvisibilitySet(TO_CATENARY)) return;
+
/* Don't draw the catenary under a low bridge */
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
@@ -1154,6 +1157,9 @@ static void DrawTile_Road(TileInfo *ti)
DrawGroundSprite(dts->ground.sprite, PAL_NONE);
+ /* End now if buildings are invisible */
+ if (IsInvisibilitySet(TO_BUILDINGS)) break;
+
for (dtss = dts->seq; dtss->image.sprite != 0; dtss++) {
SpriteID image = dtss->image.sprite;
SpriteID pal;
diff --git a/src/settings.cpp b/src/settings.cpp
index a89c2b713..8d2694d51 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1296,6 +1296,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_VAR("player_face", SLE_UINT32, S, 0, _player_face, 0,0,0xFFFFFFFF,0, STR_NULL, NULL),
SDTG_VAR("transparency_options", SLE_UINT, S, 0, _transparency_opt, 0,0,0x1FF,0, STR_NULL, NULL),
SDTG_VAR("transparency_locks", SLE_UINT, S, 0, _transparency_lock, 0,0,0x1FF,0, STR_NULL, NULL),
+ SDTG_VAR("invisibility_options", SLE_UINT, S, 0, _invisibility_opt, 0,0, 0xFF,0, STR_NULL, NULL),
SDTG_STR("keyboard", SLE_STRB, S, 0, _keyboard_opt[0], NULL, STR_NULL, NULL),
SDTG_STR("keyboard_caps", SLE_STRB, S, 0, _keyboard_opt[1], NULL, STR_NULL, NULL),
SDTG_END()
@@ -1379,7 +1380,6 @@ const SettingDesc _patch_settings[] = {
SDT_VAR(Patches, errmsg_duration, SLE_UINT8, S, 0, 5, 0, 20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION, NULL),
SDT_VAR(Patches, toolbar_pos, SLE_UINT8, S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS, v_PositionMainToolbar),
SDT_VAR(Patches, window_snap_radius, SLE_UINT8, S,D0, 10, 1, 32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS, NULL),
- SDT_BOOL(Patches, invisible_trees, S, 0, false, STR_CONFIG_PATCHES_INVISIBLE_TREES, RedrawScreen),
SDT_BOOL(Patches, population_in_label, S, 0, true, STR_CONFIG_PATCHES_POPULATION_IN_LABEL, PopulationInLabelActive),
SDT_VAR(Patches, map_x, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_X, NULL),
SDT_VAR(Patches, map_y, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_Y, NULL),
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index e1d9ef4bc..ca58c6561 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -712,7 +712,6 @@ static const char *_patches_ui[] = {
"toolbar_pos",
"measure_tooltip",
"window_snap_radius",
- "invisible_trees",
"population_in_label",
"link_terraform_toolbar",
"liveries",
diff --git a/src/settings_type.h b/src/settings_type.h
index d82297fa1..ef408749a 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -98,7 +98,6 @@ struct Patches {
bool realistic_acceleration; ///< realistic acceleration for trains
bool wagon_speed_limits; ///< enable wagon speed limits
bool forbid_90_deg; ///< forbid trains to make 90 deg turns
- bool invisible_trees; ///< don't show trees when buildings are transparent
bool no_servicing_if_no_breakdowns; ///< dont send vehicles to depot when breakdowns are disabled
bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars
bool reverse_scroll; ///< Right-Click-Scrolling scrolls in the opposite direction
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index df9e6cbbc..4c633cd50 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2184,6 +2184,9 @@ static void DrawTile_Station(TileInfo *ti)
DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
}
+ /* End now if buildings are invisible */
+ if (IsInvisibilitySet(TO_BUILDINGS)) return;
+
const DrawTileSeqStruct *dtss;
foreach_draw_tile_seq(dtss, t->seq) {
SpriteID image = dtss->image.sprite;
diff --git a/src/table/track_land.h b/src/table/track_land.h
index 920595cb1..3f4a00fb9 100644
--- a/src/table/track_land.h
+++ b/src/table/track_land.h
@@ -33,6 +33,12 @@ static const DrawTileSprites _depot_gfx_table[] = {
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NW }
};
+static const DrawTileSprites _depot_invisible_gfx_table[] = {
+ { {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_NE },
+ { {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_SE },
+ { {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_SW },
+ { {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_NW }
+};
static const DrawTileSeqStruct _waypoint_gfx_X[] = {
TILE_SEQ_LINE((1 << PALETTE_MODIFIER_COLOR) | SPR_WAYPOINT_X_1, 0, 0, 16, 5)
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 041f9bddd..4a26c177b 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -189,6 +189,9 @@ static void DrawTile_Town(TileInfo *ti)
pal = dcts->ground.pal;
DrawGroundSprite(image, pal);
+ /* If houses are invisible, do not draw the upper part */
+ if (IsInvisibilitySet(TO_HOUSES)) return;
+
/* Add a house on top of the ground? */
image = dcts->building.sprite;
if (image != 0) {
diff --git a/src/transparency.h b/src/transparency.h
index eb19d6938..35d8cbde7 100644
--- a/src/transparency.h
+++ b/src/transparency.h
@@ -28,6 +28,7 @@ enum TransparencyOption {
typedef uint TransparencyOptionBits; ///< transparency option bits
extern TransparencyOptionBits _transparency_opt;
extern TransparencyOptionBits _transparency_lock;
+extern TransparencyOptionBits _invisibility_opt;
/**
* Check if the transparency option bit is set
@@ -41,6 +42,17 @@ static inline bool IsTransparencySet(TransparencyOption to)
}
/**
+ * Check if the invisibility option bit is set
+ * and if we aren't in the game menu (there's never transparency)
+ *
+ * @param to the structure which invisibility option is ask for
+ */
+static inline bool IsInvisibilitySet(TransparencyOption to)
+{
+ return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
+}
+
+/**
* Toggle the transparency option bit
*
* @param to the transparency option to be toggled
@@ -51,6 +63,34 @@ static inline void ToggleTransparency(TransparencyOption to)
}
/**
+ * Toggle the invisibility option bit
+ *
+ * @param to the structure which invisibility option is toggle
+ */
+static inline void ToggleInvisibility(TransparencyOption to)
+{
+ ToggleBit(_invisibility_opt, to);
+}
+
+/**
+ * Toggles between invisible and solid state.
+ * If object is transparent, then it is made invisible.
+ * Used by the keyboard shortcuts.
+ *
+ * @param to the object type which invisibility option to toggle
+ */
+static inline void ToggleInvisibilityWithTransparency(TransparencyOption to)
+{
+ if (IsInvisibilitySet(to)) {
+ ClrBit(_invisibility_opt, to);
+ ClrBit(_transparency_opt, to);
+ } else {
+ SetBit(_invisibility_opt, to);
+ SetBit(_transparency_opt, to);
+ }
+}
+
+/**
* Toggle the transparency lock bit
*
* @param to the transparency option to be locked or unlocked
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index 6315d4391..a88e9fa1b 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -13,6 +13,7 @@
TransparencyOptionBits _transparency_opt;
TransparencyOptionBits _transparency_lock;
+TransparencyOptionBits _invisibility_opt;
enum TransparencyToolbarWidgets{
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
@@ -25,6 +26,9 @@ enum TransparencyToolbarWidgets{
TTW_WIDGET_CATENARY, ///< Make catenary transparent
TTW_WIDGET_LOADING, ///< Make loading indicators transparent
TTW_WIDGET_END, ///< End of toggle buttons
+
+ /* Panel with buttons for invisibility */
+ TTW_BUTTONS = 12, ///< Panel with 'invisibility' buttons
};
static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
@@ -41,6 +45,18 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
for (uint i = TO_SIGNS; i < TO_END; i++) {
if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[TTW_WIDGET_SIGNS + i].left + 1, w->widget[TTW_WIDGET_SIGNS + i].top + 1);
}
+
+ /* Do not draw button for invisible loading indicators */
+ for (uint i = 0; i < 8; i++) {
+ if (i < TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS) {
+ DrawFrameRect(i * 22, 38, i * 22 + 19, 46, true, HasBit(_invisibility_opt, i) ? FR_LOWERED : FR_NONE);
+ } else if (i == TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS) {
+ DrawFrameRect(i * 22, 38, i * 22 + 41, 46, true, HasBit(_invisibility_opt, i) ? FR_LOWERED : FR_NONE);
+ } else { // i > TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS
+ DrawFrameRect((i + 1) * 22, 38, (i + 1) * 22 + 19, 46, true, HasBit(_invisibility_opt, i) ? FR_LOWERED : FR_NONE);
+ }
+ }
+
break;
case WE_CLICK:
@@ -55,7 +71,23 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
SndPlayFx(SND_15_BEEP);
MarkWholeScreenDirty();
}
+ } else if (e->we.click.widget == TTW_BUTTONS) {
+ uint x = e->we.click.pt.x / 22;
+
+ if (x > TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS) x--;
+ if (x > TTW_WIDGET_CATENARY - TTW_WIDGET_SIGNS) break;
+
+ ToggleInvisibility((TransparencyOption)x);
+ SndPlayFx(SND_15_BEEP);
+
+ /* Redraw whole screen only if transparency is set */
+ if (IsTransparencySet((TransparencyOption)x)) {
+ MarkWholeScreenDirty();
+ } else {
+ w->InvalidateWidget(TTW_BUTTONS);
+ }
}
+
break;
}
}
@@ -77,11 +109,13 @@ static const Widget _transparency_widgets[] = {
{ WWT_IMGBTN, RESIZE_NONE, 7, 175, 196, 14, 35, SPR_BUILD_X_ELRAIL, STR_TRANSPARENT_CATENARY_DESC},
{ WWT_IMGBTN, RESIZE_NONE, 7, 197, 218, 14, 35, SPR_IMG_TRAINLIST, STR_TRANSPARENT_LOADING_DESC},
+{ WWT_PANEL, RESIZE_NONE, 7, 0, 218, 36, 48, 0x0, STR_TRANSPARENT_INVISIBLE_DESC},
+
{ WIDGETS_END},
};
static const WindowDesc _transparency_desc = {
- WDP_ALIGN_TBR, 58+36, 219, 36, 219, 36,
+ WDP_ALIGN_TBR, 58+36, 219, 49, 219, 49,
WC_TRANSPARENCY_TOOLBAR, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
_transparency_widgets,
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index e05c7d1c1..93bca6182 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -445,7 +445,7 @@ static void DrawTile_Trees(TileInfo *ti)
DrawClearLandFence(ti);
/* Do not draw trees when the invisible trees patch and transparency tree are set */
- if (IsTransparencySet(TO_TREES) && _patches.invisible_trees) return;
+ if (IsInvisibilitySet(TO_TREES)) return;
uint16 tmp = ti->x;
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 0260798ed..5a934811d 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -719,7 +719,11 @@ static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags)
*/
static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, BridgeType type, int x, int y, int z_bridge)
{
+ /* Do not draw bridge pillars if they are invisible */
+ if (IsInvisibilitySet(TO_BRIDGES)) return;
+
SpriteID image = psid->sprite;
+
if (image != 0) {
bool drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0);
@@ -771,8 +775,9 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis
* @param z the z of the bridge
* @param offset number representing whether to level or sloped and the direction
* @param overlay do we want to still see the road?
+ * @param head are we drawing bridge head?
*/
-static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay)
+static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay, bool head)
{
static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } };
static const SpriteID back_offsets[6] = { 95, 96, 99, 102, 100, 101 };
@@ -785,7 +790,12 @@ static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay)
/* The sprites under the vehicles are drawn as SpriteCombine. StartSpriteCombine() has already been called
* The bounding boxes here are the same as for bridge front/roof */
- AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BRIDGES));
+ if (head || !IsInvisibilitySet(TO_BRIDGES)) {
+ AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, !head && IsTransparencySet(TO_BRIDGES));
+ }
+
+ /* Do not draw catenary if it is set invisible */
+ if (IsInvisibilitySet(TO_CATENARY)) return;
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_CATENARY));
@@ -856,11 +866,14 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][tunnelbridge_direction], PAL_NONE);
- catenary = true;
- StartSpriteCombine();
- AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
+ /* Do not draw wires if they are invisible */
+ if (!IsInvisibilitySet(TO_CATENARY)) {
+ catenary = true;
+ StartSpriteCombine();
+ AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
+ }
}
- } else if (HasCatenary(GetRailType(ti->tile))) {
+ } else if (!IsInvisibilitySet(TO_CATENARY) && HasCatenary(GetRailType(ti->tile))) {
DrawCatenary(ti);
catenary = true;
@@ -916,9 +929,8 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
/* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on
* it doesn't disappear behind it
*/
- AddSortableSpriteToDraw(
- psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, IsTransparencySet(TO_BRIDGES)
- );
+ /* Bridge heads are drawn solid no matter how invisibility/transparency is set */
+ AddSortableSpriteToDraw(psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z);
if (transport_type == TRANSPORT_ROAD) {
RoadTypes rts = GetRoadTypes(ti->tile);
@@ -933,7 +945,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
offset += 2;
}
/* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */
- DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD));
+ DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true);
}
EndSpriteCombine();
} else if (HasCatenary(GetRailType(ti->tile))) {
@@ -1044,10 +1056,12 @@ void DrawBridgeMiddle(const TileInfo* ti)
if (transport_type == TRANSPORT_ROAD) StartSpriteCombine();
/* Draw floor and far part of bridge*/
- if (axis == AXIS_X) {
- AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
- } else {
- AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
+ if (!IsInvisibilitySet(TO_BRIDGES)) {
+ if (axis == AXIS_X) {
+ AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
+ } else {
+ AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
+ }
}
psid++;
@@ -1057,7 +1071,7 @@ void DrawBridgeMiddle(const TileInfo* ti)
if (HasBit(rts, ROADTYPE_TRAM)) {
/* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */
- DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD));
+ DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD), false);
} else {
EndSpriteCombine();
StartSpriteCombine();
@@ -1067,17 +1081,22 @@ void DrawBridgeMiddle(const TileInfo* ti)
}
/* draw roof, the component of the bridge which is logically between the vehicle and the camera */
- if (axis == AXIS_X) {
- y += 12;
- if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START);
- } else {
- x += 12;
- if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START);
+ if (!IsInvisibilitySet(TO_BRIDGES)) {
+ if (axis == AXIS_X) {
+ y += 12;
+ if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START);
+ } else {
+ x += 12;
+ if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START);
+ }
}
/* Draw TramFront as SpriteCombine */
if (transport_type == TRANSPORT_ROAD) EndSpriteCombine();
+ /* Do not draw anything more if bridges are invisible */
+ if (IsInvisibilitySet(TO_BRIDGES)) return;
+
psid++;
if (ti->z + 5 == z) {
/* draw poles below for small bridges */
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 6dc87ad08..0ff3d299f 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -171,6 +171,8 @@ static void DrawTile_Unmovable(TileInfo *ti)
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
DrawClearLandTile(ti, 2);
+ if (IsInvisibilitySet(TO_STRUCTURES)) break;
+
AddSortableSpriteToDraw(
dtu->image.sprite, PAL_NONE, ti->x | dtu->delta_x, ti->y | dtu->delta_y,
dtu->size_x, dtu->size_y, dtu->size_z, ti->z,
@@ -185,6 +187,8 @@ static void DrawTile_Unmovable(TileInfo *ti)
DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
+ if (IsInvisibilitySet(TO_STRUCTURES)) break;
+
AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, IsTransparencySet(TO_STRUCTURES));
break;
@@ -211,6 +215,8 @@ static void DrawTile_Unmovable(TileInfo *ti)
t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)];
DrawGroundSprite(t->ground.sprite, palette);
+ if (IsInvisibilitySet(TO_STRUCTURES)) break;
+
foreach_draw_tile_seq(dtss, t->seq) {
AddSortableSpriteToDraw(
dtss->image.sprite, palette,
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 934cd18c9..8f7a1df2d 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1230,8 +1230,8 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
const Sign *si;
int left, top, right, bottom;
- if (!HasBit(_display_opt, DO_SHOW_SIGNS))
- return;
+ /* Signs are turned off or are invisible */
+ if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS)) return;
left = dpi->left;
top = dpi->top;
@@ -1495,6 +1495,12 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss
uint16 colour;
if (ss->width != 0) {
+ /* Do not draw signs nor station names if they are set invisible */
+ if (IsInvisibilitySet(TO_SIGNS) && ss->string != STR_2806) {
+ ss = ss->next;
+ continue;
+ }
+
int x = UnScaleByZoom(ss->x, zoom) - 1;
int y = UnScaleByZoom(ss->y, zoom) - 1;
int bottom = y + 11;
@@ -1958,7 +1964,8 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
{
const Sign *si;
- if (!HasBit(_display_opt, DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
+ /* Signs are turned off, or they are transparent and invisibility is ON, or player is a spectator */
+ if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
switch (vp->zoom) {
case ZOOM_LVL_NORMAL:
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index eba83f1d3..822ebad45 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -597,6 +597,9 @@ static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
if (image < 4) image += water_base;
if (draw_ground) DrawGroundSprite(image, PAL_NONE);
+ /* End now if buildings are invisible */
+ if (IsInvisibilitySet(TO_BUILDINGS)) return;
+
for (; wdts->delta_x != 0x80; wdts++) {
AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette,
ti->x + wdts->delta_x, ti->y + wdts->delta_y,