OpenTTD Source 20260311-master-g511d3794ce
Hotkey Struct Reference

All data for a single hotkey. More...

#include <hotkeys.h>

Public Member Functions

 Hotkey (uint16_t default_keycode, const std::string &name, int num)
 Create a new Hotkey object with a single default keycode.
 Hotkey (const std::vector< uint16_t > &default_keycodes, const std::string &name, int num)
 Create a new Hotkey object with multiple default keycodes.
template<typename EnumType>
 Hotkey (uint16_t default_keycode, const std::string &name, EnumType num)
 Create a new Hotkey object with a single default keycode.
template<typename EnumType>
 Hotkey (const std::vector< uint16_t > &default_keycodes, const std::string &name, EnumType num)
 Create a new Hotkey object with multiple default keycodes.
void AddKeycode (uint16_t keycode)
 Add a keycode to this hotkey, from now that keycode will be matched in addition to any previously added keycodes.

Data Fields

const std::string name
int num
std::set< uint16_t > keycodes

Detailed Description

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.

Definition at line 22 of file hotkeys.h.

Constructor & Destructor Documentation

◆ Hotkey() [1/4]

Hotkey::Hotkey ( uint16_t default_keycode,
const std::string & name,
int num )

Create a new Hotkey object with a single default keycode.

Parameters
default_keycodeThe default keycode for this hotkey.
nameThe name of this hotkey.
numNumber of this hotkey, should be unique within the hotkey list.

Definition at line 221 of file hotkeys.cpp.

References AddKeycode().

Referenced by Hotkey(), and Hotkey().

◆ Hotkey() [2/4]

Hotkey::Hotkey ( const std::vector< uint16_t > & default_keycodes,
const std::string & name,
int num )

Create a new Hotkey object with multiple default keycodes.

Parameters
default_keycodesAn array of default keycodes terminated with 0.
nameThe name of this hotkey.
numNumber of this hotkey, should be unique within the hotkey list.

Definition at line 234 of file hotkeys.cpp.

References AddKeycode().

◆ Hotkey() [3/4]

template<typename EnumType>
Hotkey::Hotkey ( uint16_t default_keycode,
const std::string & name,
EnumType num )
inline

Create a new Hotkey object with a single default keycode.

Parameters
default_keycodeThe default keycode for this hotkey.
nameThe name of this hotkey.
numNumber of this hotkey, should be unique within the hotkey list.

Definition at line 28 of file hotkeys.h.

References Hotkey(), and to_underlying().

◆ Hotkey() [4/4]

template<typename EnumType>
Hotkey::Hotkey ( const std::vector< uint16_t > & default_keycodes,
const std::string & name,
EnumType num )
inline

Create a new Hotkey object with multiple default keycodes.

Parameters
default_keycodesAn array of default keycodes terminated with 0.
nameThe name of this hotkey.
numNumber of this hotkey, should be unique within the hotkey list.

Definition at line 32 of file hotkeys.h.

References Hotkey(), and to_underlying().

Member Function Documentation

◆ AddKeycode()

void Hotkey::AddKeycode ( uint16_t keycode)

Add a keycode to this hotkey, from now that keycode will be matched in addition to any previously added keycodes.

Parameters
keycodeThe keycode to add.

Definition at line 248 of file hotkeys.cpp.

Referenced by Hotkey(), Hotkey(), and ParseHotkeys().

Field Documentation

◆ keycodes

std::set<uint16_t> Hotkey::keycodes

Definition at line 38 of file hotkeys.h.

◆ name

const std::string Hotkey::name

Definition at line 36 of file hotkeys.h.

◆ num

int Hotkey::num

Definition at line 37 of file hotkeys.h.


The documentation for this struct was generated from the following files: