Changeset - r8528:2bfd692a054f
[Not reviewed]
master
0 7 0
smatz - 17 years ago 2008-02-10 15:53:26
smatz@openttd.org
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
7 files changed with 27 insertions and 23 deletions:
0 comments (0 inline, 0 general)
src/elrail.cpp
Show inline comments
 
@@ -186,13 +186,13 @@ void DrawCatenaryOnTunnel(const TileInfo
 
	const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir];
 
	const int *BB_data = _tunnel_wire_BB[dir];
 
	AddSortableSpriteToDraw(
 
		sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
		BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1,
 
		GetTileZ(ti->tile) + sss->z_offset,
 
		IsTransparencySet(TO_BUILDINGS),
 
		IsTransparencySet(TO_CATENARY),
 
		BB_data[0] - sss->x_offset, BB_data[1] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset
 
	);
 
}
 

	
 
/** Draws wires and, if required, pylons on a given tile
 
 * @param ti The Tileinfo to draw the tile for
 
@@ -333,21 +333,21 @@ static void DrawCatenaryRailway(const Ti
 
						if (trackconfig[TS_NEIGHBOUR] != 0) break;
 
						continue; /* No neighbour, go looking for a better position */
 
					}
 

	
 
					AddSortableSpriteToDraw(pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE,
 
							GetPCPElevation(ti->tile, i),
 
							IsTransparencySet(TO_BUILDINGS), -1, -1);
 
							IsTransparencySet(TO_CATENARY), -1, -1);
 
					break; /* We already have drawn a pylon, bail out */
 
				}
 
			}
 
		}
 
	}
 

	
 
	/* Don't draw a wire under a low bridge */
 
	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BUILDINGS)) {
 
	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
 
		uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
 

	
 
		if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
 
	}
 

	
 
	/* Drawing of pylons is finished, now draw the wires */
 
@@ -368,13 +368,13 @@ static void DrawCatenaryRailway(const Ti
 
			 * The "wire"-sprite position is inside the tile, i.e. 0 <= sss->?_offset < TILE_SIZE.
 
			 * Therefore it is save to use GetSlopeZ() for the elevation.
 
			 * Also note, that the result of GetSlopeZ() is very special for bridge-ramps.
 
			 */
 
			AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
				sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + sss->z_offset,
 
				IsTransparencySet(TO_BUILDINGS));
 
				IsTransparencySet(TO_CATENARY));
 
		}
 
	}
 
}
 

	
 
static void DrawCatenaryOnBridge(const TileInfo *ti)
 
{
 
@@ -401,34 +401,34 @@ static void DrawCatenaryOnBridge(const T
 
	}
 

	
 
	height = GetBridgeHeight(end);
 

	
 
	AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
		sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset,
 
		IsTransparencySet(TO_BUILDINGS)
 
		IsTransparencySet(TO_CATENARY)
 
	);
 

	
 
	/* Finished with wires, draw pylons */
 
	/* every other tile needs a pylon on the northern end */
 
	if (num % 2) {
 
		DiagDirection PCPpos = (axis == AXIS_X ? DIAGDIR_NE : DIAGDIR_NW);
 
		Direction PPPpos = (axis == AXIS_X ? DIR_NW : DIR_NE);
 
		if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
 
		uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
 
		uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
 
		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_BUILDINGS), -1, -1);
 
		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1);
 
	}
 

	
 
	/* need a pylon on the southern end of the bridge */
 
	if (GetTunnelBridgeLength(ti->tile, start) + 1 == length) {
 
		DiagDirection PCPpos = (axis == AXIS_X ? DIAGDIR_SW : DIAGDIR_SE);
 
		Direction PPPpos = (axis == AXIS_X ? DIR_NW : DIR_NE);
 
		if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
 
		uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
 
		uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
 
		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_BUILDINGS), -1, -1);
 
		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1);
 
	}
 
}
 

	
 
void DrawCatenary(const TileInfo *ti)
 
{
 
	if (_patches.disable_elrails) return;
 
@@ -448,13 +448,13 @@ void DrawCatenary(const TileInfo *ti)
 

	
 
				/* This wire is not visible with the default depot sprites */
 
				AddSortableSpriteToDraw(
 
					sss->image, PAL_NONE, 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,
 
					IsTransparencySet(TO_BUILDINGS)
 
					IsTransparencySet(TO_CATENARY)
 
				);
 
				return;
 
			}
 
			break;
 

	
 
		case MP_TUNNELBRIDGE:
src/lang/english.txt
Show inline comments
 
@@ -3338,16 +3338,17 @@ STR_DRIVE_THROUGH_ERROR_DIRECTION       
 

	
 
STR_TRANSPARENCY_TOOLB                                          :{WHITE}Transparency Options
 
STR_TRANSPARENT_SIGNS_DESC                                      :{BLACK}Toggle transparency for station signs. CTRL+click to lock.
 
STR_TRANSPARENT_TREES_DESC                                      :{BLACK}Toggle transparency for trees. CTRL+click to lock.
 
