]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge remote-tracking branch 'origin/Mario/quickmenu_merge' into terencehill/quickmen...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 7dfaa94859ec737136ee05643720959896484be4..72458cf4b4b4d9a3fbf74fb3d546b6a7ca738f48 100644 (file)
@@ -242,7 +242,7 @@ float GetPlayerColorForce(float i)
 
 float GetPlayerColor(float i)
 {
-       if not(playerslots[i].gotscores) // unconnected
+       if(!playerslots[i].gotscores) // unconnected
                return NUM_SPECTATOR;
        else if(stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR)
                return NUM_SPECTATOR;
@@ -734,12 +734,12 @@ void HUD_Weapons(void)
 
                // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
                if(autocvar_hud_panel_weapons_onlyowned)
-               if not((weapons_stat & WepSet_FromWeapon(self.weapon)) || (self.weapon == complain_weapon))
+               if (!((weapons_stat & WepSet_FromWeapon(self.weapon)) || (self.weapon == complain_weapon)))
                        continue;
 
                // figure out the drawing position of weapon
-               weapon_pos = (panel_pos 
-                       + eX * column * weapon_size_x 
+               weapon_pos = (panel_pos
+                       + eX * column * weapon_size_x
                        + eY * row * weapon_size_y);
 
                // draw background behind currently selected weapon
@@ -1133,7 +1133,7 @@ void HUD_Powerups(void)
        {
                if(!autocvar_hud_panel_powerups) return;
                if(spectatee_status == -1) return;
-               if not(getstati(STAT_ITEMS, 0, 24) & (IT_STRENGTH | IT_INVINCIBLE | IT_SUPERWEAPON)) return;
+               if(!(getstati(STAT_ITEMS, 0, 24) & (IT_STRENGTH | IT_INVINCIBLE | IT_SUPERWEAPON))) return;
                if (getstati(STAT_HEALTH) <= 0) return;
 
                strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
@@ -1543,7 +1543,7 @@ void HUD_HealthArmor(void)
                                        {
                                                float BLINK_FACTOR = 0.15;
                                                float BLINK_BASE = 0.85;
-                                               float BLINK_FREQ = 9; 
+                                               float BLINK_FREQ = 9;
                                                pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
                                        }
                                }
@@ -1664,7 +1664,7 @@ void HUD_Notify(void)
        float entries, height;
        entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
        height = mySize_y/entries;
-       
+
        vector fontsize;
        float fontheight = height * autocvar_hud_panel_notify_fontsize;
        fontsize = '0.5 0.5 0' * fontheight;
@@ -1726,7 +1726,7 @@ void HUD_Notify(void)
                        {
                                break;
                        }
-                       
+
                        attacker = notify_attackers[j];
                        victim = notify_victims[j];
                        icon = notify_icon[j];
@@ -1865,10 +1865,10 @@ void HUD_Radar(void)
                panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
                panel_pos_x = (vid_conwidth - panel_size_x) / 2;
                panel_pos_y = (vid_conheight - panel_size_y) / 2;
-               
+
                panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
                if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } // fallback
-               
+
                switch(hud_panel_radar_maximized_zoommode)
                {
                        default:
@@ -1885,7 +1885,7 @@ void HUD_Radar(void)
                                f = 1;
                                break;
                }
-               
+
                switch(hud_panel_radar_maximized_rotation)
                {
                        case 0:
@@ -1914,7 +1914,7 @@ void HUD_Radar(void)
                                f = 1;
                                break;
                }
-               
+
                switch(hud_panel_radar_rotation)
                {
                        case 0:
@@ -2297,7 +2297,7 @@ void HUD_Score(void)
                        score = tm.(teamscores[ts_primary]);
                        if(autocvar__hud_configure)
                                score = 123;
-                       
+
                        if (score > max_fragcount)
                                max_fragcount = score;
 
@@ -2752,7 +2752,7 @@ void HUD_Mod_CTF(vector pos, vector mySize)
        stat_items = getstati(STAT_ITEMS, 0, 24);
        redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
        blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
-       
+
        if(redflag || blueflag)
                mod_active = 1;
        else
@@ -3029,29 +3029,29 @@ void HUD_Mod_KH(vector pos, vector mySize)
 float kaball_prevstatus; // last remembered status
 float kaball_statuschange_time; // time when the status changed
 
-// we don't need to reset for keepaway since it immediately 
+// we don't need to reset for keepaway since it immediately
 // autocorrects prevstatus as to if the player has the ball or not
 
 void HUD_Mod_Keepaway(vector pos, vector mySize)
 {
        mod_active = 1; // keepaway should always show the mod HUD
-       
+
        float BLINK_FACTOR = 0.15;
        float BLINK_BASE = 0.85;
-       float BLINK_FREQ = 5; 
+       float BLINK_FREQ = 5;
        float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
-       
+
        float stat_items = getstati(STAT_ITEMS, 0, 24);
        float kaball = (stat_items/IT_KEY1) & 1;
-       
+
        if(kaball != kaball_prevstatus)
        {
                kaball_statuschange_time = time;
                kaball_prevstatus = kaball;
        }
-       
+
        vector kaball_pos, kaball_size;
-       
+
        if(mySize_x > mySize_y) {
                kaball_pos = pos + eX * 0.25 * mySize_x;
                kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
@@ -3059,13 +3059,13 @@ void HUD_Mod_Keepaway(vector pos, vector mySize)
                kaball_pos = pos + eY * 0.25 * mySize_y;
                kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
        }
-       
+
        float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
        float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
-       
+
        if(kaball_prevstatus && f < 1)
                drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
-       
+
        if(kaball)
                drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
 }
@@ -3123,7 +3123,7 @@ void HUD_Mod_Race(vector pos, vector mySize)
        float f; // yet another function has this
        score = me.(scores[ps_primary]);
 
-       if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
+       if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
                return; // no records in the actual race
 
        // clientside personal record
@@ -3591,7 +3591,7 @@ void HUD_EngineInfo(void)
                frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
                frametimeavg2 = frametimeavg1;
                frametimeavg1 = frametimeavg;
-               
+
                float weight;
                weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
                if(currentframetime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
@@ -3669,7 +3669,7 @@ void HUD_InfoMessages(void)
 
        vector fontsize;
        fontsize = '0.20 0.20 0' * mySize_y;
-       
+
        float a;
        a = panel_fg_alpha;
 
@@ -3704,9 +3704,7 @@ void HUD_InfoMessages(void)
                        s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
                        drawInfoMessage(s)
 
-                       if(gametype == MAPINFO_TYPE_ARENA)
-                               s = _("^1Wait for your turn to join");
-                       else if(gametype == MAPINFO_TYPE_LMS)
+                       if(gametype == MAPINFO_TYPE_LMS)
                        {
                                entity sk;
                                sk = playerslots[player_localnum];
@@ -3795,7 +3793,7 @@ void HUD_InfoMessages(void)
                        }
                }
        }
-       else 
+       else
        {
                s = _("^7Press ^3ESC ^7to show HUD options.");
                drawInfoMessage(s)
@@ -3871,7 +3869,7 @@ void HUD_Physics(void)
                        conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
                        break;
        }
-       
+
        vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
 
        float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
@@ -3894,9 +3892,9 @@ void HUD_Physics(void)
                        acceleration = (vlen(vel) - vlen(acc_prevspeed));
                else
                        acceleration = (vlen(vel - '0 0 1' * vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z));
-               
+
                acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665);
-               
+
                acc_prevspeed = vel;
                acc_prevtime = time;
 
@@ -4097,7 +4095,7 @@ float centerprint_showing;
 
 void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num)
 {
-       //print(sprintf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num));
+       //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num);
        float i, j;
 
        if(strMessage == "" && new_id == 0)
@@ -4229,9 +4227,9 @@ void HUD_CenterPrint (void)
                if (scoreboard_bottom >= 0.96 * vid_conheight)
                        return;
                vector target_pos;
-               
+
                target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
-               
+
                if(target_pos_y > panel_pos_y)
                {
                        panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
@@ -4263,8 +4261,7 @@ void HUD_CenterPrint (void)
        float a, sz, align, current_msg_pos_y = 0, msg_size;
        vector pos;
        string ts;
-
-       n = -1; // if no msg will be displayed, n stays -1
+       float all_messages_expired = TRUE;
 
        pos = panel_pos;
        if (autocvar_hud_panel_centerprint_flip)
@@ -4287,31 +4284,36 @@ void HUD_CenterPrint (void)
                                continue;
                }
 
+               all_messages_expired = FALSE;
 
-               // fade the centerprint_hud in/out 
-               if(centerprint_time[j] < 0)
-                       a = bound(0, (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1);
-               else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time)
-                       a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1);
-               else if(centerprint_expire_time[j] > time)
+               // fade the centerprint_hud in/out
+               if(centerprint_time[j] < 0)  // Expired but forced. Expire time is the fade-in time.
+                       a = (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in);
+               else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time)  // Regularily printed. Not fading out yet.
+                       a = (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in);
+               else // Expiring soon, so fade it out.
                        a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out);
-               else
-                       a = 0;
-               
+
+               if (a <= 0.5/255.0)  // Guaranteed invisible - don't show.
+                       continue;
+               if (a > 1)
+                       a = 1;
+
                // set the size from fading in/out before subsequent fading
-               sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize); 
-               
+               sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize);
+
                // also fade it based on positioning
                if(autocvar_hud_panel_centerprint_fade_subsequent)
                {
                        a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passone))), 1); // pass one: all messages after the first have half theAlpha
                        a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passtwo))), 1); // pass two: after that, gradually lower theAlpha even more for each message
                }
-               
+               a *= panel_fg_alpha;
+
                // finally set the size based on the new theAlpha from subsequent fading
-               sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize)); 
+               sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
                drawfontscale = sz * '1 1 0';
-               
+
                if (centerprint_countdown_num[j])
                        n = tokenizebyseparator(strreplace("^COUNT", count_seconds(centerprint_countdown_num[j]), centerprint_messages[j]), "\n");
                else
@@ -4346,7 +4348,8 @@ void HUD_CenterPrint (void)
                                {
                                        if (align)
                                                pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
-                                       drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       if (a > 0.5/255.0)  // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
+                                               drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a, DRAWFLAG_NORMAL);
                                        pos_y += fontsize_y;
                                }
                                else
@@ -4354,15 +4357,15 @@ void HUD_CenterPrint (void)
                        }
                }
 
