1 #include "quickmenu.qh"
3 #include <client/autocvars.qh>
4 #include <client/defs.qh>
5 #include <client/miscfunctions.qh>
6 #include <common/ent_cs.qh>
7 #include <common/minigames/cl_minigames.qh>
8 #include <client/hud/_mod.qh>
9 #include <client/mapvoting.qh>
13 // QUICKMENU_MAXLINES must be <= 10
14 const int QUICKMENU_MAXLINES = 10;
15 // visible entries are loaded from QuickMenu_Buffer into QuickMenu_Page_* arrays
16 string QuickMenu_Page_Command[QUICKMENU_MAXLINES];
17 string QuickMenu_Page_Description[QUICKMENU_MAXLINES];
18 int QuickMenu_Page_Command_Type[QUICKMENU_MAXLINES];
19 int QuickMenu_Page_Entries;
21 int QuickMenu_Page_ActivatedEntry = -1;
22 bool QuickMenu_Page_ActivatedEntry_Close;
23 float QuickMenu_Page_ActivatedEntry_Time;
24 bool QuickMenu_IsLastPage;
25 // all the entries are loaded into QuickMenu_Buffer
26 // each entry (submenu or command) is composed of 2 entries
27 const int QUICKMENU_MAXENTRIES = 256;
28 const int QUICKMENU_BUFFER_MAXENTRIES = 2 * QUICKMENU_MAXENTRIES;
29 int QuickMenu_Buffer = -1;
30 int QuickMenu_Buffer_Size;
31 int QuickMenu_Buffer_Index;
32 string QuickMenu_CurrentSubMenu;
33 float QuickMenu_TimeOut;
35 // QuickMenu_Buffer are labeled with these tags
36 #define QM_TAG_TITLE "T"
37 #define QM_TAG_SUBMENU "S"
38 #define QM_TAG_COMMAND "C"
39 #define QM_TAG_PLCOMMAND "P"
41 #define QuickMenu_Buffer_Set(tag, string) bufstr_set(QuickMenu_Buffer, QuickMenu_Buffer_Size, strcat(tag, string))
42 #define QuickMenu_Buffer_Get() bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index)
44 // if s1 is not empty s will be displayed as command otherwise as submenu
45 void QuickMenu_Page_LoadEntry(int i, string s, string s1)
48 //LOG_INFOF("^xc80 entry %d: %s, %s\n", i, s, s1);
49 strcpy(QuickMenu_Page_Description[i], s);
50 strcpy(QuickMenu_Page_Command[i], s1);
53 void QuickMenu_Page_ClearEntry(int i)
56 strfree(QuickMenu_Page_Description[i]);
57 strfree(QuickMenu_Page_Command[i]);
58 QuickMenu_Page_Command_Type[i] = 0;
61 bool HUD_QuickMenu_Forbidden()
64 || (hud_configure_prev && hud_configure_prev != -1)
65 || HUD_MinigameMenu_IsOpened()
66 || (QuickMenu_TimeOut && time > QuickMenu_TimeOut));
69 // returns true if succeded, false otherwise
70 bool QuickMenu_Open(string mode, string submenu, string file)
72 QuickMenu_TimeOut = 0;
73 if (HUD_QuickMenu_Forbidden())
81 if(file == "" || file == "0")
89 if(file == "" || file == "0")
90 LOG_INFO("No file name is set in hud_panel_quickmenu_file, loading default quickmenu");
93 fh = fopen(file, FILE_READ);
95 LOG_INFOF("Couldn't open file \"%s\", loading default quickmenu", file);
101 if(mode == "default")
103 QuickMenu_Buffer = buf_create();
104 if(QuickMenu_Buffer < 0)
107 QuickMenu_Default(submenu);
109 else if(mode == "file")
111 QuickMenu_Buffer = buf_create();
112 if(QuickMenu_Buffer < 0)
118 QuickMenu_Buffer_Size = 0;
119 while((s = fgets(fh)) && QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES)
121 // first skip invalid entries, so we don't check them anymore
123 argc = tokenize_console(s);
124 if(argc == 0 || argv(0) == "")
127 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
132 QuickMenu_Buffer_Set(QM_TAG_TITLE, argv(0));
133 ++QuickMenu_Buffer_Size;
134 QuickMenu_Buffer_Set(QM_TAG_COMMAND, argv(1));
138 // check for special keywords
139 float teamplayers = 0, without_me = 0;
142 case "ALLPLAYERS_BUT_ME": without_me = 1; // fall through
143 case "ALLPLAYERS": teamplayers = 0; break;
144 case "OWNTEAMPLAYERS_BUT_ME": without_me = 1; // fall through
145 case "OWNTEAMPLAYERS": teamplayers = 1; break;
146 case "ENEMYTEAMPLAYERS": teamplayers = 2; break;
150 if(QuickMenu_Buffer_Size + 3 < QUICKMENU_BUFFER_MAXENTRIES)
152 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
153 ++QuickMenu_Buffer_Size;
154 QuickMenu_Buffer_Set(QM_TAG_TITLE, strcat(ftos(teamplayers), ftos(without_me))); // put PLCOMMAND arguments in the title string
155 ++QuickMenu_Buffer_Size;
156 QuickMenu_Buffer_Set(QM_TAG_PLCOMMAND, argv(1));
157 ++QuickMenu_Buffer_Size;
158 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
161 ++QuickMenu_Buffer_Size;
167 LOG_WARNF("Unrecognized mode %s", mode);
171 if (QuickMenu_Buffer_Size <= 0)
173 buf_del(QuickMenu_Buffer);
174 QuickMenu_Buffer = -1;
179 QuickMenu_Page_Load(submenu, 0);
181 QuickMenu_Page_Load("", 0);
185 QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
189 void QuickMenu_Buffer_Close()
191 if (QuickMenu_Buffer >= 0)
193 buf_del(QuickMenu_Buffer);
194 QuickMenu_Buffer = -1;
195 QuickMenu_Buffer_Size = 0;
199 void QuickMenu_Close()
201 strfree(QuickMenu_CurrentSubMenu);
203 for (i = 0; i < QUICKMENU_MAXLINES; ++i)
204 QuickMenu_Page_ClearEntry(i);
205 QuickMenu_Page_Entries = 0;
207 prevMouseClicked = 0;
208 QuickMenu_Buffer_Close();
211 // It assumes submenu open tag is already detected
212 void QuickMenu_skip_submenu(string submenu)
214 string z_submenu = string_null; strcpy(z_submenu, submenu);
215 for(++QuickMenu_Buffer_Index ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
217 string s = QuickMenu_Buffer_Get();
218 if(substring(s, 0, 1) != QM_TAG_SUBMENU)
220 if(substring(s, 1, -1) == z_submenu) // submenu end
222 QuickMenu_skip_submenu(substring(s, 1, -1));
227 bool QuickMenu_IsOpened()
229 return (QuickMenu_Page_Entries > 0);
232 bool HUD_Quickmenu_PlayerListEntries_Create(string cmd, int teamplayers, bool without_me)
234 TC(int, teamplayers); TC(bool, without_me);
236 for(i = 0; i < QUICKMENU_MAXLINES; ++i)
237 QuickMenu_Page_ClearEntry(i);
238 QuickMenu_Buffer_Close();
240 QuickMenu_Buffer = buf_create();
241 if(QuickMenu_Buffer < 0)
244 HUD_Quickmenu_PlayerListEntries(cmd, teamplayers, without_me);
246 if(QuickMenu_Buffer_Size <= 0)
248 buf_del(QuickMenu_Buffer);
249 QuickMenu_Buffer = -1;
255 // new_page 0 means page 0, new_page != 0 means next page
256 int QuickMenu_Buffer_Index_Prev;
257 bool QuickMenu_Page_Load(string target_submenu, bool new_page)
260 string s = string_null, cmd = string_null, z_submenu;
267 z_submenu = strzone(target_submenu);
268 strcpy(QuickMenu_CurrentSubMenu, z_submenu);
270 QuickMenu_IsLastPage = true;
271 QuickMenu_Page_Entries = 0;
273 QuickMenu_Buffer_Index = 0;
276 // skip everything until the submenu open tag is found
277 for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
279 s = QuickMenu_Buffer_Get();
280 if(substring(s, 0, 1) == QM_TAG_SUBMENU && substring(s, 1, -1) == z_submenu)
282 //LOG_INFOF("^3 beginning of %s\n", z_submenu);
283 ++QuickMenu_Buffer_Index;
284 break; // target_submenu found!
286 //LOG_INFOF("^1 skipping %s\n", s);
288 if(QuickMenu_Buffer_Index == QuickMenu_Buffer_Size)
289 LOG_WARNF("Couldn't find submenu \"%s\"", z_submenu);
292 // only the last page can contain up to QUICKMENU_MAXLINES entries
293 // the other ones contain only (QUICKMENU_MAXLINES - 2) entries
294 // so that the panel can show an empty row and "Continue..."
295 float first_entry = QuickMenu_Page * (QUICKMENU_MAXLINES - 2);
296 int entry_num = 0; // counts entries in target_submenu
297 for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
299 s = QuickMenu_Buffer_Get();
301 if(z_submenu != "" && substring(s, 1, -1) == z_submenu)
303 //LOG_INFOF("^3 end of %s\n", z_submenu);
307 if(entry_num >= first_entry)
309 ++QuickMenu_Page_Entries;
310 if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES - 2)
311 QuickMenu_Buffer_Index_Prev = QuickMenu_Buffer_Index;
312 else if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES)
314 QuickMenu_Page_ClearEntry(QUICKMENU_MAXLINES - 1);
315 QuickMenu_Buffer_Index = QuickMenu_Buffer_Index_Prev;
316 QuickMenu_IsLastPage = false;
321 // NOTE: entries are loaded starting from 1, not from 0
322 if(substring(s, 0, 1) == QM_TAG_SUBMENU)
324 if(entry_num >= first_entry)
325 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), "");
326 QuickMenu_skip_submenu(substring(s, 1, -1));
328 else if(substring(s, 0, 1) == QM_TAG_TITLE)
330 ++QuickMenu_Buffer_Index;
331 if(entry_num >= first_entry)
333 cmd = QuickMenu_Buffer_Get();
334 string command_code = substring(cmd, 0, 1);
335 if(command_code == QM_TAG_COMMAND)
336 cmd = substring(cmd, 1, -1);
337 else if(command_code == QM_TAG_PLCOMMAND)
339 // throw away the current quickmenu buffer and load a new one
340 cmd = substring(cmd, 1, -1);
341 strunzone(z_submenu);
342 if(HUD_Quickmenu_PlayerListEntries_Create(cmd, stof(substring(s, 1, 1)), stof(substring(s, 2, 1))))
343 return QuickMenu_Page_Load("", 0);
348 tokenize_console(cmd);
349 QuickMenu_Page_Command_Type[QuickMenu_Page_Entries] = (argv(1) && argv(0) == "toggle");
351 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), cmd);
358 strunzone(z_submenu);
359 if (QuickMenu_Page_Entries == 0)
364 QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
368 bool QuickMenu_ActionForNumber(int num)
371 if (!QuickMenu_IsLastPage)
373 if (num < 0 || num >= QUICKMENU_MAXLINES)
375 if (num == QUICKMENU_MAXLINES - 1)
379 QuickMenu_Page_Load(QuickMenu_CurrentSubMenu, +1);
382 } else if (num <= 0 || num > QuickMenu_Page_Entries)
385 if (QuickMenu_Page_Command[num] != "")
387 localcmd(strcat("\n", QuickMenu_Page_Command[num], "\n"));
388 QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
391 if (QuickMenu_Page_Description[num] != "")
392 QuickMenu_Page_Load(QuickMenu_Page_Description[num], 0);
396 void QuickMenu_Page_ActiveEntry(int entry_num)
399 QuickMenu_Page_ActivatedEntry = entry_num;
400 QuickMenu_Page_ActivatedEntry_Time = time + 0.1;
401 if(QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
403 bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
404 // toggle commands don't close the quickmenu
405 if(QuickMenu_Page_Command_Type[QuickMenu_Page_ActivatedEntry] == 1)
406 QuickMenu_Page_ActivatedEntry_Close = false;
408 QuickMenu_Page_ActivatedEntry_Close = (f && !(hudShiftState & S_CTRL));
411 QuickMenu_Page_ActivatedEntry_Close = (!(hudShiftState & S_CTRL));
414 bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
417 // we only care for keyboard events
421 if(!QuickMenu_IsOpened() || autocvar__hud_configure || mv_active)
426 mousepos.x = nPrimary;
427 mousepos.y = nSecondary;
431 // allow console bind to work
432 string con_keys = findkeysforcommand("toggleconsole", 0);
433 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
434 bool hit_con_bind = false;
436 for (i = 0; i < keys; ++i)
438 if(nPrimary == stof(argv(i)))
442 if(bInputType == 0) {
443 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
444 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
445 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
447 else if(bInputType == 1) {
448 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
449 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
450 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
453 if(nPrimary == K_ESCAPE)
459 else if(nPrimary >= '0' && nPrimary <= '9')
463 QuickMenu_Page_ActiveEntry(stof(chr2str(nPrimary)));
465 if(nPrimary == K_MOUSE1)
467 if(bInputType == 0) // key pressed
468 mouseClicked |= S_MOUSE1;
469 else if(bInputType == 1) // key released
470 mouseClicked -= (mouseClicked & S_MOUSE1);
472 else if(nPrimary == K_MOUSE2)
474 if(bInputType == 0) // key pressed
475 mouseClicked |= S_MOUSE2;
476 else if(bInputType == 1) // key released
477 mouseClicked -= (mouseClicked & S_MOUSE2);
479 else if(hit_con_bind)
485 void QuickMenu_Mouse()
487 if(mv_active) return;
490 if(prevMouseClicked & S_MOUSE2)
496 panel = HUD_PANEL(QUICKMENU);
497 HUD_Panel_LoadCvars();
501 panel_pos += '1 1 0' * panel_bg_padding;
502 panel_size -= '2 2 0' * panel_bg_padding;
505 float first_entry_pos, entries_height;
507 fontsize = '1 1 0' * (panel_size.y / QUICKMENU_MAXLINES);
508 first_entry_pos = panel_pos.y + ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y) / 2;
509 entries_height = panel_size.y - ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y);
511 if (mousepos.x >= panel_pos.x && mousepos.y >= first_entry_pos && mousepos.x <= panel_pos.x + panel_size.x && mousepos.y <= first_entry_pos + entries_height)
513 int entry_num = min(QuickMenu_Page_Entries - 1, floor((mousepos.y - first_entry_pos) / fontsize.y));
514 if (QuickMenu_IsLastPage || entry_num != QUICKMENU_MAXLINES - 2)
516 // recycling panel_pos as entry_pos
517 panel_pos.y = first_entry_pos + entry_num * fontsize.y;
519 if(mouseClicked & S_MOUSE1)
521 else if(hudShiftState & S_CTRL)
525 drawfill(panel_pos, vec2(panel_size.x, fontsize.y), color, .2, DRAWFLAG_NORMAL);
527 if(!mouseClicked && (prevMouseClicked & S_MOUSE1))
528 QuickMenu_Page_ActiveEntry((entry_num < QUICKMENU_MAXLINES - 1) ? entry_num + 1 : 0);
533 void HUD_Quickmenu_DrawEntry(vector pos, string desc, string option, vector fontsize)
537 float desc_width = panel_size.x;
540 string pic = strcat(hud_skin_path, "/", option);
541 if(precache_pic(pic) == "")
542 pic = strcat("gfx/hud/default/", option);
543 vector option_size = '1 1 0' * fontsize.y * 0.8;
544 desc_width -= option_size.x;
545 drawpic(pos + vec2(desc_width, (fontsize.y - option_size.y) / 2), pic, option_size, '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
546 desc_width -= fontsize.x / 4;
548 entry = textShortenToWidth(desc, desc_width, fontsize, stringwidth_colors);
549 if (autocvar_hud_panel_quickmenu_align > 0)
551 float real_desc_width = stringwidth_colors(entry, fontsize);
552 offset = (desc_width - real_desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
556 // when there's enough room align description regardless the checkbox
557 float extra_offset = (panel_size.x - desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
558 if(offset + real_desc_width + extra_offset < desc_width)
559 offset += extra_offset;
561 offset = max(0, desc_width - real_desc_width);
563 drawcolorcodedstring(pos + eX * offset, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
566 drawcolorcodedstring(pos, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
571 if(!autocvar__hud_configure)
573 if (!hud_draw_maximized || !QuickMenu_IsOpened())
576 if (HUD_QuickMenu_Forbidden())
584 if(!QuickMenu_IsOpened())
586 QuickMenu_Page_Entries = 1;
587 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
588 ++QuickMenu_Page_Entries;
589 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
590 ++QuickMenu_Page_Entries;
591 // although real command doesn't matter here, it must not be empty
592 // otherwise the entry is displayed like a submenu
593 for (; QuickMenu_Page_Entries < QUICKMENU_MAXLINES - 1; ++QuickMenu_Page_Entries)
594 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Command%d"), QuickMenu_Page_Entries), "-");
595 ++QuickMenu_Page_Entries;
596 QuickMenu_Page_ClearEntry(QuickMenu_Page_Entries);
597 QuickMenu_IsLastPage = false;
601 HUD_Panel_LoadCvars();
608 panel_pos += '1 1 0' * panel_bg_padding;
609 panel_size -= '2 2 0' * panel_bg_padding;
615 fontsize = '1 1 0' * (panel_size.y / QUICKMENU_MAXLINES);
617 if (!QuickMenu_IsLastPage)
620 HUD_Quickmenu_DrawEntry(panel_pos + eY * (panel_size.y - fontsize.y), sprintf("%d: %s%s", 0, color, _("Continue...")), string_null, fontsize);
623 panel_pos.y += ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y) / 2;
625 for (i = 1; i <= QuickMenu_Page_Entries; ++i) {
626 if (QuickMenu_Page_Description[i] == "")
628 string option = string_null;
629 if (QuickMenu_Page_Command[i] == "")
634 if(QuickMenu_Page_Command_Type[i] == 1) // toggle command
636 int end = strstrofs(QuickMenu_Page_Command[i], ";", 0);
638 tokenize_console(QuickMenu_Page_Command[i]);
640 tokenize_console(substring(QuickMenu_Page_Command[i], 0, end));
642 if(argv(1) && argv(0) == "toggle")
644 // "enable feature xxx" "toggle xxx" (or "toggle xxx 1 0")
645 // "disable feature xxx" "toggle xxx 0 1"
646 float ON_value = 1, OFF_value = 0;
648 ON_value = stof(argv(2));
651 OFF_value = stof(argv(3));
653 OFF_value = !ON_value;
655 float value = cvar(argv(1));
656 if(value == ON_value)
657 option = "checkbox_checked";
658 else if(value == OFF_value)
659 option = "checkbox_empty";
661 option = "checkbox_undefined";
665 HUD_Quickmenu_DrawEntry(panel_pos, sprintf("%d: %s%s", i, color, QuickMenu_Page_Description[i]), option, fontsize);
667 if(QuickMenu_Page_ActivatedEntry_Time && time < QuickMenu_Page_ActivatedEntry_Time
668 && QuickMenu_Page_ActivatedEntry == i)
669 drawfill(panel_pos, vec2(panel_size.x, fontsize.y), '0.5 1 0.5', .2, DRAWFLAG_NORMAL);
671 panel_pos.y += fontsize.y;
674 if(QuickMenu_Page_ActivatedEntry >= 0 && time >= QuickMenu_Page_ActivatedEntry_Time)
676 if(!QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
678 bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
679 if(f && QuickMenu_Page_ActivatedEntry_Close)
682 else if(QuickMenu_Page_ActivatedEntry_Close)
684 QuickMenu_Page_ActivatedEntry = -1;
685 QuickMenu_Page_ActivatedEntry_Time = 0;
690 #define QUICKMENU_SMENU(submenu,eng_submenu) { \
691 if(target_submenu == eng_submenu && target_submenu_found) \
692 return; /* target_submenu entries are now loaded, exit */ \
693 if(QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES) \
694 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, submenu); \
695 ++QuickMenu_Buffer_Size; \
696 if(target_submenu == eng_submenu && !target_submenu_found) { \
697 QuickMenu_Buffer_Size = 0; /* enable load of next entries */ \
698 target_submenu_found = true; \
702 #define QUICKMENU_ENTRY(title,command) { \
703 if(QuickMenu_Buffer_Size + 1 < QUICKMENU_BUFFER_MAXENTRIES) \
705 QuickMenu_Buffer_Set(QM_TAG_TITLE, title); \
706 ++QuickMenu_Buffer_Size; \
707 QuickMenu_Buffer_Set(QM_TAG_COMMAND, command); \
709 ++QuickMenu_Buffer_Size; \
712 #define QUICKMENU_SMENU_PL(submenu,eng_submenu,command,teamplayers,without_me) { \
713 if(QuickMenu_Buffer_Size + 3 < QUICKMENU_BUFFER_MAXENTRIES) {\
714 QUICKMENU_SMENU(submenu,eng_submenu) \
715 QuickMenu_Buffer_Set(QM_TAG_TITLE, strcat(ftos(teamplayers), ftos(without_me))); \
716 ++QuickMenu_Buffer_Size; \
717 QuickMenu_Buffer_Set(QM_TAG_PLCOMMAND, command); \
718 ++QuickMenu_Buffer_Size; \
719 QUICKMENU_SMENU(submenu,eng_submenu) \
725 // useful to Translate a string inside the Command
726 #define QUICKMENU_ENTRY_TC(title,command,text,translated_text) {\
727 if(prvm_language == "en") { \
729 tc_cmd = sprintf(command, text); \
731 else if(!autocvar_hud_panel_quickmenu_translatecommands || translated_text == text) { \
732 tc_title = strcat("(en)", title); \
733 tc_cmd = sprintf(command, text); \
736 tc_title = strcat("(", prvm_language, ")", title); \
737 tc_cmd = sprintf(command, translated_text); \
739 QUICKMENU_ENTRY(tc_title, tc_cmd) \
742 void HUD_Quickmenu_PlayerListEntries(string cmd, int teamplayers, bool without_me)
744 TC(int, teamplayers); TC(bool, without_me);
746 if(teamplayers && !team_count)
749 for(pl = players.sort_next; pl; pl = pl.sort_next)
751 if(teamplayers == 1 && (pl.team != myteam || pl.team == NUM_SPECTATOR)) // only own team players
753 if(teamplayers == 2 && (pl.team == myteam || pl.team == NUM_SPECTATOR)) // only enemy team players
755 if(without_me && pl.sv_entnum == player_localnum)
757 QUICKMENU_ENTRY(entcs_GetName(pl.sv_entnum), sprintf(cmd, entcs_GetName(pl.sv_entnum)))
764 // Specifying target_submenu, this function only loads entries inside target_submenu
765 // NOTE: alternatively we could have loaded the whole default quickmenu and
766 // then called QuickMenu_Page_Load(target_submenu, 0);
767 // but this sytem is more reliable since we can always refer to target_submenu
768 // with the English title even if a translation is active
769 void QuickMenu_Default(string target_submenu)
771 bool target_submenu_found = false;
772 if(target_submenu != "")
773 QuickMenu_Buffer_Size = QUICKMENU_BUFFER_MAXENTRIES; // forbids load of next entries until target_submenu
778 QUICKMENU_SMENU(_("Chat"), "Chat")
779 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^nice one")), "say %s", ":-) / nice one", CTX(_("QMCMD^:-) / nice one")))
780 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^good game")), "say %s", "good game", CTX(_("QMCMD^good game")))
781 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^hi / good luck")), "say %s", "hi / good luck and have fun", CTX(_("QMCMD^hi / good luck and have fun")))
782 if(prvm_language != "en")
783 QUICKMENU_ENTRY(CTX(_("QMCMD^Send in English")), "toggle hud_panel_quickmenu_translatecommands 0 1; quickmenu; wait; quickmenu default Chat")
784 QUICKMENU_SMENU(_("Chat"), "Chat")
788 QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
789 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^quad soon")), "say_team %s", "quad soon", CTX(_("QMCMD^quad soon")))
790 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^free item, icon")), "say_team %s; g_waypointsprite_team_here_p", "free item %x^7 (l:%y^7)", CTX(_("QMCMD^free item %x^7 (l:%y^7)")))
791 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^took item, icon")), "say_team %s; g_waypointsprite_team_here", "took item (l:%l^7)", CTX(_("QMCMD^took item (l:%l^7)")))
792 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^negative")), "say_team %s", "negative", CTX(_("QMCMD^negative")))
793 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^positive")), "say_team %s", "positive", CTX(_("QMCMD^positive")))
794 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^need help, icon")), "say_team %s; g_waypointsprite_team_helpme; cmd voice needhelp", "need help (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)", CTX(_("QMCMD^need help (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)")))
795 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^enemy seen, icon")), "say_team %s; g_waypointsprite_team_danger_p; cmd voice incoming", "enemy seen (l:%y^7)", CTX(_("QMCMD^enemy seen (l:%y^7)")))
796 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^flag seen, icon")), "say_team %s; g_waypointsprite_team_here_p; cmd voice seenflag", "flag seen (l:%y^7)", CTX(_("QMCMD^flag seen (l:%y^7)")))
797 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^defending, icon")), "say_team %s; g_waypointsprite_team_here", "defending (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)", CTX(_("QMCMD^defending (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)")))
798 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^roaming, icon")), "say_team %s; g_waypointsprite_team_here", "roaming (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)", CTX(_("QMCMD^roaming (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)")))
799 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^attacking, icon")), "say_team %s; g_waypointsprite_team_here", "attacking (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)", CTX(_("QMCMD^attacking (l:%l^7) (h:%h^7 a:%a^7 w:%w^7)")))
800 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^killed flagcarrier, icon")), "say_team %s; g_waypointsprite_team_here_p", "killed flagcarrier (l:%y^7)", CTX(_("QMCMD^killed flagcarrier (l:%y^7)")))
801 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^dropped flag, icon")), "say_team %s; g_waypointsprite_team_here_d", "dropped flag (l:%d^7)", CTX(_("QMCMD^dropped flag (l:%d^7)")))
802 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^drop weapon, icon")), "say_team %s; g_waypointsprite_team_here; wait; dropweapon", "dropped gun %w^7 (l:%l^7)", CTX(_("QMCMD^dropped weapon %w^7 (l:%l^7)")))
803 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^drop flag/key, icon")), "say_team %s; g_waypointsprite_team_here; wait; use", "dropped flag/key %w^7 (l:%l^7)", CTX(_("QMCMD^dropped flag/key %w^7 (l:%l^7)")))
804 QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
807 QUICKMENU_SMENU_PL(CTX(_("QMCMD^Send private message to")), "Send private message to", "commandmode tell \"%s^7\"", 0, 1)
809 QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
810 QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
811 QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person view")), "toggle chase_active")
812 QUICKMENU_ENTRY(CTX(_("QMCMD^Player models like mine")), "toggle cl_forceplayermodels")
813 QUICKMENU_ENTRY(CTX(_("QMCMD^Names above players")), "toggle hud_shownames")
814 QUICKMENU_ENTRY(CTX(_("QMCMD^Crosshair per weapon")), "toggle crosshair_per_weapon")
815 QUICKMENU_ENTRY(CTX(_("QMCMD^FPS")), "toggle hud_panel_engineinfo")
816 QUICKMENU_ENTRY(CTX(_("QMCMD^Net graph")), "toggle shownetgraph")
817 QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
819 QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
820 QUICKMENU_ENTRY(CTX(_("QMCMD^Hit sound")), "toggle cl_hitsound")
821 QUICKMENU_ENTRY(CTX(_("QMCMD^Chat sound")), "toggle con_chatsound")
822 QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
824 if(spectatee_status > 0)
826 QUICKMENU_SMENU(CTX(_("QMCMD^Spectator camera")), "Spectator camera")
827 QUICKMENU_ENTRY(CTX(_("QMCMD^1st person")), "chase_active 0; -use")
828 QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person around player")), "chase_active 1; +use")
829 QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person behind")), "chase_active 1; -use")
830 QUICKMENU_SMENU(CTX(_("QMCMD^Spectator camera")), "Spectator camera")
833 if(spectatee_status == -1)
835 QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
836 QUICKMENU_ENTRY(CTX(_("QMCMD^Increase speed")), "weapnext")
837 QUICKMENU_ENTRY(CTX(_("QMCMD^Decrease speed")), "weapprev")
838 QUICKMENU_ENTRY(CTX(_("QMCMD^Wall collision off")), "+use")
839 QUICKMENU_ENTRY(CTX(_("QMCMD^Wall collision on")), "-use")
840 QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
843 QUICKMENU_ENTRY(CTX(_("QMCMD^Fullscreen")), "toggle vid_fullscreen; vid_restart")
844 QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
846 QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
847 QUICKMENU_ENTRY(CTX(_("QMCMD^Restart the map")), "vcall restart")
848 QUICKMENU_ENTRY(CTX(_("QMCMD^End match")), "vcall endmatch")
849 if(STAT(TIMELIMIT) > 0)
851 QUICKMENU_ENTRY(CTX(_("QMCMD^Reduce match time")), "vcall reducematchtime")
852 QUICKMENU_ENTRY(CTX(_("QMCMD^Extend match time")), "vcall extendmatchtime")
855 QUICKMENU_ENTRY(CTX(_("QMCMD^Shuffle teams")), "vcall shuffleteams")
856 QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
858 if(target_submenu != "" && !target_submenu_found)
860 LOG_INFOF("Couldn't find submenu \"%s\"", target_submenu);
861 if(prvm_language != "en")
862 LOG_INFOF("^3Warning: submenu title must be in English", target_submenu);
863 QuickMenu_Buffer_Size = 0;
866 #undef QUICKMENU_SMENU
867 #undef QUICKMENU_ENTRY
868 #undef QUICKMENU_ENTRY_TC