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(
"wepaon_drop" , _(
"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);
208 n =
tokenize(findkeysforcommand(from, 0));
209 for (j = 0; j < n; ++j)
219 cvar_set(
"_hud_showbinds_reload",
"1");
223 me.configureXonoticListBox(me);
240 replace_bind(
"g_waypointsprite_personal",
"waypoint_personal_here");
241 replace_bind(
"g_waypointsprite_personal_p",
"waypoint_personal_crosshair");
242 replace_bind(
"g_waypointsprite_personal_d",
"waypoint_personal_death");
243 replace_bind(
"g_waypointsprite_team_helpme",
"waypoint_here_follow");
244 replace_bind(
"g_waypointsprite_team_here",
"waypoint_here_here");
245 replace_bind(
"g_waypointsprite_team_here_p",
"waypoint_here_crosshair");
246 replace_bind(
"g_waypointsprite_team_here_d",
"waypoint_here_death");
247 replace_bind(
"g_waypointsprite_team_danger",
"waypoint_danger_here");
248 replace_bind(
"g_waypointsprite_team_danger_p",
"waypoint_danger_crosshair");
249 replace_bind(
"g_waypointsprite_team_danger_d",
"waypoint_danger_death");
250 replace_bind(
"g_waypointsprite_clear_personal",
"waypoint_clear_personal");
251 replace_bind(
"g_waypointsprite_clear",
"waypoint_clear");
255 bool force_initial_selection =
false;
257 force_initial_selection =
true;
260 if (force_initial_selection)
261 me.setSelected(me, 0);
272 me.itemAbsSize.y = absSize.y * me.itemHeight;
273 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
274 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
275 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
276 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
281 float aspect_ratio = sz.y ? sz.x / sz.y : 1;
282 me.columnIconSize = me.itemAbsSize.y / me.itemAbsSize.x * aspect_ratio;
284 me.columnTreeIconSize = me.itemAbsSize.y / me.itemAbsSize.x;
285 me.columnKeysSize = me.realFontSize.x * 12;
286 me.columnFunctionSize = 1 - me.columnKeysSize - 2 * me.realFontSize.x;
288 me.columnKeysOrigin = me.columnFunctionSize + me.realFontSize.x;
296 me.setSelected(me, me.selectedItem);
297 me.keyGrabButton.forcePressed =
true;
298 me.clearButton.disabled = 1;
306 for (
int j = 0; j < n; ++j)
320 me.keyGrabButton.forcePressed =
false;
321 me.clearButton.disabled = 0;
344 for (j = 2; j < n; ++j)
352 n =
tokenize(findkeysforcommand(func, 0));
354 for (j = 0; j < n; ++j)
365 cvar_set(
"_hud_showbinds_reload",
"1");
382 if (!me.userbindEditDialog)
401 if (!me.userbindEditDialog)
412 me.setSelected(me, me.selectedItem);
435 me.setSelected(me, me.selectedItem);
437 n =
tokenize(findkeysforcommand(func, 0));
442 cvar_set(
"_hud_showbinds_reload",
"1");
447 localcmd(
"exec binds-xonotic.cfg\n");
449 cvar_set(
"_hud_showbinds_reload",
"1");
459 i =
bound(0, i, me.nItems - 1);
460#define KEYBIND_IS_UNSELECTABLE(idx) \
461 (KeyBinds_Functions[idx] == "" || KEYBIND_IS_SPECIAL(KeyBinds_Functions[idx]))
466 if (i < me.previouslySelected)
478 i = me.previouslySelected;
480 me.previouslySelected = i;
482 if (me.userbindEditButton)
485#undef KEYBIND_IS_UNSELECTABLE
525 theColor = SKINCOLOR_KEYGRABBER_TITLES;
526 theAlpha = SKINALPHA_KEYGRABBER_TITLES;
534 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_WAITING, SKINALPHA_LISTBOX_WAITING);
536 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
540 me.focusedItemAlpha =
getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
541 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
544 theAlpha = SKINALPHA_KEYGRABBER_KEYS;
545 theColor = SKINCOLOR_KEYGRABBER_KEYS;
546 extraMargin = me.realFontSize.x * 0.5;
548 descrWidth = me.columnFunctionSize;
558 theAlpha *= SKINALPHA_DISABLED;
563 string tree_type =
substring(icon, 0, 1);
564 if (tree_type ==
"+" || tree_type ==
"T" || tree_type ==
"L")
566 string pic = (tree_type ==
"+" ?
"tree_branch" : tree_type ==
"T" ?
"tree_branch_start" :
"tree_elbow");
567 draw_Picture(extraMargin *
eX, pic, me.columnTreeIconSize *
eX +
eY,
'1 1 1', SKINALPHA_LISTBOX_SELECTED);
568 float addedMargin = me.columnTreeIconSize + 0.25 * me.realFontSize.x;
569 extraMargin += addedMargin;
570 descrWidth -= addedMargin;
575 float addedMargin = me.columnIconSize + 0.25 * me.realFontSize.x;
576 extraMargin += addedMargin;
577 descrWidth -= addedMargin;
582 draw_Text(me.realUpperMargin *
eY + extraMargin *
eX, s, me.realFontSize, theColor, theAlpha, 0);
599 theColor = SKINCOLOR_KEYGRABBER_KEYS_IMMUTABLE;
600 theAlpha = SKINALPHA_KEYGRABBER_KEYS_IMMUTABLE;
606 const bool joy_active =
cvar(
"joy_active");
607 n =
tokenize(findkeysforcommand(func, 0));
608 for (
int j = 0; j < n; ++j)
621 draw_CenterText(me.realUpperMargin *
eY + (me.columnKeysOrigin + 0.5 * me.columnKeysSize) *
eX, s, me.realFontSize, theColor, theAlpha, 0);
624#undef KEYBIND_IS_USERBIND
625#undef KEYBIND_IS_SPECIAL
626#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)