|
OpenTTD Source 20260208-master-g43af8e94d0
|
Hotkey related functions. More...
Go to the source code of this file.
Data Structures | |
| struct | Hotkey |
| All data for a single hotkey. More... | |
| struct | HotkeyList |
| List of hotkeys for a window. More... | |
Enumerations | |
| enum class | SpecialListHotkeys : int { PreviousItem = 1 << SPECIAL_HOTKEY_BIT , NextItem , FirstItem , LastItem } |
| Indexes for special hotkeys to navigate in lists. More... | |
Functions | |
| bool | IsQuitKey (uint16_t keycode) |
| Does the given keycode match one of the keycodes bound to 'quit game'? | |
| void | LoadHotkeysFromConfig () |
| Load the hotkeys from the config file. | |
| void | SaveHotkeysToConfig () |
| Save the hotkeys to the config file. | |
| void | HandleGlobalHotkeys (char32_t key, uint16_t keycode) |
| bool | IsSpecialHotkey (const int &hotkey) |
| Checks if hotkey index is special or not. | |
| template<class ItemType, class ListType> | |
| std::tuple< size_t, size_t > | GetListIndexStep (SpecialListHotkeys hotkey, const ListType &list, const ItemType ¤t_item) |
| Gets the first index in the list for given hotkey and the step to look for another if first is invalid. | |
Variables | |
| static constexpr int | SPECIAL_HOTKEY_BIT = 30 |
| Bit which denotes that hotkey isn't bound to UI button. | |
Hotkey related functions.
Definition in file hotkeys.h.
|
strong |
Indexes for special hotkeys to navigate in lists.
Values have to have SPECIAL_HOTKEY_BIT set.
| Enumerator | |
|---|---|
| PreviousItem | Hotkey to select previous item in the list. |
| NextItem | Hotkey to select next item in the list. |
| FirstItem | Hotkey to select first item in the list. |
| LastItem | Hotkey to select last item in the list. |
| std::tuple< size_t, size_t > GetListIndexStep | ( | SpecialListHotkeys | hotkey, |
| const ListType & | list, | ||
| const ItemType & | current_item ) |
Gets the first index in the list for given hotkey and the step to look for another if first is invalid.
| ItemType | The type of items stored in the list. |
| ListType | The type of the list. For example: std::vector<ItemType>, std::list<ItemType>. |
| hotkey | The special hotkey to get the index and step for. |
| list | The list containing items. |
| current_item | The item that is currently chosen, used for next and previous hotkeys. |
Definition at line 100 of file hotkeys.h.
References FirstItem, LastItem, NextItem, and PreviousItem.
Referenced by BuildRailToolbarWindow::ChangeRailTypeOnHotkey(), and BuildRoadToolbarWindow::ChangeRoadTypeOnHotkey().
| void HandleGlobalHotkeys | ( | char32_t | key, |
| uint16_t | keycode ) |
Definition at line 343 of file hotkeys.cpp.
| bool IsQuitKey | ( | uint16_t | keycode | ) |
Does the given keycode match one of the keycodes bound to 'quit game'?
| keycode | The keycode that was pressed by the user. |
Definition at line 541 of file main_gui.cpp.
Referenced by EndGameHighScoreBaseWindow::OnKeyPress().
|
inline |
Checks if hotkey index is special or not.
| hotkey | Hotkey index to check. |
Definition at line 74 of file hotkeys.h.
References HasBit(), and SPECIAL_HOTKEY_BIT.
Referenced by BuildRailToolbarWindow::OnHotkey(), and BuildRoadToolbarWindow::OnHotkey().
| void LoadHotkeysFromConfig | ( | ) |
Load the hotkeys from the config file.
Definition at line 332 of file hotkeys.cpp.
Referenced by AfterNewGRFScan::OnNewGRFsScanned().
| void SaveHotkeysToConfig | ( | ) |
Save the hotkeys to the config file.
Definition at line 338 of file hotkeys.cpp.
|
staticconstexpr |
Bit which denotes that hotkey isn't bound to UI button.
Definition at line 67 of file hotkeys.h.
Referenced by IsSpecialHotkey().