From 44bea540bef45734e17fc872b2714c3eef51b969 Mon Sep 17 00:00:00 2001 From: pelya Date: Tue, 17 May 2016 13:48:18 +0300 Subject: [PATCH] Fixed remove and one-way buttons for road and rail, broken by confirmation UI --- src/rail_gui.cpp | 4 ++++ src/road_gui.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 10869fbbd2..69e079fca4 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -397,6 +397,7 @@ static void HandleAutoSignalPlacement() struct BuildRailToolbarWindow : Window { RailType railtype; ///< Rail type to build. int last_user_action; ///< Last started user action. + bool last_user_action_remove; ///< Use bulldozer button with last action BuildRailToolbarWindow(WindowDesc *desc, RailType railtype) : Window(desc) { @@ -404,6 +405,7 @@ struct BuildRailToolbarWindow : Window { this->SetupRailToolbar(railtype); this->DisableWidget(WID_RAT_REMOVE); this->last_user_action = WIDGET_LIST_END; + this->last_user_action_remove = false; if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); } @@ -677,6 +679,7 @@ struct BuildRailToolbarWindow : Window { virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) { if (pt.x != -1) { + this->last_user_action_remove = _remove_button_clicked; switch (select_proc) { default: NOT_REACHED(); case DDSP_PLACE_AUTOROAD: @@ -783,6 +786,7 @@ struct BuildRailToolbarWindow : Window { Point dummy = {0, 0}; this->RaiseWidget(this->last_user_action); this->OnClick(dummy, this->last_user_action, 0); + if (this->last_user_action_remove) BuildRailClick_Remove(this); } virtual void OnPlacePresize(Point pt, TileIndex tile_from) diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 0ee5ee4d7b..80c6b34428 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -298,6 +298,8 @@ static bool RoadToolbar_CtrlChanged(Window *w) /** Road toolbar window handler. */ struct BuildRoadToolbarWindow : Window { int last_started_action; ///< Last started user action. + bool last_started_action_remove; ///< Use bulldozer button with last action + bool last_started_action_oneway; ///< Use 'one way road' button with last action BuildRoadToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { @@ -309,6 +311,8 @@ struct BuildRoadToolbarWindow : Window { this->OnInvalidateData(); this->last_started_action = WIDGET_LIST_END; + this->last_started_action_remove = false; + this->last_started_action_oneway = false; if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); } @@ -557,6 +561,9 @@ struct BuildRoadToolbarWindow : Window { Point dummy = {0, 0}; this->RaiseWidget(this->last_started_action); this->OnClick(dummy, this->last_started_action, 0); + if (this->last_started_action_remove) ToggleRoadButton_Remove(this); + if (this->last_started_action_oneway) this->LowerWidget(WID_ROT_ONE_WAY); + _one_way_button_clicked = this->last_started_action_oneway; } virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) @@ -609,6 +616,8 @@ struct BuildRoadToolbarWindow : Window { virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) { if (pt.x != -1) { + this->last_started_action_remove = _remove_button_clicked; + this->last_started_action_oneway = _one_way_button_clicked; switch (select_proc) { default: NOT_REACHED(); case DDSP_BUILD_BRIDGE: