Changeset - r8557:625481c26097
[Not reviewed]
master
0 4 0
belugas - 17 years ago 2008-02-14 02:57:38
belugas@openttd.org
(svn r12135) -Codechange: Road and rail bridge selection windows were identical apart the caption. So remove one window definition and set manually the caption accordingly.
-Codechange: prepare the "type" of bridge parameter only once, at the beginning of the selection process. Makes less magic around.
4 files changed with 12 insertions and 29 deletions:
0 comments (0 inline, 0 general)
src/bridge_gui.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file bridge_gui.cpp Graphical user interface for bridge construction */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "command_func.h"
 
#include "economy_func.h"
 
#include "variables.h"
 
#include "bridge.h"
 
#include "strings_func.h"
 
#include "window_func.h"
 
#include "sound_func.h"
 
#include "map_func.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "tunnelbridge.h"
 

	
 
#include "table/strings.h"
 

	
 
static struct BridgeData {
 
	uint8 last_size;
 
	uint count;
 
	TileIndex start_tile;
 
	TileIndex end_tile;
 
	uint8 type;
 
	uint32 type; ///< Data type for the bridge. Bit 16,15 = transport type, 14..8 = road/rail pieces, 7..0 = type of bridge
 
	BridgeType indexes[MAX_BRIDGES];
 
	Money costs[MAX_BRIDGES];
 

	
 
	BridgeData()
 
		: last_size(4)
 
		, count(0)
 
		{};
 
} _bridgedata;
 

	
 
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
 
}
 

	
 
static void BuildBridge(Window *w, int i)
 
{
 
	DeleteWindow(w);
 
	DoCommandP(_bridgedata.end_tile, _bridgedata.start_tile,
 
		_bridgedata.indexes[i] | (_bridgedata.type << 8), CcBuildBridge,
 
		_bridgedata.type | _bridgedata.indexes[i], CcBuildBridge,
 
		CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
 
}
 

	
 
/* Names of the build bridge selection window */
 
enum BuildBridgeSelectionWidgets {
 
	BBSW_CLOSEBOX = 0,
 
	BBSW_CAPTION,
 
	BBSW_BRIDGE_LIST,
 
	BBSW_SCROLLBAR,
 
	BBSW_RESIZEBOX
 
};
 

	
 
static void BuildBridgeWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
		case WE_CREATE:
 
			w->resize.step_height = 22;
 
			w->vscroll.count = _bridgedata.count;
 

	
 
			if (_bridgedata.last_size <= 4) {
 
				w->vscroll.cap = 4;
 
			} else {
 
				/* Resize the bridge selection window if we used a bigger one the last time */
 
				w->vscroll.cap = (w->vscroll.count > _bridgedata.last_size) ? _bridgedata.last_size : w->vscroll.count;
 
				ResizeWindow(w, 0, (w->vscroll.cap - 4) * w->resize.step_height);
 
				w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
 
			}
 
			break;
 

	
 
		case WE_PAINT: {
 
			DrawWindowWidgets(w);
 

	
 
			uint y = 15;
 
			for (uint i = 0; (i < w->vscroll.cap) && ((i + w->vscroll.pos) < _bridgedata.count); i++) {
 
				const BridgeSpec *b = GetBridgeSpec(_bridgedata.indexes[i + w->vscroll.pos]);
 

	
 
				SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
 
				SetDParam(1, b->speed * 10 / 16);
 
				SetDParam(0, b->material);
 

	
 
				DrawSprite(b->sprite, b->pal, 3, y);
 
				DrawString(44, y, STR_500D, TC_FROMSTRING);
 
				y += w->resize.step_height;
 
			}
 
			break;
 
		}
 

	
 
		case WE_KEYPRESS: {
 
@@ -98,114 +98,96 @@ static void BuildBridgeWndProc(Window *w
 
				e->we.keypress.cont = false;
 
				BuildBridge(w, i);
 
			}
 

	
 
			break;
 
		}
 

	
 
		case WE_CLICK:
 
			if (e->we.click.widget == BBSW_BRIDGE_LIST) {
 
				uint ind = ((int)e->we.click.pt.y - 14) / w->resize.step_height;
 
				if (ind < w->vscroll.cap) {
 
					ind += w->vscroll.pos;
 
					if (ind < _bridgedata.count) {
 
						BuildBridge(w, ind);
 
					}
 
				}
 
			}
 
			break;
 

	
 
		case WE_RESIZE:
 
			w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
 
			w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
 
			SetVScrollCount(w, _bridgedata.count);
 

	
 
			_bridgedata.last_size = w->vscroll.cap;
 
			break;
 
	}
 
}
 

	
 
