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 Release_Common_Keys();
198 QuickMenu_TimeOut_Set();
202 void QuickMenu_Buffer_Close()
204 if (QuickMenu_Buffer >= 0)
206 buf_del(QuickMenu_Buffer);
207 QuickMenu_Buffer = -1;
208 QuickMenu_Buffer_Size = 0;
212 void QuickMenu_Close()
214 strfree(QuickMenu_CurrentSubMenu);
216 for (i = 0; i < QUICKMENU_MAXLINES; ++i)
217 QuickMenu_Page_ClearEntry(i);
218 QuickMenu_Page_Entries = 0;
220 prevMouseClicked = 0;
221 QuickMenu_Buffer_Close();
224 // It assumes submenu open tag is already detected
225 void QuickMenu_skip_submenu(string submenu)
227 string z_submenu = string_null; strcpy(z_submenu, submenu);
228 for(++QuickMenu_Buffer_Index ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
230 string s = QuickMenu_Buffer_Get();
231 if(substring(s, 0, 1) != QM_TAG_SUBMENU)
233 if(substring(s, 1, -1) == z_submenu) // submenu end
235 QuickMenu_skip_submenu(substring(s, 1, -1));
240 bool QuickMenu_IsOpened()
242 return (QuickMenu_Page_Entries > 0);
245 bool HUD_Quickmenu_PlayerListEntries_Create(string cmd, int teamplayers, bool without_me)
247 TC(int, teamplayers); TC(bool, without_me);
249 for(i = 0; i < QUICKMENU_MAXLINES; ++i)
250 QuickMenu_Page_ClearEntry(i);
251 QuickMenu_Buffer_Close();
253 QuickMenu_Buffer = buf_create();
254 if(QuickMenu_Buffer < 0)
257 HUD_Quickmenu_PlayerListEntries(cmd, teamplayers, without_me);
259 if(QuickMenu_Buffer_Size <= 0)
261 buf_del(QuickMenu_Buffer);
262 QuickMenu_Buffer = -1;
268 // new_page 0 means page 0, new_page != 0 means next page
269 int QuickMenu_Buffer_Index_Prev;
270 bool QuickMenu_Page_Load(string target_submenu, bool new_page)
273 string s = string_null, cmd = string_null, z_submenu;
275 QuickMenu_Page_ActivatedEntry = -1;
281 z_submenu = strzone(target_submenu);
282 strcpy(QuickMenu_CurrentSubMenu, z_submenu);
284 QuickMenu_IsLastPage = true;
285 QuickMenu_Page_Entries = 0;
287 QuickMenu_Buffer_Index = 0;
290 // skip everything until the submenu open tag is found
291 for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
293 s = QuickMenu_Buffer_Get();
294 if(substring(s, 0, 1) == QM_TAG_SUBMENU && substring(s, 1, -1) == z_submenu)
296 //LOG_INFOF("^3 beginning of %s\n", z_submenu);
297 ++QuickMenu_Buffer_Index;
298 break; // target_submenu found!
300 //LOG_INFOF("^1 skipping %s\n", s);
302 if(QuickMenu_Buffer_Index == QuickMenu_Buffer_Size)
303 LOG_WARNF("Couldn't find submenu \"%s\"", z_submenu);
306 // only the last page can contain up to QUICKMENU_MAXLINES entries
307 // the other ones contain only (QUICKMENU_MAXLINES - 2) entries
308 // so that the panel can show an empty row and "Continue..."
309 float first_entry = QuickMenu_Page * (QUICKMENU_MAXLINES - 2);
310 int entry_num = 0; // counts entries in target_submenu
311 for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
313 s = QuickMenu_Buffer_Get();
315 if(z_submenu != "" && substring(s, 1, -1) == z_submenu)
317 //LOG_INFOF("^3 end of %s\n", z_submenu);
321 if(entry_num >= first_entry)
323 ++QuickMenu_Page_Entries;
324 if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES - 2)
325 QuickMenu_Buffer_Index_Prev = QuickMenu_Buffer_Index;
326 else if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES)
328 QuickMenu_Page_ClearEntry(QUICKMENU_MAXLINES - 1);
329 QuickMenu_Buffer_Index = QuickMenu_Buffer_Index_Prev;
330 QuickMenu_IsLastPage = false;
335 // NOTE: entries are loaded starting from 1, not from 0
336 if(substring(s, 0, 1) == QM_TAG_SUBMENU)
338 if(entry_num >= first_entry)
339 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), "");
340 QuickMenu_skip_submenu(substring(s, 1, -1));
342 else if(substring(s, 0, 1) == QM_TAG_TITLE)
344 ++QuickMenu_Buffer_Index;
345 if(entry_num >= first_entry)
347 cmd = QuickMenu_Buffer_Get();
348 string command_code = substring(cmd, 0, 1);
349 if(command_code == QM_TAG_COMMAND)
350 cmd = substring(cmd, 1, -1);
351 else if(command_code == QM_TAG_PLCOMMAND)
353 // throw away the current quickmenu buffer and load a new one
354 cmd = substring(cmd, 1, -1);
355 strunzone(z_submenu);
356 if(HUD_Quickmenu_PlayerListEntries_Create(cmd, stof(substring(s, 1, 1)), stof(substring(s, 2, 1))))
357 return QuickMenu_Page_Load("", 0);
362 tokenize_console(cmd);
363 QuickMenu_Page_Command_Type[QuickMenu_Page_Entries] = (argv(1) && argv(0) == "toggle");
365 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), cmd);
372 strunzone(z_submenu);
373 if (QuickMenu_Page_Entries == 0)
378 QuickMenu_TimeOut_Set();
382 bool QuickMenu_ActionForNumber(int num)
385 if (!QuickMenu_IsLastPage)
387 if (num < 0 || num >= QUICKMENU_MAXLINES)
389 if (num == QUICKMENU_MAXLINES - 1)
393 QuickMenu_Page_Load(QuickMenu_CurrentSubMenu, +1);
396 } else if (num <= 0 || num > QuickMenu_Page_Entries)
399 if (QuickMenu_Page_Command[num] != "")
401 QuickMenu_Page_ActivatedEntry_Time = time + 0.1;
402 localcmd(strcat("\n", QuickMenu_Page_Command[num], "\n"));
403 QuickMenu_TimeOut_Set();
406 if (QuickMenu_Page_Description[num] != "")
407 QuickMenu_Page_Load(QuickMenu_Page_Description[num], 0);
411 void QuickMenu_Page_ActiveEntry(int entry_num)
414 QuickMenu_Page_ActivatedEntry = entry_num;
415 if(QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
417 bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
418 // toggle commands don't close the quickmenu
419 if(QuickMenu_Page_Command_Type[QuickMenu_Page_ActivatedEntry] == 1)
420 QuickMenu_Page_ActivatedEntry_Close = false;
422 QuickMenu_Page_ActivatedEntry_Close = (f && !(hudShiftState & S_CTRL));
425 QuickMenu_Page_ActivatedEntry_Close = (!(hudShiftState & S_CTRL));
428 bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
432 if(!QuickMenu_IsOpened() || autocvar__hud_configure || mv_active)
437 mousepos.x = nPrimary;
438 mousepos.y = nSecondary;
445 // at this point bInputType can only be 0 or 1 (key pressed or released)
446 bool key_pressed = (bInputType == 0);
448 int hudShiftState_prev = hudShiftState;
449 int mouseClicked_prev = mouseClicked;
452 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
453 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
454 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
455 if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
456 if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
460 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
461 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
462 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
463 if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
464 if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
467 if(nPrimary == K_ESCAPE && key_pressed)
471 else if(nPrimary >= '0' && nPrimary <= '9' && key_pressed)
473 QuickMenu_Page_ActiveEntry(stof(chr2str(nPrimary)));
475 else if (hudShiftState_prev == hudShiftState && mouseClicked_prev == mouseClicked)
477 // allow console bind to work
478 string con_keys = findkeysforcommand("toggleconsole", 0);
479 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
480 for (int i = 0; i < keys; ++i)
482 if(nPrimary == stof(argv(i)))
483 return false; // hit console bind
493 int entry_num_prev = 0;
494 void QuickMenu_Mouse()
496 if(mv_active) return;
499 if(prevMouseClicked & S_MOUSE2)
505 panel = HUD_PANEL(QUICKMENU);
506 HUD_Panel_LoadCvars();
510 panel_pos += '1 1 0' * panel_bg_padding;
511 panel_size -= '2 2 0' * panel_bg_padding;
514 float first_entry_pos, entries_height;
516 fontsize = '1 1 0' * (panel_size.y / QUICKMENU_MAXLINES);
517 first_entry_pos = panel_pos.y + ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y) / 2;
518 entries_height = panel_size.y - ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y);
520 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)
522 int entry_num = min(QuickMenu_Page_Entries - 1, floor((mousepos.y - first_entry_pos) / fontsize.y));
523 if (entry_num != entry_num_prev)
525 QuickMenu_TimeOut_Set();
526 entry_num_prev = entry_num;
528 if (QuickMenu_IsLastPage || entry_num != QUICKMENU_MAXLINES - 2)
530 if(!mouseClicked && (prevMouseClicked & S_MOUSE1))
531 QuickMenu_Page_ActiveEntry((entry_num < QUICKMENU_MAXLINES - 1) ? entry_num + 1 : 0);
533 if (time > QuickMenu_Page_ActivatedEntry_Time)
535 vector entry_pos = panel_pos;
536 entry_pos.y = first_entry_pos + entry_num * fontsize.y;
538 if (mouseClicked & S_MOUSE1)
540 else if (hudShiftState & S_CTRL)
544 drawfill(entry_pos, vec2(panel_size.x, fontsize.y), color, .2, DRAWFLAG_NORMAL);
550 void HUD_Quickmenu_DrawEntry(vector pos, string desc, string option, vector fontsize)
554 float desc_width = panel_size.x;
557 string pic = strcat(hud_skin_path, "/", option);
558 if(precache_pic(pic) == "")
559 pic = strcat("gfx/hud/default/", option);
560 vector option_size = '1 1 0' * fontsize.y * 0.8;
561 desc_width -= option_size.x;
562 drawpic(pos + vec2(desc_width, (fontsize.y - option_size.y) / 2), pic, option_size, '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
563 desc_width -= fontsize.x / 4;
565 entry = textShortenToWidth(desc, desc_width, fontsize, stringwidth_colors);
566 if (autocvar_hud_panel_quickmenu_align > 0)
568 float real_desc_width = stringwidth_colors(entry, fontsize);
569 offset = (desc_width - real_desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
573 // when there's enough room align description regardless the checkbox
574 float extra_offset = (panel_size.x - desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
575 if(offset + real_desc_width + extra_offset < desc_width)
576 offset += extra_offset;
578 offset = max(0, desc_width - real_desc_width);
580 drawcolorcodedstring(pos + eX * offset, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
583 drawcolorcodedstring(pos, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
588 if(!autocvar__hud_configure)
590 if (!hud_draw_maximized || !QuickMenu_IsOpened())
593 if (HUD_QuickMenu_Forbidden())
601 if(!QuickMenu_IsOpened())
603 QuickMenu_Page_Entries = 1;
604 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
605 ++QuickMenu_Page_Entries;
606 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
607 ++QuickMenu_Page_Entries;
608 // although real command doesn't matter here, it must not be empty
609 // otherwise the entry is displayed like a submenu
610 for (; QuickMenu_Page_Entries < QUICKMENU_MAXLINES - 1; ++QuickMenu_Page_Entries)
611 QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Command%d"), QuickMenu_Page_Entries), "-");
612 ++QuickMenu_Page_Entries;
613 QuickMenu_Page_ClearEntry(QuickMenu_Page_Entries);
614 QuickMenu_IsLastPage = false;
618 HUD_Panel_LoadCvars();
625 panel_pos += '1 1 0' * panel_bg_padding;
626 panel_size -= '2 2 0' * panel_bg_padding;
632 fontsize = '1 1 0' * (panel_size.y / QUICKMENU_MAXLINES);
634 if (!QuickMenu_IsLastPage)
637 HUD_Quickmenu_DrawEntry(panel_pos + eY * (panel_size.y - fontsize.y), sprintf("%d: %s%s", 0, color, _("Continue...")), string_null, fontsize);
640 panel_pos.y += ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y) / 2;
642 for (i = 1; i <= QuickMenu_Page_Entries; ++i) {
643 if (QuickMenu_Page_Description[i] == "")
645 string option = string_null;
646 if (QuickMenu_Page_Command[i] == "")
651 if(QuickMenu_Page_Command_Type[i] == 1) // toggle command
653 int end = strstrofs(QuickMenu_Page_Command[i], ";", 0);
655 tokenize_console(QuickMenu_Page_Command[i]);
657 tokenize_console(substring(QuickMenu_Page_Command[i], 0, end));
659 if(argv(1) && argv(0) == "toggle")
661 // "enable feature xxx" "toggle xxx" (or "toggle xxx 1 0")
662 // "disable feature xxx" "toggle xxx 0 1"
663 float ON_value = 1, OFF_value = 0;
665 ON_value = stof(argv(2));
668 OFF_value = stof(argv(3));
670 OFF_value = !ON_value;
672 float value = cvar(argv(1));
673 if(value == ON_value)
674 option = "checkbox_checked";
675 else if(value == OFF_value)
676 option = "checkbox_empty";
678 option = "checkbox_undefined";
682 HUD_Quickmenu_DrawEntry(panel_pos, sprintf("%d: %s%s", i, color, QuickMenu_Page_Description[i]), option, fontsize);
684 if (time < QuickMenu_Page_ActivatedEntry_Time && QuickMenu_Page_ActivatedEntry == i)
685 drawfill(panel_pos, vec2(panel_size.x, fontsize.y), '0.5 1 0.5', .2, DRAWFLAG_NORMAL);
687 panel_pos.y += fontsize.y;
690 if(QuickMenu_Page_ActivatedEntry >= 0 && time >= QuickMenu_Page_ActivatedEntry_Time)
692 if(!QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
694 bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
695 if(f && QuickMenu_Page_ActivatedEntry_Close)
698 else if(QuickMenu_Page_ActivatedEntry_Close)
700 QuickMenu_Page_ActivatedEntry = -1;
701 QuickMenu_Page_ActivatedEntry_Time = 0;
706 #define QUICKMENU_SMENU(submenu,eng_submenu) { \
707 if(target_submenu == eng_submenu && target_submenu_found) \
708 return; /* target_submenu entries are now loaded, exit */ \
709 if(QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES) \
710 QuickMenu_Buffer_Set(QM_TAG_SUBMENU, submenu); \
711 ++QuickMenu_Buffer_Size; \
712 if(target_submenu == eng_submenu && !target_submenu_found) { \
713 QuickMenu_Buffer_Size = 0; /* enable load of next entries */ \
714 target_submenu_found = true; \
718 #define QUICKMENU_ENTRY(title,command) { \
719 if(QuickMenu_Buffer_Size + 1 < QUICKMENU_BUFFER_MAXENTRIES) \
721 QuickMenu_Buffer_Set(QM_TAG_TITLE, title); \
722 ++QuickMenu_Buffer_Size; \
723 QuickMenu_Buffer_Set(QM_TAG_COMMAND, command); \
725 ++QuickMenu_Buffer_Size; \
728 #define QUICKMENU_SMENU_PL(submenu,eng_submenu,command,teamplayers,without_me) { \
729 if(QuickMenu_Buffer_Size + 3 < QUICKMENU_BUFFER_MAXENTRIES) {\
730 QUICKMENU_SMENU(submenu,eng_submenu) \
731 QuickMenu_Buffer_Set(QM_TAG_TITLE, strcat(ftos(teamplayers), ftos(without_me))); \
732 ++QuickMenu_Buffer_Size; \
733 QuickMenu_Buffer_Set(QM_TAG_PLCOMMAND, command); \
734 ++QuickMenu_Buffer_Size; \
735 QUICKMENU_SMENU(submenu,eng_submenu) \
741 // useful to Translate a string inside the Command
742 #define QUICKMENU_ENTRY_TC(title,command,text,translated_text) {\
743 if(prvm_language == "en") { \
745 tc_cmd = sprintf(command, text); \
747 else if(!autocvar_hud_panel_quickmenu_translatecommands || translated_text == text) { \
748 tc_title = strcat("(en)", title); \
749 tc_cmd = sprintf(command, text); \
752 tc_title = strcat("(", prvm_language, ")", title); \
753 tc_cmd = sprintf(command, translated_text); \
755 QUICKMENU_ENTRY(tc_title, tc_cmd) \
758 void HUD_Quickmenu_PlayerListEntries(string cmd, int teamplayers, bool without_me)
760 TC(int, teamplayers); TC(bool, without_me);
762 if(teamplayers && !team_count)
765 Scoreboard_UpdatePlayerTeams();
766 for(pl = players.sort_next; pl; pl = pl.sort_next)
768 if(teamplayers == 1 && (pl.team != myteam || pl.team == NUM_SPECTATOR)) // only own team players
770 if(teamplayers == 2 && (pl.team == myteam || pl.team == NUM_SPECTATOR)) // only enemy team players
772 if(without_me && pl.sv_entnum == player_localnum)
774 QUICKMENU_ENTRY(strcat("^7", entcs_GetName(pl.sv_entnum)), sprintf(cmd, entcs_GetName(pl.sv_entnum)))
781 // Specifying target_submenu, this function only loads entries inside target_submenu
782 // NOTE: alternatively we could have loaded the whole default quickmenu and
783 // then called QuickMenu_Page_Load(target_submenu, 0);
784 // but this sytem is more reliable since we can always refer to target_submenu
785 // with the English title even if a translation is active
786 void QuickMenu_Default(string target_submenu)
788 bool target_submenu_found = false;
789 if(target_submenu != "")
790 QuickMenu_Buffer_Size = QUICKMENU_BUFFER_MAXENTRIES; // forbids load of next entries until target_submenu
795 QUICKMENU_SMENU(_("Chat"), "Chat")
796 QUICKMENU_SMENU_PL(CTX(_("QMCMD^Send public message to")), "Send public message to", "commandmode say %s:^7", 0, 1)
797 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^nice one")), "say %s", ":-) / nice one", CTX(_("QMCMD^:-) / nice one")))
798 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^good game")), "say %s", "good game", CTX(_("QMCMD^good game")))
799 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^hi / good luck")), "say %s", "hi / good luck and have fun", CTX(_("QMCMD^hi / good luck and have fun")))
800 if(prvm_language != "en")
801 QUICKMENU_ENTRY(CTX(_("QMCMD^Send in English")), "toggle hud_panel_quickmenu_translatecommands 0 1; quickmenu; wait; quickmenu default Chat")
802 QUICKMENU_SMENU(_("Chat"), "Chat")
806 QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
807 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^strength soon")), "say_team %s", "strength soon", CTX(_("QMCMD^strength soon")))
808 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)")))
809 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)")))
810 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^negative")), "say_team %s", "negative", CTX(_("QMCMD^negative")))
811 QUICKMENU_ENTRY_TC(CTX(_("QMCMD^positive")), "say_team %s", "positive", CTX(_("QMCMD^positive")))
812 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)")))
813 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)")))
814 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)")))
815 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)")))
816 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)")))
817 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)")))
818 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)")))
819 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)")))
820 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)")))
821 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)")))
822 QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
825 QUICKMENU_SMENU_PL(CTX(_("QMCMD^Send private message to")), "Send private message to", "commandmode tell \"%s^7\"", 0, 1)
827 QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
828 QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
829 QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person view")), "toggle chase_active")
830 QUICKMENU_ENTRY(CTX(_("QMCMD^Player models like mine")), "toggle cl_forceplayermodels")
831 QUICKMENU_ENTRY(CTX(_("QMCMD^Names above players")), "toggle hud_shownames")
832 QUICKMENU_ENTRY(CTX(_("QMCMD^Crosshair per weapon")), "toggle crosshair_per_weapon")
833 QUICKMENU_ENTRY(CTX(_("QMCMD^FPS")), "toggle hud_panel_engineinfo")
834 QUICKMENU_ENTRY(CTX(_("QMCMD^Net graph")), "toggle shownetgraph")
835 QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
837 QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
838 QUICKMENU_ENTRY(CTX(_("QMCMD^Hit sound")), "toggle cl_hitsound")
839 QUICKMENU_ENTRY(CTX(_("QMCMD^Chat sound")), "toggle con_chatsound")
840 QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
842 if(spectatee_status > 0)
844 QUICKMENU_ENTRY(CTX(_("QMCMD^Change spectator camera")), "dropweapon")
847 if(spectatee_status == -1)
849 QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
850 QUICKMENU_ENTRY(CTX(_("QMCMD^Increase speed")), "weapnext")
851 QUICKMENU_ENTRY(CTX(_("QMCMD^Decrease speed")), "weapprev")
852 QUICKMENU_ENTRY(CTX(_("QMCMD^Wall collision")), "toggle cl_clippedspectating")
853 QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
856 QUICKMENU_ENTRY(CTX(_("QMCMD^Fullscreen")), "toggle vid_fullscreen; vid_restart")
857 QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
859 QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
860 QUICKMENU_ENTRY(CTX(_("QMCMD^Restart the map")), "vcall restart")
861 QUICKMENU_ENTRY(CTX(_("QMCMD^End match")), "vcall endmatch")
862 if(STAT(TIMELIMIT) > 0)
864 QUICKMENU_ENTRY(CTX(_("QMCMD^Reduce match time")), "vcall reducematchtime")
865 QUICKMENU_ENTRY(CTX(_("QMCMD^Extend match time")), "vcall extendmatchtime")
868 QUICKMENU_ENTRY(CTX(_("QMCMD^Shuffle teams")), "vcall shuffleteams")
869 QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
871 if(spectatee_status != 0)
873 QUICKMENU_SMENU_PL(CTX(_("QMCMD^Spectate a player")), "Spectate a player", "spectate \"%s^7\"", 0, 1)
876 if(target_submenu != "" && !target_submenu_found)
878 LOG_INFOF("Couldn't find submenu \"%s\"", target_submenu);
879 if(prvm_language != "en")
880 LOG_INFO("^3Warning: submenu title must be in English");
881 QuickMenu_Buffer_Size = 0;
884 #undef QUICKMENU_SMENU
885 #undef QUICKMENU_ENTRY
886 #undef QUICKMENU_ENTRY_TC