tron@2186: /* $Id$ */ tron@2186: truelight@0: #include "stdafx.h" Darkvater@1891: #include "openttd.h" tron@3150: #include "road_map.h" tron@1363: #include "table/sprites.h" tron@507: #include "table/strings.h" tron@2163: #include "functions.h" tron@679: #include "map.h" tron@1209: #include "tile.h" truelight@0: #include "window.h" truelight@0: #include "gui.h" truelight@0: #include "viewport.h" truelight@0: #include "gfx.h" tron@337: #include "sound.h" truelight@0: #include "command.h" tron@2159: #include "variables.h" Celestar@568: //needed for catchments Celestar@568: #include "station.h" Celestar@568: truelight@0: tron@1093: static void ShowBusStationPicker(void); tron@1093: static void ShowTruckStationPicker(void); tron@1093: static void ShowRoadDepotPicker(void); truelight@0: truelight@0: static bool _remove_button_clicked; truelight@0: truelight@0: static byte _place_road_flag; truelight@0: truelight@0: static byte _road_depot_orientation; truelight@0: static byte _road_station_picker_orientation; truelight@0: tron@1977: void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2) truelight@0: { tron@541: if (success) SndPlayTileFx(SND_1F_SPLAT, tile); truelight@0: } truelight@0: tron@1977: static void PlaceRoad_NE(TileIndex tile) truelight@0: { truelight@0: _place_road_flag = (_tile_fract_coords.y >= 8) + 4; truelight@0: VpStartPlaceSizing(tile, VPM_FIX_X); truelight@0: } truelight@0: tron@1977: static void PlaceRoad_NW(TileIndex tile) truelight@0: { truelight@0: _place_road_flag = (_tile_fract_coords.x >= 8) + 0; truelight@0: VpStartPlaceSizing(tile, VPM_FIX_Y); truelight@0: } truelight@0: tron@1977: static void PlaceRoad_Bridge(TileIndex tile) truelight@0: { truelight@0: VpStartPlaceSizing(tile, VPM_X_OR_Y); truelight@0: } truelight@0: truelight@0: tron@1977: void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) truelight@0: { truelight@0: if (success) { tron@541: SndPlayTileFx(SND_20_SPLAT_2, tile); truelight@0: ResetObjectToPlace(); truelight@0: } else { truelight@0: SetRedErrorSquare(_build_tunnel_endtile); truelight@0: } truelight@0: } truelight@0: tron@1977: static void PlaceRoad_Tunnel(TileIndex tile) truelight@0: { truelight@543: DoCommandP(tile, 0x200, 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); truelight@0: } truelight@0: tron@1977: static void BuildRoadOutsideStation(TileIndex tile, int direction) truelight@0: { truelight@0: static const byte _roadbits_by_dir[4] = {2,1,8,4}; tron@900: tile += TileOffsByDir(direction); darkvater@5: // if there is a roadpiece just outside of the station entrance, build a connecting route tron@3150: if (IsTileType(tile, MP_STREET) && GetRoadType(tile) == ROAD_NORMAL) { truelight@0: DoCommandP(tile, _roadbits_by_dir[direction], 0, NULL, CMD_BUILD_ROAD); truelight@0: } truelight@0: } truelight@0: tron@1977: void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) truelight@0: { truelight@0: if (success) { tron@541: SndPlayTileFx(SND_1F_SPLAT, tile); truelight@0: ResetObjectToPlace(); truelight@0: BuildRoadOutsideStation(tile, (int)p1); truelight@0: } truelight@0: } truelight@0: tron@1977: static void PlaceRoad_Depot(TileIndex tile) truelight@0: { truelight@543: 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)); truelight@0: } truelight@0: tron@1977: static void PlaceRoad_BusStation(TileIndex tile) truelight@0: { celestar@1217: DoCommandP(tile, _road_station_picker_orientation, RS_BUS, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION)); truelight@0: } truelight@0: tron@1977: static void PlaceRoad_TruckStation(TileIndex tile) truelight@0: { celestar@1217: DoCommandP(tile, _road_station_picker_orientation, RS_TRUCK, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION)); truelight@0: } truelight@0: tron@1977: static void PlaceRoad_DemolishArea(TileIndex tile) truelight@0: { truelight@0: VpStartPlaceSizing(tile, 4); truelight@0: } truelight@0: truelight@0: typedef void OnButtonClick(Window *w); truelight@0: truelight@0: static void BuildRoadClick_NE(Window *w) truelight@0: { Darkvater@1914: HandlePlacePushButton(w, 3, SPR_CURSOR_ROAD_NESW, 1, PlaceRoad_NE); truelight@0: } truelight@0: truelight@0: static void BuildRoadClick_NW(Window *w) truelight@0: { Darkvater@1914: HandlePlacePushButton(w, 4, SPR_CURSOR_ROAD_NWSE, 1, PlaceRoad_NW); truelight@0: } truelight@0: truelight@0: truelight@0: static void BuildRoadClick_Demolish(Window *w) truelight@0: { darkvater@756: HandlePlacePushButton(w, 5, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea); truelight@0: } truelight@0: truelight@0: static void BuildRoadClick_Depot(Window *w) truelight@0: { darkvater@661: if (_game_mode == GM_EDITOR) return; Darkvater@1914: if (HandlePlacePushButton(w, 6, SPR_CURSOR_ROAD_DEPOT, 1, PlaceRoad_Depot)) ShowRoadDepotPicker(); truelight@0: } truelight@0: truelight@0: static void BuildRoadClick_BusStation(Window *w) truelight@0: { darkvater@661: if (_game_mode == GM_EDITOR) return; Darkvater@1914: if (HandlePlacePushButton(w, 7, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowBusStationPicker(); truelight@0: } truelight@0: truelight@0: static void BuildRoadClick_TruckStation(Window *w) truelight@0: { darkvater@661: if (_game_mode == GM_EDITOR) return; Darkvater@1914: if (HandlePlacePushButton(w, 8, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker(); truelight@0: } truelight@0: truelight@0: static void BuildRoadClick_Bridge(Window *w) truelight@0: { Darkvater@1914: HandlePlacePushButton(w, 9, SPR_CURSOR_BRIDGE, 1, PlaceRoad_Bridge); truelight@0: } truelight@0: truelight@0: static void BuildRoadClick_Tunnel(Window *w) truelight@0: { Darkvater@1914: HandlePlacePushButton(w, 10, SPR_CURSOR_ROAD_TUNNEL, 3, PlaceRoad_Tunnel); truelight@0: } truelight@0: truelight@0: static void BuildRoadClick_Remove(Window *w) truelight@0: { tron@2635: if (HASBIT(w->disabled_state, 11)) return; truelight@0: SetWindowDirty(w); tron@541: SndPlayFx(SND_15_BEEP); tron@2635: TOGGLEBIT(w->click_state, 11); tron@3132: SetSelectionRed(HASBIT(w->click_state, 11)); truelight@0: } truelight@0: dominik@606: static void BuildRoadClick_Landscaping(Window *w) truelight@0: { dominik@606: ShowTerraformToolbar(); truelight@0: } truelight@0: tron@2639: static OnButtonClick* const _build_road_button_proc[] = { truelight@0: BuildRoadClick_NE, truelight@0: BuildRoadClick_NW, truelight@0: BuildRoadClick_Demolish, truelight@0: BuildRoadClick_Depot, truelight@0: BuildRoadClick_BusStation, truelight@0: BuildRoadClick_TruckStation, truelight@0: BuildRoadClick_Bridge, truelight@0: BuildRoadClick_Tunnel, truelight@0: BuildRoadClick_Remove, dominik@606: BuildRoadClick_Landscaping, truelight@0: }; truelight@0: tron@2639: static void BuildRoadToolbWndProc(Window* w, WindowEvent* e) tron@2639: { tron@2639: switch (e->event) { truelight@0: case WE_PAINT: darkvater@756: w->disabled_state &= ~(1 << 11); darkvater@756: if (!(w->click_state & ((1<<3)|(1<<4)))) { darkvater@756: w->disabled_state |= (1 << 11); darkvater@756: w->click_state &= ~(1<<11); truelight@0: } truelight@0: DrawWindowWidgets(w); truelight@0: break; truelight@0: truelight@0: case WE_CLICK: { tron@2639: if (e->click.widget >= 3) _build_road_button_proc[e->click.widget - 3](w); truelight@0: } break; truelight@0: truelight@0: case WE_KEYPRESS: tron@2631: switch (e->keypress.keycode) { tron@2631: case '1': BuildRoadClick_NE(w); break; tron@2631: case '2': BuildRoadClick_NW(w); break; tron@2631: case '3': BuildRoadClick_Demolish(w); break; tron@2631: case '4': BuildRoadClick_Depot(w); break; tron@2631: case '5': BuildRoadClick_BusStation(w); break; tron@2631: case '6': BuildRoadClick_TruckStation(w); break; tron@2631: case 'B': BuildRoadClick_Bridge(w); break; tron@2631: case 'T': BuildRoadClick_Tunnel(w); break; tron@2631: case 'R': BuildRoadClick_Remove(w); break; tron@2631: case 'L': BuildRoadClick_Landscaping(w); break; tron@2631: default: return; truelight@0: } darkvater@756: MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection truelight@0: e->keypress.cont = false; truelight@0: break; truelight@0: truelight@0: case WE_PLACE_OBJ: darkvater@756: _remove_button_clicked = (w->click_state & (1 << 11)) != 0; truelight@0: _place_proc(e->place.tile); truelight@0: break; truelight@0: truelight@0: case WE_ABORT_PLACE_OBJ: darkvater@756: UnclickWindowButtons(w); truelight@0: SetWindowDirty(w); truelight@0: truelight@0: w = FindWindowById(WC_BUS_STATION, 0); tron@2639: if (w != NULL) WP(w,def_d).close = true; truelight@0: w = FindWindowById(WC_TRUCK_STATION, 0); tron@2639: if (w != NULL) WP(w,def_d).close = true; truelight@0: w = FindWindowById(WC_BUILD_DEPOT, 0); tron@2639: if (w != NULL) WP(w,def_d).close = true; truelight@0: break; truelight@0: truelight@0: case WE_PLACE_DRAG: { truelight@0: int sel_method; truelight@0: if (e->place.userdata == 1) { truelight@0: sel_method = VPM_FIX_X; truelight@0: _place_road_flag = (_place_road_flag&~2) | ((e->place.pt.y&8)>>2); truelight@0: } else if (e->place.userdata == 2) { truelight@0: sel_method = VPM_FIX_Y; truelight@0: _place_road_flag = (_place_road_flag&~2) | ((e->place.pt.x&8)>>2); truelight@0: } else if (e->place.userdata == 4) { truelight@0: sel_method = VPM_X_AND_Y; truelight@0: } else { truelight@0: sel_method = VPM_X_OR_Y; truelight@0: } truelight@193: truelight@0: VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method); truelight@0: return; truelight@0: } truelight@0: truelight@0: case WE_PLACE_MOUSEUP: truelight@0: if (e->place.pt.x != -1) { tron@1977: TileIndex start_tile = e->place.starttile; tron@1977: TileIndex end_tile = e->place.tile; tron@1977: truelight@0: if (e->place.userdata == 0) { truelight@0: ResetObjectToPlace(); truelight@0: ShowBuildBridgeWindow(start_tile, end_tile, 0x80); truelight@0: } else if (e->place.userdata != 4) { truelight@193: DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D, truelight@193: _remove_button_clicked ? truelight@0: CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) : truelight@0: CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE)); truelight@0: } else { truelight@0: DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); truelight@0: } truelight@0: } truelight@0: break; truelight@0: truelight@0: case WE_PLACE_PRESIZE: { tron@1977: TileIndex tile = e->place.tile; tron@1977: truelight@0: DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL); truelight@0: VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile); truelight@0: break; truelight@0: } peter1138@2619: peter1138@2619: case WE_DESTROY: peter1138@2619: if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); peter1138@2619: break; truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _build_road_widgets[] = { truelight@867: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_NONE, 7, 11, 227, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_STICKYBOX, RESIZE_NONE, 7, 228, 239, 0, 13, 0x0, STR_STICKY_BUTTON}, dominik@606: truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_ROAD_NW, STR_180B_BUILD_ROAD_SECTION}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_ROAD_NE, STR_180B_BUILD_ROAD_SECTION}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_ROAD_DEPOT, STR_180C_BUILD_ROAD_VEHICLE_DEPOT}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_BUS_STATION, STR_180D_BUILD_BUS_STATION}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 110, 131, 14, 35, SPR_IMG_TRUCK_BAY, STR_180E_BUILD_TRUCK_LOADING_BAY}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 132, 173, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_ROAD_BRIDGE}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 174, 195, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_1810_BUILD_ROAD_TUNNEL}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 196, 217, 14, 35, SPR_IMG_REMOVE, STR_1811_TOGGLE_BUILD_REMOVE_FOR}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 218, 239, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_road_desc = { dominik@606: 640-240, 22, 240, 36, truelight@0: WC_BUILD_TOOLBAR,0, darkvater@756: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, truelight@0: _build_road_widgets, truelight@0: BuildRoadToolbWndProc truelight@0: }; truelight@0: tron@1093: void ShowBuildRoadToolbar(void) truelight@0: { dominik@946: if (_current_player == OWNER_SPECTATOR) return; truelight@0: DeleteWindowById(WC_BUILD_TOOLBAR, 0); truelight@0: AllocateWindowDesc(&_build_road_desc); peter1138@2619: if (_patches.link_terraform_toolbar) ShowTerraformToolbar(); truelight@0: } truelight@0: truelight@0: static const Widget _build_road_scen_widgets[] = { peter1138@2725: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_NONE, 7, 11, 161, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_STICKYBOX, RESIZE_NONE, 7, 162, 173, 0, 13, 0x0, STR_STICKY_BUTTON}, darkvater@661: truelight@867: { WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, 0x51D, STR_180B_BUILD_ROAD_SECTION}, truelight@867: { WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, 0x51E, STR_180B_BUILD_ROAD_SECTION}, truelight@867: { WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC}, truelight@867: { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, truelight@867: { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, truelight@867: { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, truelight@867: { WWT_IMGBTN, RESIZE_NONE, 7, 66, 107, 14, 35, 0xA22, STR_180F_BUILD_ROAD_BRIDGE}, truelight@867: { WWT_IMGBTN, RESIZE_NONE, 7, 108, 129, 14, 35, 0x97D, STR_1810_BUILD_ROAD_TUNNEL}, truelight@867: { WWT_IMGBTN, RESIZE_NONE, 7, 130, 151, 14, 35, 0x2CA, STR_1811_TOGGLE_BUILD_REMOVE_FOR}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 152, 173, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_road_scen_desc = { darkvater@661: -1, -1, 174, 36, truelight@0: WC_SCEN_BUILD_ROAD,0, darkvater@777: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, truelight@0: _build_road_scen_widgets, truelight@0: BuildRoadToolbWndProc truelight@0: }; truelight@0: tron@1093: void ShowBuildRoadScenToolbar(void) truelight@0: { truelight@0: AllocateWindowDescFront(&_build_road_scen_desc, 0); truelight@0: } truelight@0: tron@2639: static void BuildRoadDepotWndProc(Window* w, WindowEvent* e) tron@2639: { tron@2639: switch (e->event) { truelight@0: case WE_PAINT: truelight@0: w->click_state = (1<<3) << _road_depot_orientation; truelight@0: DrawWindowWidgets(w); truelight@0: truelight@0: DrawRoadDepotSprite(70, 17, 0); truelight@0: DrawRoadDepotSprite(70, 69, 1); tron@2639: DrawRoadDepotSprite( 2, 69, 2); tron@2639: DrawRoadDepotSprite( 2, 17, 3); truelight@0: break; truelight@0: truelight@0: case WE_CLICK: { darkvater@1116: switch (e->click.widget) { darkvater@1116: case 3: case 4: case 5: case 6: truelight@0: _road_depot_orientation = e->click.widget - 3; tron@541: SndPlayFx(SND_15_BEEP); truelight@0: SetWindowDirty(w); truelight@0: break; truelight@193: } truelight@0: } break; truelight@193: truelight@0: case WE_MOUSELOOP: tron@2639: if (WP(w,def_d).close) DeleteWindow(w); truelight@0: break; celestar@1072: celestar@1072: case WE_DESTROY: tron@2639: if (!WP(w,def_d).close) ResetObjectToPlace(); celestar@1072: break; truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _build_road_depot_widgets[] = { truelight@867: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_road_depot_desc = { truelight@0: -1,-1, 140, 122, truelight@0: WC_BUILD_DEPOT,WC_BUILD_TOOLBAR, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_road_depot_widgets, truelight@0: BuildRoadDepotWndProc truelight@0: }; truelight@0: tron@1093: static void ShowRoadDepotPicker(void) truelight@0: { truelight@0: AllocateWindowDesc(&_build_road_depot_desc); truelight@0: } truelight@0: darkvater@987: static void RoadStationPickerWndProc(Window *w, WindowEvent *e) darkvater@987: { tron@2952: switch (e->event) { truelight@0: case WE_PAINT: { truelight@0: int image; truelight@0: darkvater@987: if (WP(w,def_d).close) return; darkvater@987: truelight@0: w->click_state = ((1<<3) << _road_station_picker_orientation) | truelight@0: ((1<<7) << _station_show_coverage); truelight@0: DrawWindowWidgets(w); truelight@0: darkvater@987: if (_station_show_coverage) { darkvater@987: int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4; darkvater@987: SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); darkvater@987: } else darkvater@987: SetTileSelectSize(1, 1); truelight@0: truelight@0: image = (w->window_class == WC_BUS_STATION) ? 0x47 : 0x43; truelight@0: truelight@0: StationPickerDrawSprite(103, 35, 0, image); truelight@0: StationPickerDrawSprite(103, 85, 0, image+1); truelight@0: StationPickerDrawSprite(35, 85, 0, image+2); truelight@0: StationPickerDrawSprite(35, 35, 0, image+3); truelight@0: truelight@0: DrawStringCentered(70, 120, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0); truelight@0: DrawStationCoverageAreaText(2, 146, Celestar@568: ((w->window_class == WC_BUS_STATION) ? (1<click.widget) { darkvater@1116: case 3: case 4: case 5: case 6: truelight@0: _road_station_picker_orientation = e->click.widget - 3; tron@541: SndPlayFx(SND_15_BEEP); truelight@0: SetWindowDirty(w); truelight@0: break; darkvater@1116: case 7: case 8: truelight@0: _station_show_coverage = e->click.widget - 7; tron@541: SndPlayFx(SND_15_BEEP); truelight@0: SetWindowDirty(w); truelight@0: break; truelight@0: } truelight@0: } break; truelight@193: truelight@0: case WE_MOUSELOOP: { truelight@0: if (WP(w,def_d).close) { truelight@0: DeleteWindow(w); truelight@0: return; truelight@0: } truelight@0: truelight@0: CheckRedrawStationCoverage(w); truelight@0: } break; tron@1109: celestar@1072: case WE_DESTROY: tron@2639: if (!WP(w,def_d).close) ResetObjectToPlace(); celestar@1072: break; truelight@193: } truelight@0: } truelight@0: truelight@0: static const Widget _bus_station_picker_widgets[] = { truelight@867: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_3042_BUS_STATION_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 176, 0x0, STR_NULL}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, peter1138@2725: { WWT_TEXTBTN, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF,STR_3065_DON_T_HIGHLIGHT_COVERAGE}, peter1138@2725: { WWT_TEXTBTN, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _bus_station_picker_desc = { truelight@0: -1,-1, 140, 177, truelight@0: WC_BUS_STATION,WC_BUILD_TOOLBAR, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _bus_station_picker_widgets, truelight@0: RoadStationPickerWndProc truelight@0: }; truelight@0: tron@1093: static void ShowBusStationPicker(void) truelight@0: { truelight@0: AllocateWindowDesc(&_bus_station_picker_desc); truelight@0: } truelight@0: truelight@0: static const Widget _truck_station_picker_widgets[] = { truelight@867: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_3043_TRUCK_STATION_ORIENT, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 176, 0x0, STR_NULL}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, truelight@867: { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, peter1138@2725: { WWT_TEXTBTN, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, peter1138@2725: { WWT_TEXTBTN, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _truck_station_picker_desc = { truelight@0: -1,-1, 140, 177, truelight@0: WC_TRUCK_STATION,WC_BUILD_TOOLBAR, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _truck_station_picker_widgets, truelight@0: RoadStationPickerWndProc truelight@0: }; truelight@0: tron@1093: static void ShowTruckStationPicker(void) truelight@0: { truelight@0: AllocateWindowDesc(&_truck_station_picker_desc); truelight@0: } truelight@0: tron@1093: void InitializeRoadGui(void) truelight@0: { truelight@0: _road_depot_orientation = 3; truelight@0: _road_station_picker_orientation = 3; truelight@0: }