/* Widget definition for the rail bridge selection window */
 
static const Widget _build_bridge_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW},            // BBSW_CLOSEBOX
 
{    WWT_CAPTION,   RESIZE_NONE,  7,  11, 199,   0,  13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},  // BBSW_CAPTION
 
{     WWT_MATRIX, RESIZE_BOTTOM,  7,   0, 187,  14, 101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},  // BBSW_BRIDGE_LIST
 
{  WWT_SCROLLBAR, RESIZE_BOTTOM,  7, 188, 199,  14,  89, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
 
{  WWT_RESIZEBOX,     RESIZE_TB,  7, 188, 199,  90, 101, 0x0,                         STR_RESIZE_BUTTON},                // BBSW_RESIZEBOX
 
{   WIDGETS_END},
 
};
 

	
 
/* Window definition for the rail bridge selection window */
 
static const WindowDesc _build_bridge_desc = {
 
	WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
 
	WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
 
	_build_bridge_widgets,
 
	BuildBridgeWndProc
 
};
 

	
 
/* Widget definition for the road bridge selection window */
 
static const Widget _build_road_bridge_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW},            // BBSW_CLOSEBOX
 
{    WWT_CAPTION,   RESIZE_NONE,  7,  11, 199,   0,  13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},  // BBSW_CAPTION
 
{     WWT_MATRIX, RESIZE_BOTTOM,  7,   0, 187,  14, 101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},  // BBSW_BRIDGE_LIST
 
{  WWT_SCROLLBAR, RESIZE_BOTTOM,  7, 188, 199,  14,  89, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
 
{  WWT_RESIZEBOX,     RESIZE_TB,  7, 188, 199,  90, 101, 0x0,                         STR_RESIZE_BUTTON},                // BBSW_RESIZEBOX
 
{   WIDGETS_END},
 
};
 

	
 
/* Window definition for the road bridge selection window */
 
static const WindowDesc _build_road_bridge_desc = {
 
	WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
 
	WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
 
	_build_road_bridge_widgets,
 
	BuildBridgeWndProc
 
};
 

	
 

	
 
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
 
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type)
 
{
 
	DeleteWindowById(WC_BUILD_BRIDGE, 0);
 

	
 
	_bridgedata.type = bridge_type;
 
	_bridgedata.type = ((transport_type << 7) | bridge_type) << 8; //prepare the parameter for use only once
 
	_bridgedata.start_tile = start;
 
	_bridgedata.end_tile = end;
 

	
 
	/* only query bridge building possibility once, result is the same for all bridges!
 
	 * returns CMD_ERROR on failure, and price on success */
 
	StringID errmsg = INVALID_STRING_ID;
 
	CommandCost ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
 
	CommandCost ret = DoCommand(end, start, _bridgedata.type, DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
 

	
 
	uint8 j = 0;
 
	if (CmdFailed(ret)) {
 
		errmsg = _error_message;
 
	} else {
 
		/* check which bridges can be built
 
		 * get absolute bridge length
 
		 * length of the middle parts of the bridge */
 
		const uint bridge_len = GetTunnelBridgeLength(start, end);
 
		/* total length of bridge */
 
		const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2);
 

	
 
		/* loop for all bridgetypes */
 
		for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
 
			if (CheckBridge_Stuff(brd_type, bridge_len)) {
 
				/* bridge is accepted, add to list */
 
				const BridgeSpec *b = GetBridgeSpec(brd_type);
 
				/* Add to terraforming & bulldozing costs the cost of the
 
				 * bridge itself (not computed with DC_QUERY_COST) */
 
				_bridgedata.costs[j] = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8);
 
				_bridgedata.indexes[j] = brd_type;
 
				j++;
 
			}
 
		}
 

	
 
		_bridgedata.count = j;
 
	}
 

	
 
	if (j != 0) {
 
		AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
 
		Window *w = AllocateWindowDesc(&_build_bridge_desc);
 
		/* Change the data, or the caption of the gui. Set it to road or rail, accordingly */
 
		w->widget[BBSW_CAPTION].data = (transport_type == TRANSPORT_ROAD) ? STR_1803_SELECT_ROAD_BRIDGE : STR_100D_SELECT_RAIL_BRIDGE;
 
	} else {
 
		ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
 
	}
 
}
src/gui.h
Show inline comments
 
