]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/dynamic_hud
authorterencehill <piuntn@gmail.com>
Sat, 26 Mar 2016 23:30:20 +0000 (00:30 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 26 Mar 2016 23:30:20 +0000 (00:30 +0100)
Conflicts:
qcsrc/client/quickmenu.qc

1  2 
qcsrc/client/autocvars.qh
qcsrc/client/hud/hud.qc
qcsrc/client/hud/panel/modicons.qc
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/client/hud/panel/racetimer.qc
qcsrc/client/main.qc
qcsrc/client/view.qc
qcsrc/common/minigames/cl_minigames_hud.qc

index f7db0e30a0b8e0fa51ad3171ddb758e7b0f660d4,3320b16620927c9840efeb86021f73ec1392484d..558a7f393fe8b027afcc8689588027337d76be55
@@@ -82,6 -82,7 +82,7 @@@ bool autocvar_cl_vehicles_hud_tactical 
  float autocvar_cl_vehicles_hudscale = 0.5;
  float autocvar_cl_vehicles_notify_time = 15;
  float autocvar_cl_vehicles_crosshair_size = 0.5;
+ bool autocvar_cl_vehicles_crosshair_colorize = true;
  bool autocvar__vehicles_shownchasemessage;
  bool autocvar_cl_velocityzoom_enabled;
  float autocvar_cl_velocityzoom_factor;
@@@ -370,7 -371,6 +371,7 @@@ float autocvar_hud_shownames_offset
  string autocvar_hud_skin;
  float autocvar_menu_mouse_speed;
  string autocvar_menu_skin;
 +float autocvar_r_drawviewmodel;
  int autocvar_r_fakelight;
  int autocvar_r_fullbright;
  float autocvar_r_letterbox;
diff --combined qcsrc/client/hud/hud.qc
index 795b84998a7d5ef6a5d5ba8389eaa7796f805f37,99605536018ba17e8a9fabe330b7af957079f938..0be0f47351de4ee4dc4e2586cefca90546061134
@@@ -114,86 -114,6 +114,6 @@@ vector HUD_GetTableSize_BestItemAR(int 
                return eX * best_columns + eY * best_rows;
  }
  
- // return the string of the onscreen race timer
- string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname)
- {
-     TC(int, cp);
-       string col;
-       string timestr;
-       string cpname;
-       string lapstr;
-       lapstr = "";
-       if(theirtime == 0) // goal hit
-       {
-               if(mytime > 0)
-               {
-                       timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
-                       col = "^1";
-               }
-               else if(mytime == 0)
-               {
-                       timestr = "+0.0";
-                       col = "^3";
-               }
-               else
-               {
-                       timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
-                       col = "^2";
-               }
-               if(lapdelta > 0)
-               {
-                       lapstr = sprintf(_(" (-%dL)"), lapdelta);
-                       col = "^2";
-               }
-               else if(lapdelta < 0)
-               {
-                       lapstr = sprintf(_(" (+%dL)"), -lapdelta);
-                       col = "^1";
-               }
-       }
-       else if(theirtime > 0) // anticipation
-       {
-               if(mytime >= theirtime)
-                       timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS));
-               else
-                       timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime));
-               col = "^3";
-       }
-       else
-       {
-               col = "^7";
-               timestr = "";
-       }
-       if(cp == 254)
-               cpname = _("Start line");
-       else if(cp == 255)
-               cpname = _("Finish line");
-       else if(cp)
-               cpname = sprintf(_("Intermediate %d"), cp);
-       else
-               cpname = _("Finish line");
-       if(theirtime < 0)
-               return strcat(col, cpname);
-       else if(theirname == "")
-               return strcat(col, sprintf("%s (%s)", cpname, timestr));
-       else
-               return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr)));
- }
- // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
- int race_CheckName(string net_name)
- {
-       int i;
-       for (i=RANKINGS_CNT-1;i>=0;--i)
-               if(grecordholder[i] == net_name)
-                       return i+1;
-       return 0;
- }
  /*
  ==================
  HUD panels
@@@ -216,9 -136,6 +136,9 @@@ void HUD_Panel_DrawProgressBar(vector t
        else if(length_ratio < 0)
                return;
  
 +      theOrigin = HUD_Shift(theOrigin);
 +      theSize = HUD_Scale(theSize);
 +
        vector square;
        vector width, height;
        if(vertical) {
@@@ -314,9 -231,6 +234,9 @@@ void HUD_Panel_DrawHighlight(vector pos
        if(!theAlpha)
                return;
  
 +      pos = HUD_Shift(pos);
 +      mySize = HUD_Scale(mySize);
 +
        string pic;
        pic = strcat(hud_skin_path, "/num_leading");
        if(precache_pic(pic) == "") {
@@@ -467,102 -381,6 +387,102 @@@ void HUD_Reset(
                HUD_Mod_CTF_Reset();
  }
  
 +float autocvar_hud_dynamic_shake;
 +float autocvar_hud_dynamic_shake_damage_max;
 +float autocvar_hud_dynamic_shake_damage_min;
 +float autocvar_hud_dynamic_shake_scale;
 +float hud_dynamic_shake_x[10] = {0,    1, -0.7,  0.5, -0.3,  0.2, -0.1,  0.1,  0.0, 0};
 +float hud_dynamic_shake_y[10] = {0,  0.4,  0.8, -0.2, -0.6,  0.0,  0.3,  0.1, -0.1, 0};
 +bool Hud_Shake_Update()
 +{
 +      if(time - hud_dynamic_shake_time < 0)
 +              return false;
 +
 +      float anim_speed = 17 + 9 * hud_dynamic_shake_factor;
 +      float elapsed_time = (time - hud_dynamic_shake_time) * anim_speed;
 +      int i = floor(elapsed_time);
 +      if(i >= 9)
 +              return false;
 +
 +      float f = elapsed_time - i;
 +      hud_dynamic_shake_realofs.x = (1 - f) * hud_dynamic_shake_x[i] + f * hud_dynamic_shake_x[i+1];
 +      hud_dynamic_shake_realofs.y = (1 - f) * hud_dynamic_shake_y[i] + f * hud_dynamic_shake_y[i+1];
 +      hud_dynamic_shake_realofs.z = 0;
 +      hud_dynamic_shake_realofs *= hud_dynamic_shake_factor * autocvar_hud_dynamic_shake_scale;
 +      hud_dynamic_shake_realofs.x = bound(-0.1, hud_dynamic_shake_realofs.x, 0.1) * vid_conwidth;
 +      hud_dynamic_shake_realofs.y = bound(-0.1, hud_dynamic_shake_realofs.y, 0.1) * vid_conheight;
 +      return true;
 +}
 +
 +void calc_followmodel_ofs(entity view);
 +void Hud_Dynamic_Frame()
 +{
 +      vector ofs = '0 0 0';
 +      hud_scale = '1 1 0';
 +      hud_shift = '0 0 0';
 +      if (autocvar_hud_dynamic_follow)
 +      {
 +              entity view = CSQCModel_server2csqc(player_localentnum - 1);
 +              calc_followmodel_ofs(view);
 +              ofs = -cl_followmodel_ofs * autocvar_hud_dynamic_follow_scale;
 +              ofs.x *= autocvar_hud_dynamic_follow_scale_xyz.z;
 +              ofs.y *= autocvar_hud_dynamic_follow_scale_xyz.x;
 +              ofs.z *= autocvar_hud_dynamic_follow_scale_xyz.y;
 +
 +              if (fabs(ofs.x) < 0.001) ofs.x = 0;
 +              if (fabs(ofs.y) < 0.001) ofs.y = 0;
 +              if (fabs(ofs.z) < 0.001) ofs.z = 0;
 +              ofs.x = bound(-0.1, ofs.x, 0.1);
 +              ofs.y = bound(-0.1, ofs.y, 0.1);
 +              ofs.z = bound(-0.1, ofs.z, 0.1);
 +
 +              hud_shift.x = ofs.y * vid_conwidth;
 +              hud_shift.y = ofs.z * vid_conheight;
 +              hud_shift.z = ofs.x;
 +
 +              hud_scale.x = (1 + hud_shift.z);
 +              hud_scale.y = hud_scale.x;
 +      }
 +
 +      if(autocvar_hud_dynamic_shake > 0)
 +      {
 +              if(hud_dynamic_shake_factor == -1) // don't allow the effect for this frame
 +                      hud_dynamic_shake_factor = 0;
 +              else
 +              {
 +                      float health = STAT(HEALTH);
 +                      float new_hud_dynamic_shake_factor = 0;
 +                      if(prev_health - health >= autocvar_hud_dynamic_shake_damage_min && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min)
 +                      {
 +                              float m = max(autocvar_hud_dynamic_shake_damage_min, 1);
 +                              new_hud_dynamic_shake_factor = (prev_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
 +                              if(new_hud_dynamic_shake_factor >= 1)
 +                                      new_hud_dynamic_shake_factor = 1;
 +                              if(new_hud_dynamic_shake_factor >= hud_dynamic_shake_factor)
 +                              {
 +                                      hud_dynamic_shake_factor = new_hud_dynamic_shake_factor;
 +                                      hud_dynamic_shake_time = time;
 +                              }
 +                      }
 +                      if(hud_dynamic_shake_factor)
 +                              if(!Hud_Shake_Update())
 +                                      hud_dynamic_shake_factor = 0;
 +              }
 +
 +              if(hud_dynamic_shake_factor > 0)
 +              {
 +                      hud_shift.x += hud_dynamic_shake_realofs.x;
 +                      hud_shift.y += hud_dynamic_shake_realofs.y;
 +              }
 +      }
 +
 +      hud_scale_center.x = 0.5 * vid_conwidth;
 +      hud_scale_center.y = 0.5 * vid_conheight;
 +
 +      hud_scale_current = hud_scale;
 +      hud_shift_current = hud_shift;
 +}
 +
  void HUD_Main()
  {
        int i;
  
        HUD_Configure_Frame();
  
 +      Hud_Dynamic_Frame();
 +
        // panels that we want to be active together with the scoreboard
        // they must fade only when the menu does
        if(scoreboard_fade_alpha == 1)
index 479c594db56e5ad07b5b9187df84c9568f7f05c7,5b4665f563f8f10ceb22f94316cb8562da5219d3..957fe1f3941d2823d75b7ac8a4d4f16e0995c0a6
@@@ -491,13 -491,33 +491,33 @@@ float srecordtime_change_time; // time 
  float race_status_time;
  int race_status_prev;
  string race_status_name_prev;
+ // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
+ int race_CheckName(string net_name)
+ {
+       int i;
+       for (i=RANKINGS_CNT-1;i>=0;--i)
+               if(grecordholder[i] == net_name)
+                       return i+1;
+       return 0;
+ }
+ void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f)
+ {
+       drawstring_aspect(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawstring_aspect(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       if (f < 1) {
+               drawstring_aspect_expanding(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
+               drawstring_aspect_expanding(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
+       }
+ }
  void HUD_Mod_Race(vector pos, vector mySize)
  {
        mod_active = 1; // race should never hide the mod icons panel
        entity me;
        me = playerslots[player_localnum];
        float score;
-       float f; // yet another function has this
        score = me.(scores[ps_primary]);
  
        if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
                db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
                if(autocvar_cl_autodemo_delete_keeprecords)
                {
-                       f = autocvar_cl_autodemo_delete;
+                       float f = autocvar_cl_autodemo_delete;
                        f &= ~1;
                        cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
                }
                textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
                medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
        }
+       vector textSize = eX * squareSize + eY * 0.25 * squareSize;
  
-       f = time - crecordtime_change_time;
-       if (f > 1) {
-               drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       } else {
-               drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
-               drawstring_aspect_expanding(pos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
-       }
+       race_showTime(_("Personal best"), textPos, eY * 0.25 * squareSize, t, textSize, time - crecordtime_change_time);
  
        // server record
        t = race_server_record;
                srecordtime_prev = t;
                srecordtime_change_time = time;
        }
-       f = time - srecordtime_change_time;
  
-       if (f > 1) {
-               drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       } else {
-               drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect_expanding(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
-               drawstring_aspect_expanding(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
-       }
+       textPos += eY * 0.5 * squareSize;
+       race_showTime(_("Server best"), textPos, eY * 0.25 * squareSize, t, textSize, time - srecordtime_change_time);
  
        if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
                race_status_time = time + 5;
@@@ -766,7 -769,6 +769,7 @@@ void HUD_ModIcons(
        else
                mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
  
 +      HUD_Scale_Enable();
        if(mod_alpha)
                HUD_Panel_DrawBg(mod_alpha);
  
index dd733a8134d7ca41a50cc3307e7021f841a8626f,de4a05f132d185505b08c7e34c2dfcc94e6839f9..a6b616e7bc86e1bef7dacadac20ee1d1435175fb
  #include "quickmenu.qh"
  // QuickMenu (#23)
  
- #include <client/quickmenu.qc>
+ #include <common/ent_cs.qh>
+ #include <client/hud/all.qh>
+ #include <client/mapvoting.qh>
+ // QUICKMENU_MAXLINES must be <= 10
+ const int QUICKMENU_MAXLINES = 10;
+ // visible entries are loaded from QuickMenu_Buffer into QuickMenu_Page_* arrays
+ string QuickMenu_Page_Command[QUICKMENU_MAXLINES];
+ string QuickMenu_Page_Description[QUICKMENU_MAXLINES];
+ int QuickMenu_Page_Command_Type[QUICKMENU_MAXLINES];
+ int QuickMenu_Page_Entries;
+ int QuickMenu_Page;
+ int QuickMenu_Page_ActivatedEntry = -1;
+ bool QuickMenu_Page_ActivatedEntry_Close;
+ float QuickMenu_Page_ActivatedEntry_Time;
+ bool QuickMenu_IsLastPage;
+ // all the entries are loaded into QuickMenu_Buffer
+ // each entry (submenu or command) is composed of 2 entries
+ const int QUICKMENU_MAXENTRIES = 256;
+ const int QUICKMENU_BUFFER_MAXENTRIES = 2 * QUICKMENU_MAXENTRIES;
+ int QuickMenu_Buffer = -1;
+ int QuickMenu_Buffer_Size;
+ int QuickMenu_Buffer_Index;
+ string QuickMenu_CurrentSubMenu;
+ float QuickMenu_TimeOut;
+ // QuickMenu_Buffer are labeled with these tags
+ #define QM_TAG_TITLE "T"
+ #define QM_TAG_SUBMENU "S"
+ #define QM_TAG_COMMAND "C"
+ #define QM_TAG_PLCOMMAND "P"
+ #define QuickMenu_Buffer_Set(tag, string) bufstr_set(QuickMenu_Buffer, QuickMenu_Buffer_Size, strcat(tag, string))
+ #define QuickMenu_Buffer_Get() bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index)
+ // if s1 is not empty s will be displayed as command otherwise as submenu
+ void QuickMenu_Page_LoadEntry(int i, string s, string s1)
+ {
+     TC(int, i);
+       //printf("^xc80 entry %d: %s, %s\n", i, s, s1);
+       if (QuickMenu_Page_Description[i])
+               strunzone(QuickMenu_Page_Description[i]);
+       QuickMenu_Page_Description[i] = strzone(s);
+       if (QuickMenu_Page_Command[i])
+               strunzone(QuickMenu_Page_Command[i]);
+       QuickMenu_Page_Command[i] = strzone(s1);
+ }
+ void QuickMenu_Page_ClearEntry(int i)
+ {
+     TC(int, i);
+       if (QuickMenu_Page_Description[i])
+               strunzone(QuickMenu_Page_Description[i]);
+       QuickMenu_Page_Description[i] = string_null;
+       if (QuickMenu_Page_Command[i])
+               strunzone(QuickMenu_Page_Command[i]);
+       QuickMenu_Page_Command[i] = string_null;
+ }
+ float QuickMenu_Page_Load(string target_submenu, float new_page);
+ void QuickMenu_Default(string submenu);
+ bool QuickMenu_Open(string mode, string submenu)
+ {
+       int fh = -1;
+       string s;
+       if(mode == "")
+       {
+               if(autocvar_hud_panel_quickmenu_file == "" || autocvar_hud_panel_quickmenu_file == "0")
+                       mode = "default";
+               else
+                       mode = "file";
+       }
+       if(mode == "file")
+       {
+               if(autocvar_hud_panel_quickmenu_file == "" || autocvar_hud_panel_quickmenu_file == "0")
+                       LOG_INFO("No file name is set in hud_panel_quickmenu_file, loading default quickmenu\n");
+               else
+               {
+                       fh = fopen(autocvar_hud_panel_quickmenu_file, FILE_READ);
+                       if(fh < 0)
+                               LOG_INFOF("Couldn't open file \"%s\", loading default quickmenu\n", autocvar_hud_panel_quickmenu_file);
+               }
+               if(fh < 0)
+                       mode = "default";
+       }
+       if(mode == "default")
+       {
+               QuickMenu_Buffer = buf_create();
+               if(QuickMenu_Buffer < 0)
+                       return false;
+               QuickMenu_Default(submenu);
+       }
+       else if(mode == "file")
+       {
+               QuickMenu_Buffer = buf_create();
+               if(QuickMenu_Buffer < 0)
+               {
+                       fclose(fh);
+                       return false;
+               }
+               QuickMenu_Buffer_Size = 0;
+               while((s = fgets(fh)) && QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES)
+               {
+                       // first skip invalid entries, so we don't check them anymore
+                       float argc;
+                       argc = tokenize_console(s);
+                       if(argc == 0 || argv(0) == "")
+                               continue;
+                       if(argc == 1)
+                               QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
+                       else if(argc == 2)
+                       {
+                               if(argv(1) == "")
+                                       continue;
+                               QuickMenu_Buffer_Set(QM_TAG_TITLE, argv(0));
+                               ++QuickMenu_Buffer_Size;
+                               QuickMenu_Buffer_Set(QM_TAG_COMMAND, argv(1));
+                       }
+                       else if(argc == 3)
+                       {
+                               // check for special keywords
+                               float teamplayers = 0, without_me = 0;
+                               switch(argv(2))
+                               {
+                                       case "ALLPLAYERS_BUT_ME":               without_me = 1; // fall through
+                                       case "ALLPLAYERS":                              teamplayers = 0; break;
+                                       case "OWNTEAMPLAYERS_BUT_ME":   without_me = 1; // fall through
+                                       case "OWNTEAMPLAYERS":                  teamplayers = 1; break;
+                                       case "ENEMYTEAMPLAYERS":                teamplayers = 2; break;
+                                       default: continue;
+                               }
+                               if(QuickMenu_Buffer_Size + 3 < QUICKMENU_BUFFER_MAXENTRIES)
+                               {
+                                       QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
+                                       ++QuickMenu_Buffer_Size;
+                                       QuickMenu_Buffer_Set(QM_TAG_TITLE, strcat(ftos(teamplayers), ftos(without_me))); // put PLCOMMAND arguments in the title string
+                                       ++QuickMenu_Buffer_Size;
+                                       QuickMenu_Buffer_Set(QM_TAG_PLCOMMAND, argv(1));
+                                       ++QuickMenu_Buffer_Size;
+                                       QuickMenu_Buffer_Set(QM_TAG_SUBMENU, argv(0));
+                               }
+                       }
+                       ++QuickMenu_Buffer_Size;
+               }
+               fclose(fh);
+       }
+       else
+       {
+               LOG_WARNINGF("Unrecognized mode %s\n", mode);
+               return false;
+       }
+       if (QuickMenu_Buffer_Size <= 0)
+       {
+               buf_del(QuickMenu_Buffer);
+               QuickMenu_Buffer = -1;
+               return false;
+       }
+       if(mode == "file")
+               QuickMenu_Page_Load(submenu, 0);
+       else
+               QuickMenu_Page_Load("", 0);
+       hud_panel_quickmenu = 1;
+       if(autocvar_hud_cursormode)
+               setcursormode(1);
+       hudShiftState = 0;
+       QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
+       return true;
+ }
+ void QuickMenu_Buffer_Close()
+ {
+       if (QuickMenu_Buffer >= 0)
+       {
+               buf_del(QuickMenu_Buffer);
+               QuickMenu_Buffer = -1;
+               QuickMenu_Buffer_Size = 0;
+       }
+ }
+ void QuickMenu_Close()
+ {
+       if (QuickMenu_CurrentSubMenu)
+               strunzone(QuickMenu_CurrentSubMenu);
+       QuickMenu_CurrentSubMenu = string_null;
+       int i;
+       for (i = 0; i < QUICKMENU_MAXLINES; ++i)
+               QuickMenu_Page_ClearEntry(i);
+       QuickMenu_Page_Entries = 0;
+       hud_panel_quickmenu = 0;
+       mouseClicked = 0;
+       prevMouseClicked = 0;
+       QuickMenu_Buffer_Close();
+       if(autocvar_hud_cursormode)
+       if(!mv_active)
+               setcursormode(0);
+ }
+ // It assumes submenu open tag is already detected
+ void 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 = QuickMenu_Buffer_Get();
+               if(substring(s, 0, 1) != QM_TAG_SUBMENU)
+                       continue;
+               if(substring(s, 1, -1) == z_submenu) // submenu end
+                       break;
+               QuickMenu_skip_submenu(substring(s, 1, -1));
+       }
+       strunzone(z_submenu);
+ }
+ bool QuickMenu_IsOpened()
+ {
+       return (QuickMenu_Page_Entries > 0);
+ }
+ void HUD_Quickmenu_PlayerListEntries(string cmd, int teamplayers, bool without_me);
+ bool HUD_Quickmenu_PlayerListEntries_Create(string cmd, int teamplayers, bool without_me)
+ {
+     TC(int, teamplayers); TC(bool, without_me);
+       int i;
+       for(i = 0; i < QUICKMENU_MAXLINES; ++i)
+               QuickMenu_Page_ClearEntry(i);
+       QuickMenu_Buffer_Close();
+       QuickMenu_Buffer = buf_create();
+       if(QuickMenu_Buffer < 0)
+               return false;
+       HUD_Quickmenu_PlayerListEntries(cmd, teamplayers, without_me);
+       if(QuickMenu_Buffer_Size <= 0)
+       {
+               buf_del(QuickMenu_Buffer);
+               QuickMenu_Buffer = -1;
+               return false;
+       }
+       return true;
+ }
+ // new_page 0 means page 0, new_page != 0 means next page
+ int QuickMenu_Buffer_Index_Prev;
+ bool QuickMenu_Page_Load(string target_submenu, bool new_page)
+ {
+     TC(bool, new_page);
+       string s = string_null, cmd = string_null, z_submenu;
+       if (new_page == 0)
+               QuickMenu_Page = 0;
+       else
+               ++QuickMenu_Page;
+       z_submenu = strzone(target_submenu);
+       if (QuickMenu_CurrentSubMenu)
+               strunzone(QuickMenu_CurrentSubMenu);
+       QuickMenu_CurrentSubMenu = strzone(z_submenu);
+       QuickMenu_IsLastPage = true;
+       QuickMenu_Page_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 = QuickMenu_Buffer_Get();
+                       if(substring(s, 0, 1) == QM_TAG_SUBMENU && substring(s, 1, -1) == z_submenu)
+                       {
+                               // printf("^3 beginning of %s\n", z_submenu);
+                               ++QuickMenu_Buffer_Index;
+                               break; // target_submenu found!
+                       }
+                       // printf("^1 skipping %s\n", s);
+               }
+               if(QuickMenu_Buffer_Index == QuickMenu_Buffer_Size)
+                       LOG_WARNINGF("Couldn't find submenu \"%s\"\n", z_submenu);
+       }
+       // only the last page can contain up to QUICKMENU_MAXLINES entries
+       // the other ones contain only (QUICKMENU_MAXLINES - 2) entries
+       // so that the panel can show an empty row and "Continue..."
+       float first_entry = QuickMenu_Page * (QUICKMENU_MAXLINES - 2);
+       int entry_num = 0; // counts entries in target_submenu
+       for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
+       {
+               s = QuickMenu_Buffer_Get();
+               if(z_submenu != "" && substring(s, 1, -1) == z_submenu)
+               {
+                       // printf("^3 end of %s\n", z_submenu);
+                       break;
+               }
+               if(entry_num >= first_entry)
+               {
+                       ++QuickMenu_Page_Entries;
+                       if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES - 2)
+                               QuickMenu_Buffer_Index_Prev = QuickMenu_Buffer_Index;
+                       else if(QuickMenu_Page_Entries == QUICKMENU_MAXLINES)
+                       {
+                               QuickMenu_Page_ClearEntry(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(substring(s, 0, 1) == QM_TAG_SUBMENU)
+               {
+                       if(entry_num >= first_entry)
+                               QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), "");
+                       QuickMenu_skip_submenu(substring(s, 1, -1));
+               }
+               else if(entry_num >= first_entry && substring(s, 0, 1) == QM_TAG_TITLE)
+               {
+                       ++QuickMenu_Buffer_Index;
+                       cmd = QuickMenu_Buffer_Get();
+                       string command_code = substring(cmd, 0, 1);
+                       if(command_code == QM_TAG_COMMAND)
+                               cmd = substring(cmd, 1, -1);
+                       else if(command_code == QM_TAG_PLCOMMAND)
+                       {
+                               // throw away the current quickmenu buffer and load a new one
+                               cmd = substring(cmd, 1, -1);
+                               strunzone(z_submenu);
+                               if(HUD_Quickmenu_PlayerListEntries_Create(cmd, stof(substring(s, 1, 1)), stof(substring(s, 2, 1))))
+                                       return QuickMenu_Page_Load("", 0);
+                               QuickMenu_Close();
+                               return false;
+                       }
+                       tokenize_console(cmd);
+                       QuickMenu_Page_Command_Type[QuickMenu_Page_Entries] = (argv(1) && argv(0) == "toggle");
+                       QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, substring(s, 1, -1), cmd);
+               }
+               ++entry_num;
+       }
+       strunzone(z_submenu);
+       if (QuickMenu_Page_Entries == 0)
+       {
+               QuickMenu_Close();
+               return false;
+       }
+       QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
+       return true;
+ }
+ bool QuickMenu_ActionForNumber(int num)
+ {
+     TC(int, num);
+       if (!QuickMenu_IsLastPage)
+       {
+               if (num < 0 || num >= QUICKMENU_MAXLINES)
+                       return false;
+               if (num == QUICKMENU_MAXLINES - 1)
+                       return false;
+               if (num == 0)
+               {
+                       QuickMenu_Page_Load(QuickMenu_CurrentSubMenu, +1);
+                       return false;
+               }
+       } else if (num <= 0 || num > QuickMenu_Page_Entries)
+               return false;
+       if (QuickMenu_Page_Command[num] != "")
+       {
+               localcmd(strcat("\n", QuickMenu_Page_Command[num], "\n"));
+               QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
+               return true;
+       }
+       if (QuickMenu_Page_Description[num] != "")
+               QuickMenu_Page_Load(QuickMenu_Page_Description[num], 0);
+       return false;
+ }
+ void QuickMenu_Page_ActiveEntry(int entry_num)
+ {
+     TC(int, entry_num);
+       QuickMenu_Page_ActivatedEntry = entry_num;
+       QuickMenu_Page_ActivatedEntry_Time = time + 0.1;
+       if(QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
+       {
+               bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
+               // toggle commands don't close the quickmenu
+               if(QuickMenu_Page_Command_Type[QuickMenu_Page_ActivatedEntry] == 1)
+                       QuickMenu_Page_ActivatedEntry_Close = false;
+               else
+                       QuickMenu_Page_ActivatedEntry_Close = (f && !(hudShiftState & S_CTRL));
+       }
+       else
+               QuickMenu_Page_ActivatedEntry_Close = (!(hudShiftState & S_CTRL));
+ }
+ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
+ {
+     TC(int, bInputType);
+       // we only care for keyboard events
+       if(bInputType == 2)
+               return false;
+       if(!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
+       bool hit_con_bind = false;
+       int i;
+       for (i = 0; i < keys; ++i)
+       {
+               if(nPrimary == stof(argv(i)))
+                       hit_con_bind = true;
+       }
+       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;
+               QuickMenu_Close();
+       }
+       else if(nPrimary >= '0' && nPrimary <= '9')
+       {
+               if (bInputType == 1)
+                       return true;
+               QuickMenu_Page_ActiveEntry(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 QuickMenu_Mouse()
+ {
+       if(mv_active) return;
+       if(!mouseClicked)
+       if(prevMouseClicked & S_MOUSE2)
+       {
+               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_Page_Entries) * fontsize.y) / 2;
+       entries_height = panel_size.y - ((QUICKMENU_MAXLINES - QuickMenu_Page_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))
+                               QuickMenu_Page_ActiveEntry((entry_num < QUICKMENU_MAXLINES - 1) ? entry_num + 1 : 0);
+               }
+       }
+       draw_cursor_normal(mousepos, '1 1 1', 0.8);
+       prevMouseClicked = mouseClicked;
+ }
+ void HUD_Quickmenu_DrawEntry(vector pos, string desc, string option, vector fontsize)
+ {
+       string entry;
+       float offset;
+       float desc_width = panel_size.x;
+       if(option)
+       {
+               string pic = strcat(hud_skin_path, "/", option);
+               if(precache_pic(pic) == "")
+                       pic = strcat("gfx/hud/default/", option);
+               vector option_size = '1 1 0' * fontsize.y * 0.8;
+               desc_width -= option_size.x;
+               drawpic(pos + eX * desc_width + eY * (fontsize.y - option_size.y) / 2, pic, option_size, '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
+               desc_width -= fontsize.x / 4;
+       }
+       entry = textShortenToWidth(desc, desc_width, fontsize, stringwidth_colors);
+       if (autocvar_hud_panel_quickmenu_align > 0)
+       {
+               float real_desc_width = stringwidth_colors(entry, fontsize);
+               offset = (desc_width - real_desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
+               if(option)
+               {
+                       // when there's enough room align description regardless the checkbox
+                       float extra_offset = (panel_size.x - desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
+                       if(offset + real_desc_width + extra_offset < desc_width)
+                               offset += extra_offset;
+                       else
+                               offset = max(0, desc_width - real_desc_width);
+               }
+               drawcolorcodedstring(pos + eX * offset, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
+       }
+       else
+               drawcolorcodedstring(pos, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
+ }
+ void HUD_QuickMenu()
+ {
+       if(!autocvar__hud_configure)
+       {
+               if (hud_configure_prev && hud_configure_prev != -1)
+                       QuickMenu_Close();
+               if(!hud_draw_maximized) return;
+               if(mv_active) return;
+               //if(!autocvar_hud_panel_quickmenu) return;
+               if(!hud_panel_quickmenu) return;
+               if(QuickMenu_TimeOut)
+               if(time > QuickMenu_TimeOut)
+               {
+                       QuickMenu_Close();
+                       return;
+               }
+       }
+       else
+       {
+               if(!QuickMenu_IsOpened())
+               {
+                       QuickMenu_Page_Entries = 1;
+                       QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
+                       ++QuickMenu_Page_Entries;
+                       QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Submenu%d"), QuickMenu_Page_Entries), "");
+                       ++QuickMenu_Page_Entries;
+                       // although real command doesn't matter here, it must not be empty
+                       // otherwise the entry is displayed like a submenu
+                       for (; QuickMenu_Page_Entries < QUICKMENU_MAXLINES - 1; ++QuickMenu_Page_Entries)
+                               QuickMenu_Page_LoadEntry(QuickMenu_Page_Entries, sprintf(_("Command%d"), QuickMenu_Page_Entries), "-");
+                       ++QuickMenu_Page_Entries;
+                       QuickMenu_Page_ClearEntry(QuickMenu_Page_Entries);
+                       QuickMenu_IsLastPage = false;
+               }
+       }
+       HUD_Panel_UpdateCvars();
++      HUD_Scale_Enable();
+       HUD_Panel_DrawBg(1);
+       if(panel_bg_padding)
+       {
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
+       }
+       int 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...")), string_null, fontsize);
+       }
+       else
+               panel_pos.y += ((QUICKMENU_MAXLINES - QuickMenu_Page_Entries) * fontsize.y) / 2;
+       for (i = 1; i <= QuickMenu_Page_Entries; ++i) {
+               if (QuickMenu_Page_Description[i] == "")
+                       break;
+               string option = string_null;
+               if (QuickMenu_Page_Command[i] == "")
+                       color = "^4";
+               else
+               {
+                       color = "^3";
+                       if(QuickMenu_Page_Command_Type[i] == 1) // toggle command
+                       {
+                               int end = strstrofs(QuickMenu_Page_Command[i], ";", 0);
+                               if(end < 0)
+                                       tokenize_console(QuickMenu_Page_Command[i]);
+                               else
+                                       tokenize_console(substring(QuickMenu_Page_Command[i], 0, end));
+                               //if(argv(1) && argv(0) == "toggle") // already checked
+                               {
+                                       // "enable feature xxx" "toggle xxx" (or "toggle xxx 1 0")
+                                       // "disable feature xxx" "toggle xxx 0 1"
+                                       float ON_value = 1, OFF_value = 0;
+                                       if(argv(2))
+                                               ON_value = stof(argv(2));
+                                       if(argv(3))
+                                               OFF_value = stof(argv(3));
+                                       else
+                                               OFF_value = !ON_value;
+                                       float value = cvar(argv(1));
+                                       if(value == ON_value)
+                                               option = "checkbox_checked";
+                                       else if(value == OFF_value)
+                                               option = "checkbox_empty";
+                                       else
+                                               option = "checkbox_undefined";
+                               }
+                       }
+               }
+               HUD_Quickmenu_DrawEntry(panel_pos, sprintf("%d: %s%s", i, color, QuickMenu_Page_Description[i]), option, fontsize);
+               if(QuickMenu_Page_ActivatedEntry_Time && time < QuickMenu_Page_ActivatedEntry_Time
+                       && QuickMenu_Page_ActivatedEntry == i)
+                       drawfill(panel_pos, eX * panel_size.x + eY * fontsize.y, '0.5 1 0.5', .2, DRAWFLAG_NORMAL);
+               panel_pos.y += fontsize.y;
+       }
+       if(QuickMenu_Page_ActivatedEntry >= 0 && time >= QuickMenu_Page_ActivatedEntry_Time)
+       {
+               if(!QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
+               {
+                       bool f = QuickMenu_ActionForNumber(QuickMenu_Page_ActivatedEntry);
+                       if(f && QuickMenu_Page_ActivatedEntry_Close)
+                               QuickMenu_Close();
+               }
+               else if(QuickMenu_Page_ActivatedEntry_Close)
+                       QuickMenu_Close();
+               QuickMenu_Page_ActivatedEntry = -1;
+               QuickMenu_Page_ActivatedEntry_Time = 0;
+       }
+ }
+ #define QUICKMENU_SMENU(submenu,eng_submenu) { \
+       if(target_submenu == eng_submenu && target_submenu_found) \
+               return; /* target_submenu entries are now loaded, exit */ \
+       if(QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES) \
+               QuickMenu_Buffer_Set(QM_TAG_SUBMENU, submenu); \
+       ++QuickMenu_Buffer_Size; \
+       if(target_submenu == eng_submenu && !target_submenu_found) { \
+               QuickMenu_Buffer_Size = 0; /* enable load of next entries */ \
+               target_submenu_found = true; \
+       } \
+ }
+ #define QUICKMENU_ENTRY(title,command) { \
+       if(QuickMenu_Buffer_Size + 1 < QUICKMENU_BUFFER_MAXENTRIES) \
+       { \
+               QuickMenu_Buffer_Set(QM_TAG_TITLE, title); \
+               ++QuickMenu_Buffer_Size; \
+               QuickMenu_Buffer_Set(QM_TAG_COMMAND, command); \
+       } \
+       ++QuickMenu_Buffer_Size; \
+ }
+ #define QUICKMENU_SMENU_PL(submenu,eng_submenu,command,teamplayers,without_me) { \
+       if(QuickMenu_Buffer_Size + 3 < QUICKMENU_BUFFER_MAXENTRIES) {\
+               QUICKMENU_SMENU(submenu,eng_submenu) \
+               QuickMenu_Buffer_Set(QM_TAG_TITLE, strcat(ftos(teamplayers), ftos(without_me))); \
+               ++QuickMenu_Buffer_Size; \
+               QuickMenu_Buffer_Set(QM_TAG_PLCOMMAND, command); \
+               ++QuickMenu_Buffer_Size; \
+               QUICKMENU_SMENU(submenu,eng_submenu) \
+       } \
+ }
+ // useful to Translate a string inside the Command
+ #define QUICKMENU_ENTRY_TC(title,command,text,translated_text) {\
+       if(prvm_language == "en") \
+               QUICKMENU_ENTRY(title, sprintf(command, text)) \
+       else if(!autocvar_hud_panel_quickmenu_translatecommands || translated_text == text) \
+               QUICKMENU_ENTRY(strcat("(en)", title), sprintf(command, text)) \
+       else \
+               QUICKMENU_ENTRY(strcat("(", prvm_language, ")", title), sprintf(command, translated_text)) \
+ }
+ void HUD_Quickmenu_PlayerListEntries(string cmd, int teamplayers, bool without_me)
+ {
+     TC(int, teamplayers); TC(bool, without_me);
+       entity pl;
+       if(teamplayers && !team_count)
+               return;
+       for(pl = players.sort_next; pl; pl = pl.sort_next)
+       {
+               if(teamplayers == 1 && (pl.team != myteam || pl.team == NUM_SPECTATOR)) // only own team players
+                       continue;
+               if(teamplayers == 2 && (pl.team == myteam || pl.team == NUM_SPECTATOR)) // only enemy team players
+                       continue;
+               if(without_me && pl.sv_entnum == player_localnum)
+                       continue;
+               QUICKMENU_ENTRY(entcs_GetName(pl.sv_entnum), sprintf(cmd, entcs_GetName(pl.sv_entnum)))
+       }
+       return;
+ }
+ // Specifying target_submenu, this function only loads entries inside target_submenu
+ // NOTE: alternatively we could have loaded the whole default quickmenu and
+ // then called QuickMenu_Page_Load(target_submenu, 0);
+ // but this sytem is more reliable since we can always refer to target_submenu
+ // with the English title even if a translation is active
+ void QuickMenu_Default(string target_submenu)
+ {
+       bool target_submenu_found = false;
+       if(target_submenu != "")
+               QuickMenu_Buffer_Size = QUICKMENU_BUFFER_MAXENTRIES; // forbids load of next entries until target_submenu
+       QUICKMENU_SMENU(CTX(_("QMCMD^Chat")), "Chat")
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^nice one")), "say %s", ":-) / nice one", CTX(_("QMCMD^:-) / nice one")))
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^good game")), "say %s", "good game", CTX(_("QMCMD^good game")))
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^hi / good luck")), "say %s", "hi / good luck and have fun", CTX(_("QMCMD^hi / good luck and have fun")))
+       QUICKMENU_SMENU(CTX(_("QMCMD^Chat")), "Chat")
+       if(teamplay)
+       {
+       QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^quad soon")), "say_team %s", "quad soon", CTX(_("QMCMD^quad soon")))
+               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)")))
+               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)")))
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^negative")), "say_team %s", "negative", CTX(_("QMCMD^negative")))
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^positive")), "say_team %s", "positive", CTX(_("QMCMD^positive")))
+               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)")))
+               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)")))
+               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)")))
+               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)")))
+               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)")))
+               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)")))
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^killed flag, icon")), "say_team %s; g_waypointsprite_team_here_p", "killed flagcarrier (l:%y^7)", CTX(_("QMCMD^killed flagcarrier (l:%y^7)")))
+               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)")))
+               QUICKMENU_ENTRY_TC(CTX(_("QMCMD^drop gun, icon")), "say_team %s; g_waypointsprite_team_here; wait; dropweapon", "dropped gun %w^7 (l:%l^7)", CTX(_("QMCMD^dropped gun %w^7 (l:%l^7)")))
+               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)")))
+       QUICKMENU_SMENU(CTX(_("QMCMD^Team chat")), "Team chat")
+       }
+       QUICKMENU_SMENU_PL(CTX(_("QMCMD^Send private message to")), "Send private message to", "commandmode tell \"%s^7\"", 0, 1)
+       QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
+               QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person view")), "toggle chase_active")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Player models like mine")), "toggle cl_forceplayermodels")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Names above players")), "toggle hud_shownames")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Crosshair per weapon")), "toggle crosshair_per_weapon")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^FPS")), "toggle hud_panel_engineinfo")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Net graph")), "toggle shownetgraph")
+               QUICKMENU_SMENU(CTX(_("QMCMD^View/HUD settings")), "View/HUD settings")
+               QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Hit sound")), "toggle cl_hitsound")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Chat sound")), "toggle con_chatsound")
+               QUICKMENU_SMENU(CTX(_("QMCMD^Sound settings")), "Sound settings")
+               if(spectatee_status > 0)
+               {
+               QUICKMENU_SMENU(CTX(_("QMCMD^Spectator camera")), "Spectator camera")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^1st person")), "chase_active 0; -use")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person around player")), "chase_active 1; +use")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^3rd person behind")), "chase_active 1; -use")
+               QUICKMENU_SMENU(CTX(_("QMCMD^Spectator camera")), "Spectator camera")
+               }
+               if(spectatee_status == -1)
+               {
+               QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Increase speed")), "weapnext")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Decrease speed")), "weapprev")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Wall collision off")), "+use")
+                       QUICKMENU_ENTRY(CTX(_("QMCMD^Wall collision on")), "-use")
+               QUICKMENU_SMENU(CTX(_("QMCMD^Observer camera")), "Observer camera")
+               }
+               QUICKMENU_ENTRY(CTX(_("QMCMD^Fullscreen")), "toggle vid_fullscreen; vid_restart")
+               if(prvm_language != "en")
+               QUICKMENU_ENTRY(CTX(_("QMCMD^Translate chat messages")), "toggle hud_panel_quickmenu_translatecommands")
+       QUICKMENU_SMENU(CTX(_("QMCMD^Settings")), "Settings")
+       QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
+               QUICKMENU_ENTRY(CTX(_("QMCMD^Restart the map")), "vcall restart")
+               QUICKMENU_ENTRY(CTX(_("QMCMD^End match")), "vcall endmatch")
+               if(STAT(TIMELIMIT) > 0)
+               {
+               QUICKMENU_ENTRY(CTX(_("QMCMD^Reduce match time")), "vcall reducematchtime")
+               QUICKMENU_ENTRY(CTX(_("QMCMD^Extend match time")), "vcall extendmatchtime")
+               }
+               if(teamplay)
+               QUICKMENU_ENTRY(CTX(_("QMCMD^Shuffle teams")), "vcall shuffleteams")
+       QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
+       if(target_submenu != "" && !target_submenu_found)
+       {
+               LOG_WARNINGF("Couldn't find submenu \"%s\"\n", target_submenu);
+               if(prvm_language != "en")
+                       LOG_WARNINGF("^3Warning: submenu must be in English\n", target_submenu);
+               QuickMenu_Buffer_Size = 0;
+       }
+ }
+ #undef QUICKMENU_SMENU
+ #undef QUICKMENU_ENTRY
+ #undef QUICKMENU_ENTRY_TC
index 449b1682cadd1faa7ea7945cb01be57b31a6e0eb,365ba01dd74babd7540df066241633f9001255fe..3ad0bb0f79e8c1216e4f91e7b6c05f643e89b66c
@@@ -3,6 -3,77 +3,77 @@@
  #include <common/mapinfo.qh>
  
  /** Race timer (#8) */
+ // return the string of the onscreen race timer
+ string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname)
+ {
+       TC(int, cp);
+       string col;
+       string timestr;
+       string cpname;
+       string lapstr;
+       lapstr = "";
+       if(theirtime == 0) // goal hit
+       {
+               if(mytime > 0)
+               {
+                       timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
+                       col = "^1";
+               }
+               else if(mytime == 0)
+               {
+                       timestr = "+0.0";
+                       col = "^3";
+               }
+               else
+               {
+                       timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
+                       col = "^2";
+               }
+               if(lapdelta > 0)
+               {
+                       lapstr = sprintf(_(" (-%dL)"), lapdelta);
+                       col = "^2";
+               }
+               else if(lapdelta < 0)
+               {
+                       lapstr = sprintf(_(" (+%dL)"), -lapdelta);
+                       col = "^1";
+               }
+       }
+       else if(theirtime > 0) // anticipation
+       {
+               if(mytime >= theirtime)
+                       timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS));
+               else
+                       timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime));
+               col = "^3";
+       }
+       else
+       {
+               col = "^7";
+               timestr = "";
+       }
+       if(cp == 254)
+               cpname = _("Start line");
+       else if(cp == 255)
+               cpname = _("Finish line");
+       else if(cp)
+               cpname = sprintf(_("Intermediate %d"), cp);
+       else
+               cpname = _("Finish line");
+       if(theirtime < 0)
+               return strcat(col, cpname);
+       else if(theirname == "")
+               return strcat(col, sprintf("%s (%s)", cpname, timestr));
+       else
+               return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr)));
+ }
  void HUD_RaceTimer ()
  {
        if(!autocvar__hud_configure)
@@@ -18,7 -89,6 +89,7 @@@
        pos = panel_pos;
        mySize = panel_size;
  
 +      HUD_Scale_Enable();
        HUD_Panel_DrawBg(1);
        if(panel_bg_padding)
        {
diff --combined qcsrc/client/main.qc
index bdffae574e8efa44a3ba203be2bc510e21e0ca1d,98b266c6d18410a39a466a66b77b452ee10a9ef5..bb1cf9b4aab3ea5b47c0c4837709fd24836f071a
@@@ -4,7 -4,7 +4,7 @@@
  #include "hud/all.qh"
  #include "mapvoting.qh"
  #include "mutators/events.qh"
- #include "quickmenu.qh"
+ #include "hud/panel/quickmenu.qh"
  #include "scoreboard.qh"
  #include "shownames.qh"
  #include <common/t_items.qh>
@@@ -537,7 -537,6 +537,7 @@@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool 
                // clear race stuff
                race_laptime = 0;
                race_checkpointtime = 0;
 +              hud_dynamic_shake_factor = -1;
        }
        if (autocvar_hud_panel_healtharmor_progressbar_gfx)
        {
diff --combined qcsrc/client/view.qc
index b9730407ddc6339a9eced9fdedc6c6dad5686685,f1b7a9be5ede7c8ccd4ca511bfb8cfc9851059b8..6ea2bb91b42a79b8d406b08b04c849bd804ca670
@@@ -5,7 -5,7 +5,7 @@@
  #include "mapvoting.qh"
  #include "scoreboard.qh"
  #include "shownames.qh"
- #include "quickmenu.qh"
+ #include "hud/panel/quickmenu.qh"
  
  #include "mutators/events.qh"
  
@@@ -114,99 -114,17 +114,99 @@@ float autocvar_cl_leanmodel_lowpass = 0
        highpass(value.z, frac, ref_store.z, ref_out.z); \
  } MACRO_END
  
 -void viewmodel_animate(entity this)
 +void calc_followmodel_ofs(entity view)
  {
 -      static float prevtime;
 -      float frametime = (time - prevtime);
 -      prevtime = time;
 +      if(cl_followmodel_time == time)
 +              return; // cl_followmodel_ofs already calculated for this frame
  
 -      if (autocvar_chase_active) return;
 -      if (STAT(HEALTH) <= 0) return;
 +      float frac;
 +      vector gunorg = '0 0 0';
 +      static vector vel_average;
 +      static vector gunorg_prev = '0 0 0';
 +      static vector gunorg_adjustment_highpass;
 +      static vector gunorg_adjustment_lowpass;
 +
 +      vector vel;
 +      if (autocvar_cl_followmodel_velocity_absolute)
 +              vel = view.velocity;
 +      else
 +      {
 +              vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
 +              MAKEVECTORS(makevectors, view_angles, forward, right, up);
 +              vel.x = view.velocity * forward;
 +              vel.y = view.velocity * right * -1;
 +              vel.z = view.velocity * up;
 +      }
  
 -      entity view = CSQCModel_server2csqc(player_localentnum - 1);
 +      vel.x = bound(vel_average.x - autocvar_cl_followmodel_limit, vel.x, vel_average.x + autocvar_cl_followmodel_limit);
 +      vel.y = bound(vel_average.y - autocvar_cl_followmodel_limit, vel.y, vel_average.y + autocvar_cl_followmodel_limit);
 +      vel.z = bound(vel_average.z - autocvar_cl_followmodel_limit, vel.z, vel_average.z + autocvar_cl_followmodel_limit);
 +
 +      frac = avg_factor(autocvar_cl_followmodel_velocity_lowpass);
 +      lowpass3(vel, frac, vel_average, gunorg);
 +
 +      gunorg *= -autocvar_cl_followmodel_speed * 0.042;
 +
 +      // perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
 +      // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
 +      frac = avg_factor(autocvar_cl_followmodel_highpass);
 +      highpass3(gunorg, frac, gunorg_adjustment_highpass, gunorg);
 +      frac = avg_factor(autocvar_cl_followmodel_lowpass);
 +      lowpass3(gunorg, frac, gunorg_adjustment_lowpass, gunorg);
 +
 +      if (autocvar_cl_followmodel_velocity_absolute)
 +      {
 +              vector fixed_gunorg;
 +              vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
 +              MAKEVECTORS(makevectors, view_angles, forward, right, up);
 +              fixed_gunorg.x = gunorg * forward;
 +              fixed_gunorg.y = gunorg * right * -1;
 +              fixed_gunorg.z = gunorg * up;
 +              gunorg = fixed_gunorg;
 +      }
 +
 +      cl_followmodel_ofs = gunorg;
 +      cl_followmodel_time = time;
 +}
 +
 +vector leanmodel_ofs(entity view)
 +{
 +      float frac;
 +      vector gunangles = '0 0 0';
 +      static vector gunangles_prev = '0 0 0';
 +      static vector gunangles_highpass = '0 0 0';
 +      static vector gunangles_adjustment_highpass;
 +      static vector gunangles_adjustment_lowpass;
 +
 +      if (view.csqcmodel_teleported)
 +              gunangles_prev = view_angles;
 +
 +      // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
 +      gunangles_highpass += gunangles_prev;
 +      PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
 +      YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
 +      ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
 +      frac = avg_factor(autocvar_cl_leanmodel_highpass1);
 +      highpass2_limited(view_angles, frac, autocvar_cl_leanmodel_limit, gunangles_highpass, gunangles);
 +      gunangles_prev = view_angles;
 +      gunangles_highpass -= gunangles_prev;
  
 +      PITCH(gunangles) *= -autocvar_cl_leanmodel_speed;
 +      YAW(gunangles) *= -autocvar_cl_leanmodel_speed;
 +
 +      // we assume here: PITCH = 0, YAW = 1, ROLL = 2
 +      frac = avg_factor(autocvar_cl_leanmodel_highpass);
 +      highpass2(gunangles, frac, gunangles_adjustment_highpass, gunangles);
 +      frac = avg_factor(autocvar_cl_leanmodel_lowpass);
 +      lowpass2(gunangles, frac, gunangles_adjustment_lowpass, gunangles);
 +
 +      gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
 +
 +      return gunangles;
 +}
 +
 +vector bobmodel_ofs(entity view)
 +{
        bool clonground = !(view.anim_implicit_state & ANIMIMPLICITSTATE_INAIR);
        static bool oldonground;
        static float hitgroundtime;
        }
        oldonground = clonground;
  
 -
 -      bool teleported = view.csqcmodel_teleported;
 -
 -      float frac;
 -      if(autocvar_cl_followmodel)
 +      // calculate for swinging gun model
 +      // the gun bobs when running on the ground, but doesn't bob when you're in the air.
 +      vector gunorg = '0 0 0';
 +      static float bobmodel_scale = 0;
 +      static float time_ofs = 0; // makes the effect always restart in the same way
 +      if (clonground)
        {
 -              vector gunorg = '0 0 0';
 -              static vector vel_average;
 -              static vector gunorg_prev = '0 0 0';
 -              static vector gunorg_adjustment_highpass;
 -              static vector gunorg_adjustment_lowpass;
 -
 -              vector vel;
 -              if(autocvar_cl_followmodel_velocity_absolute)
 -                      vel = view.velocity;
 -              else
 -              {
 -                      vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
 -                      MAKEVECTORS(makevectors, view_angles, forward, right, up);
 -                      vel.x = view.velocity * forward;
 -                      vel.y = view.velocity * right * -1;
 -                      vel.z = view.velocity * up;
 -              }
 -
 -              vel.x = bound(vel_average.x - autocvar_cl_followmodel_limit, vel.x, vel_average.x + autocvar_cl_followmodel_limit);
 -              vel.y = bound(vel_average.y - autocvar_cl_followmodel_limit, vel.y, vel_average.y + autocvar_cl_followmodel_limit);
 -              vel.z = bound(vel_average.z - autocvar_cl_followmodel_limit, vel.z, vel_average.z + autocvar_cl_followmodel_limit);
 -
 -              frac = avg_factor(autocvar_cl_followmodel_velocity_lowpass);
 -              lowpass3(vel, frac, vel_average, gunorg);
 -
 -              gunorg *= -autocvar_cl_followmodel_speed * 0.042;
 -
 -              // perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
 -              // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
 -              frac = avg_factor(autocvar_cl_followmodel_highpass);
 -              highpass3(gunorg, frac, gunorg_adjustment_highpass, gunorg);
 -              frac = avg_factor(autocvar_cl_followmodel_lowpass);
 -              lowpass3(gunorg, frac, gunorg_adjustment_lowpass, gunorg);
 -
 -              if(autocvar_cl_followmodel_velocity_absolute)
 -              {
 -                      vector fixed_gunorg;
 -                      vector forward = '0 0 0', right = '0 0 0', up = '0 0 0';
 -                      MAKEVECTORS(makevectors, view_angles, forward, right, up);
 -                      fixed_gunorg.x = gunorg * forward;
 -                      fixed_gunorg.y = gunorg * right * -1;
 -                      fixed_gunorg.z = gunorg * up;
 -                      gunorg = fixed_gunorg;
 -              }
 -
 -              this.origin += gunorg;
 +              if (time - hitgroundtime > 0.05)
 +                      bobmodel_scale = min(1, bobmodel_scale + frametime * 5);
        }
 +      else
 +              bobmodel_scale = max(0, bobmodel_scale - frametime * 5);
  
 -      if(autocvar_cl_leanmodel)
 +      float xyspeed = bound(0, vlen(vec2(view.velocity)), 400);
 +      if (bobmodel_scale && xyspeed)
        {
 -              vector gunangles = '0 0 0';
 -              static vector gunangles_prev = '0 0 0';
 -              static vector gunangles_highpass = '0 0 0';
 -              static vector gunangles_adjustment_highpass;
 -              static vector gunangles_adjustment_lowpass;
 -
 -              if (teleported)
 -                      gunangles_prev = view_angles;
 -
 -              // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
 -              gunangles_highpass += gunangles_prev;
 -              PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
 -              YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
 -              ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
 -              frac = avg_factor(autocvar_cl_leanmodel_highpass1);
 -              highpass2_limited(view_angles, frac, autocvar_cl_leanmodel_limit, gunangles_highpass, gunangles);
 -              gunangles_prev = view_angles;
 -              gunangles_highpass -= gunangles_prev;
 +              float bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale;
 +              float s = (time - time_ofs) * autocvar_cl_bobmodel_speed;
 +              gunorg.y = bspeed * autocvar_cl_bobmodel_side * sin(s);
 +              gunorg.z = bspeed * autocvar_cl_bobmodel_up * cos(s * 2);
 +      }
 +      else
 +              time_ofs = time;
  
 -              PITCH(gunangles) *= -autocvar_cl_leanmodel_speed;
 -              YAW(gunangles) *= -autocvar_cl_leanmodel_speed;
 +      return gunorg;
 +}
  
 -              // we assume here: PITCH = 0, YAW = 1, ROLL = 2
 -              frac = avg_factor(autocvar_cl_leanmodel_highpass);
 -              highpass2(gunangles, frac, gunangles_adjustment_highpass, gunangles);
 -              frac = avg_factor(autocvar_cl_leanmodel_lowpass);
 -              lowpass2(gunangles, frac, gunangles_adjustment_lowpass, gunangles);
 +void viewmodel_animate(entity this)
 +{
 +      if (autocvar_chase_active) return;
 +      if (STAT(HEALTH) <= 0) return;
 +
 +      entity view = CSQCModel_server2csqc(player_localentnum - 1);
  
 -              gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
 -              this.angles += gunangles;
 +      if (autocvar_cl_followmodel)
 +      {
 +              calc_followmodel_ofs(view);
 +              this.origin += cl_followmodel_ofs;
        }
  
 -      float xyspeed = bound(0, vlen(vec2(view.velocity)), 400);
 +      if (autocvar_cl_leanmodel)
 +              this.angles += leanmodel_ofs(view);
  
        // vertical view bobbing code
        // TODO: cl_bob
  
        // gun model bobbing code
        if (autocvar_cl_bobmodel)
 -      {
 -              // calculate for swinging gun model
 -              // the gun bobs when running on the ground, but doesn't bob when you're in the air.
 -              static float bobmodel_scale = 0;
 -              static float time_ofs = 0; // makes the effect always restart in the same way
 -              if (clonground)
 -              {
 -                      if (time - hitgroundtime > 0.05)
 -                              bobmodel_scale = min(1, bobmodel_scale + frametime * 5);
 -              }
 -              else
 -                      bobmodel_scale = max(0, bobmodel_scale - frametime * 5);
 -              if(bobmodel_scale && xyspeed)
 -              {
 -                      float bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale;
 -                      float s = (time - time_ofs) * autocvar_cl_bobmodel_speed;
 -                      vector gunorg = '0 0 0';
 -                      gunorg.y = bspeed * autocvar_cl_bobmodel_side * sin(s);
 -                      gunorg.z = bspeed * autocvar_cl_bobmodel_up * cos(s * 2);
 -
 -                      this.origin += gunorg;
 -              }
 -              else
 -                      time_ofs = time;
 -      }
 +              this.origin += bobmodel_ofs(view);
  }
  
  .vector viewmodel_origin, viewmodel_angles;
  
  void viewmodel_draw(entity this)
  {
 -      if(!activeweapon)
 +      if(!activeweapon || !autocvar_r_drawviewmodel)
                return;
        int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
        float a = this.alpha;
@@@ -853,10 -842,88 +853,88 @@@ void HitSound(
        }
  }
  