-               ++g; // move next position number up 
-               
+               ++g; // move next position number up
+
                msg_size = pos_y - msg_size;
                if (autocvar_hud_panel_centerprint_flip)
                {
                        pos_y = current_msg_pos_y - CENTERPRINT_SPACING * fontsize_y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
                                pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
-                               
+
                        if (pos_y < panel_pos_y) // check if the next message can be shown
                        {
                                drawfontscale = '1 1 0';
@@ -4374,7 +4377,7 @@ void HUD_CenterPrint (void)
                        pos_y += CENTERPRINT_SPACING * fontsize_y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
                                pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
-                               
+
                        if(pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next message can be shown
                        {
                                drawfontscale = '1 1 0';
@@ -4383,13 +4386,484 @@ void HUD_CenterPrint (void)
                }
        }
        drawfontscale = '1 1 0';
-       if (n == -1)
+       if (all_messages_expired)
        {
                centerprint_showing = FALSE;
                reset_centerprint_messages();
        }
 }
 
+// QuickMenu (#17)
+//
+// QUICKMENU_MAXLINES must be <= 10
+#define QUICKMENU_MAXLINES 10
+#define QUICKMENU_MAXENTRIES 256
+string QuickMenu_Command[QUICKMENU_MAXLINES];
+string QuickMenu_Description[QUICKMENU_MAXLINES];
+float QuickMenu_CurrentPage;
+float QuickMenu_IsLastPage;
+var float QuickMenu_Buffer = -1;
+float QuickMenu_Buffer_Size;
+float QuickMenu_Buffer_Index;
+string QuickMenu_CurrentSubMenu;
+float QuickMenu_CurrentPage_FirstEntry;
+var float QuickMenu_Entries;
+void HUD_QuickMenu_load_entry(float i, string s, string s1)
+{
+       //print(sprintf("^xc80 entry %d: %s, %s\n", i, s, s1));
+       if (QuickMenu_Description[i])
+               strunzone(QuickMenu_Description[i]);
+       QuickMenu_Description[i] = strzone(s);
+       if (QuickMenu_Command[i])
+               strunzone(QuickMenu_Command[i]);
+       QuickMenu_Command[i] = strzone(s1);
+}
+void HUD_QuickMenu_clear_entry(float i)
+{
+       if (QuickMenu_Description[i])
+               strunzone(QuickMenu_Description[i]);
+       QuickMenu_Description[i] = string_null;
+       if (QuickMenu_Command[i])
+               strunzone(QuickMenu_Command[i]);
+       QuickMenu_Command[i] = string_null;
+}
+
+float HUD_QuickMenu_Buffer_Init()
+{
+       float fh, i;
+       string s;
+       fh = fopen(autocvar_hud_panel_quickmenu_file, FILE_READ);
+       if(fh < 0)
+       {
+               print(sprintf(_("Error: Couldn't open file %s!\n"), autocvar_hud_panel_quickmenu_file));
+               return false;
+       }
+
+       QuickMenu_Buffer = buf_create();
+       if (QuickMenu_Buffer < 0)
+       {
+               fclose(fh);
+               return false;
+       }
+
+       i = 0;
+       while((s = fgets(fh)) && i < QUICKMENU_MAXENTRIES)
+       {
+               // first skip invalid entries, so we don't check them anymore
+               float argc;
+               argc = tokenize_console(s);
+               if(argc == 0 || argc > 2)
+                       continue;
+
+               bufstr_set(QuickMenu_Buffer, i, s);
+               ++i;
+       }
+       QuickMenu_Buffer_Size = i;
+
+       if (QuickMenu_Buffer_Size <= 0)
+       {
+               buf_del(QuickMenu_Buffer);
+               QuickMenu_Buffer = -1;
+       }
+       fclose(fh);
+       return true;
+}
+
+void HUD_QuickMenu_Buffer_Close()
+{
+       if (QuickMenu_Buffer >= 0)
+       {
+               buf_del(QuickMenu_Buffer);
+               QuickMenu_Buffer = -1;
+               QuickMenu_Buffer_Size = 0;
+       }
+}
+
+void HUD_QuickMenu_Close()
+{
+       if (QuickMenu_CurrentSubMenu)
+               strunzone(QuickMenu_CurrentSubMenu);
+       QuickMenu_CurrentSubMenu = string_null;
+       float i;
+       for (i = 0; i < QUICKMENU_MAXLINES; ++i)
+               HUD_QuickMenu_clear_entry(i);
+       QuickMenu_Entries = 0;
+       hud_panel_quickmenu = 0;
+       mouseClicked = 0;
+       prevMouseClicked = 0;
+       HUD_QuickMenu_Buffer_Close();
+
+       if(autocvar_hud_cursormode)
+       if(!mv_active)
+               setcursormode(0);
+}
+
+// It assumes submenu open tag is already detected
+void HUD_QuickMenu_skip_submenu(string submenu)
+{
+       string s, z_submenu;
+       z_submenu = strzone(submenu);
+       for(++QuickMenu_Buffer_Index ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
+       {
+               s = bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index);
+               float argc;
+               argc = tokenize_console(s);
+               if(argc == 2)
+                       continue;
+               if (argv(0) == "")
+                       continue;
+               if (argv(0) == z_submenu) // submenu end
+                       break;
+               HUD_QuickMenu_skip_submenu(argv(0));
+       }
+       strunzone(z_submenu);
+}
+
+float HUD_QuickMenu_IsOpened()
+{
+       return (QuickMenu_Entries > 0);
+}
+
+// new_page 0 means page 0, new_page != 0 means next page
+float QuickMenu_Buffer_Index_Prev;
+float HUD_QuickMenu_Page(string target_submenu, float new_page)
+{
+       string s, z_submenu;
+
+       if (new_page == 0)
+               QuickMenu_CurrentPage = 0;
+       else
+               ++QuickMenu_CurrentPage;
+       QuickMenu_CurrentPage_FirstEntry = QuickMenu_CurrentPage * (QUICKMENU_MAXLINES - 2);
+
+       z_submenu = strzone(target_submenu);
+       if (QuickMenu_CurrentSubMenu)
+               strunzone(QuickMenu_CurrentSubMenu);
+       QuickMenu_CurrentSubMenu = strzone(z_submenu);
+
+       QuickMenu_IsLastPage = TRUE;
+       QuickMenu_Entries = 0;
+
+       QuickMenu_Buffer_Index = 0;
+       if (z_submenu != "")
+       {
+               // skip everything until the submenu open tag is found
+               for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
+               {
+                       s = bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index);
+                       if (tokenize_console(s) == 1 && argv(0) == z_submenu)
+                       {
+                               // print(sprintf("^3 beginning of %s\n", z_submenu));
+                               ++QuickMenu_Buffer_Index;
+                               break;
+                       }
+                       // print(sprintf("^1 skipping %s\n", s));
+               }
+       }
+       float total = 0;
+       for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
+       {
+               s = bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index);
+               float argc;
+               argc = tokenize_console(s);
+
+               if (z_submenu != "" && z_submenu == argv(0))
+               {
+                       // print(sprintf("^3 end of %s\n", z_submenu));
+                       break;
+               }
+
+               if (total - QuickMenu_CurrentPage_FirstEntry >= 0)
+               {
+                       ++QuickMenu_Entries;
+                       if(QuickMenu_Entries == QUICKMENU_MAXLINES - 2)
+                               QuickMenu_Buffer_Index_Prev = QuickMenu_Buffer_Index;
+                       else if(QuickMenu_Entries == QUICKMENU_MAXLINES)
+                       {
+                               HUD_QuickMenu_clear_entry(QUICKMENU_MAXLINES - 1);
+                               QuickMenu_Buffer_Index = QuickMenu_Buffer_Index_Prev;
+                               QuickMenu_IsLastPage = FALSE;
+                               break;
+                       }
+               }
+
+               // NOTE: entries are loaded starting from 1, not from 0
+               if (argc == 1 && argv(0) != "") // submenu
+               {
+                       if (total - QuickMenu_CurrentPage_FirstEntry >= 0)
+                               HUD_QuickMenu_load_entry(QuickMenu_Entries, argv(0), "");
+                       HUD_QuickMenu_skip_submenu(argv(0));
+               }
+               else if (total - QuickMenu_CurrentPage_FirstEntry >= 0)
+                       HUD_QuickMenu_load_entry(QuickMenu_Entries, argv(0), argv(1));
+
+               ++total;
+       }
+       strunzone(z_submenu);
+       if (QuickMenu_Entries == 0)
+       {
+               HUD_QuickMenu_Close();
+               return 0;
+       }
+       return 1;
+}
+
+void HUD_QuickMenu_Open()
+{
+       if(!HUD_QuickMenu_Buffer_Init()) return;
+
+       hud_panel_quickmenu = 1;
+       if(autocvar_hud_cursormode)
+               setcursormode(1);
+       hudShiftState = 0;
+
+       HUD_QuickMenu_Page("", 0);
+}
+
+float HUD_QuickMenu_ActionForNumber(float num)
+{
+       if (!QuickMenu_IsLastPage)
+       {
+               if (num < 0 || num >= QUICKMENU_MAXLINES)
+                       return 0;
+               if (num == QUICKMENU_MAXLINES - 1)
+                       return 0;
+               if (num == 0)
+               {
+                       HUD_QuickMenu_Page(QuickMenu_CurrentSubMenu, +1);
+                       return 0;
+               }
+       } else if (num <= 0 || num > QuickMenu_Entries)
+               return 0;
+
+       if (QuickMenu_Command[num] != "")
+       {
+               localcmd(strcat("\n", QuickMenu_Command[num], "\n"));
+               return 1;
+       }
+       if (QuickMenu_Description[num] != "")
+               HUD_QuickMenu_Page(QuickMenu_Description[num], 0);
+       return 0;
+}
+
+float HUD_QuickMenu_InputEvent(float bInputType, float nPrimary, float nSecondary)
+{
+       // we only care for keyboard events
+       if(bInputType == 2)
+               return false;
+
+       if(!HUD_QuickMenu_IsOpened() || autocvar__hud_configure || mv_active)
+               return false;
+
+       if(bInputType == 3)
+       {
+               mousepos_x = nPrimary;
+               mousepos_y = nSecondary;
+               return true;
+       }
+
+       // allow console bind to work
+       string con_keys;
+       float keys;
+       con_keys = findkeysforcommand("toggleconsole", 0);
+       keys = tokenize(con_keys); // findkeysforcommand returns data for this
+
+       float hit_con_bind = 0, i;
+       for (i = 0; i < keys; ++i)
+       {
+               if(nPrimary == stof(argv(i)))
+                       hit_con_bind = 1;
+       }
+
+       if(bInputType == 0) {
+               if(nPrimary == K_ALT) hudShiftState |= S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
+       }
+       else if(bInputType == 1) {
+               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
+               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
+               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+       }
+
+       if(nPrimary == K_ESCAPE)
+       {
+               if (bInputType == 1)
+                       return true;
+               HUD_QuickMenu_Close();
+       }
+       else if(nPrimary >= '0' && nPrimary <= '9')
+       {
+               if (bInputType == 1)
+                       return true;
+               HUD_QuickMenu_ActionForNumber(stof(chr2str(nPrimary)));
+       }
+       if(nPrimary == K_MOUSE1)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE1;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE1);
+       }
+       else if(nPrimary == K_MOUSE2)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE2;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE2);
+       }
+       else if(hit_con_bind)
+               return false;
+
+       return true;
+}
+void HUD_QuickMenu_Mouse()
+{
+       if(mv_active) return;
+
+       if(!mouseClicked)
+       if(prevMouseClicked & S_MOUSE2)
+       {
+               HUD_QuickMenu_Close();
+               return;
+       }
+
+       if(!autocvar_hud_cursormode)
+       {
+               mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
+
+               mousepos_x = bound(0, mousepos_x, vid_conwidth);
+               mousepos_y = bound(0, mousepos_y, vid_conheight);
+       }
+
+       HUD_Panel_UpdateCvars()
+
+       if(panel_bg_padding)
+       {
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
+       }
+
+       float first_entry_pos, entries_height;
+       vector fontsize;
+       fontsize = '1 1 0' * (panel_size_y / QUICKMENU_MAXLINES);
+       first_entry_pos = panel_pos_y + ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y) / 2;
+       entries_height = panel_size_y - ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y);
+
+       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)
+       {
+               float entry_num;
+               entry_num = floor((mousepos_y - first_entry_pos) / fontsize_y);
+               if (QuickMenu_IsLastPage || entry_num != QUICKMENU_MAXLINES - 2)
+               {
+                       panel_pos_y = first_entry_pos + entry_num * fontsize_y;
+                       vector color;
+                       if(mouseClicked & S_MOUSE1)
+                               color = '0.5 1 0.5';
+                       else if(hudShiftState & S_CTRL)
+                               color = '1 1 0.3';
+                       else
+                               color = '1 1 1';
+                       drawfill(panel_pos, eX * panel_size_x + eY * fontsize_y, color, .2, DRAWFLAG_NORMAL);
+
+                       if(!mouseClicked && (prevMouseClicked & S_MOUSE1))
+                       {
+                               float f;
+                               if (entry_num < QUICKMENU_MAXLINES - 1)
+                                       f = HUD_QuickMenu_ActionForNumber(entry_num + 1);
+                               else
+                                       f = HUD_QuickMenu_ActionForNumber(0);
+                               if(f && !(hudShiftState & S_CTRL))
+                                       HUD_QuickMenu_Close();
+                       }
+               }
+       }
+
+       const vector cursorsize = '32 32 0';
+       drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+
+       prevMouseClicked = mouseClicked;
+}
+void HUD_QuickMenu_DrawEntry(vector pos, string s, vector fontsize)
+{
+       string entry;
+       float offset;
+       entry = textShortenToWidth(s, panel_size_x, fontsize, stringwidth_colors);
+       if (autocvar_hud_panel_quickmenu_align > 0)
+       {
+               offset = (panel_size_x - stringwidth_colors(entry, fontsize)) * min(autocvar_hud_panel_quickmenu_align, 1);
+               drawcolorcodedstring(pos + eX * offset, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
+       }
+       else
+               drawcolorcodedstring(pos, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
+}
+void HUD_QuickMenu(void)
+{
+       if(!autocvar__hud_configure)
+       {
+               if (hud_configure_prev && hud_configure_prev != -1)
+                       HUD_QuickMenu_Close();
+
+               if(!hud_draw_maximized) return;
+               if(mv_active) return;
+               //if(!autocvar_hud_panel_quickmenu) return; // autocvar exists only for conformity with other panels
+               if(!hud_panel_quickmenu) return;
+       }
+       else
+       {
+               if(!HUD_QuickMenu_IsOpened())
+               {
+                       QuickMenu_Entries = 1;
+                       HUD_QuickMenu_load_entry(QuickMenu_Entries, sprintf(_("Submenu%d"), QuickMenu_Entries), "");
+                       ++QuickMenu_Entries;
+                       HUD_QuickMenu_load_entry(QuickMenu_Entries, sprintf(_("Submenu%d"), QuickMenu_Entries), "");
+                       ++QuickMenu_Entries;
+                       // although real command doesn't matter here, it must not be empty
+                       // otherwise the entry is displayed like a submenu
+                       for (; QuickMenu_Entries < QUICKMENU_MAXLINES - 1; ++QuickMenu_Entries)
+                               HUD_QuickMenu_load_entry(QuickMenu_Entries, sprintf(_("Command%d"), QuickMenu_Entries), "-");
+                       ++QuickMenu_Entries;
+                       HUD_QuickMenu_clear_entry(QuickMenu_Entries);
+                       QuickMenu_IsLastPage = FALSE;
+               }
+       }
+
+       HUD_Panel_UpdateCvars();
+       HUD_Panel_ApplyFadeAlpha();
+
+       HUD_Panel_DrawBg(1);
+
+       if(panel_bg_padding)
+       {
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
+       }
+
+       float i;
+       vector fontsize;
+       string color;
+       fontsize = '1 1 0' * (panel_size_y / QUICKMENU_MAXLINES);
+
+       if (!QuickMenu_IsLastPage)
+       {
+               color = "^5";
+               HUD_QuickMenu_DrawEntry(panel_pos + eY * (panel_size_y - fontsize_y), sprintf("%d: %s%s", 0, color, _("Continue...")), fontsize);
+       }
+       else
+               panel_pos_y += ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y) / 2;
+
+       for (i = 1; i <= QuickMenu_Entries; ++i) {
+               if (QuickMenu_Description[i] == "")
+                       break;
+               if (QuickMenu_Command[i] == "")
+                       color = "^4";
+               else
+                       color = "^3";
+               HUD_QuickMenu_DrawEntry(panel_pos, sprintf("%d: %s%s", i, color, QuickMenu_Description[i]), fontsize);
+               panel_pos_y += fontsize_y;
+       }
+}
+
 /*
 ==================
 Main HUD system
@@ -4569,6 +5043,8 @@ void HUD_Main (void)
                (panel = HUD_PANEL(RADAR)).panel_draw();
        if(autocvar__con_chat_maximized)
                (panel = HUD_PANEL(CHAT)).panel_draw();
+       if(hud_panel_quickmenu)
+               (panel = HUD_PANEL(QUICKMENU)).panel_draw();
 
        if(autocvar__hud_configure)
        {