From 5a2bf89cafad925c566a67fe93ee1ed13cbc24b0 Mon Sep 17 00:00:00 2001 From: alberth Date: Tue, 21 Dec 2010 16:26:34 +0000 Subject: (svn r21579) -Codechange: Remove _build_air_button_proc and its functions to a switch statement, record the last started action. --- src/airport_gui.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index a59cd4b1b..a85944c13 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -65,28 +65,15 @@ enum AirportToolbarWidgets { }; -static void BuildAirClick_Airport(Window *w) -{ - if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT, PlaceAirport)) ShowBuildAirportPicker(w); -} - -static void BuildAirClick_Demolish(Window *w) -{ - HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea); -} - - -typedef void OnButtonClick(Window *w); -static OnButtonClick * const _build_air_button_proc[] = { - BuildAirClick_Airport, - BuildAirClick_Demolish, -}; - +/** Airport build toolbar window handler. */ struct BuildAirToolbarWindow : Window { + int last_user_action; // Last started user action. + BuildAirToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window() { this->InitNested(desc, window_number); if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); + this->last_user_action = WIDGET_LIST_END; } ~BuildAirToolbarWindow() @@ -96,9 +83,21 @@ struct BuildAirToolbarWindow : Window { virtual void OnClick(Point pt, int widget, int click_count) { - if (!IsInsideBS(widget, ATW_AIRPORT, lengthof(_build_air_button_proc))) return; + switch (widget) { + case ATW_AIRPORT: + if (HandlePlacePushButton(this, ATW_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT, PlaceAirport)) { + ShowBuildAirportPicker(this); + this->last_user_action = widget; + } + break; - _build_air_button_proc[widget - ATW_AIRPORT](this); + case ATW_DEMOLISH: + HandlePlacePushButton(this, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea); + this->last_user_action = widget; + break; + + default: break; + } } -- cgit v1.2.3-70-g09d2