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
199 me.configureXonoticKeyBinder(me);
206 n =
tokenize(findkeysforcommand(from, 0));
207 for (j = 0; j < n; ++j)
214 cvar_set(
"_hud_showbinds_reload",
"1");
218 me.configureXonoticListBox(me);
223 bool force_initial_selection =
false;
225 force_initial_selection =
true;
228 if (force_initial_selection)
229 me.setSelected(me, 0);
240 me.itemAbsSize.y = absSize.y * me.itemHeight;
241 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
242 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
243 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
244 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
249 float aspect_ratio = sz.y ? sz.x / sz.y : 1;
250 me.columnIconSize = me.itemAbsSize.y / me.itemAbsSize.x * aspect_ratio;
252 me.columnTreeIconSize = me.itemAbsSize.y / me.itemAbsSize.x;
253 me.columnKeysSize = me.realFontSize.x * 12;
254 me.columnFunctionSize = 1 - me.columnKeysSize - 2 * me.realFontSize.x;
256 me.columnKeysOrigin = me.columnFunctionSize + me.realFontSize.x;
264 me.setSelected(me, me.selectedItem);
265 me.keyGrabButton.forcePressed =
true;
266 me.clearButton.disabled = 1;
274 for (
int j = 0; j < n; ++j)
288 me.keyGrabButton.forcePressed =
false;
289 me.clearButton.disabled = 0;
312 for (j = 2; j < n; ++j)
320 n =
tokenize(findkeysforcommand(func, 0));
322 for (j = 0; j < n; ++j)
333 cvar_set(
"_hud_showbinds_reload",
"1");
350 if (!me.userbindEditDialog)
369 if (!me.userbindEditDialog)
380 me.setSelected(me, me.selectedItem);
403 me.setSelected(me, me.selectedItem);
405 n =
tokenize(findkeysforcommand(func, 0));
410 cvar_set(
"_hud_showbinds_reload",
"1");
415 localcmd(
"exec binds-xonotic.cfg\n");
417 cvar_set(
"_hud_showbinds_reload",
"1");
427 i =
bound(0, i, me.nItems - 1);
428#define KEYBIND_IS_UNSELECTABLE(idx) \
429 (KeyBinds_Functions[idx] == "" || KEYBIND_IS_SPECIAL(KeyBinds_Functions[idx]))
434 if (i < me.previouslySelected)
446 i = me.previouslySelected;
448 me.previouslySelected = i;
450 if (me.userbindEditButton)
453#undef KEYBIND_IS_UNSELECTABLE
493 theColor = SKINCOLOR_KEYGRABBER_TITLES;
494 theAlpha = SKINALPHA_KEYGRABBER_TITLES;
502 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_WAITING, SKINALPHA_LISTBOX_WAITING);
504 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
508 me.focusedItemAlpha =
getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
509 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
512 theAlpha = SKINALPHA_KEYGRABBER_KEYS;
513 theColor = SKINCOLOR_KEYGRABBER_KEYS;
514 extraMargin = me.realFontSize.x * 0.5;
516 descrWidth = me.columnFunctionSize;
526 theAlpha *= SKINALPHA_DISABLED;
531 string tree_type =
substring(icon, 0, 1);
532 if (tree_type ==
"+" || tree_type ==
"T" || tree_type ==
"L")
534 string pic = (tree_type ==
"+" ?
"tree_branch" : tree_type ==
"T" ?
"tree_branch_start" :
"tree_elbow");
535 draw_Picture(extraMargin *
eX, pic, me.columnTreeIconSize *
eX +
eY,
'1 1 1', SKINALPHA_LISTBOX_SELECTED);
536 float addedMargin = me.columnTreeIconSize + 0.25 * me.realFontSize.x;
537 extraMargin += addedMargin;
538 descrWidth -= addedMargin;
543 float addedMargin = me.columnIconSize + 0.25 * me.realFontSize.x;
544 extraMargin += addedMargin;
545 descrWidth -= addedMargin;
550 draw_Text(me.realUpperMargin *
eY + extraMargin *
eX, s, me.realFontSize, theColor, theAlpha, 0);
567 theColor = SKINCOLOR_KEYGRABBER_KEYS_IMMUTABLE;
568 theAlpha = SKINALPHA_KEYGRABBER_KEYS_IMMUTABLE;
574 const bool joy_active =
cvar(
"joy_active");
575 n =
tokenize(findkeysforcommand(func, 0));
576 for (
int j = 0; j < n; ++j)
589 draw_CenterText(me.realUpperMargin *
eY + (me.columnKeysOrigin + 0.5 * me.columnKeysSize) *
eX, s, me.realFontSize, theColor, theAlpha, 0);
592#undef KEYBIND_IS_USERBIND
593#undef KEYBIND_IS_SPECIAL
594#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)