- void HUD_Crosshair()
- {SELFPARAM();
+ vector crosshair_getcolor(entity this, float health_stat)
+ {
        static float rainbow_last_flicker;
        static vector rainbow_prev_color;
+       vector wcross_color = '0 0 0';
+       switch(autocvar_crosshair_color_special)
+       {
+               case 1: // crosshair_color_per_weapon
+               {
+                       if(this)
+                       {
+                               wcross_color = this.wpcolor;
+                               break;
+                       }
+                       else { goto normalcolor; }
+               }
+               case 2: // crosshair_color_by_health
+               {
+                       float x = health_stat;
+                       //x = red
+                       //y = green
+                       //z = blue
+                       wcross_color.z = 0;
+                       if(x > 200)
+                       {
+                               wcross_color.x = 0;
+                               wcross_color.y = 1;
+                       }
+                       else if(x > 150)
+                       {
+                               wcross_color.x = 0.4 - (x-150)*0.02 * 0.4;
+                               wcross_color.y = 0.9 + (x-150)*0.02 * 0.1;
+                       }
+                       else if(x > 100)
+                       {
+                               wcross_color.x = 1 - (x-100)*0.02 * 0.6;
+                               wcross_color.y = 1 - (x-100)*0.02 * 0.1;
+                               wcross_color.z = 1 - (x-100)*0.02;
+                       }
+                       else if(x > 50)
+                       {
+                               wcross_color.x = 1;
+                               wcross_color.y = 1;
+                               wcross_color.z = 0.2 + (x-50)*0.02 * 0.8;
+                       }
+                       else if(x > 20)
+                       {
+                               wcross_color.x = 1;
+                               wcross_color.y = (x-20)*90/27/100;
+                               wcross_color.z = (x-20)*90/27/100 * 0.2;
+                       }
+                       else
+                       {
+                               wcross_color.x = 1;
+                               wcross_color.y = 0;
+                       }
+                       break;
+               }
+               case 3: // crosshair_color_rainbow
+               {
+                       if(time >= rainbow_last_flicker)
+                       {
+                               rainbow_prev_color = randomvec() * autocvar_crosshair_color_special_rainbow_brightness;
+                               rainbow_last_flicker = time + autocvar_crosshair_color_special_rainbow_delay;
+                       }
+                       wcross_color = rainbow_prev_color;
+                       break;
+               }
+ LABEL(normalcolor)
+               default: { wcross_color = stov(autocvar_crosshair_color); break; }
+       }
+       return wcross_color;
+ }
+ void HUD_Crosshair()
+ {SELFPARAM();
        entity e = this;
        float f, i, j;
        vector v;
                        wcross_name = strcat("gfx/crosshair", wcross_style);
  
                // MAIN CROSSHAIR COLOR DECISION
-               switch(autocvar_crosshair_color_special)
-               {
-                       case 1: // crosshair_color_per_weapon
-                       {
-                               if(e)
-                               {
-                                       wcross_color = e.wpcolor;
-                                       break;
-                               }
-                               else { goto normalcolor; }
-                       }
-                       case 2: // crosshair_color_by_health
-                       {
-                               float x = STAT(HEALTH);
-                               //x = red
-                               //y = green
-                               //z = blue
-                               wcross_color.z = 0;
-                               if(x > 200)
-                               {
-                                       wcross_color.x = 0;
-                                       wcross_color.y = 1;
-                               }
-                               else if(x > 150)
-                               {
-                                       wcross_color.x = 0.4 - (x-150)*0.02 * 0.4;
-                                       wcross_color.y = 0.9 + (x-150)*0.02 * 0.1;
-                               }
-                               else if(x > 100)
-                               {
-                                       wcross_color.x = 1 - (x-100)*0.02 * 0.6;
-                                       wcross_color.y = 1 - (x-100)*0.02 * 0.1;
-                                       wcross_color.z = 1 - (x-100)*0.02;
-                               }
-                               else if(x > 50)
-                               {
-                                       wcross_color.x = 1;
-                                       wcross_color.y = 1;
-                                       wcross_color.z = 0.2 + (x-50)*0.02 * 0.8;
-                               }
-                               else if(x > 20)
-                               {
-                                       wcross_color.x = 1;
-                                       wcross_color.y = (x-20)*90/27/100;
-                                       wcross_color.z = (x-20)*90/27/100 * 0.2;
-                               }
-                               else
-                               {
-                                       wcross_color.x = 1;
-                                       wcross_color.y = 0;
-                               }
-                               break;
-                       }
-                       case 3: // crosshair_color_rainbow
-                       {
-                               if(time >= rainbow_last_flicker)
-                               {
-                                       rainbow_prev_color = randomvec() * autocvar_crosshair_color_special_rainbow_brightness;
-                                       rainbow_last_flicker = time + autocvar_crosshair_color_special_rainbow_delay;
-                               }
-                               wcross_color = rainbow_prev_color;
-                               break;
-                       }
- LABEL(normalcolor)
-                       default: { wcross_color = stov(autocvar_crosshair_color); break; }
-               }
+               wcross_color = crosshair_getcolor(e, STAT(HEALTH));
  
                if(autocvar_crosshair_effect_scalefade)
                {
@@@ -1340,7 -1337,6 +1348,7 @@@ void HUD_Draw(
  
                        HUD_Main();
                        HUD_DrawScoreboard();
 +                      HUD_Scale_Disable();
                }
  
        // crosshair goes VERY LAST
@@@ -1383,8 -1379,6 +1391,8 @@@ void CSQC_UpdateView(float w, float h
  
        lasthud = hud;
  
 +      HUD_Scale_Disable();
 +
        if(autocvar__hud_showbinds_reload) // menu can set this one
        {
                db_close(binddb);
                        if(!gen)
                                ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
                }
-               if(WantEventchase(self) || (!autocvar_cl_orthoview && ons_roundlost))
+               if(WantEventchase(this) || (!autocvar_cl_orthoview && ons_roundlost))
                {
                        eventchase_running = true;
  
                        entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1));
                        if(!local_player)
-                               local_player = self; // fall back!
+                               local_player = this; // fall back!
  
                        // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)
                        vector current_view_origin = (csqcplayer ? csqcplayer.origin : pmove_org);
  
                        if(view_offset)
                        {
-                               WarpZone_TraceLine(current_view_origin, current_view_origin + view_offset + ('0 0 1' * autocvar_cl_eventchase_maxs.z), MOVE_WORLDONLY, self);
+                               WarpZone_TraceLine(current_view_origin, current_view_origin + view_offset + ('0 0 1' * autocvar_cl_eventchase_maxs.z), MOVE_WORLDONLY, this);
                                if(trace_fraction == 1) { current_view_origin += view_offset; }
                                else { current_view_origin.z += max(0, (trace_endpos.z - current_view_origin.z) - autocvar_cl_eventchase_maxs.z); }
                        }
                        makevectors(view_angles);
  
                        vector eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_distance));
-                       WarpZone_TraceBox(current_view_origin, autocvar_cl_eventchase_mins, autocvar_cl_eventchase_maxs, eventchase_target_origin, MOVE_WORLDONLY, self);
+                       WarpZone_TraceBox(current_view_origin, autocvar_cl_eventchase_mins, autocvar_cl_eventchase_maxs, eventchase_target_origin, MOVE_WORLDONLY, this);
  
                        // If the boxtrace fails, revert back to line tracing.
                        if(!local_player.viewloc)
                        if(trace_startsolid)
                        {
                                eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_distance));
-                               WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);
+                               WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, this);
                                setproperty(VF_ORIGIN, (trace_endpos - (v_forward * autocvar_cl_eventchase_mins.z)));
                        }
                        else { setproperty(VF_ORIGIN, trace_endpos); }
index a61d8bfbc6519da43388cb66c9f49fe041de1383,ca2a0ed17c9234e306d03b4cabce5910cf9d79f8..c12399527ad45d7931d115953b4ad29f76e2424a
@@@ -115,7 -115,7 +115,7 @@@ void HUD_MinigameMenu_Click(entity menu
  {SELFPARAM();
        if ( menuitem )
        {
-               WITH(entity, self, menuitem, menuitem.use());
+               WITHSELF(menuitem, menuitem.use());
        }
  }
  
@@@ -476,7 -476,6 +476,7 @@@ void HUD_MinigameMenu (
  
        HUD_Panel_UpdateCvars();
  
 +      HUD_Scale_Disable();
        HUD_Panel_DrawBg(1);
  
        if(panel_bg_padding)