DDraceNetwork Docs
binds.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_BINDS_H
4#define GAME_CLIENT_COMPONENTS_BINDS_H
5
6#include <engine/console.h>
7#include <engine/keys.h>
8
10
11#include <vector>
12
13class IConfigManager;
14
15class CBinds : public CComponent
16{
17 static void ConBind(IConsole::IResult *pResult, void *pUserData);
18 static void ConBinds(IConsole::IResult *pResult, void *pUserData);
19 static void ConUnbind(IConsole::IResult *pResult, void *pUserData);
20 static void ConUnbindAll(IConsole::IResult *pResult, void *pUserData);
21 class IConsole *GetConsole() const { return Console(); }
22
23 static void ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData);
24
26 {
27 public:
28 int m_Key;
30
31 CBindSlot(int Key, int ModifierMask) :
32 m_Key(Key),
33 m_ModifierMask(ModifierMask)
34 {
35 }
36 };
37 CBindSlot GetBindSlot(const char *pBindString) const;
38
39public:
40 CBinds();
41 ~CBinds();
42 virtual int Sizeof() const override { return sizeof(*this); }
43
45 {
46 public:
48 virtual int Sizeof() const override { return sizeof(*this); }
49 virtual bool OnInput(const IInput::CEvent &Event) override;
50 };
51
53
54 enum
55 {
63 };
64
66
67 void Bind(int KeyId, const char *pStr, bool FreeOnly = false, int ModifierCombination = MODIFIER_NONE);
68 void SetDefaults();
69 void UnbindAll();
70 const char *Get(int KeyId, int ModifierCombination);
71 void GetKey(const char *pBindStr, char *pBuf, size_t BufSize);
72 static int GetModifierMask(IInput *pInput);
73 static int GetModifierMaskOfKey(int Key);
74 static const char *GetModifierName(int Modifier);
75 static void GetKeyBindModifiersName(int ModifierCombination, char *pBuf, size_t BufSize);
76
77 virtual void OnConsoleInit() override;
78 virtual bool OnInput(const IInput::CEvent &Event) override;
79
80 // DDRace
81
82 void SetDDRaceBinds(bool FreeOnly);
83
84private:
86 std::vector<CBindSlot> m_vActiveBinds;
87};
88#endif
Definition: binds.h:26
CBindSlot(int Key, int ModifierMask)
Definition: binds.h:31
int m_Key
Definition: binds.h:28
int m_ModifierMask
Definition: binds.h:29
Definition: binds.h:45
virtual int Sizeof() const override
Definition: binds.h:48
virtual bool OnInput(const IInput::CEvent &Event) override
Definition: binds.cpp:14
CBinds * m_pBinds
Definition: binds.h:47
Definition: binds.h:16
bool m_MouseOnAction
Definition: binds.h:52
void Bind(int KeyId, const char *pStr, bool FreeOnly=false, int ModifierCombination=MODIFIER_NONE)
Definition: binds.cpp:41
~CBinds()
Definition: binds.cpp:36
static void ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)
Definition: binds.cpp:473
const char * Get(int KeyId, int ModifierCombination)
Definition: binds.cpp:231
CBindSlot GetBindSlot(const char *pBindString) const
Definition: binds.cpp:415
virtual bool OnInput(const IInput::CEvent &Event) override
Definition: binds.cpp:114
static int GetModifierMask(IInput *pInput)
Definition: binds.cpp:69
static const char * GetModifierName(int Modifier)
Definition: binds.cpp:442
virtual void OnConsoleInit() override
Definition: binds.cpp:307
static void ConUnbindAll(IConsole::IResult *pResult, void *pUserData)
Definition: binds.cpp:409
void SetDefaults()
Definition: binds.cpp:260
static void ConBind(IConsole::IResult *pResult, void *pUserData)
Definition: binds.cpp:319
void GetKey(const char *pBindStr, char *pBuf, size_t BufSize)
Definition: binds.cpp:238
void UnbindAll()
Definition: binds.cpp:219
char * m_aapKeyBindings[MODIFIER_COMBINATION_COUNT][KEY_LAST]
Definition: binds.h:85
static int GetModifierMaskOfKey(int Key)
Definition: binds.cpp:93
class IConsole * GetConsole() const
Definition: binds.h:21
static void GetKeyBindModifiersName(int ModifierCombination, char *pBuf, size_t BufSize)
Definition: binds.cpp:460
virtual int Sizeof() const override
Definition: binds.h:42
CBindsSpecial m_SpecialBinds
Definition: binds.h:65
void SetDDRaceBinds(bool FreeOnly)
Definition: binds.cpp:506
@ MODIFIER_COMBINATION_COUNT
Definition: binds.h:62
@ MODIFIER_CTRL
Definition: binds.h:57
@ MODIFIER_GUI
Definition: binds.h:60
@ MODIFIER_SHIFT
Definition: binds.h:59
@ MODIFIER_ALT
Definition: binds.h:58
@ MODIFIER_COUNT
Definition: binds.h:61
@ MODIFIER_NONE
Definition: binds.h:56
static void ConBinds(IConsole::IResult *pResult, void *pUserData)
Definition: binds.cpp:350
static void ConUnbind(IConsole::IResult *pResult, void *pUserData)
Definition: binds.cpp:392
CBinds()
Definition: binds.cpp:30
std::vector< CBindSlot > m_vActiveBinds
Definition: binds.h:86
Definition: component.h:20
class IConsole * Console() const
Definition: component.cpp:18
Definition: config.h:9
Definition: console.h:45
Definition: console.h:18
Definition: input.h:24
Definition: input.h:20
@ KEY_LAST
Definition: keys.h:319