Codechange: Reorganise hotkey initialisation. (#10951)

Hotkeys are now initialized inline, and use std::vector instead of
separate static C-arrays and std::string instead of char *. The list end
marker is no longer required.
This commit is contained in:
PeterN
2023-06-05 18:12:30 +01:00
committed by GitHub
parent 921f5afc4d
commit f814c86389
15 changed files with 410 additions and 502 deletions

View File

@@ -1546,25 +1546,21 @@ public:
this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST);
}
static HotkeyList hotkeys;
static inline HotkeyList hotkeys{"order", {
Hotkey('D', "skip", OHK_SKIP),
Hotkey('F', "delete", OHK_DELETE),
Hotkey('G', "goto", OHK_GOTO),
Hotkey('H', "nonstop", OHK_NONSTOP),
Hotkey('J', "fullload", OHK_FULLLOAD),
Hotkey('K', "unload", OHK_UNLOAD),
Hotkey(0, "nearest_depot", OHK_NEAREST_DEPOT),
Hotkey(0, "always_service", OHK_ALWAYS_SERVICE),
Hotkey(0, "transfer", OHK_TRANSFER),
Hotkey(0, "no_unload", OHK_NO_UNLOAD),
Hotkey(0, "no_load", OHK_NO_LOAD),
}};
};
static Hotkey order_hotkeys[] = {
Hotkey('D', "skip", OHK_SKIP),
Hotkey('F', "delete", OHK_DELETE),
Hotkey('G', "goto", OHK_GOTO),
Hotkey('H', "nonstop", OHK_NONSTOP),
Hotkey('J', "fullload", OHK_FULLLOAD),
Hotkey('K', "unload", OHK_UNLOAD),
Hotkey((uint16)0, "nearest_depot", OHK_NEAREST_DEPOT),
Hotkey((uint16)0, "always_service", OHK_ALWAYS_SERVICE),
Hotkey((uint16)0, "transfer", OHK_TRANSFER),
Hotkey((uint16)0, "no_unload", OHK_NO_UNLOAD),
Hotkey((uint16)0, "no_load", OHK_NO_LOAD),
HOTKEY_LIST_END
};
HotkeyList OrdersWindow::hotkeys("order", order_hotkeys);
/** Nested widget definition for "your" train orders. */
static const NWidgetPart _nested_orders_train_widgets[] = {
NWidget(NWID_HORIZONTAL),