2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ttd.h"
|
2004-11-25 10:47:30 +00:00
|
|
|
#include "table/strings.h"
|
2004-12-15 22:18:54 +00:00
|
|
|
#include "map.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "window.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "viewport.h"
|
|
|
|
#include "gfx.h"
|
2004-11-05 23:12:33 +00:00
|
|
|
#include "sound.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "command.h"
|
2004-12-08 15:46:13 +00:00
|
|
|
//needed for catchments
|
|
|
|
#include "station.h"
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowBusStationPicker(void);
|
|
|
|
static void ShowTruckStationPicker(void);
|
|
|
|
static void ShowRoadDepotPicker(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static bool _remove_button_clicked;
|
|
|
|
static bool _build_road_flag;
|
|
|
|
|
|
|
|
static byte _place_road_flag;
|
|
|
|
|
|
|
|
static byte _road_depot_orientation;
|
|
|
|
static byte _road_station_picker_orientation;
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void CcPlaySound1D(bool success, uint tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-04 09:26:39 +00:00
|
|
|
if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_NE(uint tile)
|
|
|
|
{
|
|
|
|
_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_X);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_NW(uint tile)
|
|
|
|
{
|
|
|
|
_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_Y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_Bridge(uint tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void CcBuildRoadTunnel(bool success, uint tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
} else {
|
|
|
|
SetRedErrorSquare(_build_tunnel_endtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_Tunnel(uint tile)
|
|
|
|
{
|
2004-12-04 17:54:56 +00:00
|
|
|
DoCommandP(tile, 0x200, 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadOutsideStation(uint tile, int direction)
|
|
|
|
{
|
|
|
|
static const byte _roadbits_by_dir[4] = {2,1,8,4};
|
2005-01-05 13:32:03 +00:00
|
|
|
tile += TileOffsByDir(direction);
|
2004-08-10 14:50:42 +00:00
|
|
|
// if there is a roadpiece just outside of the station entrance, build a connecting route
|
2005-01-16 11:24:58 +00:00
|
|
|
if (IsTileType(tile, MP_STREET) && !(_map5[tile] & 0x20)) {
|
2004-08-09 17:04:08 +00:00
|
|
|
DoCommandP(tile, _roadbits_by_dir[direction], 0, NULL, CMD_BUILD_ROAD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void CcRoadDepot(bool success, uint tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
BuildRoadOutsideStation(tile, (int)p1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_Depot(uint tile)
|
|
|
|
{
|
2004-12-04 17:54:56 +00:00
|
|
|
DoCommandP(tile, _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_BusStation(uint tile)
|
|
|
|
{
|
2004-12-04 17:54:56 +00:00
|
|
|
DoCommandP(tile, _road_station_picker_orientation, 0, CcRoadDepot, CMD_BUILD_BUS_STATION | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_TruckStation(uint tile)
|
|
|
|
{
|
2004-12-04 17:54:56 +00:00
|
|
|
DoCommandP(tile, _road_station_picker_orientation, 0, CcRoadDepot, CMD_BUILD_TRUCK_STATION | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRoad_DemolishArea(uint tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
|
|
|
|
static void BuildRoadClick_NE(Window *w)
|
|
|
|
{
|
|
|
|
_build_road_flag = 0;
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 3, 0x51F, 1, PlaceRoad_NE);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_NW(Window *w)
|
|
|
|
{
|
|
|
|
_build_road_flag = 0;
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 4, 0x520, 1, PlaceRoad_NW);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void BuildRoadClick_Demolish(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 5, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_Depot(Window *w)
|
|
|
|
{
|
2004-12-15 11:42:05 +00:00
|
|
|
if (_game_mode == GM_EDITOR) return;
|
2004-12-22 00:18:40 +00:00
|
|
|
if (HandlePlacePushButton(w, 6, 0x511, 1, PlaceRoad_Depot)) ShowRoadDepotPicker();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_BusStation(Window *w)
|
|
|
|
{
|
2004-12-15 11:42:05 +00:00
|
|
|
if (_game_mode == GM_EDITOR) return;
|
2004-12-22 00:18:40 +00:00
|
|
|
if (HandlePlacePushButton(w, 7, 0xAA5, 1, PlaceRoad_BusStation)) ShowBusStationPicker();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_TruckStation(Window *w)
|
|
|
|
{
|
2004-12-15 11:42:05 +00:00
|
|
|
if (_game_mode == GM_EDITOR) return;
|
2004-12-22 00:18:40 +00:00
|
|
|
if (HandlePlacePushButton(w, 8, 0xAA6, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_Bridge(Window *w)
|
|
|
|
{
|
|
|
|
_build_road_flag = 0;
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 9, 0xA21, 1, PlaceRoad_Bridge);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_Tunnel(Window *w)
|
|
|
|
{
|
|
|
|
_build_road_flag = 0;
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 10, 0x981, 3, PlaceRoad_Tunnel);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_Remove(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
if (w->disabled_state & (1<<11))
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
SetWindowDirty(w);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-12-22 00:18:40 +00:00
|
|
|
_thd.make_square_red = !!((w->click_state ^= (1 << 11)) & (1<<11));
|
2004-11-26 21:52:18 +00:00
|
|
|
MarkTileDirty(_thd.pos.x, _thd.pos.y);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildRoadClick_Landscaping(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-12 17:42:04 +00:00
|
|
|
ShowTerraformToolbar();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static OnButtonClick * const _build_road_button_proc[] = {
|
|
|
|
BuildRoadClick_NE,
|
|
|
|
BuildRoadClick_NW,
|
|
|
|
BuildRoadClick_Demolish,
|
|
|
|
BuildRoadClick_Depot,
|
|
|
|
BuildRoadClick_BusStation,
|
|
|
|
BuildRoadClick_TruckStation,
|
|
|
|
BuildRoadClick_Bridge,
|
|
|
|
BuildRoadClick_Tunnel,
|
|
|
|
BuildRoadClick_Remove,
|
2004-12-12 17:42:04 +00:00
|
|
|
BuildRoadClick_Landscaping,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) {
|
|
|
|
switch(e->event) {
|
|
|
|
case WE_PAINT:
|
2004-12-22 00:18:40 +00:00
|
|
|
w->disabled_state &= ~(1 << 11);
|
|
|
|
if (!(w->click_state & ((1<<3)|(1<<4)))) {
|
|
|
|
w->disabled_state |= (1 << 11);
|
|
|
|
w->click_state &= ~(1<<11);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_CLICK: {
|
2004-12-22 00:18:40 +00:00
|
|
|
if (e->click.widget >= 3)
|
|
|
|
_build_road_button_proc[e->click.widget - 3](w);
|
2004-08-09 17:04:08 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case WE_KEYPRESS:
|
|
|
|
switch(e->keypress.keycode) {
|
|
|
|
case '1': BuildRoadClick_NE(w); break;
|
|
|
|
case '2': BuildRoadClick_NW(w); break;
|
|
|
|
case '3': BuildRoadClick_Demolish(w); break;
|
2004-12-12 17:42:04 +00:00
|
|
|
case '4': BuildRoadClick_Depot(w); break;
|
|
|
|
case '5': BuildRoadClick_BusStation(w); break;
|
|
|
|
case '6': BuildRoadClick_TruckStation(w); break;
|
2004-08-09 17:04:08 +00:00
|
|
|
case 'B': BuildRoadClick_Bridge(w); break;
|
|
|
|
case 'T': BuildRoadClick_Tunnel(w); break;
|
|
|
|
case 'R': BuildRoadClick_Remove(w); break;
|
2004-12-12 17:42:04 +00:00
|
|
|
case 'L': BuildRoadClick_Landscaping(w); break;
|
2004-08-09 17:04:08 +00:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2004-12-22 00:18:40 +00:00
|
|
|
MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
|
2004-08-09 17:04:08 +00:00
|
|
|
e->keypress.cont = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_PLACE_OBJ:
|
2004-12-22 00:18:40 +00:00
|
|
|
_remove_button_clicked = (w->click_state & (1 << 11)) != 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
_place_proc(e->place.tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_ABORT_PLACE_OBJ:
|
2004-12-22 00:18:40 +00:00
|
|
|
UnclickWindowButtons(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
|
|
|
|
w = FindWindowById(WC_BUS_STATION, 0);
|
|
|
|
if (w != NULL) WP(w,def_d).close=true;
|
|
|
|
w = FindWindowById(WC_TRUCK_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_DRAG: {
|
|
|
|
int sel_method;
|
|
|
|
if (e->place.userdata == 1) {
|
|
|
|
sel_method = VPM_FIX_X;
|
|
|
|
_place_road_flag = (_place_road_flag&~2) | ((e->place.pt.y&8)>>2);
|
|
|
|
} else if (e->place.userdata == 2) {
|
|
|
|
sel_method = VPM_FIX_Y;
|
|
|
|
_place_road_flag = (_place_road_flag&~2) | ((e->place.pt.x&8)>>2);
|
|
|
|
} else if (e->place.userdata == 4) {
|
|
|
|
sel_method = VPM_X_AND_Y;
|
|
|
|
} else {
|
|
|
|
sel_method = VPM_X_OR_Y;
|
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WE_PLACE_MOUSEUP:
|
|
|
|
if (e->place.pt.x != -1) {
|
|
|
|
uint start_tile = e->place.starttile;
|
|
|
|
uint end_tile = e->place.tile;
|
|
|
|
if (e->place.userdata == 0) {
|
|
|
|
ResetObjectToPlace();
|
|
|
|
ShowBuildBridgeWindow(start_tile, end_tile, 0x80);
|
|
|
|
} else if (e->place.userdata != 4) {
|
2004-09-10 19:02:27 +00:00
|
|
|
DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D,
|
|
|
|
_remove_button_clicked ?
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
|
|
|
|
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
|
|
|
|
} else {
|
|
|
|
DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_PLACE_PRESIZE: {
|
|
|
|
uint tile = e->place.tile;
|
|
|
|
DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
|
|
|
VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _build_road_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 227, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 228, 239, 0, 13, 0x0, STR_STICKY_BUTTON},
|
|
|
|
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_ROAD_NW, STR_180B_BUILD_ROAD_SECTION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_ROAD_NE, STR_180B_BUILD_ROAD_SECTION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_ROAD_DEPOT, STR_180C_BUILD_ROAD_VEHICLE_DEPOT},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_BUS_STATION, STR_180D_BUILD_BUS_STATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 110, 131, 14, 35, SPR_IMG_TRUCK_BAY, STR_180E_BUILD_TRUCK_LOADING_BAY},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 132, 173, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_ROAD_BRIDGE},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 174, 195, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_1810_BUILD_ROAD_TUNNEL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 196, 217, 14, 35, SPR_IMG_REMOVE, STR_1811_TOGGLE_BUILD_REMOVE_FOR},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 218, 239, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_road_desc = {
|
2004-12-12 17:42:04 +00:00
|
|
|
640-240, 22, 240, 36,
|
2004-08-09 17:04:08 +00:00
|
|
|
WC_BUILD_TOOLBAR,0,
|
2004-12-22 00:18:40 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
2004-08-09 17:04:08 +00:00
|
|
|
_build_road_widgets,
|
|
|
|
BuildRoadToolbWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void ShowBuildRoadToolbar(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-01-08 20:55:21 +00:00
|
|
|
if (_current_player == OWNER_SPECTATOR) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
|
|
|
|
AllocateWindowDesc(&_build_road_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _build_road_scen_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 161, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 162, 173, 0, 13, 0x0, STR_STICKY_BUTTON},
|
|
|
|
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, 0x51D, STR_180B_BUILD_ROAD_SECTION},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, 0x51E, STR_180B_BUILD_ROAD_SECTION},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 107, 14, 35, 0xA22, STR_180F_BUILD_ROAD_BRIDGE},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 108, 129, 14, 35, 0x97D, STR_1810_BUILD_ROAD_TUNNEL},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 130, 151, 14, 35, 0x2CA, STR_1811_TOGGLE_BUILD_REMOVE_FOR},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 152, 173, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_road_scen_desc = {
|
2004-12-15 11:42:05 +00:00
|
|
|
-1, -1, 174, 36,
|
2004-08-09 17:04:08 +00:00
|
|
|
WC_SCEN_BUILD_ROAD,0,
|
2004-12-23 11:36:22 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
2004-08-09 17:04:08 +00:00
|
|
|
_build_road_scen_widgets,
|
|
|
|
BuildRoadToolbWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void ShowBuildRoadScenToolbar(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDescFront(&_build_road_scen_desc, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadDepotWndProc(Window *w, WindowEvent *e) {
|
|
|
|
switch(e->event) {
|
|
|
|
case WE_PAINT:
|
|
|
|
w->click_state = (1<<3) << _road_depot_orientation;
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
|
|
DrawRoadDepotSprite(70, 17, 0);
|
|
|
|
DrawRoadDepotSprite(70, 69, 1);
|
|
|
|
DrawRoadDepotSprite(2, 69, 2);
|
|
|
|
DrawRoadDepotSprite(2, 17, 3);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_CLICK: {
|
2005-01-23 15:25:17 +00:00
|
|
|
switch (e->click.widget) {
|
|
|
|
case 3: case 4: case 5: case 6:
|
2004-08-09 17:04:08 +00:00
|
|
|
_road_depot_orientation = e->click.widget - 3;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
} break;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_MOUSELOOP:
|
|
|
|
if (WP(w,def_d).close)
|
|
|
|
DeleteWindow(w);
|
|
|
|
break;
|
2005-01-20 08:36:15 +00:00
|
|
|
|
|
|
|
case WE_DESTROY:
|
2005-01-23 15:25:17 +00:00
|
|
|
if (!WP(w,def_d).close)
|
|
|
|
ResetObjectToPlace();
|
2005-01-20 08:36:15 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _build_road_depot_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_road_depot_desc = {
|
|
|
|
-1,-1, 140, 122,
|
|
|
|
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_build_road_depot_widgets,
|
|
|
|
BuildRoadDepotWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowRoadDepotPicker(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDesc(&_build_road_depot_desc);
|
|
|
|
}
|
|
|
|
|
2005-01-12 00:50:08 +00:00
|
|
|
static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
2004-08-09 17:04:08 +00:00
|
|
|
switch(e->event) {
|
|
|
|
case WE_PAINT: {
|
|
|
|
int image;
|
|
|
|
|
2005-01-12 00:50:08 +00:00
|
|
|
if (WP(w,def_d).close) return;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
w->click_state = ((1<<3) << _road_station_picker_orientation) |
|
|
|
|
((1<<7) << _station_show_coverage);
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
2005-01-12 00:50:08 +00:00
|
|
|
if (_station_show_coverage) {
|
|
|
|
int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
|
|
|
|
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
|
|
|
} else
|
|
|
|
SetTileSelectSize(1, 1);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
image = (w->window_class == WC_BUS_STATION) ? 0x47 : 0x43;
|
|
|
|
|
|
|
|
StationPickerDrawSprite(103, 35, 0, image);
|
|
|
|
StationPickerDrawSprite(103, 85, 0, image+1);
|
|
|
|
StationPickerDrawSprite(35, 85, 0, image+2);
|
|
|
|
StationPickerDrawSprite(35, 35, 0, image+3);
|
|
|
|
|
|
|
|
DrawStringCentered(70, 120, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
|
|
|
|
DrawStationCoverageAreaText(2, 146,
|
2004-12-08 15:46:13 +00:00
|
|
|
((w->window_class == WC_BUS_STATION) ? (1<<CT_PASSENGERS) : ~(1<<CT_PASSENGERS)),
|
|
|
|
3);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case WE_CLICK: {
|
2005-01-23 15:25:17 +00:00
|
|
|
switch (e->click.widget) {
|
|
|
|
case 3: case 4: case 5: case 6:
|
2004-08-09 17:04:08 +00:00
|
|
|
_road_station_picker_orientation = e->click.widget - 3;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2005-01-23 15:25:17 +00:00
|
|
|
case 7: case 8:
|
2004-08-09 17:04:08 +00:00
|
|
|
_station_show_coverage = e->click.widget - 7;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} break;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_MOUSELOOP: {
|
|
|
|
if (WP(w,def_d).close) {
|
|
|
|
DeleteWindow(w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckRedrawStationCoverage(w);
|
|
|
|
} break;
|
2005-01-23 13:09:35 +00:00
|
|
|
|
2005-01-20 08:36:15 +00:00
|
|
|
case WE_DESTROY:
|
2005-01-23 15:25:17 +00:00
|
|
|
if (!WP(w,def_d).close)
|
|
|
|
ResetObjectToPlace();
|
2005-01-20 08:36:15 +00:00
|
|
|
break;
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _bus_station_picker_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_3042_BUS_STATION_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 176, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF,STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _bus_station_picker_desc = {
|
|
|
|
-1,-1, 140, 177,
|
|
|
|
WC_BUS_STATION,WC_BUILD_TOOLBAR,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_bus_station_picker_widgets,
|
|
|
|
RoadStationPickerWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowBusStationPicker(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDesc(&_bus_station_picker_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _truck_station_picker_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_3043_TRUCK_STATION_ORIENT, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 176, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF,STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _truck_station_picker_desc = {
|
|
|
|
-1,-1, 140, 177,
|
|
|
|
WC_TRUCK_STATION,WC_BUILD_TOOLBAR,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_truck_station_picker_widgets,
|
|
|
|
RoadStationPickerWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowTruckStationPicker(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDesc(&_truck_station_picker_desc);
|
|
|
|
}
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void InitializeRoadGui(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
_road_depot_orientation = 3;
|
|
|
|
_road_station_picker_orientation = 3;
|
|
|
|
}
|