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

diff --combined qcsrc/client/hud/hud.qc
index e26b4e2f5b890dc973897e1a980d95ffecce3503,2becced8e0cbcda94ad910946fc4480939b21856..9b5b4699337c971a0fbf2f4117dde2e75a1aa82a
@@@ -75,14 -75,14 +75,14 @@@ vector HUD_Get_Num_Color (float hp, flo
  
  float HUD_GetRowCount(int item_count, vector size, float item_aspect)
  {
-     TC(int, item_count);
+       TC(int, item_count);
        float aspect = size_y / size_x;
        return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
  }
  
  vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
  {
-     TC(int, item_count);
+       TC(int, item_count);
        float columns, rows;
        float ratio, best_ratio = 0;
        float best_columns = 1, best_rows = 1;
@@@ -180,7 -180,7 +180,7 @@@ void HUD_Panel_LoadCvars(
  //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
  void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
  {
-     TC(bool, vertical); TC(int, drawflag);
+       TC(bool, vertical); TC(int, drawflag);
        if(!length_ratio || !theAlpha)
                return;
        if(length_ratio > 1)
  
  void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
  {
-     TC(int, drawflag);
+       TC(int, drawflag);
        if(!theAlpha)
                return;
  
  
  void DrawNumIcon_expanding(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha, float fadelerp)
  {
-     TC(bool, vertical); TC(int, icon_right_align);
+       TC(bool, vertical); TC(int, icon_right_align);
        vector newPos = '0 0 0', newSize = '0 0 0';
        vector picpos, numpos;
  
  
  void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha)
  {
-     TC(bool, vertical); TC(int, icon_right_align);
+       TC(bool, vertical); TC(int, icon_right_align);
        DrawNumIcon_expanding(myPos, mySize, theTime, icon, vertical, icon_right_align, color, theAlpha, 0);
  }
  
@@@ -561,49 -561,6 +561,49 @@@ void Hud_Dynamic_Frame(
        HUD_Scale_Disable();
  }
  
 +bool cursor_activestate;
 +
 +bool HUD_WouldShowCursor()
 +{
 +      if(autocvar__hud_configure)
 +              return true;
 +      if(hud_panel_radar_mouse)
 +              return true;
 +      if(mv_active)
 +              return true;
 +      //entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1)); // TODO: doesn't use regular cursor handling
 +      //if(local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
 +              //return true;
 +      if(HUD_Radar_Clickable())
 +              return true;
 +      if(HUD_MinigameMenu_IsOpened() || active_minigame)
 +              return true;
 +      if(QuickMenu_IsOpened())
 +              return true;
 +      return false;
 +}
 +void HUD_Cursor()
 +{
 +      if(HUD_WouldShowCursor())
 +      {
 +              if(!cursor_activestate)
 +              {
 +                      cursor_activestate = true;
 +                      if(autocvar_hud_cursormode)
 +                              setcursormode(1);
 +              }
 +      }
 +      else
 +      {
 +              if(cursor_activestate)
 +              {
 +                      cursor_activestate = false;
 +                      if(autocvar_hud_cursormode)
 +                              setcursormode(0);
 +              }
 +      }
 +}
 +
  void HUD_Main()
  {
        int i;
                HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
        HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
  
 +      HUD_Cursor();
 +
        if (intermission == 2)
                HUD_Reset();
  
index a9029b25168394629ad4131dd0ddf33fd58bf0c9,98b15ee9537257443d0a19d06dba2beed6ce4c4a..02259f8ee04743acb56fdd359ca0582a5cf7b2af
@@@ -43,7 -43,7 +43,7 @@@ float QuickMenu_TimeOut
  // 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);
+       TC(int, i);
        //LOG_INFOF("^xc80 entry %d: %s, %s\n", i, s, s1);
        strcpy(QuickMenu_Page_Description[i], s);
        strcpy(QuickMenu_Page_Command[i], s1);
@@@ -51,7 -51,7 +51,7 @@@
  
  void QuickMenu_Page_ClearEntry(int i)
  {
-     TC(int, i);
+       TC(int, i);
        strfree(QuickMenu_Page_Description[i]);
        strfree(QuickMenu_Page_Command[i]);
        QuickMenu_Page_Command_Type[i] = 0;
@@@ -167,6 -167,8 +167,6 @@@ bool QuickMenu_Open(string mode, strin
                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);
@@@ -194,6 -196,10 +194,6 @@@ void QuickMenu_Close(
        mouseClicked = 0;
        prevMouseClicked = 0;
        QuickMenu_Buffer_Close();
 -
 -      if(autocvar_hud_cursormode)
 -      if(!mv_active)
 -              setcursormode(0);
  }
  
  // It assumes submenu open tag is already detected
@@@ -219,7 -225,7 +219,7 @@@ bool QuickMenu_IsOpened(
  
  bool HUD_Quickmenu_PlayerListEntries_Create(string cmd, int teamplayers, bool without_me)
  {
-     TC(int, teamplayers); TC(bool, without_me);
+       TC(int, teamplayers); TC(bool, without_me);
        int i;
        for(i = 0; i < QUICKMENU_MAXLINES; ++i)
                QuickMenu_Page_ClearEntry(i);
  int QuickMenu_Buffer_Index_Prev;
  bool QuickMenu_Page_Load(string target_submenu, bool new_page)
  {
-     TC(bool, new_page);
+       TC(bool, new_page);
        string s = string_null, cmd = string_null, z_submenu;
  
        if (new_page == 0)
  
  bool QuickMenu_ActionForNumber(int num)
  {
-     TC(int, num);
+       TC(int, num);
        if (!QuickMenu_IsLastPage)
        {
                if (num < 0 || num >= QUICKMENU_MAXLINES)
  
  void QuickMenu_Page_ActiveEntry(int entry_num)
  {
-     TC(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 QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
  {
-     TC(int, bInputType);
+       TC(int, bInputType);
        // we only care for keyboard events
        if(bInputType == 2)
                return false;
@@@ -481,6 -487,9 +481,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)
@@@ -735,7 -748,7 +735,7 @@@ void HUD_QuickMenu(
  
  void HUD_Quickmenu_PlayerListEntries(string cmd, int teamplayers, bool without_me)
  {
-     TC(int, teamplayers); TC(bool, without_me);
+       TC(int, teamplayers); TC(bool, without_me);
        entity pl;
        if(teamplayers && !team_count)
                return;
index 2f0777bb1f481893c9fe146b31dc1ed92f0788b4,65073d9fed09700f5c8aebc6dfd6c322f6a05294..9176aa0ff99782b05ed207495bacf5134675ff4c
@@@ -19,7 -19,7 +19,7 @@@ bool HUD_Radar_Clickable(
  
  void HUD_Radar_Show_Maximized(bool doshow, bool clickable)
  {
-     TC(bool, doshow);
+       TC(bool, doshow);
        hud_panel_radar_maximized = doshow;
        hud_panel_radar_temp_hidden = 0;
  
@@@ -27,6 -27,8 +27,6 @@@
        {
                if (clickable)
                {
 -                      if(autocvar_hud_cursormode)
 -                              setcursormode(1);
                        hud_panel_radar_mouse = 1;
  
                        // we must unset the player's buttons, as they aren't released elsewhere
@@@ -41,6 -43,9 +41,6 @@@
        {
                hud_panel_radar_mouse = 0;
                mouseClicked = 0;
 -              if(autocvar_hud_cursormode)
 -              if(!mv_active)
 -                      setcursormode(0);
        }
  }
  void HUD_Radar_Hide_Maximized()
@@@ -51,7 -56,7 +51,7 @@@
  
  float HUD_Radar_InputEvent(int bInputType, float nPrimary, float nSecondary)
  {
-     TC(int, bInputType);
+       TC(int, bInputType);
        if(!hud_panel_radar_maximized || !hud_panel_radar_mouse ||
                autocvar__hud_configure || mv_active)
                return false;
@@@ -136,6 -141,9 +136,6 @@@ void HUD_Radar_Mouse(
                return;
        }
  
 -      if (!autocvar_hud_cursormode)
 -              update_mousepos();
 -
        panel = HUD_PANEL(RADAR);
        HUD_Panel_LoadCvars();
  
                HUD_Radar_Hide_Maximized();
                return;
        }
 -
 -
 -      draw_cursor_normal(mousepos, '1 1 1', 0.8);
  }
  
  void HUD_Radar()
diff --combined qcsrc/client/main.qc
index 3a6d60742fb80ec78844047ff09048745195f78a,863905a3d32fd4fb5ec1b4c9ae9e2d2dbf45df31..df13ca7f62fad43879b6ba209b78153d2e4cc9b9
@@@ -230,7 -230,7 +230,7 @@@ void Shutdown(
  .float has_team;
  float SetTeam(entity o, int Team)
  {
-     TC(int, Team);
+       TC(int, Team);
        devassert_once(Team);
        entity tm;
        if(teamplay)
@@@ -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;
index 8d4d8ba9f6b8900d7e156d1580302bb188e29817,03e94dc7f304238bc916443bc4a6fbef512d7bc7..37cb59e082101f645ac197f6c224c12715f62bfd
@@@ -43,7 -43,7 +43,7 @@@ int n_ssdirs
  
  string MapVote_FormatMapItem(int id, string map, float _count, float maxwidth, vector fontsize)
  {
-     TC(int, id);
+       TC(int, id);
        string pre, post;
        pre = sprintf("%d. ", id+1);
        if(mv_detail)
@@@ -64,7 -64,7 +64,7 @@@
  
  vector MapVote_RGB(int id)
  {
-     TC(int, id);
+       TC(int, id);
        if(!(mv_flags[id] & GTV_AVAILABLE))
                return '1 1 1';
        if(id == mv_ownvote)
@@@ -77,7 -77,7 +77,7 @@@
  
  void GameTypeVote_DrawGameTypeItem(vector pos, float maxh, float tsize, string gtype, string pic, float _count, int id)
  {
-     TC(int, id);
+       TC(int, id);
        // Find the correct alpha
        float alpha;
        if(!(mv_flags_start[id] & GTV_AVAILABLE))
  
  void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, string pic, float _count, int id)
  {
-     TC(int, id);
+       TC(int, id);
        vector img_size = '0 0 0';
        string label;
        float text_size;
  
  void MapVote_DrawAbstain(vector pos, float isize, float tsize, float _count, int id)
  {
-     TC(int, id);
+       TC(int, id);
        vector rgb;
        float text_size;
        string label;
  
  vector MapVote_GridVec(vector gridspec, int i, int m)
  {
-     TC(int, i); TC(int, m);
+       TC(int, i); TC(int, m);
        int r = i % m;
        return
                '1 0 0' * (gridspec.x * r)
@@@ -321,7 -321,6 +321,7 @@@ float MapVote_Selection(vector topleft
        return mv_mouse_selection;
  }
  
 +vector prev_mousepos;
  void MapVote_Draw()
  {
        string map;
  
        if (!autocvar_hud_cursormode)
        {
 -              vector mpos = mousepos;
 -              update_mousepos();
 -              if (mpos.x != mousepos.x || mpos.y != mousepos.y)
 +              if (mousepos.x != prev_mousepos.x || mousepos.y != prev_mousepos.y)
 +              {
                        mv_selection_keyboard = 0;
 +                      prev_mousepos = mousepos;
 +              }
        }
  
        center = (vid_conwidth - 1)/2;
                pos.x = (xmax+xmin)*0.5;
                MapVote_DrawAbstain(pos, dist.x, xmax - xmin, tmp, i);
        }
 -
 -      draw_cursor_normal(mousepos, '1 1 1', panel_fg_alpha);
  }
  
  void Cmd_MapVote_MapDownload(int argc)
  {
-     TC(int, argc);
+       TC(int, argc);
        entity pak;
  
        if(argc != 2 || !mv_pk3list)
  
  void MapVote_CheckPK3(string pic, string pk3, int id)
  {
-     TC(int, id);
+       TC(int, id);
        entity pak;
        pak = spawn();
        pak.netname = pk3;
  
  void MapVote_CheckPic(string pic, string pk3, int id)
  {
-     TC(int, id);
+       TC(int, id);
        // never try to retrieve a pic for the "don't care" 'map'
        if(mv_abstain && id == mv_num_maps - 1)
                return;
@@@ -587,7 -587,7 +587,7 @@@ void MapVote_ReadMask(
  
  void MapVote_ReadOption(int i)
  {
-     TC(int, i);
+       TC(int, i);
        string map = strzone(ReadString());
        string pk3 = strzone(ReadString());
        int j = bound(0, ReadByte(), n_ssdirs - 1);
  
  void GameTypeVote_ReadOption(int i)
  {
-     TC(int, i);
+       TC(int, i);
        string gt = strzone(ReadString());
  
        mv_maps[i] = gt;
  void MapVote_Init()
  {
        mv_active = 1;
 -      if(autocvar_hud_cursormode) setcursormode(1);
 -      else mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
 +      if(!autocvar_hud_cursormode) mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
        mv_selection = -1;
        mv_selection_keyboard = 0;
  
  
  void MapVote_SendChoice(int index)
  {
-     TC(int, index);
+       TC(int, index);
        localcmd(strcat("\nimpulse ", ftos(index+1), "\n"));
  }
  
  int MapVote_MoveLeft(int pos)
  {
-     TC(int, pos);
+       TC(int, pos);
        int imp;
        if ( pos < 0 )
                imp = mv_num_maps - 1;
  }
  int MapVote_MoveRight(int pos)
  {
-     TC(int, pos);
+       TC(int, pos);
        int imp;
        if ( pos < 0 )
                imp = 0;
  }
  int MapVote_MoveUp(int pos)
  {
-     TC(int, pos);
+       TC(int, pos);
        int imp;
        if ( pos < 0 )
                imp = mv_num_maps - 1;
  }
  int MapVote_MoveDown(int pos)
  {
-     TC(int, pos);
+       TC(int, pos);
        int imp;
        if ( pos < 0 )
                imp = 0;
  
  float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
  {
-     TC(int, bInputType);
+       TC(int, bInputType);
        float imp;
  
        if (!mv_active)
diff --combined qcsrc/client/view.qc
index 3a5f1b5e766dd8145ccdae954c3a8cae1b001818,a7fbe136825b960bb2718fc518183d5d259d8e47..27fa344b39cfa437321a303cfe3f732071e4caac
@@@ -491,9 -491,8 +491,8 @@@ vector GetCurrentFov(float fov
        if(zoomfactor < 1 || zoomfactor > 30)
                zoomfactor = 2.5;
        zoomspeed = autocvar_cl_zoomspeed;
-       if(zoomspeed >= 0)
-       if(zoomspeed < 0.5 || zoomspeed > 16)
-                       zoomspeed = 3.5;
+       if (zoomspeed >= 0 && (zoomspeed < 0.5 || zoomspeed > 16))
+               zoomspeed = 3.5;
  
        zoomdir = button_zoom;
  
  
        if(zoomdir) { zoomin_effect = 0; }
  
-       if(camera_active)
+       if (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2)
+       {
+               current_viewzoom = 1;
+       }
+       else if (camera_active)
        {
                current_viewzoom = min(1, current_viewzoom + drawframetime);
        }
  
        if(autocvar_cl_velocityzoom_enabled && autocvar_cl_velocityzoom_type) // _type = 0 disables velocity zoom too
        {
-               if(intermission) { curspeed = 0; }
+               if (intermission || (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2))
+                       curspeed = 0;
                else
                {
                        makevectors(view_angles);
                        v = pmove_vel;
                        if(csqcplayer)
@@@ -1552,52 -1555,6 +1555,52 @@@ void ViewLocation_Mouse(
        //draw_cursor(viewloc_mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
  }
  
 +float mouse_over_panel;
 +void HUD_Draw_Mouse()
 +{
 +      float cursor_alpha = 1 - autocvar__menu_alpha;
 +      if(!mouse_over_panel)
 +              draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
 +      else if(mouse_over_panel == 1)
 +              draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
 +      else if(mouse_over_panel == 2)
 +              draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
 +      else
 +              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(!HUD_WouldShowCursor())
 +      {
 +              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_Draw_Mouse();
 +}
 +
  bool ov_enabled;
  float oldr_nearclip;
  float oldr_farclip_base;
@@@ -1611,7 -1568,7 +1614,7 @@@ int lasthud
  float vh_notice_time;
  void CSQC_UpdateView(entity this, float w, float h)
  {
-     TC(int, w); TC(int, h);
+       TC(int, w); TC(int, h);
        entity e;
        float fov;
        float f;
                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();