]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/cursor
authorterencehill <piuntn@gmail.com>
Tue, 18 Sep 2018 12:02:25 +0000 (14:02 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 18 Sep 2018 12:02:25 +0000 (14:02 +0200)
1  2 
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/client/main.qc
qcsrc/client/view.qc

index a3141c225dc88e945e3cc3b68d2fc8678911fb2a,e7e3c6d65241b9b7a207faa2aedcaa9603ac4009..29907505bceffef9edf1fb472f8554b1567fd5ea
@@@ -4,7 -4,6 +4,7 @@@
  #include <client/defs.qh>
  #include <client/miscfunctions.qh>
  #include <common/ent_cs.qh>
 +#include <common/minigames/cl_minigames.qh>
  #include <client/hud/_mod.qh>
  #include <client/mapvoting.qh>
  
@@@ -58,21 -57,8 +58,21 @@@ void QuickMenu_Page_ClearEntry(int i
        QuickMenu_Page_Command_Type[i] = 0;
  }
  
 +bool HUD_QuickMenu_Forbidden()
 +{
 +      return (mv_active
 +              || (hud_configure_prev && hud_configure_prev != -1)
 +              || HUD_MinigameMenu_IsOpened()
 +              || (QuickMenu_TimeOut && time > QuickMenu_TimeOut));
 +}
 +
 +// returns true if succeded, false otherwise
  bool QuickMenu_Open(string mode, string submenu, string file)
  {
 +      QuickMenu_TimeOut = 0;
 +      if (HUD_QuickMenu_Forbidden())
 +              return false;
 +
        int fh = -1;
        string s;
  
                while((s = fgets(fh)) && QuickMenu_Buffer_Size < QUICKMENU_BUFFER_MAXENTRIES)
                {
                        // first skip invalid entries, so we don't check them anymore
-                       float argc;
+                       int argc;
                        argc = tokenize_console(s);
                        if(argc == 0 || argv(0) == "")
                                continue;
        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);
@@@ -203,9 -192,14 +203,9 @@@ void QuickMenu_Close(
        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
@@@ -493,6 -487,9 +493,6 @@@ void QuickMenu_Mouse(
                return;
        }
  
 -      if (!autocvar_hud_cursormode)
 -              update_mousepos();
 -
        panel = HUD_PANEL(QUICKMENU);
        HUD_Panel_LoadCvars();
  
                                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)
@@@ -570,10 -571,16 +570,10 @@@ 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 (!hud_draw_maximized || !QuickMenu_IsOpened())
 +                      return;
  
 -              if(QuickMenu_TimeOut)
 -              if(time > QuickMenu_TimeOut)
 +              if (HUD_QuickMenu_Forbidden())
                {
                        QuickMenu_Close();
                        return;
diff --combined qcsrc/client/main.qc
index df13ca7f62fad43879b6ba209b78153d2e4cc9b9,6844b1e078d7ad30380aae9913c1301832a5bc1d..9d182c5175f5c197ac30d712e176536df43941d6
@@@ -228,7 -228,7 +228,7 @@@ void Shutdown(
  }
  
  .float has_team;
float SetTeam(entity o, int Team)
bool SetTeam(entity o, int Team)
  {
        TC(int, Team);
        devassert_once(Team);
@@@ -363,21 -363,20 +363,21 @@@ void PostInit(
  // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
  float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
  {
 -    TC(int, bInputType);
 -      if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
 +      TC(int, bInputType);
 +      bool override = false;
 +      override |= HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary);
 +      if (override)
                return true;
  
 -      if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
 -              return true;
 +      override |= QuickMenu_InputEvent(bInputType, nPrimary, nSecondary);
  
 -      if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
 -              return true;
 +      override |= HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary);
  
 -      if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
 -              return true;
 +      override |= MapVote_InputEvent(bInputType, nPrimary, nSecondary);
 +
 +      override |= HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary);
  
 -      if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
 +      if(override)
                return true;
  
        return false;
@@@ -578,14 -577,14 +578,14 @@@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isne
        {
                for(j = 0; j < maxclients; ++j)
                        if(playerslots[j])
-                               playerslots[j].ready = 1;
+                               playerslots[j].ready = true;
                for(i = 1; i <= maxclients; i += 8)
                {
                        f = ReadByte();
                        for(j = i-1, b = BIT(0); b < BIT(8); b <<= 1, ++j)
                                if (!(f & b))
                                        if(playerslots[j])
-                                               playerslots[j].ready = 0;
+                                               playerslots[j].ready = false;
                }
        }
  
@@@ -606,7 -605,7 +606,7 @@@ NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS
        if (sf & 1) {
                for (int j = 0; j < maxclients; ++j) {
                        if (playerslots[j]) {
-                               playerslots[j].eliminated = 1;
+                               playerslots[j].eliminated = true;
                        }
                }
                for (int i = 1; i <= maxclients; i += 8) {
                                if (f & BIT(b)) continue;
                                int j = i - 1 + b;
                                if (playerslots[j]) {
-                                       playerslots[j].eliminated = 0;
+                                       playerslots[j].eliminated = false;
                                }
                        }
                }
diff --combined qcsrc/client/view.qc
index 9555f31143630a332371ae99225a888ed8af09e2,ff9b47cbcdaa97fb2c7d735bc96167d09b02298b..f733e69a68d77bbadbfba8b07fa2ccaa15ea863a
@@@ -48,6 -48,7 +48,7 @@@
  #define EFMASK_CHEAP (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NODRAW | EF_NOSHADOW | EF_SELECTABLE | EF_TELEPORT_BIT)
  
  float autocvar_cl_viewmodel_scale;
+ float autocvar_cl_viewmodel_alpha;
  
  bool autocvar_cl_bobmodel;
  float autocvar_cl_bobmodel_speed;
@@@ -297,12 -298,9 +298,9 @@@ void viewmodel_draw(entity this
        if(!this.activeweapon || !autocvar_r_drawviewmodel)
                return;
        int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
-       float a = this.alpha;
-       static bool wasinvehicle;
+       float a = ((autocvar_cl_viewmodel_alpha) ? bound(-1, autocvar_cl_viewmodel_alpha, this.m_alpha) : this.m_alpha);
        bool invehicle = player_localentnum > maxclients;
        if (invehicle) a = -1;
-       else if (wasinvehicle) a = 1;
-       wasinvehicle = invehicle;
        Weapon wep = this.activeweapon;
        int c = entcs_GetClientColors(current_player);
        vector g = weaponentity_glowmod(wep, NULL, c, this);
@@@ -427,6 -425,10 +425,10 @@@ void Porto_Draw(entity this
  
                vector pos = view_origin;
                vector dir = view_forward;
+               makevectors(((autocvar_chase_active) ? warpzone_save_view_angles : view_angles));
+               pos += v_right * -wepent.movedir.y
+                       +  v_up * wepent.movedir.z;
                if (wepent.angles_held_status)
                {
                        makevectors(wepent.angles_held);
@@@ -1555,51 -1557,6 +1557,51 @@@ void ViewLocation_Mouse(
        //draw_cursor(viewloc_mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
  }
  
 +void HUD_Cursor_Show()
 +{
 +      float cursor_alpha = 1 - autocvar__menu_alpha;
 +      if(cursor_type == CURSOR_NORMAL)
 +              draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
 +      else if(cursor_type == CURSOR_MOVE)
 +              draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
 +      else if(cursor_type == CURSOR_RESIZE)
 +              draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
 +      else if(cursor_type == CURSOR_RESIZE2)
 +              draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
 +}
 +
 +void HUD_Mouse(entity player)
 +{
 +      if(autocvar__menu_alpha == 1)
 +              return;
 +
 +      if(!cursor_active)
 +      {
 +              if(player.viewloc && (player.viewloc.spawnflags & VIEWLOC_FREEAIM))
 +                      ViewLocation_Mouse(); // NOTE: doesn't use cursormode
 +              return;
 +      }
 +
 +      if(!autocvar_hud_cursormode)
 +              update_mousepos();
 +
 +      if(autocvar__hud_configure)
 +              HUD_Panel_Mouse();
 +      else
 +      {
 +              if (HUD_MinigameMenu_IsOpened() || active_minigame)
 +                      HUD_Minigame_Mouse();
 +              if (QuickMenu_IsOpened())
 +                      QuickMenu_Mouse();
 +              if (HUD_Radar_Clickable())
 +                      HUD_Radar_Mouse();
 +      }
 +
 +      prevMouseClicked = mouseClicked;
 +
 +      HUD_Cursor_Show();
 +}
 +
  bool ov_enabled;
  float oldr_nearclip;
  float oldr_farclip_base;
@@@ -2489,7 -2446,16 +2491,7 @@@ void CSQC_UpdateView(entity this, floa
                cvar_set("vid_conheight", h0);
        }
  
 -      if(autocvar__hud_configure)
 -              HUD_Panel_Mouse();
 -      else if (HUD_MinigameMenu_IsOpened() || active_minigame)
 -              HUD_Minigame_Mouse();
 -      else if(QuickMenu_IsOpened())
 -              QuickMenu_Mouse();
 -      else if(local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
 -              ViewLocation_Mouse(); // NOTE: doesn't use cursormode
 -      else
 -              HUD_Radar_Mouse();
 +      HUD_Mouse(local_player);
  
        cl_notice_run();
        unpause_update();