@@ -61,59 +61,59 @@ enum {
 
	DDSP_CREATE_ROCKS,
 
	DDSP_CREATE_WATER,
 
	DDSP_CREATE_RIVER,
 
	DDSP_PLANT_TREES,
 
	DDSP_BUILD_BRIDGE,
 

	
 
	/* Rail specific actions */
 
	DDSP_PLACE_RAIL_NE,
 
	DDSP_PLACE_RAIL_NW,
 
	DDSP_PLACE_AUTORAIL,
 
	DDSP_BUILD_SIGNALS,
 
	DDSP_BUILD_STATION,
 
	DDSP_REMOVE_STATION,
 
	DDSP_CONVERT_RAIL,
 

	
 
	/* Road specific actions */
 
	DDSP_PLACE_ROAD_X_DIR,
 
	DDSP_PLACE_ROAD_Y_DIR,
 
	DDSP_PLACE_AUTOROAD,
 
};
 

	
 
/* misc_gui.cpp */
 
void PlaceLandBlockInfo();
 
void ShowAboutWindow();
 
void ShowBuildTreesToolbar();
 
void ShowBuildTreesScenToolbar();
 
void ShowTownDirectory();
 
void ShowIndustryDirectory();
 
void ShowSubsidiesList();
 

	
 
void ShowEstimatedCostOrIncome(Money cost, int x, int y);
 
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y);
 

	
 
void ShowSmallMap();
 
void ShowExtraViewPortWindow();
 
void SetVScrollCount(Window *w, int num);
 
void SetVScroll2Count(Window *w, int num);
 
void SetHScrollCount(Window *w, int num);
 

	
 
void ShowCheatWindow();
 

	
 
void BuildFileList();
 
void SetFiosType(const byte fiostype);
 

	
 
/* FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
 
extern const TextColour _fios_colors[];
 

	
 
/* bridge_gui.cpp */
 
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte type);
 
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType Transport_type, byte type);
 

	
 
void ShowBuildIndustryWindow();
 
void ShowMusicWindow();
 

	
 
/* main_gui.cpp */
 
void HandleOnEditText(const char *str);
 

	
 
void InitializeGUI();
 

	
 
#endif /* GUI_H */
src/rail_gui.cpp
Show inline comments
 
