src/road_gui.cpp
changeset 6691 f9adbb0be102
parent 6678 4d901bc54b74
child 6693 00bef74e4d3a
equal deleted inserted replaced
6690:de0a758369eb 6691:f9adbb0be102
    92 		{ STR_CAN_T_REMOVE_BUS_STATION,     STR_CAN_T_REMOVE_TRUCK_STATION     },
    92 		{ STR_CAN_T_REMOVE_BUS_STATION,     STR_CAN_T_REMOVE_TRUCK_STATION     },
    93 
    93 
    94 		SPR_CURSOR_ROAD_NESW,
    94 		SPR_CURSOR_ROAD_NESW,
    95 		SPR_CURSOR_ROAD_NWSE,
    95 		SPR_CURSOR_ROAD_NWSE,
    96 	},
    96 	},
       
    97 	{
       
    98 		STR_1804_CAN_T_BUILD_TRAMWAY_HERE,
       
    99 		STR_1805_CAN_T_REMOVE_TRAMWAY_FROM,
       
   100 		STR_1807_CAN_T_BUILD_TRAM_VEHICLE,
       
   101 		{ STR_1808_CAN_T_BUILD_PASSENGER_TRAM_STATION, STR_1809_CAN_T_BUILD_CARGO_TRAM_STATION },
       
   102 		{ STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION,     STR_CAN_T_REMOVE_CARGO_TRAM_STATION     },
       
   103 
       
   104 		SPR_CURSOR_TRAMWAY_NESW,
       
   105 		SPR_CURSOR_TRAMWAY_NWSE,
       
   106 	},
    97 };
   107 };
    98 
   108 
    99 static void PlaceRoad_Tunnel(TileIndex tile)
   109 static void PlaceRoad_Tunnel(TileIndex tile)
   100 {
   110 {
   101 	DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
   111 	DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
   373 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   383 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   374 	_build_road_widgets,
   384 	_build_road_widgets,
   375 	BuildRoadToolbWndProc
   385 	BuildRoadToolbWndProc
   376 };
   386 };
   377 
   387 
       
   388 static const Widget _build_tramway_widgets[] = {
       
   389 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
       
   390 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   205,     0,    13, STR_1802_TRAMWAY_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
       
   391 {  WWT_STICKYBOX,   RESIZE_NONE,     7,   206,   217,     0,    13, 0x0,                        STR_STICKY_BUTTON},
       
   392 
       
   393 {     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_TRAMWAY_NW,         STR_180B_BUILD_TRAMWAY_SECTION},
       
   394 {     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_TRAMWAY_NE,         STR_180B_BUILD_TRAMWAY_SECTION},
       
   395 {     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},
       
   396 {     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_ROAD_DEPOT,         STR_180C_BUILD_TRAM_VEHICLE_DEPOT},
       
   397 {     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   109,    14,    35, SPR_IMG_BUS_STATION,        STR_180D_BUILD_PASSENGER_TRAM_STATION},
       
   398 {     WWT_IMGBTN,   RESIZE_NONE,     7,   110,   131,    14,    35, SPR_IMG_TRUCK_BAY,          STR_180E_BUILD_CARGO_TRAM_STATION},
       
   399 
       
   400 {     WWT_IMGBTN,   RESIZE_NONE,     7,   132,   173,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_TRAMWAY_BRIDGE},
       
   401 {     WWT_IMGBTN,   RESIZE_NONE,     7,   174,   195,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_TRAMWAY_TUNNEL},
       
   402 {     WWT_IMGBTN,   RESIZE_NONE,     7,   196,   217,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS},
       
   403 {   WIDGETS_END},
       
   404 };
       
   405 
       
   406 static const WindowDesc _build_tramway_desc = {
       
   407 	WDP_ALIGN_TBR, 22, 218, 36,
       
   408 	WC_BUILD_TOOLBAR, WC_NONE,
       
   409 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
       
   410 	_build_tramway_widgets,
       
   411 	BuildRoadToolbWndProc
       
   412 };
       
   413 
   378 void ShowBuildRoadToolbar(RoadType roadtype)
   414 void ShowBuildRoadToolbar(RoadType roadtype)
   379 {
   415 {
   380 	if (!IsValidPlayer(_current_player)) return;
   416 	if (!IsValidPlayer(_current_player)) return;
   381 	_cur_roadtype = roadtype;
   417 	_cur_roadtype = roadtype;
   382 
   418 
   383 	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
   419 	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
   384 	Window *w = AllocateWindowDesc(&_build_road_desc);
   420 	Window *w = AllocateWindowDesc(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc);
   385 	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
   421 	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
   386 }
   422 }
   387 
   423 
   388 static const Widget _build_road_scen_widgets[] = {
   424 static const Widget _build_road_scen_widgets[] = {
   389 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
   425 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
   460 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
   496 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
   461 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
   497 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
   462 {   WIDGETS_END},
   498 {   WIDGETS_END},
   463 };
   499 };
   464 
   500 
       
   501 static const Widget _build_tram_depot_widgets[] = {
       
   502 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
       
   503 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_TRAM_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
       
   504 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},
       
   505 {      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
       
   506 {      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
       
   507 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
       
   508 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
       
   509 {   WIDGETS_END},
       
   510 };
       
   511 
   465 static const WindowDesc _build_road_depot_desc = {
   512 static const WindowDesc _build_road_depot_desc = {
   466 	WDP_AUTO, WDP_AUTO, 140, 122,
   513 	WDP_AUTO, WDP_AUTO, 140, 122,
   467 	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
   514 	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
   468 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   515 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   469 	_build_road_depot_widgets,
   516 	_build_road_depot_widgets,
   470 	BuildRoadDepotWndProc
   517 	BuildRoadDepotWndProc
   471 };
   518 };
   472 
   519 
       
   520 static const WindowDesc _build_tram_depot_desc = {
       
   521 	WDP_AUTO, WDP_AUTO, 140, 122,
       
   522 	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
       
   523 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
       
   524 	_build_tram_depot_widgets,
       
   525 	BuildRoadDepotWndProc
       
   526 };
       
   527 
   473 static void ShowRoadDepotPicker()
   528 static void ShowRoadDepotPicker()
   474 {
   529 {
   475 	AllocateWindowDesc(&_build_road_depot_desc);
   530 	AllocateWindowDesc(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
   476 }
   531 }
   477 
   532 
   478 static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
   533 static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
   479 {
   534 {
   480 	switch (e->event) {
   535 	switch (e->event) {
   579 	RoadStationPickerWndProc
   634 	RoadStationPickerWndProc
   580 };
   635 };
   581 
   636 
   582 static void ShowBusStationPicker()
   637 static void ShowBusStationPicker()
   583 {
   638 {
   584 	AllocateWindowDesc(&_bus_station_picker_desc);
   639 	Window *w = AllocateWindowDesc(&_bus_station_picker_desc);
       
   640 	if (w != NULL) w->widget[1].data = (_cur_roadtype == ROADTYPE_ROAD) ? STR_3042_BUS_STATION_ORIENTATION : STR_3042_PASSENGER_TRAM_STATION_ORIENTATION;
   585 }
   641 }
   586 
   642 
   587 static const Widget _truck_station_picker_widgets[] = {
   643 static const Widget _truck_station_picker_widgets[] = {
   588 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
   644 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
   589 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_3043_TRUCK_STATION_ORIENT,    STR_018C_WINDOW_TITLE_DRAG_THIS},
   645 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_3043_TRUCK_STATION_ORIENT,    STR_018C_WINDOW_TITLE_DRAG_THIS},
   608 	RoadStationPickerWndProc
   664 	RoadStationPickerWndProc
   609 };
   665 };
   610 
   666 
   611 static void ShowTruckStationPicker()
   667 static void ShowTruckStationPicker()
   612 {
   668 {
   613 	AllocateWindowDesc(&_truck_station_picker_desc);
   669 	Window *w = AllocateWindowDesc(&_truck_station_picker_desc);
       
   670 	if (w != NULL) w->widget[1].data = (_cur_roadtype == ROADTYPE_ROAD) ? STR_3043_TRUCK_STATION_ORIENT : STR_3043_CARGO_TRAM_STATION_ORIENT;
   614 }
   671 }
   615 
   672 
   616 void InitializeRoadGui()
   673 void InitializeRoadGui()
   617 {
   674 {
   618 	_road_depot_orientation = DIAGDIR_NW;
   675 	_road_depot_orientation = DIAGDIR_NW;