Xonotic
keybinder.qh File Reference
#include "listbox.qh"
+ Include dependency graph for keybinder.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  XonoticKeyBinder
 

Functions

void KeyBinder_Bind_Change (entity btn, entity me)
 
void KeyBinder_Bind_Clear (entity btn, entity me)
 
void KeyBinder_Bind_Edit (entity btn, entity me)
 
void KeyBinder_Bind_Reset_All (entity btn, entity me)
 
entity makeXonoticKeyBinder ()
 

Function Documentation

◆ KeyBinder_Bind_Change()

void KeyBinder_Bind_Change ( entity  btn,
entity  me 
)

Definition at line 206 of file keybinder.qc.

References KEYBIND_IS_SPECIAL, KeyBinds_Functions, and keyGrabber.

Referenced by XonoticKeyBinder_doubleClickListBoxItem(), XonoticKeyBinder_keyDown(), and XonoticKeyBinder_keyGrabbed().

207 {
208  string func = KeyBinds_Functions[me.selectedItem];
209  if(func == "" || KEYBIND_IS_SPECIAL(func))
210  return;
211 
212  me.keyGrabButton.forcePressed = 1;
213  me.clearButton.disabled = 1;
214  keyGrabber = me;
215 }
string KeyBinds_Functions[MAX_KEYBINDS]
Definition: keybinder.qc:13
#define KEYBIND_IS_SPECIAL(func)
+ Here is the caller graph for this function:

◆ KeyBinder_Bind_Clear()

void KeyBinder_Bind_Clear ( entity  btn,
entity  me 
)

Definition at line 313 of file keybinder.qc.

References argv(), cvar_set(), KEY_NOT_BOUND_CMD, KEYBIND_IS_SPECIAL, KeyBinds_Functions, keynumtostring(), localcmd, m_play_click_sound(), MENU_SOUND_CLEAR, stof(), and tokenize().

Referenced by XonoticKeyBinder_keyDown().

314 {
315  float n, j, k;
316 
317  string func = KeyBinds_Functions[me.selectedItem];
318  if(func == "" || KEYBIND_IS_SPECIAL(func))
319  return;
320 
321  n = tokenize(findkeysforcommand(func, 0)); // uses '...' strings
322  for(j = 0; j < n; ++j)
323  {
324  k = stof(argv(j));
325  if(k != -1)
326  {
327  // bind to empty cmd instead of using unbind so it gets saved in config and overrides any default binds
328  localcmd("\nbind \"", keynumtostring(k), "\" \"", KEY_NOT_BOUND_CMD, "\"\n");
329  }
330  }
332  localcmd("-zoom\n"); // to make sure we aren't in togglezoom'd state
333  cvar_set("_hud_showbinds_reload", "1");
334 }
string KeyBinds_Functions[MAX_KEYBINDS]
Definition: keybinder.qc:13
#define KEYBIND_IS_SPECIAL(func)
const string KEY_NOT_BOUND_CMD
Definition: keybinder.qc:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ KeyBinder_Bind_Edit()

void KeyBinder_Bind_Edit ( entity  btn,
entity  me 
)

Definition at line 294 of file keybinder.qc.

References cvar_string(), DialogOpenButton_Click(), KEYBIND_IS_SPECIAL, KeyBinds_Descriptions, KeyBinds_Functions, strcat(), strlen(), and substring().

Referenced by XonoticKeyBinder_keyDown().

295 {
296  if(!me.userbindEditDialog)
297  return;
298 
299  string func = KeyBinds_Functions[me.selectedItem];
300  if(func == "" || KEYBIND_IS_SPECIAL(func))
301  return;
302 
303  string descr = KeyBinds_Descriptions[me.selectedItem];
304  if(substring(descr, 0, 1) != "$")
305  return;
306  descr = substring(descr, 1, strlen(descr) - 1);
307 
308  // Hooray! It IS a user bind!
309  me.userbindEditDialog.loadUserBind(me.userbindEditDialog, cvar_string(strcat(descr, "_description")), cvar_string(strcat(descr, "_press")), cvar_string(strcat(descr, "_release")));
310 
311  DialogOpenButton_Click(btn, me.userbindEditDialog);
312 }
string KeyBinds_Descriptions[MAX_KEYBINDS]
Definition: keybinder.qc:14
string KeyBinds_Functions[MAX_KEYBINDS]
Definition: keybinder.qc:13
#define KEYBIND_IS_SPECIAL(func)
void DialogOpenButton_Click(entity button, entity tab)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ KeyBinder_Bind_Reset_All()

void KeyBinder_Bind_Reset_All ( entity  btn,
entity  me 
)

Definition at line 335 of file keybinder.qc.

References cvar_set(), and localcmd.

336 {
337  localcmd("unbindall\n");
338  localcmd("exec binds-xonotic.cfg\n");
339  localcmd("-zoom\n"); // to make sure we aren't in togglezoom'd state
340  cvar_set("_hud_showbinds_reload", "1");
341  me.close(me);
342 }
+ Here is the call graph for this function:

◆ makeXonoticKeyBinder()

entity makeXonoticKeyBinder ( )

Definition at line 140 of file keybinder.qc.

References entity(), and NEW.

Referenced by XonoticInputSettingsTab_fill().

141 {
142  entity me;
143  me = NEW(XonoticKeyBinder);
144  me.configureXonoticKeyBinder(me);
145  return me;
146 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function: