1 #include "quickmenu.qh"
3 #include <client/draw.qh>
4 #include <client/hud/_mod.qh>
5 #include <client/mapvoting.qh>
6 #include <common/ent_cs.qh>
7 #include <common/minigames/cl_minigames.qh>
11 void HUD_QuickMenu_Export(int fh)
13 // allow saving cvars that aesthetically change the panel into hud skin files
14 HUD_Write_Cvar("hud_panel_quickmenu_align");
17 // QUICKMENU_MAXLINES must be <= 10
18 const int QUICKMENU_MAXLINES = 10;
19 // visible entries are loaded from QuickMenu_Buffer into QuickMenu_Page_* arrays
20 string QuickMenu_Page_Command[QUICKMENU_MAXLINES];
21 string QuickMenu_Page_Description[QUICKMENU_MAXLINES];
22 int QuickMenu_Page_Command_Type[QUICKMENU_MAXLINES];
23 int QuickMenu_Page_Entries;
25 int QuickMenu_Page_ActivatedEntry = -1;
26 bool QuickMenu_Page_ActivatedEntry_Close;
27 float QuickMenu_Page_ActivatedEntry_Time;
28 bool QuickMenu_IsLastPage;
29 // all the entries are loaded into QuickMenu_Buffer
30 // each entry (submenu or command) is composed of 2 entries
31 const int QUICKMENU_MAXENTRIES = 256;
32 const int QUICKMENU_BUFFER_MAXENTRIES = 2 * QUICKMENU_MAXENTRIES;
33 int QuickMenu_Buffer = -1;
34 int QuickMenu_Buffer_Size;
35 int QuickMenu_Buffer_Index;
36 string QuickMenu_CurrentSubMenu;
37 float QuickMenu_TimeOut;
39 // QuickMenu_Buffer are labeled with these tags
40 #define QM_TAG_TITLE "T"
41 #define QM_TAG_SUBMENU "S"
42 #define QM_TAG_COMMAND "C"
43 #define QM_TAG_PLCOMMAND "P"
45 #define QuickMenu_Buffer_Set(tag, string) bufstr_set(QuickMenu_Buffer, QuickMenu_Buffer_Size, strcat(tag, string))
46 #define QuickMenu_Buffer_Get() bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index)
48 void QuickMenu_TimeOut_Set()
50 QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
53 // if s1 is not empty s will be displayed as command otherwise as submenu
54 void QuickMenu_Page_LoadEntry(int i, string s, string s1)
57 //LOG_INFOF("^xc80 entry %d: %s, %s\n", i, s, s1);
58 strcpy(QuickMenu_Page_Description[i], s);
59 strcpy(QuickMenu_Page_Command[i], s1);
62 void QuickMenu_Page_ClearEntry(int i)
65 strfree(QuickMenu_Page_Description[i]);
66 strfree(QuickMenu_Page_Command[i]);
67 QuickMenu_Page_Command_Type[i] = 0;
70 bool HUD_QuickMenu_Forbidden()
73 || scoreboard_ui_enabled
74 || (hud_configure_prev && hud_configure_prev != -1)
75 || HUD_MinigameMenu_IsOpened()
76 || (QuickMenu_TimeOut && time > QuickMenu_TimeOut));
79 // returns true if succeded, false otherwise
80 bool QuickMenu_Open(string mode, string submenu, string file)
82 QuickMenu_TimeOut = 0;
83 if (HUD_QuickMenu_Forbidden())
91 if(file == "" || file == "0")
99 if(file == "" || file == "0")
100 LOG_INFO("No file name is set in hud_panel_quickmenu_file, loading default quickmenu");
103 fh = fopen(file, FILE_READ);
105 LOG_INFOF("Couldn't open file \"%s\", loading default quickmenu", file);
111 if(mode == "default")
113 QuickMenu_Buffer = buf_create();
114 if(QuickMenu_Buffer < 0)
117 QuickMenu_Default(submenu);
119 else if(mode == "file")
121 QuickMenu_Buffer = buf_create();
122 if(QuickMenu_Buffer < 0)
128 QuickMenu_Buffer_Size = 0;
129 while((s = fgets(fh)) && QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES)
131 // first skip invalid entries, so we don't check them anymore
133 argc = tokenize_console(s);
134 if(argc == 0 || argv(0) == "")
137 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
142 QuickMenu_Buffer_Set(QM_TAG_TITLE, argv(0));
143 ++QuickMenu_Buffer_Size;
144 QuickMenu_Buffer_Set(QM_TAG_COMMAND, argv(1));
148 // check for special keywords
149 float teamplayers = 0, without_me = 0;
152 case "ALLPLAYERS_BUT_ME": without_me = 1; // fall through
153 case "ALLPLAYERS": teamplayers = 0; break;
154 case "OWNTEAMPLAYERS_BUT_ME": without_me = 1; // fall through
155 case "OWNTEAMPLAYERS": teamplayers = 1; break;
156 case "ENEMYTEAMPLAYERS": teamplayers = 2; break;
160 if(QuickMenu_Buffer_Size + 3 < QUICKMENU_BUFFER_MAXENTRIES)
162 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
163 ++QuickMenu_Buffer_Size;
164 QuickMenu_Buffer_Set(QM_TAG_TITLE, strcat(ftos(teamplayers), ftos(without_me))); // put PLCOMMAND arguments in the title string
165 ++QuickMenu_Buffer_Size;
166 QuickMenu_Buffer_Set(QM_TAG_PLCOMMAND, argv(1));
167 ++QuickMenu_Buffer_Size;
168 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
171 ++QuickMenu_Buffer_Size;
177 LOG_WARNF("Unrecognized mode %s", mode);
181 if (QuickMenu_Buffer_Size <= 0)
183 buf_del(QuickMenu_Buffer);
184 QuickMenu_Buffer = -1;
189 QuickMenu_Page_Load(submenu, 0);
191 QuickMenu_Page_Load("", 0);
196 // we must unset the player's buttons, as they aren't released elsewhere
198 localcmd("-fire2\n");
203 QuickMenu_TimeOut_Set();
207 void QuickMenu_Buffer_Close()
209 if (QuickMenu_Buffer >= 0)
211 buf_del(QuickMenu_Buffer);
212 QuickMenu_Buffer = -1;
213 QuickMenu_Buffer_Size = 0;
217 void QuickMenu_Close()
219 strfree(QuickMenu_CurrentSubMenu);
221 for (i = 0; i < QUICKMENU_MAXLINES; ++i)
222 QuickMenu_Page_ClearEntry(i);
223 QuickMenu_Page_Entries = 0;
225 prevMouseClicked = 0;
226 QuickMenu_Buffer_Close();
229 // It assumes submenu open tag is already detected
230 void QuickMenu_skip_submenu(string submenu)
232 string z_submenu = string_null; strcpy(z_submenu, submenu);
233 for(++QuickMenu_Buffer_Index ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
235 string s = QuickMenu_Buffer_Get();
236 if(substring(s, 0, 1) != QM_TAG_SUBMENU)
238 if(substring(s, 1, -1) == z_submenu) // submenu end
240 QuickMenu_skip_submenu(substring(s, 1, -1));
245 bool QuickMenu_IsOpened()
247 return (QuickMenu_Page_Entries > 0);
250 bool HUD_Quickmenu_PlayerListEntries_Create(string cmd, int teamplayers, bool without_me)
252 TC(int, teamplayers); TC(bool, without_me);
254 for(i = 0; i < QUICKMENU_MAXLINES; ++i)
255 QuickMenu_Page_ClearEntry(i);
256 QuickMenu_Buffer_Close();
258 QuickMenu_Buffer = buf_create();
259 if(QuickMenu_Buffer < 0)
262 HUD_Quickmenu_PlayerListEntries(cmd, teamplayers, without_me);
264 if(QuickMenu_Buffer_Size <= 0)
266 buf_del(QuickMenu_Buffer);
267 QuickMenu_Buffer = -1;
273 // new_page 0 means page 0, new_page != 0 means next page
274 int QuickMenu_Buffer_Index_Prev;
275 bool QuickMenu_Page_Load(string target_submenu, bool new_page)
278 string s = string_null, cmd = string_null, z_submenu;
280 QuickMenu_Page_ActivatedEntry = -1;
286 z_submenu = strzone(target_submenu);
287 strcpy(QuickMenu_CurrentSubMenu, z_submenu);
289 QuickMenu_IsLastPage = true;
290 QuickMenu_Page_Entries = 0;
292 QuickMenu_Buffer_Index = 0;
295 // skip everything until the submenu open tag is found
296 for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
298 s = QuickMenu_Buffer_Get();
299 if(substring(s, 0, 1) == QM_TAG_SUBMENU && substring(s, 1, -1) == z_submenu)
301 //LOG_INFOF("^3 beginning of %s\n", z_submenu);
302 ++QuickMenu_Buffer_Index;
303 break; // target_submenu found!
305 //LOG_INFOF("^1 skipping %s\n", s);
307 if(QuickMenu_Buffer_Index == QuickMenu_Buffer_Size)
308 LOG_WARNF("Couldn't find submenu \"%s\"", z_submenu);
311 // only the last page can contain up to QUICKMENU_MAXLINES entries
312 // the other ones contain only (QUICKMENU_MAXLINES - 2) entries
313 // so that the panel can show an empty row and "Continue..."
314 float first_entry = QuickMenu_Page * (QUICKMENU_MAXLINES - 2);
315 int entry_num = 0; // counts entries in target_submenu
316 for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
318 s = QuickMenu_Buffer_Get();
320 if(z_submenu != "" && substring(s, 1, -1) == z_submenu)
322 //LOG_INFOF("^3 end of %s\n", z_submenu);
326 if(entry_num >= first_entry)
328 ++QuickMenu_Page_Entries;
329 if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES - 2)
330 QuickMenu_Buffer_Index_Prev = QuickMenu_Buffer_Index;
331 else if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES)
333 QuickMenu_Page_ClearEntry(QUICKMENU_MAXLINES - 1);
334 QuickMenu_Buffer_Index = QuickMenu_Buffer_Index_Prev;
335 QuickMenu_IsLastPage = false;
340 // NOTE: entries are loaded starting from 1, not from 0
341 if(substring(s, 0, 1) == QM_TAG_SUBMENU)
343 if(entry_num >= first_entry)
344 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), "");
345 QuickMenu_skip_submenu(substring(s, 1, -1));
347 else if(substring(s, 0, 1) == QM_TAG_TITLE)
349 ++QuickMenu_Buffer_Index;
350 if(entry_num >= first_entry)
352 cmd = QuickMenu_Buffer_Get();
353 string command_code = substring(cmd, 0, 1);
354 if(command_code == QM_TAG_COMMAND)
355 cmd = substring(cmd, 1, -1);
356 else if(command_code == QM_TAG_PLCOMMAND)
358 // throw away the current quickmenu buffer and load a new one
359 cmd = substring(cmd, 1, -1);
360 strunzone(z_submenu);
361 if(HUD_Quickmenu_PlayerListEntries_Create(cmd, stof(substring(s, 1, 1)), stof(substring(s, 2, 1))))
362 return QuickMenu_Page_Load("", 0);
367 tokenize_console(cmd);
368 QuickMenu_Page_Command_Type[QuickMenu_Page_Entries] = (argv(1) && argv(0) == "toggle");
370 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), cmd);
377 strunzone(z_submenu);
378 if (QuickMenu_Page_Entries == 0)
383 QuickMenu_TimeOut_Set();
387 bool QuickMenu_ActionForNumber(int num)
390 if (!QuickMenu_IsLastPage)
392 if (num < 0 || num >= QUICKMENU_MAXLINES)
394 if (num == QUICKMENU_MAXLINES - 1)
398 QuickMenu_Page_Load(QuickMenu_CurrentSubMenu, +1);
401 } else if (num <= 0 || num > QuickMenu_Page_Entries)
404 if (QuickMenu_Page_Command[num] != "")
406 QuickMenu_Page_ActivatedEntry_Time = time + 0.1;
407 localcmd(strcat("\n", QuickMenu_Page_Command[num], "\n"));
408 QuickMenu_TimeOut_Set();
411 if (QuickMenu_Page_Description[num] != "")
412 QuickMenu_Page_Load(QuickMenu_Page_Description[num], 0);
416 void QuickMenu_Page_ActiveEntry(int entry_num)
419 QuickMenu_Page_ActivatedEntry = entry_num;
420 if(QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
422 bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
423 // toggle commands don't close the quickmenu
424 if(QuickMenu_Page_Command_Type[QuickMenu_Page_ActivatedEntry] == 1)
425 QuickMenu_Page_ActivatedEntry_Close = false;
427 QuickMenu_Page_ActivatedEntry_Close = (f && !(hudShiftState & S_CTRL));
430 QuickMenu_Page_ActivatedEntry_Close = (!(hudShiftState & S_CTRL));
433 bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
437 if(!QuickMenu_IsOpened() || autocvar__hud_configure || mv_active)
442 mousepos.x = nPrimary;
443 mousepos.y = nSecondary;
450 // at this point bInputType can only be 0 or 1 (key pressed or released)
451 bool key_pressed = (bInputType == 0);
453 int hudShiftState_prev = hudShiftState;
454 int mouseClicked_prev = mouseClicked;
457 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
458 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
459 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
460 if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
461 if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
465 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
466 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
467 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
468 if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
469 if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
472 if(nPrimary == K_ESCAPE && key_pressed)
476 else if(nPrimary >= '0' && nPrimary <= '9' && key_pressed)
478 QuickMenu_Page_ActiveEntry(stof(chr2str(nPrimary)));
480 else if (hudShiftState_prev == hudShiftState && mouseClicked_prev == mouseClicked)
482 // allow console bind to work
483 string con_keys = findkeysforcommand("toggleconsole", 0);
484 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
485 for (int i = 0; i < keys; ++i)
487 if(nPrimary == stof(argv(i)))
488 return false; // hit console bind
498 int entry_num_prev = 0;
499 void QuickMenu_Mouse()
501 if(mv_active) return;
504 if(prevMouseClicked & S_MOUSE2)
510 panel = HUD_PANEL(QUICKMENU);
511 HUD_Panel_LoadCvars();
515 panel_pos += '1 1 0' * panel_bg_padding;
516 panel_size -= '2 2 0' * panel_bg_padding;
519 float first_entry_pos, entries_height;
521 fontsize = '1 1 0' * (panel_size.y / QUICKMENU_MAXLINES);
522 first_entry_pos = panel_pos.y + ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y) / 2;
523 entries_height = panel_size.y - ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y);
525 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)
527 int entry_num = min(QuickMenu_Page_Entries - 1, floor((mousepos.y - first_entry_pos) / fontsize.y));
528 if (entry_num != entry_num_prev)
530 QuickMenu_TimeOut_Set();
531 entry_num_prev = entry_num;
533 if (QuickMenu_IsLastPage || entry_num != QUICKMENU_MAXLINES - 2)
535 if(!mouseClicked && (prevMouseClicked & S_MOUSE1))
536 QuickMenu_Page_ActiveEntry((entry_num < QUICKMENU_MAXLINES - 1) ? entry_num + 1 : 0);
538 if (time > QuickMenu_Page_ActivatedEntry_Time)
540 vector entry_pos = panel_pos;
541 entry_pos.y = first_entry_pos + entry_num * fontsize.y;
543 if (mouseClicked & S_MOUSE1)
545 else if (hudShiftState & S_CTRL)
549 drawfill(entry_pos, vec2(panel_size.x, fontsize.y), color, .2, DRAWFLAG_NORMAL);
555 void HUD_Quickmenu_DrawEntry(vector pos, string desc, string option, vector fontsize)
559 float desc_width = panel_size.x;
562 string pic = strcat(hud_skin_path, "/", option);
563 if(precache_pic(pic) == "")
564 pic = strcat("gfx/hud/default/", option);
565 vector option_size = '1 1 0' * fontsize.y * 0.8;
566 desc_width -= option_size.x;
567 drawpic(pos + vec2(desc_width, (fontsize.y - option_size.y) / 2), pic, option_size, '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
568 desc_width -= fontsize.x / 4;
570 entry = textShortenToWidth(desc, desc_width, fontsize, stringwidth_colors);
571 if (autocvar_hud_panel_quickmenu_align > 0)
573 float real_desc_width = stringwidth_colors(entry, fontsize);
574 offset = (desc_width - real_desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
578 // when there's enough room align description regardless the checkbox
579 float extra_offset = (panel_size.x - desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
580 if(offset + real_desc_width + extra_offset < desc_width)
581 offset += extra_offset;
583 offset = max(0, desc_width - real_desc_width);
585 drawcolorcodedstring(pos + eX * offset, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
588 drawcolorcodedstring(pos, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
593 if(!autocvar__hud_configure)
595 if (!hud_draw_maximized || !QuickMenu_IsOpened())
598 if (HUD_QuickMenu_Forbidden())
606 if(!QuickMenu_IsOpened())
608 QuickMenu_Page_Entries = 1;
609 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
610 ++QuickMenu_Page_Entries;
611 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
612 ++QuickMenu_Page_Entries;
613 // although real command doesn't matter here, it must not be empty
614 // otherwise the entry is displayed like a submenu
615 for (; QuickMenu_Page_Entries < QUICKMENU_MAXLINES - 1; ++QuickMenu_Page_Entries)
616 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Command%d"), QuickMenu_Page_Entries), "-");
617 ++QuickMenu_Page_Entries;
618 QuickMenu_Page_ClearEntry(QuickMenu_Page_Entries);
619 QuickMenu_IsLastPage = false;
623 HUD_Panel_LoadCvars();
630 panel_pos += '1 1 0' * panel_bg_padding;
631 panel_size -= '2 2 0' * panel_bg_padding;
637 fontsize = '1 1 0' * (panel_size.y / QUICKMENU_MAXLINES);
639 if (!QuickMenu_IsLastPage)
642 HUD_Quickmenu_DrawEntry(panel_pos + eY * (panel_size.y - fontsize.y), sprintf("%d: %s%s", 0, color, _("Continue...")), string_null, fontsize);
645 panel_pos.y += ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y) / 2;
647 for (i = 1; i <= QuickMenu_Page_Entries; ++i) {
648 if (QuickMenu_Page_Description[i] == "")
650 string option = string_null;
651 if (QuickMenu_Page_Command[i] == "")
656 if(QuickMenu_Page_Command_Type[i] == 1) // toggle command
658 int end = strstrofs(QuickMenu_Page_Command[i], ";", 0);
660 tokenize_console(QuickMenu_Page_Command[i]);
662 tokenize_console(substring(QuickMenu_Page_Command[i], 0, end));
664 if(argv(1) && argv(0) == "toggle")
666 // "enable feature xxx" "toggle xxx" (or "toggle xxx 1 0")
667 // "disable feature xxx" "toggle xxx 0 1"
668 float ON_value = 1, OFF_value = 0;
670 ON_value = stof(argv(2));
673 OFF_value = stof(argv(3));
675 OFF_value = !ON_value;
677 float value = cvar(argv(1));
678 if(value == ON_value)
679 option = "checkbox_checked";
680 else if(value == OFF_value)
681 option = "checkbox_empty";
683 option = "checkbox_undefined";
687 HUD_Quickmenu_DrawEntry(panel_pos, sprintf("%d: %s%s", i, color, QuickMenu_Page_Description[i]), option, fontsize);
689 if (time < QuickMenu_Page_ActivatedEntry_Time && QuickMenu_Page_ActivatedEntry == i)
690 drawfill(panel_pos, vec2(panel_size.x, fontsize.y), '0.5 1 0.5', .2, DRAWFLAG_NORMAL);
692 panel_pos.y += fontsize.y;
695 if(QuickMenu_Page_ActivatedEntry >= 0 && time >= QuickMenu_Page_ActivatedEntry_Time)
697 if(!QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
699 bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
700 if(f && QuickMenu_Page_ActivatedEntry_Close)
703 else if(QuickMenu_Page_ActivatedEntry_Close)
705 QuickMenu_Page_ActivatedEntry = -1;
706 QuickMenu_Page_ActivatedEntry_Time = 0;
711 #define QUICKMENU_SMENU(submenu,eng_submenu) { \
712 if(target_submenu == eng_submenu && target_submenu_found) \
713 return; /* target_submenu entries are now loaded, exit */ \
714 if(QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES) \
715 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, submenu); \
716 ++QuickMenu_Buffer_Size; \
717 if(target_submenu == eng_submenu && !target_submenu_found) { \
718 QuickMenu_Buffer_Size = 0; /* enable load of next entries */ \
719 target_submenu_found = true; \
723 #define QUICKMENU_ENTRY(title,command) { \
724 if(QuickMenu_Buffer_Size + 1 < QUICKMENU_BUFFER_MAXENTRIES) \
726 QuickMenu_Buffer_Set(QM_TAG_TITLE, title); \
727 ++QuickMenu_Buffer_Size; \
728 QuickMenu_Buffer_Set(QM_TAG_COMMAND, command); \
730 ++QuickMenu_Buffer_Size; \
733 #define QUICKMENU_SMENU_PL(submenu,eng_submenu,command,teamplayers,without_me) { \
734 if(QuickMenu_Buffer_Size + 3 < QUICKMENU_BUFFER_MAXENTRIES) {\
735 QUICKMENU_SMENU(submenu,eng_submenu) \
736 QuickMenu_Buffer_Set(QM_TAG_TITLE, strcat(ftos(teamplayers), ftos(without_me))); \
737 ++QuickMenu_Buffer_Size; \
738 QuickMenu_Buffer_Set(QM_TAG_PLCOMMAND, command); \
739 ++QuickMenu_Buffer_Size; \
740 QUICKMENU_SMENU(submenu,eng_submenu) \
746 // useful to Translate a string inside the Command
747 #define QUICKMENU_ENTRY_TC(title,command,text,translated_text) {\
748 if(prvm_language == "en") { \
750 tc_cmd = sprintf(command, text); \
752 else if(!autocvar_hud_panel_quickmenu_translatecommands || translated_text == text) { \
753 tc_title = strcat("(en)", title); \
754 tc_cmd = sprintf(command, text); \
757 tc_title = strcat("(", prvm_language, ")", title); \
758 tc_cmd = sprintf(command, translated_text); \
760 QUICKMENU_ENTRY(tc_title, tc_cmd) \
763 void HUD_Quickmenu_PlayerListEntries(string cmd, int teamplayers, bool without_me)
765 TC(int, teamplayers); TC(bool, without_me);
767 if(teamplayers && !team_count)
770 Scoreboard_UpdatePlayerTeams();
771 for(pl = players.sort_next; pl; pl = pl.sort_next)
773 if(teamplayers == 1 && (pl.team != myteam || pl.team == NUM_SPECTATOR)) // only own team players
775 if(teamplayers == 2 && (pl.team == myteam || pl.team == NUM_SPECTATOR)) // only enemy team players
777 if(without_me && pl.sv_entnum == player_localnum)
779 QUICKMENU_ENTRY(strcat("^7", entcs_GetName(pl.sv_entnum)), sprintf(cmd, entcs_GetName(pl.sv_entnum)))
786 // Specifying target_submenu, this function only loads entries inside target_submenu
787 // NOTE: alternatively we could have loaded the whole default quickmenu and
788 // then called QuickMenu_Page_Load(target_submenu, 0);
789 // but this sytem is more reliable since we can always refer to target_submenu
790 // with the English title even if a translation is active
791 void QuickMenu_Default(string target_submenu)
793 bool target_submenu_found = false;
794 if(target_submenu != "")
795 QuickMenu_Buffer_Size = QUICKMENU_BUFFER_MAXENTRIES; // forbids load of next entries until target_submenu
800 QUICKMENU_SMENU(_("Chat"), "Chat")
801 QUICKMENU_SMENU_PL(CTX(_("QMCMD^Send public message to")), "Send public message to", "commandmode say %s:^7", 0, 1)
802 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^nice one")), "say %s", ":-) / nice one", CTX(_("QMCMD^:-) / nice one")))
803 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^good game")), "say %s", "good game", CTX(_("QMCMD^good game")))
804 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^hi / good luck")), "say %s", "hi / good luck and have fun", CTX(_("QMCMD^hi / good luck and have fun")))
805 if(prvm_language != "en")
806 QUICKMENU_ENTRY(CTX(_("QMCMD^Send in English")), "toggle hud_panel_quickmenu_translatecommands 0 1; quickmenu; wait; quickmenu default Chat")
807 QUICKMENU_SMENU(_("Chat"), "Chat")
811 QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
812 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^strength soon")), "say_team %s", "strength soon", CTX(_("QMCMD^strength soon")))
813 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)")))
814 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)")))
815 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^negative")), "say_team %s", "negative", CTX(_("QMCMD^negative")))
816 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^positive")), "say_team %s", "positive", CTX(_("QMCMD^positive")))
817 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)")))
818 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)")))
819 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)")))
820 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)")))
821 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)")))
822 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)")))
823 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)")))
824 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)")))
825 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)")))
826 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)")))
827 QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
830 QUICKMENU_SMENU_PL(CTX(_("QMCMD^Send private message to")), "Send private message to", "commandmode tell \"%s^7\"", 0, 1)
832 QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
833 QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
834 QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person view")), "toggle chase_active")
835 QUICKMENU_ENTRY(CTX(_("QMCMD^Player models like mine")), "toggle cl_forceplayermodels")
836 QUICKMENU_ENTRY(CTX(_("QMCMD^Names above players")), "toggle hud_shownames")
837 QUICKMENU_ENTRY(CTX(_("QMCMD^Crosshair per weapon")), "toggle crosshair_per_weapon")
838 QUICKMENU_ENTRY(CTX(_("QMCMD^FPS")), "toggle hud_panel_engineinfo")
839 QUICKMENU_ENTRY(CTX(_("QMCMD^Net graph")), "toggle shownetgraph")
840 QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
842 QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
843 QUICKMENU_ENTRY(CTX(_("QMCMD^Hit sound")), "toggle cl_hitsound")
844 QUICKMENU_ENTRY(CTX(_("QMCMD^Chat sound")), "toggle con_chatsound")
845 QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
847 if(spectatee_status > 0)
849 QUICKMENU_ENTRY(CTX(_("QMCMD^Change spectator camera")), "dropweapon")
852 if(spectatee_status == -1)
854 QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
855 QUICKMENU_ENTRY(CTX(_("QMCMD^Increase speed")), "weapnext")
856 QUICKMENU_ENTRY(CTX(_("QMCMD^Decrease speed")), "weapprev")
857 QUICKMENU_ENTRY(CTX(_("QMCMD^Wall collision")), "toggle cl_clippedspectating")
858 QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
861 QUICKMENU_ENTRY(CTX(_("QMCMD^Fullscreen")), "toggle vid_fullscreen; vid_restart")
862 QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
864 QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
865 QUICKMENU_ENTRY(CTX(_("QMCMD^Restart the map")), "vcall restart")
866 QUICKMENU_ENTRY(CTX(_("QMCMD^End match")), "vcall endmatch")
867 if(STAT(TIMELIMIT) > 0)
869 QUICKMENU_ENTRY(CTX(_("QMCMD^Reduce match time")), "vcall reducematchtime")
870 QUICKMENU_ENTRY(CTX(_("QMCMD^Extend match time")), "vcall extendmatchtime")
873 QUICKMENU_ENTRY(CTX(_("QMCMD^Shuffle teams")), "vcall shuffleteams")
874 QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
876 if(spectatee_status != 0)
878 QUICKMENU_SMENU_PL(CTX(_("QMCMD^Spectate a player")), "Spectate a player", "spectate \"%s^7\"", 0, 1)
881 if(target_submenu != "" && !target_submenu_found)
883 LOG_INFOF("Couldn't find submenu \"%s\"", target_submenu);
884 if(prvm_language != "en")
885 LOG_INFO("^3Warning: submenu title must be in English");
886 QuickMenu_Buffer_Size = 0;
889 #undef QUICKMENU_SMENU
890 #undef QUICKMENU_ENTRY
891 #undef QUICKMENU_ENTRY_TC