diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 5686cebe3b..82d187b711 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -753,14 +753,35 @@ struct BuildRailToolbarWindow : Window { { MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection - if (hotkey == HOTKEY_POLYRAIL || hotkey == HOTKEY_NEW_POLYRAIL) { - /* Indicate to the OnClick that the action comes from a hotkey rather - * then from a click and that the CTRL state should be ignored. */ - this->last_user_action = hotkey; - hotkey = WID_RAT_POLYRAIL; - } + switch (hotkey) { + case HOTKEY_POLYRAIL: + case HOTKEY_NEW_POLYRAIL: + /* Indicate to the OnClick that the action comes from a hotkey rather + * then from a click and that the CTRL state should be ignored. */ + this->last_user_action = hotkey; + hotkey = WID_RAT_POLYRAIL; + return this->Window::OnHotkey(hotkey); - return this->Window::OnHotkey(hotkey); + case WID_RAT_CONVERT_RAIL: { + HandlePlacePushButton(this, WID_RAT_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT | HT_DIAGONAL); + this->last_user_action = WID_RAT_CONVERT_RAIL; + this->UpdateRemoveWidgetStatus(WID_RAT_CONVERT_RAIL); + if (_ctrl_pressed) RailToolbar_CtrlChanged(this); + return ES_HANDLED; + } + + case WID_RAT_CONVERT_RAIL_TRACK: { + bool active = HandlePlacePushButton(this, WID_RAT_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RAIL); + if (active) _thd.square_palette = SPR_ZONING_INNER_HIGHLIGHT_GREEN; + this->last_user_action = WID_RAT_CONVERT_RAIL; + this->UpdateRemoveWidgetStatus(WID_RAT_CONVERT_RAIL); + if (_ctrl_pressed) RailToolbar_CtrlChanged(this); + return ES_HANDLED; + } + + default: + return this->Window::OnHotkey(hotkey); + } } void OnPlaceObject(Point pt, TileIndex tile) override @@ -973,6 +994,7 @@ static Hotkey railtoolbar_hotkeys[] = { Hotkey('T', "tunnel", WID_RAT_BUILD_TUNNEL), Hotkey('R', "remove", WID_RAT_REMOVE), Hotkey('C', "convert", WID_RAT_CONVERT_RAIL), + Hotkey(WKC_CTRL | 'C', "convert_track", WID_RAT_CONVERT_RAIL_TRACK), HOTKEY_LIST_END }; HotkeyList BuildRailToolbarWindow::hotkeys("railtoolbar", railtoolbar_hotkeys, RailToolbarGlobalHotkeys); diff --git a/src/widgets/rail_widget.h b/src/widgets/rail_widget.h index 950c01113a..c27b130789 100644 --- a/src/widgets/rail_widget.h +++ b/src/widgets/rail_widget.h @@ -29,6 +29,7 @@ enum RailToolbarWidgets { WID_RAT_BUILD_TUNNEL, ///< Build a tunnel. WID_RAT_REMOVE, ///< Bulldozer to remove rail. WID_RAT_CONVERT_RAIL, ///< Convert other rail to this type. + WID_RAT_CONVERT_RAIL_TRACK, ///< Convert other rail to this type (track). }; /** Widgets of the #BuildRailStationWindow class. */