Fix #10117: Decrement object burst limit after build check
[openttd-github.git] / src / hotkeys.h
blob59fec345709479f517b9db1e14f41c3e7143dfd1
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file hotkeys.h %Hotkey related functions. */
10 #ifndef HOTKEYS_H
11 #define HOTKEYS_H
13 #include "core/smallvec_type.hpp"
14 #include "gfx_type.h"
15 #include "window_type.h"
16 #include "string_type.h"
18 /**
19 * All data for a single hotkey. The name (for saving/loading a configfile),
20 * a list of keycodes and a number to help identifying this hotkey.
22 struct Hotkey {
23 Hotkey(uint16 default_keycode, const char *name, int num);
24 Hotkey(const uint16 *default_keycodes, const char *name, int num);
26 void AddKeycode(uint16 keycode);
28 const char *name;
29 int num;
30 std::vector<uint16> keycodes;
33 #define HOTKEY_LIST_END Hotkey((uint16)0, nullptr, -1)
35 struct IniFile;
37 /**
38 * List of hotkeys for a window.
40 struct HotkeyList {
41 typedef EventState (*GlobalHotkeyHandlerFunc)(int hotkey);
43 HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler = nullptr);
44 ~HotkeyList();
46 void Load(IniFile *ini);
47 void Save(IniFile *ini) const;
49 int CheckMatch(uint16 keycode, bool global_only = false) const;
51 GlobalHotkeyHandlerFunc global_hotkey_handler;
52 private:
53 const char *ini_group;
54 Hotkey *items;
56 /**
57 * Dummy private copy constructor to prevent compilers from
58 * copying the structure, which fails due to _hotkey_lists.
60 HotkeyList(const HotkeyList &other);
63 bool IsQuitKey(uint16 keycode);
65 void LoadHotkeysFromConfig();
66 void SaveHotkeysToConfig();
69 void HandleGlobalHotkeys(WChar key, uint16 keycode);
71 #endif /* HOTKEYS_H */