src/road_gui.cpp
changeset 8785 871586967963
parent 8692 632cf5d186f8
child 8821 1411d08e26b3
equal deleted inserted replaced
8784:c2e9d649a9ce 8785:871586967963
    14 #include "variables.h"
    14 #include "variables.h"
    15 #include "road_type.h"
    15 #include "road_type.h"
    16 #include "road_cmd.h"
    16 #include "road_cmd.h"
    17 #include "road_map.h"
    17 #include "road_map.h"
    18 #include "station_map.h"
    18 #include "station_map.h"
    19 #include "station.h"
       
    20 #include "functions.h"
    19 #include "functions.h"
    21 #include "window_func.h"
    20 #include "window_func.h"
    22 #include "vehicle_func.h"
    21 #include "vehicle_func.h"
    23 #include "sound_func.h"
    22 #include "sound_func.h"
    24 #include "player_func.h"
    23 #include "player_func.h"
    25 #include "settings_type.h"
    24 #include "settings_type.h"
    26 
    25 
    27 #include "table/sprites.h"
    26 #include "table/sprites.h"
    28 #include "table/strings.h"
    27 #include "table/strings.h"
    29 
    28 
    30 static void ShowRVStationPicker(RoadStop::Type rs);
    29 static void ShowRVStationPicker(RoadStopType rs);
    31 static void ShowRoadDepotPicker();
    30 static void ShowRoadDepotPicker();
    32 
    31 
    33 static bool _remove_button_clicked;
    32 static bool _remove_button_clicked;
    34 static bool _one_way_button_clicked;
    33 static bool _one_way_button_clicked;
    35 
    34 
   213 }
   212 }
   214 
   213 
   215 static void PlaceRoad_BusStation(TileIndex tile)
   214 static void PlaceRoad_BusStation(TileIndex tile)
   216 {
   215 {
   217 	if (_remove_button_clicked) {
   216 	if (_remove_button_clicked) {
   218 		DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::BUS]));
   217 		DoCommandP(tile, 0, ROADSTOP_BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]));
   219 	} else {
   218 	} else {
   220 		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::BUS]));
   219 		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS]));
   221 	}
   220 	}
   222 }
   221 }
   223 
   222 
   224 static void PlaceRoad_TruckStation(TileIndex tile)
   223 static void PlaceRoad_TruckStation(TileIndex tile)
   225 {
   224 {
   226 	if (_remove_button_clicked) {
   225 	if (_remove_button_clicked) {
   227 		DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::TRUCK]));
   226 		DoCommandP(tile, 0, ROADSTOP_TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]));
   228 	} else {
   227 	} else {
   229 		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::TRUCK]));
   228 		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK]));
   230 	}
   229 	}
   231 }
   230 }
   232 
   231 
   233 static void PlaceRoad_DemolishArea(TileIndex tile)
   232 static void PlaceRoad_DemolishArea(TileIndex tile)
   234 {
   233 {
   332 }
   331 }
   333 
   332 
   334 static void BuildRoadClick_BusStation(Window *w)
   333 static void BuildRoadClick_BusStation(Window *w)
   335 {
   334 {
   336 	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
   335 	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
   337 	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(RoadStop::BUS);
   336 	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(ROADSTOP_BUS);
   338 }
   337 }
   339 
   338 
   340 static void BuildRoadClick_TruckStation(Window *w)
   339 static void BuildRoadClick_TruckStation(Window *w)
   341 {
   340 {
   342 	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
   341 	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
   343 	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(RoadStop::TRUCK);
   342 	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(ROADSTOP_TRUCK);
   344 }
   343 }
   345 
   344 
   346 /**
   345 /**
   347  * Function that handles the click on the
   346  * Function that handles the click on the
   348  *  one way road button.
   347  *  one way road button.
   940 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   939 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   941 	_rv_station_picker_widgets,
   940 	_rv_station_picker_widgets,
   942 	RoadStationPickerWndProc
   941 	RoadStationPickerWndProc
   943 };
   942 };
   944 
   943 
   945 static void ShowRVStationPicker(RoadStop::Type rs)
   944 static void ShowRVStationPicker(RoadStopType rs)
   946 {
   945 {
   947 	Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
   946 	Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
   948 	if (w == NULL) return;
   947 	if (w == NULL) return;
   949 
   948 
   950 	w->window_class = (rs == RoadStop::BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
   949 	w->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
   951 	w->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
   950 	w->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
   952 	for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
   951 	for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
   953 }
   952 }
   954 
   953 
   955 void InitializeRoadGui()
   954 void InitializeRoadGui()