STR_TRANSPARENT_HOUSES_DESC                                     :{BLACK}Toggle transparency for houses. CTRL+click to lock.
 
STR_TRANSPARENT_INDUSTRIES_DESC                                 :{BLACK}Toggle transparency for industries. CTRL+click to lock.
 
STR_TRANSPARENT_BUILDINGS_DESC                                  :{BLACK}Toggle transparency for buildables like stations, depots, waypoints and catenary. CTRL+click to lock.
 
STR_TRANSPARENT_BUILDINGS_DESC                                  :{BLACK}Toggle transparency for buildables like stations, depots and waypoints. CTRL+click to lock.
 
STR_TRANSPARENT_BRIDGES_DESC                                    :{BLACK}Toggle transparency for bridges. CTRL+click to lock.
 
STR_TRANSPARENT_STRUCTURES_DESC                                 :{BLACK}Toggle transparency for structures like lighthouses and antennas. CTRL+click to lock.
 
STR_TRANSPARENT_LOADING_DESC                                    :{BLACK}Toggle transparency for loading indicators. CTRL+click to lock.
 
STR_TRANSPARENT_CATENARY_DESC                                   :{BLACK}Toggle transparency for catenary. CTRL+click to lock.
 

	
 
STR_PERCENT_UP_SMALL                                            :{TINYFONT}{WHITE}{NUM}%{UPARROW}
 
STR_PERCENT_UP                                                  :{WHITE}{NUM}%{UPARROW}
 
STR_PERCENT_DOWN_SMALL                                          :{TINYFONT}{WHITE}{NUM}%{DOWNARROW}
 
STR_PERCENT_DOWN                                                :{WHITE}{NUM}%{DOWNARROW}
 
STR_PERCENT_UP_DOWN_SMALL                                       :{TINYFONT}{WHITE}{NUM}%{UPARROW}{DOWNARROW}
src/road_cmd.cpp
Show inline comments
 
@@ -942,13 +942,13 @@ static bool AlwaysDrawUnpavedRoads(TileI
 
 * @param ti   information about the tile (slopes, height etc)
 
 * @param tram the roadbits for the tram
 
 */
 
void DrawTramCatenary(TileInfo *ti, RoadBits tram)
 
{
 
	/* Don't draw the catenary under a low bridge */
 
	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BUILDINGS)) {
 
	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
 
		uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
 

	
 
		if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
 
	}
 

	
 
	SpriteID front;
 
@@ -959,14 +959,14 @@ void DrawTramCatenary(TileInfo *ti, Road
 
		front = SPR_TRAMWAY_FRONT_WIRES_SLOPED + _road_sloped_sprites[ti->tileh - 1];
 
	} else {
 
		back  = SPR_TRAMWAY_BASE + _road_backpole_sprites_1[tram];
 
		front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram];
 
	}
 

	
 
	AddSortableSpriteToDraw(back,  PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_BUILDINGS));
 
	AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_BUILDINGS));
 
	AddSortableSpriteToDraw(back,  PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
 
	AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
 
}
 

	
 
