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

@@ -338,27 +338,23 @@ struct SignListWindow : Window, SignList {
}
}
static HotkeyList hotkeys;
};
/**
* Handler for global hotkeys of the SignListWindow.
* @param hotkey Hotkey
* @return ES_HANDLED if hotkey was accepted.
*/
static EventState SignListGlobalHotkeys(int hotkey)
{
if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
Window *w = ShowSignList();
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
}
/**
* Handler for global hotkeys of the SignListWindow.
* @param hotkey Hotkey
* @return ES_HANDLED if hotkey was accepted.
*/
static EventState SignListGlobalHotkeys(int hotkey)
{
if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
Window *w = ShowSignList();
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
}
static Hotkey signlist_hotkeys[] = {
Hotkey('F', "focus_filter_box", SLHK_FOCUS_FILTER_BOX),
HOTKEY_LIST_END
static inline HotkeyList hotkeys{"signlist", {
Hotkey('F', "focus_filter_box", SLHK_FOCUS_FILTER_BOX),
}, SignListGlobalHotkeys};
};
HotkeyList SignListWindow::hotkeys("signlist", signlist_hotkeys, SignListGlobalHotkeys);
static const NWidgetPart _nested_sign_list_widgets[] = {
NWidget(NWID_HORIZONTAL),