23#define KEYBIND_IS_USERBIND(descr) (substring(descr, 0, 1) == "$")
27#define KEYBIND_IS_SPECIAL(func) (substring(func, 0 ,1) == "*")
31#define KEYBIND_IS_OVERRIDER(func) (substring(func, 0 ,1) == ";")
44 #define KEYBIND_DEF_WITH_ICON(func, desc, icon) MACRO_BEGIN \
45 if (KeyBinds_Count < MAX_KEYBINDS) \
47 KeyBinds_Functions[KeyBinds_Count] = strzone(func); \
48 KeyBinds_Descriptions[KeyBinds_Count] = strzone(desc); \
49 KeyBinds_Icons[KeyBinds_Count] = strzone(icon); \
53 #define KEYBIND_DEF(func, desc) KEYBIND_DEF_WITH_ICON(func, desc, "")
54 #define KEYBIND_DEF_SPECIAL_WITH_ICON(func, desc, icon) KEYBIND_DEF_WITH_ICON(strcat("*", func), desc, icon)
55 #define KEYBIND_DEF_OVERRIDER_WITH_ICON(func, desc, icon) KEYBIND_DEF_WITH_ICON(strcat(";", func), desc, icon)
57 #define KEYBIND_EMPTY_LINE() KEYBIND_DEF("", "")
58 #define KEYBIND_HEADER(str) KEYBIND_DEF("", str)
83 KEYBIND_DEF(
"dropweapon" , _(
"drop weapon / throw nade"));
85 #define SHOWABLE_WEAPON(w) \
86 (!(it.spawnflags & WEP_FLAG_SPECIALATTACK) && \
87 !((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && (it.spawnflags & WEP_FLAG_HIDDEN)) )
92 string w_override_list =
"";
99 w_override_list =
strcat(w_override_list,
";weapon_", it.netname);
129 #undef SHOWABLE_WEAPON
138 KEYBIND_DEF(
"+hud_panel_radar_maximized" , _(
"maximize radar"));
139 KEYBIND_DEF(
"toggle chase_active" , _(
"3rd person view"));
146 KEYBIND_DEF(
"+con_chat_maximize" , _(
"show chat history"));
164 KEYBIND_DEF(
"team_selection_show" , _(
"team selection"));
169 KEYBIND_DEF(
"+use" , _(
"drop key/flag, exit vehicle"));
178 for (
int i = 1; i <= 32; ++i)
184 KEYBIND_DEF(
"menu_showsandboxtools" , _(
"sandbox menu"));
185 KEYBIND_DEF(
"+button8" , _(
"drag object (sandbox)"));
186 KEYBIND_DEF(
"wpeditor_menu" , _(
"waypoint editor menu"));
188 #undef KEYBIND_DEF_WITH_ICON
190 #undef KEYBIND_EMPTY_LINE
191 #undef KEYBIND_HEADER
192 #undef KEYBIND_DEF_SPECIAL_WITH_ICON
193 #undef KEYBIND_DEF_OVERRIDER_WITH_ICON
200 me.configureXonoticKeyBinder(me);
207 n =
tokenize(findkeysforcommand(from, 0));
208 for (j = 0; j < n; ++j)
215 cvar_set(
"_hud_showbinds_reload",
"1");
219 me.configureXonoticListBox(me);
224 bool force_initial_selection =
false;
226 force_initial_selection =
true;
229 if (force_initial_selection)
230 me.setSelected(me, 0);
241 me.itemAbsSize.y = absSize.y * me.itemHeight;
242 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
243 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
244 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
245 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
250 float aspect_ratio = sz.y ? sz.x / sz.y : 1;
251 me.columnIconSize = me.itemAbsSize.y / me.itemAbsSize.x * aspect_ratio;
253 me.columnTreeIconSize = me.itemAbsSize.y / me.itemAbsSize.x;
254 me.columnKeysSize = me.realFontSize.x * 12;
255 me.columnFunctionSize = 1 - me.columnKeysSize - 2 * me.realFontSize.x;
257 me.columnKeysOrigin = me.columnFunctionSize + me.realFontSize.x;
265 me.setSelected(me, me.selectedItem);
266 me.keyGrabButton.forcePressed =
true;
267 me.clearButton.disabled = 1;
275 for (
int j = 0; j < n; ++j)
289 me.keyGrabButton.forcePressed =
false;
290 me.clearButton.disabled = 0;
313 for (j = 2; j < n; ++j)
321 n =
tokenize(findkeysforcommand(func, 0));
323 for (j = 0; j < n; ++j)
334 cvar_set(
"_hud_showbinds_reload",
"1");
351 if (!me.userbindEditDialog)
370 if (!me.userbindEditDialog)
381 me.setSelected(me, me.selectedItem);
404 me.setSelected(me, me.selectedItem);
406 n =
tokenize(findkeysforcommand(func, 0));
411 cvar_set(
"_hud_showbinds_reload",
"1");
416 localcmd(
"exec binds-xonotic.cfg\n");
418 cvar_set(
"_hud_showbinds_reload",
"1");
428 i =
bound(0, i, me.nItems - 1);
429#define KEYBIND_IS_UNSELECTABLE(idx) \
430 (KeyBinds_Functions[idx] == "" || KEYBIND_IS_SPECIAL(KeyBinds_Functions[idx]))
435 if (i < me.previouslySelected)
447 i = me.previouslySelected;
449 me.previouslySelected = i;
451 if (me.userbindEditButton)
454#undef KEYBIND_IS_UNSELECTABLE
494 theColor = SKINCOLOR_KEYGRABBER_TITLES;
495 theAlpha = SKINALPHA_KEYGRABBER_TITLES;
503 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_WAITING, SKINALPHA_LISTBOX_WAITING);
505 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
509 me.focusedItemAlpha =
getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
510 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
513 theAlpha = SKINALPHA_KEYGRABBER_KEYS;
514 theColor = SKINCOLOR_KEYGRABBER_KEYS;
515 extraMargin = me.realFontSize.x * 0.5;
517 descrWidth = me.columnFunctionSize;
527 theAlpha *= SKINALPHA_DISABLED;
532 string tree_type =
substring(icon, 0, 1);
533 if (tree_type ==
"+" || tree_type ==
"T" || tree_type ==
"L")
535 string pic = (tree_type ==
"+" ?
"tree_branch" : tree_type ==
"T" ?
"tree_branch_start" :
"tree_elbow");
536 draw_Picture(extraMargin *
eX, pic, me.columnTreeIconSize *
eX +
eY,
'1 1 1', SKINALPHA_LISTBOX_SELECTED);
537 float addedMargin = me.columnTreeIconSize + 0.25 * me.realFontSize.x;
538 extraMargin += addedMargin;
539 descrWidth -= addedMargin;
544 float addedMargin = me.columnIconSize + 0.25 * me.realFontSize.x;
545 extraMargin += addedMargin;
546 descrWidth -= addedMargin;
551 draw_Text(me.realUpperMargin *
eY + extraMargin *
eX, s, me.realFontSize, theColor, theAlpha, 0);
568 theColor = SKINCOLOR_KEYGRABBER_KEYS_IMMUTABLE;
569 theAlpha = SKINALPHA_KEYGRABBER_KEYS_IMMUTABLE;
575 const bool joy_active =
cvar(
"joy_active");
576 n =
tokenize(findkeysforcommand(func, 0));
577 for (
int j = 0; j < n; ++j)
590 draw_CenterText(me.realUpperMargin *
eY + (me.columnKeysOrigin + 0.5 * me.columnKeysSize) *
eX, s, me.realFontSize, theColor, theAlpha, 0);
593#undef KEYBIND_IS_USERBIND
594#undef KEYBIND_IS_SPECIAL
595#undef KEYBIND_IS_OVERRIDER
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
string translate_key(string key)
#define tokenizebyseparator
ERASEABLE string CTX(string s)
#define FOREACH(list, cond, body)
void KeyBinder_Bind_UnbindAllForFunction(int n)
void KeyBinder_Bind_Reset_All(entity btn, entity me)
#define SHOWABLE_WEAPON(w)
const int MAX_KEYS_PER_FUNCTION
float XonoticKeyBinder_keyDown(entity me, int key, bool ascii, float shift)
void XonoticKeyBinder_loadKeyBinds(entity me)
void XonoticKeyBinder_destroy(entity me)
string XonoticKeyBinder_cb_name
void KeyBinder_Bind_Edit(entity btn, entity me)
const string KEY_NOT_BOUND_CMD
void XonoticKeyBinder_showNotify(entity me)
#define KEYBIND_IS_UNSELECTABLE(idx)
#define KEYBIND_IS_OVERRIDER(func)
string KeyBinds_Functions[MAX_KEYBINDS]
void KeyBinder_Bind_Change(entity btn, entity me)
#define KEYBIND_DEF_WITH_ICON(func, desc, icon)
void XonoticKeyBinder_keyGrabbed(entity me, int key, bool ascii)
void XonoticKeyBinder_configureXonoticKeyBinder(entity me)
string KeyBinds_Descriptions[MAX_KEYBINDS]
#define KEYBIND_IS_SPECIAL(func)
void KeyBinds_BuildList()
void KeyBinder_Bind_Clear(entity btn, entity me)
void replace_bind(string from, string to)
void XonoticKeyBinder_doubleClickListBoxItem(entity me, float i, vector where)
string KeyBinds_Icons[MAX_KEYBINDS]
entity makeXonoticKeyBinder()
void XonoticKeyBinder_cb(string _name, string _icon)
#define KEYBIND_HEADER(str)
void XonoticKeyBinder_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
void XonoticKeyBinder_setSelected(entity me, int i)
void XonoticKeyBinder_editUserbind(entity me, string theName, string theCommandPress, string theCommandRelease)
#define KEYBIND_DEF_SPECIAL_WITH_ICON(func, desc, icon)
string XonoticKeyBinder_cb_icon
#define KEYBIND_EMPTY_LINE()
void XonoticKeyBinder_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
#define KEYBIND_DEF(func, desc)
#define KEYBIND_IS_USERBIND(descr)
void DialogOpenButton_Click(entity button, entity tab)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define REGISTRY_GET(id, i)
ERASEABLE string cons_mid(string a, string mid, string b)
#define startsWith(haystack, needle)