/**
 
 * Draws details on/around the road
 
 * @param img the sprite to draw
 
 * @param ti  the tile to draw on
src/settings.cpp
Show inline comments
 
@@ -1279,14 +1279,14 @@ static const SettingDescGlobVarList _mis
 
	 SDTG_BOOL("small_aa",                   S, 0, _freetype.small_aa,    false,    STR_NULL, NULL),
 
	 SDTG_BOOL("medium_aa",                  S, 0, _freetype.medium_aa,   false,    STR_NULL, NULL),
 
	 SDTG_BOOL("large_aa",                   S, 0, _freetype.large_aa,    false,    STR_NULL, NULL),
 
#endif
 
	  SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size,     4, 1, 64, 0, STR_NULL, NULL),
 
	  SDTG_VAR("player_face",    SLE_UINT32, S, 0, _player_face,      0,0,0xFFFFFFFF,0, STR_NULL, NULL),
 
	  SDTG_VAR("transparency_options", SLE_UINT8, S, 0, _transparency_opt, 0, 0,0xFF,0, STR_NULL, NULL),
 
	  SDTG_VAR("transparency_locks", SLE_UINT8, S, 0, _transparency_lock, 0, 0,0xFF,0, STR_NULL, NULL),
 
	  SDTG_VAR("transparency_options", SLE_UINT, S, 0, _transparency_opt,  0, 0,0xFF,0, STR_NULL, NULL),
 
	  SDTG_VAR("transparency_locks", SLE_UINT, S, 0, _transparency_lock,   0, 0,0xFF,0, STR_NULL, NULL),
 
	  SDTG_END()
 
};
 

	
 
#ifdef ENABLE_NETWORK
 
static const SettingDescGlobVarList _network_settings[] = {
 
	  SDTG_VAR("sync_freq",           SLE_UINT16,C|S,0, _network_sync_freq,            100, 0,   100,   0, STR_NULL, NULL),
src/transparency.h
Show inline comments
 
@@ -19,17 +19,18 @@ enum TransparencyOption {
 
	TO_TREES,      ///< trees
 
	TO_HOUSES,     ///< town buildings
 
	TO_INDUSTRIES, ///< industries
 
	TO_BUILDINGS,  ///< player buildings - depots, stations, HQ, ...
 
	TO_BRIDGES,    ///< bridges
 
	TO_STRUCTURES, ///< unmovable structures
 
	TO_CATENARY,   ///< catenary
 
	TO_LOADING,    ///< loading indicators
 
	TO_END,
 
};
 

	
 
typedef byte TransparencyOptionBits; ///< transparency option bits
 
typedef uint TransparencyOptionBits; ///< transparency option bits
 
extern TransparencyOptionBits _transparency_opt;
 
extern TransparencyOptionBits _transparency_lock;
 

	
 
/**
 
 * Check if the transparency option bit is set
 
 * and if we aren't in the game menu (there's never transparency)
src/transparency_gui.cpp
Show inline comments
 
@@ -19,12 +19,13 @@ enum TransparencyToolbarWidgets{
 
	TTW_WIDGET_TREES,        ///< Make trees transparent
 
	TTW_WIDGET_HOUSES,       ///< Make houses transparent
 
	TTW_WIDGET_INDUSTRIES,   ///< Make Industries transparent
 
	TTW_WIDGET_BUILDINGS,    ///< Make player buildings and structures transparent
 
	TTW_WIDGET_BRIDGES,      ///< Make bridges transparent
 
	TTW_WIDGET_STRUCTURES,   ///< Make unmovable structures transparent
 
	TTW_WIDGET_CATENARY,     ///< Make catenary transparent
 
	TTW_WIDGET_LOADING,      ///< Make loading indicators transperent
 
	TTW_WIDGET_END,          ///< End of toggle buttons
 
};
 

	
 
static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
 
{
 
@@ -40,13 +41,13 @@ static void TransparencyToolbWndProc(Win
 
			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);
 
			}
 
			break;
 

	
 
		case WE_CLICK:
 
			if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
 
			if (e->we.click.widget >= TTW_WIDGET_SIGNS && e->we.click.widget < TTW_WIDGET_END) {
 
				if (_ctrl_pressed) {
 
					/* toggle the bit of the transparencies lock variable */
 
					ToggleTransparencyLock((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
 
					SetWindowDirty(w);
 
				} else {
 
					/* toggle the bit of the transparencies variable and play a sound */
 
@@ -58,31 +59,32 @@ static void TransparencyToolbWndProc(Win
 
			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, 184,   0,  13, STR_TRANSPARENCY_TOOLB,   STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{WWT_STICKYBOX,   RESIZE_NONE,  7, 185, 196,   0,  13, STR_NULL,                 STR_STICKY_BUTTON},
 
{  WWT_CAPTION,   RESIZE_NONE,  7,  11, 206,   0,  13, STR_TRANSPARENCY_TOOLB,   STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{WWT_STICKYBOX,   RESIZE_NONE,  7, 207, 218,   0,  13, STR_NULL,                 STR_STICKY_BUTTON},
 

	
 
/* transparency widgets:
 
 * transparent signs, trees, houses, industries, player's buildings, bridges, unmovable structures and loading indicators */
 
{   WWT_IMGBTN,   RESIZE_NONE,  7,   0,  21,  14,  35, SPR_IMG_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},
 
{   WWT_IMGBTN,   RESIZE_NONE,  7, 175, 196,  14,  35, SPR_IMG_TRAINLIST,    STR_TRANSPARENT_LOADING_DESC},
 
{   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},
 

	
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _transparency_desc = {
 
	WDP_ALIGN_TBR, 58+36, 197, 36, 197, 36,
 
	WDP_ALIGN_TBR, 58+36, 219, 36, 219, 36,
 
	WC_TRANSPARENCY_TOOLBAR, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
 
	_transparency_widgets,
 
	TransparencyToolbWndProc
 
};
 

	
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -759,20 +759,20 @@ static void DrawBridgeTramBits(int x, in
 
	static const uint front_bb_offset_y[6] = {  0, 15, 15,  0, 15,  0 };
 

	
 
	/* 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));
 

	
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset],  PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS));
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset],  PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_CATENARY));
 

	
 
	/* Start a new SpriteCombine for the front part */
 
	EndSpriteCombine();
 
	StartSpriteCombine();
 

	
 
	/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS), front_bb_offset_x[offset], front_bb_offset_y[offset]);
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]);
 
}
 

	
 
/**
 
 * Draws a tunnel of bridge tile.
 
 * For tunnels, this is rather simple, as you only needa draw the entrance.
 
 * Bridges are a bit more complex. base_offset is where the sprite selection comes into play
 
@@ -829,13 +829,13 @@ static void DrawTile_TunnelBridge(TileIn
 
				static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, {  5, 76, 77,  4 } };
 

	
 
				DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE);
 

	
 
				catenary = true;
 
				StartSpriteCombine();
 
				AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_BUILDINGS), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
 
				AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, 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 (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) {
 
			DrawCatenary(ti);
 

	
 
			catenary = true;
 
			StartSpriteCombine();
0 comments (0 inline, 0 general)