diff options
Diffstat (limited to 'src/dock_gui.cpp')
-rw-r--r-- | src/dock_gui.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index c25bca0e3..03c661dd0 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -269,6 +269,19 @@ struct BuildDocksToolbarWindow : Window { static HotkeyList hotkeys; }; +/** + * Handler for global hotkeys of the BuildDocksToolbarWindow. + * @param hotkey Hotkey + * @return ES_HANDLED if hotkey was accepted. + */ +static EventState DockToolbarGlobalHotkeys(int hotkey) +{ + if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED; + Window *w = ShowBuildDocksToolbar(); + if (w == NULL) return ES_NOT_HANDLED; + return w->OnHotkey(hotkey); +} + const uint16 _dockstoolbar_aqueduct_keys[] = {'B', '8', 0}; static Hotkey dockstoolbar_hotkeys[] = { @@ -282,7 +295,7 @@ static Hotkey dockstoolbar_hotkeys[] = { Hotkey(_dockstoolbar_aqueduct_keys, "aqueduct", WID_DT_BUILD_AQUEDUCT), HOTKEY_LIST_END }; -HotkeyList BuildDocksToolbarWindow::hotkeys("dockstoolbar", dockstoolbar_hotkeys); +HotkeyList BuildDocksToolbarWindow::hotkeys("dockstoolbar", dockstoolbar_hotkeys, DockToolbarGlobalHotkeys); /** * Nested widget parts of docks toolbar, game version. @@ -329,15 +342,6 @@ Window *ShowBuildDocksToolbar() return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER); } -EventState DockToolbarGlobalHotkeys(uint16 key, uint16 keycode) -{ - int num = BuildDocksToolbarWindow::hotkeys.CheckMatch(keycode, true); - if (num == -1) return ES_NOT_HANDLED; - Window *w = ShowBuildDocksToolbar(); - if (w == NULL) return ES_NOT_HANDLED; - return w->OnHotkey(num); -} - /** * Nested widget parts of docks toolbar, scenario editor version. * Positions of #WID_DT_DEPOT, #WID_DT_STATION, and #WID_DT_BUOY widgets have changed. |