]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/hud_notify_panel_update' into 'master'
authorterencehill <piuntn@gmail.com>
Mon, 24 May 2021 13:08:32 +0000 (13:08 +0000)
committerterencehill <piuntn@gmail.com>
Mon, 24 May 2021 13:08:32 +0000 (13:08 +0000)
Notify panel update

Closes #2581

See merge request xonotic/xonotic-data.pk3dir!904

1  2 
qcsrc/client/hud/panel/scoreboard.qc

index b70513f44b7ae127a9822ef2c125de7a19e22c8b,e00343e791c63de81bb96282615c6df16f8c5dda..2db57485b948815f946d3921c295375c20b44c28
@@@ -34,7 -34,6 +34,7 @@@ void Scoreboard_Draw_Export(int fh
        HUD_Write_Cvar("hud_panel_scoreboard_bg_teams_color_team");
        HUD_Write_Cvar("hud_panel_scoreboard_accuracy_doublerows");
        HUD_Write_Cvar("hud_panel_scoreboard_accuracy_nocolors");
 +      HUD_Write_Cvar("hud_panel_scoreboard_spectators_position");
  }
  
  const int MAX_SBT_FIELDS = MAX_SCORE;
@@@ -81,7 -80,6 +81,7 @@@ float autocvar_hud_panel_scoreboard_tab
  float autocvar_hud_panel_scoreboard_bg_teams_color_team = 0;
  float autocvar_hud_panel_scoreboard_namesize = 15;
  float autocvar_hud_panel_scoreboard_team_size_position = 0;
 +float autocvar_hud_panel_scoreboard_spectators_position = 1;
  
  bool autocvar_hud_panel_scoreboard_accuracy = true;
  bool autocvar_hud_panel_scoreboard_accuracy_doublerows = false;
@@@ -1737,33 -1735,6 +1737,33 @@@ bool Scoreboard_ItemStats_WouldDraw(flo
        return true;
  }
  
 +vector Scoreboard_Spectators_Draw(vector pos, entity tm, string str, vector hud_fontsize) {
 +
 +      entity pl;
 +
 +      for(pl = players.sort_next; pl; pl = pl.sort_next)
 +      {
 +              if(pl.team == NUM_SPECTATOR)
 +              {
 +                      for(tm = teams.sort_next; tm; tm = tm.sort_next)
 +                              if(tm.team == NUM_SPECTATOR)
 +                                      break;
 +                      str = sprintf("%s (%d)", _("Spectators"), tm.team_size);
 +                      draw_beginBoldFont();
 +                      drawstring(pos, str, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 +                      draw_endBoldFont();
 +                      pos.y += 1.25 * hud_fontsize.y;
 +
 +                      pos = Scoreboard_DrawOthers(pos, '0 0 0', pl.team, NULL, pl, 0);
 +                      pos.y += 1.25 * hud_fontsize.y;
 +
 +                      break;
 +              }
 +      }
 +
 +      return pos;
 +}
 +
  void Scoreboard_Draw()
  {
        if(!autocvar__hud_configure)
  
        float excess = max(0, max_namesize - autocvar_hud_panel_scoreboard_namesize * hud_fontsize.x);
        float fixed_scoreboard_width = bound(vid_conwidth * autocvar_hud_panel_scoreboard_minwidth, vid_conwidth - excess, vid_conwidth * 0.93);
-       panel_pos.x = 0.5 * (vid_conwidth - fixed_scoreboard_width);
+       scoreboard_left = 0.5 * (vid_conwidth - fixed_scoreboard_width);
+       scoreboard_right = scoreboard_left + fixed_scoreboard_width;
+       panel_pos.x = scoreboard_left;
        panel_size.x = fixed_scoreboard_width;
  
        Scoreboard_UpdatePlayerTeams();
  
-       float initial_pos_y = panel_pos.y;
+       scoreboard_top = panel_pos.y;
        vector pos = panel_pos;
 -      entity pl, tm;
 +      entity tm;
        string str;
        vector str_pos;
  
                pos = Scoreboard_MakeTable(pos, tm, panel_bg_color, bg_size);
        }
  
 +      // draw scoreboard spectators before accuracy and item stats
 +      if (autocvar_hud_panel_scoreboard_spectators_position == 0) {
 +              pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
 +      }
 +
 +      // draw accuracy and item stats 
        if (Scoreboard_AccuracyStats_WouldDraw(pos.y))
                pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size);
        if (Scoreboard_ItemStats_WouldDraw(pos.y))
                pos = Scoreboard_ItemStats_Draw(pos, panel_bg_color, bg_size);
  
 +      // draw scoreboard spectators after accuracy and item stats and before rankings
 +      if (autocvar_hud_panel_scoreboard_spectators_position == 1) {
 +              pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
 +      }
 +
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
                if(race_speedaward) {
                pos = Scoreboard_Rankings_Draw(pos, ranktitle, playerslots[player_localnum], panel_bg_color, bg_size);
        }
  
 -      pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size);
 -
 -      // List spectators
 -      for(pl = players.sort_next; pl; pl = pl.sort_next)
 -      {
 -              if(pl.team == NUM_SPECTATOR)
 -              {
 -                      for(tm = teams.sort_next; tm; tm = tm.sort_next)
 -                              if(tm.team == NUM_SPECTATOR)
 -                                      break;
 -                      str = sprintf("%s (%d)", _("Spectators"), tm.team_size);
 -                      draw_beginBoldFont();
 -                      drawstring(pos, str, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 -                      draw_endBoldFont();
 -                      pos.y += 1.25 * hud_fontsize.y;
 +      // draw scoreboard spectators after rankings
 +      if (autocvar_hud_panel_scoreboard_spectators_position == 2) {
 +              pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
 +      }
  
 -                      pos = Scoreboard_DrawOthers(pos, '0 0 0', pl.team, NULL, pl, 0);
 -                      pos.y += 1.25 * hud_fontsize.y;
 +      pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size);
  
 -                      break;
 -              }
 +      // draw scoreboard spectators after mapstats
 +      if (autocvar_hud_panel_scoreboard_spectators_position == 3) {
 +              pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
        }
  
  
  
        pos.y += 2 * hud_fontsize.y;
        if (scoreboard_fade_alpha < 1)
-               scoreboard_bottom = initial_pos_y + (pos.y - initial_pos_y) * scoreboard_fade_alpha;
+               scoreboard_bottom = scoreboard_top + (pos.y - scoreboard_top) * scoreboard_fade_alpha;
        else if (pos.y != scoreboard_bottom)
        {
                if (pos.y > scoreboard_bottom)
-                       scoreboard_bottom = min(pos.y, scoreboard_bottom + frametime * 10 * (pos.y - initial_pos_y));
+                       scoreboard_bottom = min(pos.y, scoreboard_bottom + frametime * 10 * (pos.y - scoreboard_top));
                else
-                       scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - initial_pos_y));
+                       scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - scoreboard_top));
        }
  }