@@ -504,97 +504,97 @@ static void UpdateRemoveWidgetStatus(Win
 
static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_CREATE: w->DisableWidget(RTW_REMOVE); break;
 

	
 
	case WE_PAINT: DrawWindowWidgets(w); break;
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget >= RTW_BUILD_NS) {
 
			_remove_button_clicked = false;
 
			_build_railroad_button_proc[e->we.click.widget - RTW_BUILD_NS](w);
 
		}
 
		UpdateRemoveWidgetStatus(w, e->we.click.widget);
 
		break;
 

	
 
	case WE_KEYPRESS:
 
		for (uint8 i = 0; i != lengthof(_rail_keycodes); i++) {
 
			if (e->we.keypress.keycode == _rail_keycodes[i]) {
 
				e->we.keypress.cont = false;
 
				_remove_button_clicked = false;
 
				_build_railroad_button_proc[i](w);
 
				UpdateRemoveWidgetStatus(w, i + RTW_BUILD_NS);
 
				break;
 
			}
 
		}
 
		MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
 
		break;
 

	
 
	case WE_PLACE_OBJ:
 
		_place_proc(e->we.place.tile);
 
		return;
 

	
 
	case WE_PLACE_DRAG: {
 
		/* no dragging if you have pressed the convert button */
 
		if (_convert_signal_button && w->IsWidgetLowered(RTW_BUILD_SIGNALS)) return;
 

	
 
		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
 
		return;
 
	}
 

	
 
	case WE_PLACE_MOUSEUP:
 
		if (e->we.place.pt.x != -1) {
 
			TileIndex start_tile = e->we.place.starttile;
 
			TileIndex end_tile = e->we.place.tile;
 

	
 
			switch (e->we.place.select_proc) {
 
				case DDSP_BUILD_BRIDGE:
 
					ResetObjectToPlace();
 
					ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
 
					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
 
					break;
 

	
 
				case DDSP_PLACE_AUTORAIL:
 
					HandleAutodirPlacement();
 
					break;
 

	
 
				case DDSP_BUILD_SIGNALS:
 
					HandleAutoSignalPlacement();
 
					break;
 

	
 
				case DDSP_DEMOLISH_AREA:
 
					GUIPlaceProcDragXY(e);
 
					break;
 

	
 
				case DDSP_REMOVE_STATION:
 
					DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
 
					break;
 

	
 
				case DDSP_CONVERT_RAIL:
 
					DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
 
					break;
 

	
 
				case DDSP_BUILD_STATION:
 
					HandleStationPlacement(start_tile, end_tile);
 
					break;
 

	
 
				case DDSP_PLACE_RAIL_NE:
 
				case DDSP_PLACE_RAIL_NW:
 
					DoRailroadTrack(e->we.place.select_proc == DDSP_PLACE_RAIL_NE ? TRACK_X : TRACK_Y);
 
					break;
 
			}
 
		}
 
		break;
 

	
 
	case WE_ABORT_PLACE_OBJ:
 
		w->RaiseButtons();
 
		w->DisableWidget(RTW_REMOVE);
 
		w->InvalidateWidget(RTW_REMOVE);
 

	
 
		w = FindWindowById(WC_BUILD_SIGNAL, 0);
 
		if (w != NULL) WP(w, def_d).close = true;
 
		w = FindWindowById(WC_BUILD_STATION, 0);
 
		if (w != NULL) WP(w, def_d).close = true;
 
		w = FindWindowById(WC_BUILD_DEPOT, 0);
 
		if (w != NULL) WP(w, def_d).close = true;
 
		break;
 

	
 
	case WE_PLACE_PRESIZE: {
 
@@ -1534,48 +1534,49 @@ void SetDefaultRailGui()
 
	if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return;
 

	
 
	extern RailType _last_built_railtype;
 
	RailType rt = (RailType)_patches.default_rail_type;
 
	if (rt >= RAILTYPE_END) {
 
		if (rt == RAILTYPE_END + 2) {
 
			/* Find the most used rail type */
 
			RailType count[RAILTYPE_END];
 
			memset(count, 0, sizeof(count));
 
			for (TileIndex t = 0; t < MapSize(); t++) {
 
				if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || IsRailwayStationTile(t) ||
 
						(IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
 
					count[GetRailType(t)]++;
 
				}
 
			}
 

	
 
			rt = RAILTYPE_RAIL;
 
			for (RailType r = RAILTYPE_ELECTRIC; r < RAILTYPE_END; r++) {
 
				if (count[r] >= count[rt]) rt = r;
 
			}
 

	
 
			/* No rail, just get the first available one */
 
			if (count[rt] == 0) rt = RAILTYPE_END;
 
		}
 
		switch (rt) {
 
			case RAILTYPE_END + 0:
 
				rt = RAILTYPE_RAIL;
 
				while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_player, rt)) rt++;
 
				break;
 

	
 
			case RAILTYPE_END + 1:
 
				rt = GetBestRailtype(_local_player);
 
				break;
 

	
 
			default:
 
				break;
 
		}
 
	}
 

	
 
	_last_built_railtype = _cur_railtype = rt;
 
	Window *w = FindWindowById(WC_BUILD_TOOLBAR, 0);
 
	if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
 
		SetupRailToolbar(_cur_railtype, w);
 
		SetWindowDirty(w);
 
	}
 
}
 

	
 

	
 

	
src/road_gui.cpp
Show inline comments
 
