diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hotkeys.cpp | 2 | ||||
-rw-r--r-- | src/order_gui.cpp | 31 |
2 files changed, 17 insertions, 16 deletions
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index e130dd928..b67ff83ff 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -229,6 +229,7 @@ void SaveLoadHotkeyGroup(IniGroup *group, T *hotkey_list, bool save) struct TerraformToolbarWindow; struct ScenarioEditorLandscapeGenerationWindow; +struct OrdersWindow; static void SaveLoadHotkeys(bool save) { @@ -244,6 +245,7 @@ static void SaveLoadHotkeys(bool save) SL_HOTKEYS(terraform, TerraformToolbarWindow); SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow); + SL_HOTKEYS(order, OrdersWindow); #undef SL_HOTKEYS diff --git a/src/order_gui.cpp b/src/order_gui.cpp index ffa009257..4f23a7140 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -29,6 +29,7 @@ #include "station_base.h" #include "waypoint_base.h" #include "core/geometry_func.hpp" +#include "hotkeys.h" #include "table/sprites.h" #include "table/strings.h" @@ -1222,25 +1223,10 @@ public: virtual EventState OnKeyPress(uint16 key, uint16 keycode) { - static const KeyToEvent keytoevent[] = { - {'D', &OrdersWindow::OrderClick_Skip}, - {'F', &OrdersWindow::OrderClick_Delete}, - {'G', &OrdersWindow::OrderClick_Goto}, - {'H', &OrdersWindow::OrderClick_Nonstop}, - {'J', &OrdersWindow::OrderClick_FullLoad}, - {'K', &OrdersWindow::OrderClick_Unload}, - //('?', &OrdersWindow::OrderClick_Service}, - }; if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED; - for (uint i = 0; i < lengthof(keytoevent); i++) { - if (keycode == keytoevent[i].keycode) { - (this->*(keytoevent[i].proc))(-1); - return ES_HANDLED; - } - } - return ES_NOT_HANDLED; + return CheckHotkeyMatch<OrdersWindow>(order_hotkeys, keycode, this) != -1 ? ES_HANDLED : ES_NOT_HANDLED; } virtual void OnPlaceObject(Point pt, TileIndex tile) @@ -1344,7 +1330,20 @@ public: } } } + + static Hotkey<OrdersWindow> order_hotkeys[]; +}; + +Hotkey<OrdersWindow> OrdersWindow::order_hotkeys[]= { + Hotkey<OrdersWindow>('D', "skip", 0, &OrdersWindow::OrderClick_Skip), + Hotkey<OrdersWindow>('F', "delete", 0, &OrdersWindow::OrderClick_Delete), + Hotkey<OrdersWindow>('G', "goto", 0, &OrdersWindow::OrderClick_Goto), + Hotkey<OrdersWindow>('H', "nonstop", 0, &OrdersWindow::OrderClick_Nonstop), + Hotkey<OrdersWindow>('J', "fullload", 0, &OrdersWindow::OrderClick_FullLoad), + Hotkey<OrdersWindow>('K', "unload", 0, &OrdersWindow::OrderClick_Unload), + HOTKEY_LIST_END(OrdersWindow) }; +Hotkey<OrdersWindow> *_order_hotkeys = OrdersWindow::order_hotkeys; /** Nested widget definition for "your" train orders. */ static const NWidgetPart _nested_orders_train_widgets[] = { |