/* * This file is part of OpenTTD. * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. *//** @file hotkeys.h %Hotkey related functions. */#ifndef HOTKEYS_H#define HOTKEYS_H#include"gfx_type.h"#include"window_type.h"#include"string_type.h"/** * All data for a single hotkey. The name (for saving/loading a configfile), * a list of keycodes and a number to help identifying this hotkey. */structHotkey{Hotkey(uint16_tdefault_keycode,conststd::string&name,intnum);Hotkey(conststd::vector<uint16_t>&default_keycodes,conststd::string&name,intnum);voidAddKeycode(uint16_tkeycode);conststd::stringname;intnum;std::set<uint16_t>keycodes;};structIniFile;/** * List of hotkeys for a window. */structHotkeyList{typedefEventState(*GlobalHotkeyHandlerFunc)(inthotkey);HotkeyList(conststd::string&ini_group,conststd::vector<Hotkey>&items,GlobalHotkeyHandlerFuncglobal_hotkey_handler=nullptr);~HotkeyList();voidLoad(constIniFile&ini);voidSave(IniFile&ini)const;intCheckMatch(uint16_tkeycode,boolglobal_only=false)const;GlobalHotkeyHandlerFuncglobal_hotkey_handler;private:conststd::stringini_group;std::vector<Hotkey>items;/** * Dummy private copy constructor to prevent compilers from * copying the structure, which fails due to _hotkey_lists. */HotkeyList(constHotkeyList&other);};boolIsQuitKey(uint16_tkeycode);voidLoadHotkeysFromConfig();voidSaveHotkeysToConfig();voidHandleGlobalHotkeys(char32_tkey,uint16_tkeycode);#endif /* HOTKEYS_H */