@@ -487,97 +487,97 @@ static void BuildRoadToolbWndProc(Window
 

	
 
	case WE_PLACE_DRAG:
 
		/* Here we update the end tile flags
 
		 * of the road placement actions.
 
		 * At first we reset the end halfroad
 
		 * bits and if needed we set them again. */
 
		switch (e->we.place.select_proc) {
 
			case DDSP_PLACE_ROAD_X_DIR:
 
				_place_road_flag &= ~RF_END_HALFROAD_X;
 
				if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
 
				break;
 

	
 
			case DDSP_PLACE_ROAD_Y_DIR:
 
				_place_road_flag &= ~RF_END_HALFROAD_Y;
 
				if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
 
				break;
 

	
 
			case DDSP_PLACE_AUTOROAD:
 
				_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
 
				if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
 
				if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
 

	
 
				/* For autoroad we need to update the
 
				 * direction of the road */
 
				if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
 
						( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
 
						  (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
 
					/* Set dir = X */
 
					_place_road_flag &= ~RF_DIR_Y;
 
				} else {
 
					/* Set dir = Y */
 
					_place_road_flag |= RF_DIR_Y;
 
				}
 

	
 
				break;
 
		}
 

	
 
		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
 
		return;
 

	
 
	case WE_PLACE_MOUSEUP:
 
		if (e->we.place.pt.x != -1) {
 
			TileIndex start_tile = e->we.place.starttile;
 
			TileIndex end_tile = e->we.place.tile;
 

	
 
			switch (e->we.place.select_proc) {
 
				case DDSP_BUILD_BRIDGE:
 
					ResetObjectToPlace();
 
					ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
 
					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
 
					break;
 

	
 
				case DDSP_DEMOLISH_AREA:
 
					DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
 
					break;
 

	
 
				case DDSP_PLACE_ROAD_X_DIR:
 
				case DDSP_PLACE_ROAD_Y_DIR:
 
				case DDSP_PLACE_AUTOROAD:
 
					/* Flag description:
 
					 * Use the first three bits (0x07) if dir == Y
 
					 * else use the last 2 bits (X dir has
 
					 * not the 3rd bit set) */
 
					_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
 

	
 
					DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), CcPlaySound1D,
 
						(_ctrl_pressed || _remove_button_clicked) ?
 
						CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
 
						CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
 
					break;
 
			}
 
		}
 
		break;
 

	
 
	case WE_PLACE_PRESIZE: {
 
		TileIndex tile = e->we.place.tile;
 

	
 
		DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
 
		VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
 
		break;
 
	}
 

	
 
	case WE_DESTROY:
 
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
		break;
 
	}
 
}
 

	
 
/** Widget definition of the build road toolbar */
 
static const Widget _build_road_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},             // RTW_CLOSEBOX
 
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   250,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // RTW_CAPTION
 
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   251,   262,     0,    13, 0x0,                        STR_STICKY_BUTTON},                 // RTW_STICKY
 

	
 
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_ROAD_X_DIR,         STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_X
 
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_ROAD_Y_DIR,         STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_Y
 
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_AUTOROAD,           STR_BUILD_AUTOROAD_TIP},            // RTW_AUTOROAD
 
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},   // RTW_DEMOLISH
0 comments (0 inline, 0 general)