@@ -696,68 +696,80 @@ struct BuildRoadToolbarWindow : Window {
}
void OnPlacePresize(Point pt, TileIndex tile) override
{
DoCommand(tile, _cur_roadtype | (TRANSPORT_ROAD << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
EventState OnCTRLStateChange() override
if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
return ES_NOT_HANDLED;
static HotkeyList road_hotkeys;
static HotkeyList tram_hotkeys;
};
/**
* Handler for global hotkeys of the BuildRoadToolbarWindow.
* @param hotkey Hotkey
* @param last_build Last build road type
* @return ES_HANDLED if hotkey was accepted.
*/
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build)
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
Window *w = (_game_mode == GM_NORMAL) ? ShowBuildRoadToolbar(last_build) : ShowBuildRoadScenToolbar(last_build);
Window* w = nullptr;
switch (_game_mode) {
case GM_NORMAL:
if (!CanBuildVehicleInfrastructure(VEH_ROAD, rtt)) return ES_NOT_HANDLED;
w = ShowBuildRoadToolbar(last_build);
break;
case GM_EDITOR:
if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
w = ShowBuildRoadScenToolbar(last_build);
default:
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
static EventState RoadToolbarGlobalHotkeys(int hotkey)
if (_game_mode == GM_NORMAL && !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_ROAD)) return ES_NOT_HANDLED;
extern RoadType _last_built_roadtype;
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype);
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
static EventState TramToolbarGlobalHotkeys(int hotkey)
if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_TRAM)) return ES_NOT_HANDLED;
extern RoadType _last_built_tramtype;
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype);
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
static Hotkey roadtoolbar_hotkeys[] = {
Hotkey('1', "build_x", WID_ROT_ROAD_X),
Hotkey('2', "build_y", WID_ROT_ROAD_Y),
Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
Hotkey('4', "demolish", WID_ROT_DEMOLISH),
Hotkey('5', "depot", WID_ROT_DEPOT),
Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
Hotkey('8', "oneway", WID_ROT_ONE_WAY),
Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
Hotkey('R', "remove", WID_ROT_REMOVE),
Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
HOTKEY_LIST_END
HotkeyList BuildRoadToolbarWindow::road_hotkeys("roadtoolbar", roadtoolbar_hotkeys, RoadToolbarGlobalHotkeys);
static Hotkey tramtoolbar_hotkeys[] = {
Status change: