diff options
author | alberth <alberth@openttd.org> | 2010-12-21 16:26:34 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-12-21 16:26:34 +0000 |
commit | 5a2bf89cafad925c566a67fe93ee1ed13cbc24b0 (patch) | |
tree | 7761314d5ee116018a6fdeb2cf73b48b75336475 | |
parent | adc1760b0d495547ad15f6b11a34edf8ec13e36d (diff) | |
download | openttd-5a2bf89cafad925c566a67fe93ee1ed13cbc24b0.tar.xz |
(svn r21579) -Codechange: Remove _build_air_button_proc and its functions to a switch statement, record the last started action.
-rw-r--r-- | src/airport_gui.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
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; + } } |