diff options
author | frosch <frosch@openttd.org> | 2013-06-15 15:31:22 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-06-15 15:31:22 +0000 |
commit | fef30983e643943df24a7090a7175cfa66f3ba15 (patch) | |
tree | 5129b4c530168788d3a4ebec180d3c910c37b942 /src/airport_gui.cpp | |
parent | ee4e68bd5e4882397bc023040a2977047d22ccb7 (diff) | |
download | openttd-fef30983e643943df24a7090a7175cfa66f3ba15.tar.xz |
(svn r25414) -Codechange: Move handling of global hotkeys to HotkeyList.
Diffstat (limited to 'src/airport_gui.cpp')
-rw-r--r-- | src/airport_gui.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index e2fed7f9c..34d0ec63d 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -138,12 +138,25 @@ struct BuildAirToolbarWindow : Window { static HotkeyList hotkeys; }; +/** + * Handler for global hotkeys of the BuildAirToolbarWindow. + * @param hotkey Hotkey + * @return ES_HANDLED if hotkey was accepted. + */ +static EventState AirportToolbarGlobalHotkeys(int hotkey) +{ + if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED; + Window *w = ShowBuildAirToolbar(); + if (w == NULL) return ES_NOT_HANDLED; + return w->OnHotkey(hotkey); +} + static Hotkey airtoolbar_hotkeys[] = { Hotkey('1', "airport", WID_AT_AIRPORT), Hotkey('2', "demolish", WID_AT_DEMOLISH), HOTKEY_LIST_END }; -HotkeyList BuildAirToolbarWindow::hotkeys("airtoolbar", airtoolbar_hotkeys); +HotkeyList BuildAirToolbarWindow::hotkeys("airtoolbar", airtoolbar_hotkeys, AirportToolbarGlobalHotkeys); static const NWidgetPart _nested_air_toolbar_widgets[] = { NWidget(NWID_HORIZONTAL), @@ -181,16 +194,6 @@ Window *ShowBuildAirToolbar() return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR); } -EventState AirportToolbarGlobalHotkeys(uint16 key, uint16 keycode) -{ - if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED; - int num = BuildAirToolbarWindow::hotkeys.CheckMatch(keycode, true); - if (num == -1) return ES_NOT_HANDLED; - Window *w = ShowBuildAirToolbar(); - if (w == NULL) return ES_NOT_HANDLED; - return w->OnHotkey(num); -} - class BuildAirportWindow : public PickerWindowBase { SpriteID preview_sprite; ///< Cached airport preview sprite. int line_height; |