mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Clean up key binding a bit
This commit is contained in:
parent
f352daf00d
commit
35befec54c
|
@ -33,11 +33,14 @@ CBinds::~CBinds()
|
|||
mem_free(m_apKeyBindings[i]);
|
||||
}
|
||||
|
||||
void CBinds::Bind(int KeyID, const char *pStr)
|
||||
void CBinds::Bind(int KeyID, const char *pStr, bool FreeOnly)
|
||||
{
|
||||
if(KeyID < 0 || KeyID >= KEY_LAST)
|
||||
return;
|
||||
|
||||
if(FreeOnly && Get(KeyID)[0])
|
||||
return;
|
||||
|
||||
if(m_apKeyBindings[KeyID])
|
||||
{
|
||||
mem_free(m_apKeyBindings[KeyID]);
|
||||
|
@ -121,8 +124,8 @@ void CBinds::SetDefaults()
|
|||
Bind(KEY_BACKQUOTE, "+statboard");
|
||||
Bind(KEY_F10, "screenshot");
|
||||
|
||||
Bind('a', "+left");
|
||||
Bind('d', "+right");
|
||||
Bind(KEY_A, "+left");
|
||||
Bind(KEY_D, "+right");
|
||||
|
||||
Bind(KEY_SPACE, "+jump");
|
||||
Bind(KEY_MOUSE_1, "+fire");
|
||||
|
@ -147,27 +150,27 @@ void CBinds::SetDefaults()
|
|||
#endif
|
||||
|
||||
|
||||
Bind('1', "+weapon1");
|
||||
Bind('2', "+weapon2");
|
||||
Bind('3', "+weapon3");
|
||||
Bind('4', "+weapon4");
|
||||
Bind('5', "+weapon5");
|
||||
Bind(KEY_1, "+weapon1");
|
||||
Bind(KEY_2, "+weapon2");
|
||||
Bind(KEY_3, "+weapon3");
|
||||
Bind(KEY_4, "+weapon4");
|
||||
Bind(KEY_5, "+weapon5");
|
||||
|
||||
Bind(KEY_MOUSE_WHEEL_UP, "+prevweapon");
|
||||
Bind(KEY_MOUSE_WHEEL_DOWN, "+nextweapon");
|
||||
|
||||
Bind('t', "+show_chat; chat all");
|
||||
Bind('y', "+show_chat; chat team");
|
||||
Bind('z', "+show_chat; chat team"); // For German keyboards
|
||||
Bind('u', "+show_chat");
|
||||
Bind('i', "+show_chat; chat all /c ");
|
||||
Bind(KEY_T, "+show_chat; chat all");
|
||||
Bind(KEY_Y, "+show_chat; chat team");
|
||||
Bind(KEY_Z, "+show_chat; chat team"); // For German keyboards
|
||||
Bind(KEY_U, "+show_chat");
|
||||
Bind(KEY_I, "+show_chat; chat all /c ");
|
||||
|
||||
Bind(KEY_F3, "vote yes");
|
||||
Bind(KEY_F4, "vote no");
|
||||
|
||||
Bind('k', "kill");
|
||||
Bind('q', "say /pause");
|
||||
Bind('p', "say /pause");
|
||||
Bind(KEY_K, "kill");
|
||||
Bind(KEY_Q, "say /pause");
|
||||
Bind(KEY_P, "say /pause");
|
||||
|
||||
// DDRace
|
||||
|
||||
|
@ -314,101 +317,37 @@ void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData)
|
|||
|
||||
void CBinds::SetDDRaceBinds(bool FreeOnly)
|
||||
{
|
||||
if(!FreeOnly)
|
||||
{
|
||||
Bind(KEY_KP_PLUS, "zoom+");
|
||||
Bind(KEY_KP_MINUS, "zoom-");
|
||||
Bind(KEY_KP_MULTIPLY, "zoom");
|
||||
Bind(KEY_HOME, "kill");
|
||||
Bind(KEY_PAUSE, "say /pause");
|
||||
Bind(KEY_UP, "+jump");
|
||||
Bind(KEY_LEFT, "+left");
|
||||
Bind(KEY_RIGHT, "+right");
|
||||
Bind('[', "+prevweapon");
|
||||
Bind(']', "+nextweapon");
|
||||
Bind('c', "say /rank");
|
||||
Bind('v', "say /info");
|
||||
Bind('b', "say /top5");
|
||||
Bind('x', "emote 14");
|
||||
Bind('h', "emote 2");
|
||||
Bind('m', "emote 5");
|
||||
Bind('s', "+showhookcoll");
|
||||
Bind('x', "toggle cl_dummy 0 1");
|
||||
Bind(KEY_KP_PLUS, "zoom+", FreeOnly);
|
||||
Bind(KEY_KP_MINUS, "zoom-", FreeOnly);
|
||||
Bind(KEY_KP_MULTIPLY, "zoom", FreeOnly);
|
||||
Bind(KEY_HOME, "kill", FreeOnly);
|
||||
Bind(KEY_PAUSE, "say /pause", FreeOnly);
|
||||
Bind(KEY_UP, "+jump", FreeOnly);
|
||||
Bind(KEY_LEFT, "+left", FreeOnly);
|
||||
Bind(KEY_RIGHT, "+right", FreeOnly);
|
||||
Bind(KEY_LEFTBRACKET, "+prevweapon", FreeOnly);
|
||||
Bind(KEY_RIGHTBRACKET, "+nextweapon", FreeOnly);
|
||||
Bind(KEY_C, "say /rank", FreeOnly);
|
||||
Bind(KEY_V, "say /info", FreeOnly);
|
||||
Bind(KEY_B, "say /top5", FreeOnly);
|
||||
Bind(KEY_X, "emote 14", FreeOnly);
|
||||
Bind(KEY_H, "emote 2", FreeOnly);
|
||||
Bind(KEY_M, "emote 5", FreeOnly);
|
||||
Bind(KEY_S, "+showhookcoll", FreeOnly);
|
||||
Bind(KEY_X, "toggle cl_dummy 0 1", FreeOnly);
|
||||
#if !defined(__ANDROID__)
|
||||
Bind(KEY_PAGEDOWN, "toggle cl_show_quads 0 1");
|
||||
Bind(KEY_PAGEUP, "toggle cl_overlay_entities 0 100");
|
||||
Bind(KEY_PAGEDOWN, "toggle cl_show_quads 0 1", FreeOnly);
|
||||
Bind(KEY_PAGEUP, "toggle cl_overlay_entities 0 100", FreeOnly);
|
||||
#endif
|
||||
Bind(KEY_KP_0, "say /emote normal 999999");
|
||||
Bind(KEY_KP_1, "say /emote happy 999999");
|
||||
Bind(KEY_KP_2, "say /emote angry 999999");
|
||||
Bind(KEY_KP_3, "say /emote pain 999999");
|
||||
Bind(KEY_KP_4, "say /emote surprise 999999");
|
||||
Bind(KEY_KP_5, "say /emote blink 999999");
|
||||
Bind(KEY_MOUSE_3, "+spectate");
|
||||
Bind(KEY_MINUS, "spectate_previous");
|
||||
Bind(KEY_EQUALS, "spectate_next");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!Get(KEY_KP_PLUS)[0])
|
||||
Bind(KEY_KP_PLUS, "zoom+");
|
||||
if(!Get(KEY_KP_MINUS)[0])
|
||||
Bind(KEY_KP_MINUS, "zoom-");
|
||||
if(!Get(KEY_KP_MULTIPLY)[0])
|
||||
Bind(KEY_KP_MULTIPLY, "zoom");
|
||||
if(!Get(KEY_HOME)[0])
|
||||
Bind(KEY_HOME, "kill");
|
||||
if(!Get(KEY_PAUSE)[0])
|
||||
Bind(KEY_PAUSE, "say /pause");
|
||||
if(!Get(KEY_UP)[0])
|
||||
Bind(KEY_UP, "+jump");
|
||||
if(!Get(KEY_LEFT)[0])
|
||||
Bind(KEY_LEFT, "+left");
|
||||
if(!Get(KEY_RIGHT)[0])
|
||||
Bind(KEY_RIGHT, "+right");
|
||||
if(!Get('[')[0])
|
||||
Bind('[', "+prevweapon");
|
||||
if(!Get(']')[0])
|
||||
Bind(']', "+nextweapon");
|
||||
if(!Get('c')[0])
|
||||
Bind('c', "say /rank");
|
||||
if(!Get('v')[0])
|
||||
Bind('v', "say /info");
|
||||
if(!Get('b')[0])
|
||||
Bind('b', "say /top5");
|
||||
if(!Get('x')[0])
|
||||
Bind('x', "emote 14");
|
||||
if(!Get(KEY_KP_PLUS)[0])
|
||||
Bind('h', "emote 2");
|
||||
if(!Get('m')[0])
|
||||
Bind('m', "emote 5");
|
||||
if(!Get('s')[0])
|
||||
Bind('s', "+showhookcoll");
|
||||
if(!Get('x')[0])
|
||||
Bind('x', "toggle cl_dummy 0 1");
|
||||
if(!Get(KEY_PAGEDOWN)[0])
|
||||
Bind(KEY_PAGEDOWN, "toggle cl_show_quads 0 1");
|
||||
if(!Get(KEY_PAGEUP)[0])
|
||||
Bind(KEY_PAGEUP, "toggle cl_overlay_entities 0 100");
|
||||
if(!Get(KEY_KP_0)[0])
|
||||
Bind(KEY_KP_0, "say /emote normal 999999");
|
||||
if(!Get(KEY_KP_1)[0])
|
||||
Bind(KEY_KP_1, "say /emote happy 999999");
|
||||
if(!Get(KEY_KP_2)[0])
|
||||
Bind(KEY_KP_2, "say /emote angry 999999");
|
||||
if(!Get(KEY_KP_3)[0])
|
||||
Bind(KEY_KP_3, "say /emote pain 999999");
|
||||
if(!Get(KEY_KP_4)[0])
|
||||
Bind(KEY_KP_4, "say /emote surprise 999999");
|
||||
if(!Get(KEY_KP_5)[0])
|
||||
Bind(KEY_KP_5, "say /emote blink 999999");
|
||||
if(!Get(KEY_MOUSE_3)[0])
|
||||
Bind(KEY_MOUSE_3, "+spectate");
|
||||
if(!Get(KEY_MINUS)[0])
|
||||
Bind(KEY_MINUS, "spectate_previous");
|
||||
if(!Get(KEY_EQUALS)[0])
|
||||
Bind(KEY_EQUALS, "spectate_next");
|
||||
}
|
||||
Bind(KEY_KP_0, "say /emote normal 999999", FreeOnly);
|
||||
Bind(KEY_KP_1, "say /emote happy 999999", FreeOnly);
|
||||
Bind(KEY_KP_2, "say /emote angry 999999", FreeOnly);
|
||||
Bind(KEY_KP_3, "say /emote pain 999999", FreeOnly);
|
||||
Bind(KEY_KP_4, "say /emote surprise 999999", FreeOnly);
|
||||
Bind(KEY_KP_5, "say /emote blink 999999", FreeOnly);
|
||||
Bind(KEY_MOUSE_3, "+spectate", FreeOnly);
|
||||
Bind(KEY_MINUS, "spectate_previous", FreeOnly);
|
||||
Bind(KEY_EQUALS, "spectate_next", FreeOnly);
|
||||
|
||||
g_Config.m_ClDDRaceBindsSet = 1;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
CBindsSpecial m_SpecialBinds;
|
||||
|
||||
void Bind(int KeyID, const char *pStr);
|
||||
void Bind(int KeyID, const char *pStr, bool FreeOnly = false);
|
||||
void SetDefaults();
|
||||
void UnbindAll();
|
||||
const char *Get(int KeyID);
|
||||
|
|
Loading…
Reference in a new issue