]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/newpanelhud
authorterencehill <piuntn@gmail.com>
Sat, 25 Dec 2010 15:07:54 +0000 (16:07 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 25 Dec 2010 15:07:54 +0000 (16:07 +0100)
Conflicts:
qcsrc/client/hud.qc
qcsrc/server/cl_client.qc

1  2 
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/miscfunctions.qc
qcsrc/client/scoreboard.qc
qcsrc/server/cl_client.qc

Simple merge
Simple merge
index 2590a9a65e74188a9ffb16b180dd2ba72343da97,2b3db644eb9426cb97ff1d767cf1c754b08fc122..d1fa437d769168478a018cd993cb6684e862836d
@@@ -821,10 -1768,10 +819,10 @@@ void HUD_Weapons(void
                                drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  
                        // draw ammo status bar
-                       if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
 -                      if(show_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
++                      if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
                        {
                                a = 0;
-                               type = GetAmmoTypeForWep(weapid);
+                               type = GetAmmoTypeForWep(self.weapon);
                                if(type != -1)
                                        a = getstati(GetAmmoStat(type)); // how much ammo do we have?
  
@@@ -1071,54 -2013,12 +1068,53 @@@ void HUD_Ammo(void
                        column = column + 1;
                }
        }
-       drawfont = hud_font;
  }
  
 -void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
 +void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
  {
 -      vector newPos;
 -      float newSize_x, newSize_y;
 +      vector newPos, newSize;
 +      vector picpos, numpos;
 +
 +      if (vertical)
 +      {
 +              if(mySize_y/mySize_x > 2)
 +              {
 +                      newSize_y = 2 * mySize_x;
 +                      newSize_x = mySize_x;
 +
 +                      newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
 +                      newPos_x = myPos_x;
 +              }
 +              else
 +              {
 +                      newSize_x = 1/2 * mySize_y;
 +                      newSize_y = mySize_y;
 +
 +                      newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
 +                      newPos_y = myPos_y;
 +              }
 +
 +              if(icon_right_align)
 +              {
 +                      numpos = newPos;
 +                      picpos = newPos + eY * newSize_x;
 +              }
 +              else
 +              {
 +                      picpos = newPos;
 +                      numpos = newPos + eY * newSize_x;
 +              }
 +
 +              newSize_y /= 2;
 +              drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
 +              // make number smaller than icon, it looks better
 +              // reduce only y to draw numbers with different number of digits with the same y size
 +              numpos_y += newSize_y * ((1 - 0.7) / 2);
 +              newSize_y *= 0.7;
 +              drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
 +              return;
 +      }
 +
        if(mySize_x/mySize_y > 3)
        {
                newSize_x = 3 * mySize_y;
@@@ -1224,13 -2147,11 +1220,12 @@@ void HUD_Powerups(void
                rightexact = strength_time;
        }
  
-       drawfont = hud_bigfont;
        float baralign = autocvar_hud_panel_powerups_baralign;
 -    float barflip;
        float iconalign = autocvar_hud_panel_powerups_iconalign;
 -      float progressbar = autocvar_hud_panel_powerups_progressbar;
 -      if (mySize_x/mySize_y > 4)
 +
 +      float panel_ar = mySize_x/mySize_y;
 +      float is_vertical = (panel_ar < 1);
 +      if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
        {
          barsize = eX * 0.5 * mySize_x + eY * mySize_y;
                if(leftcnt)
                        }
              if(autocvar_hud_panel_powerups_text)
              {
 -                if(rightcnt <= 5)
 -                    drawpic_aspect_skin_expanding(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (rightcnt - rightexact) / 0.5, 1));
 -                if(rightcnt > 1)
 -                    drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 -                drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 -            }
 +                              if(rightcnt > 1)
 +                                      DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
 +                              if(rightcnt <= 5)
 +                                      DrawNumIcon_expanding(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
 +                      }
                }
        }
-       drawfont = hud_font;
  }
  
  // Health/armor (#3)
@@@ -1342,12 -2340,28 +1336,11 @@@ void HUD_HealthArmor(void
                mySize -= '2 2 0' * panel_bg_padding;
        }
  
 -      float armor, health, fuel;
 -      armor = getstati(STAT_ARMOR);
 -      health = getstati(STAT_HEALTH);
 -      fuel = getstati(STAT_FUEL);
 -
 -      if(autocvar__hud_configure)
 -      {
 -              armor = 75;
 -              health = 150;
 -              fuel = 20;
 -      }
 -
 -      if(health <= 0)
 -              return;
 -
 -      vector barpos, barsize;
 -      vector picpos;
 -      vector numpos;
 +      vector barsize;
 +      vector picpos, numpos;
  
-       drawfont = hud_bigfont;
        float baralign = autocvar_hud_panel_healtharmor_baralign;
        float iconalign = autocvar_hud_panel_healtharmor_iconalign;
 -      float progressbar = autocvar_hud_panel_healtharmor_progressbar;
  
      float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
      float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
@@@ -2569,91 -3669,8 +2559,89 @@@ void HUD_Score(void
                // race record display
                if (distribution <= 0)
                        HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawfont = hud_bigfont;
                drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawfont = hud_font;
        } else if (!teamplay) { // non-teamgames
 +              if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
 +              {
 +#define SCOREPANEL_MAX_ENTRIES 6
 +#define SCOREPANEL_ASPECTRATIO 2
 +                      const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
 +                      const float height = mySize_y/entries;
 +                      const vector fontsize = '0.9 0.9 0' * height;
 +                      pos_y += height * (1 - 0.9) / 2;
 +
 +                      vector rgb;
 +                      rgb = '1 1 1';
 +
 +                      const float name_size = mySize_x*0.75;
 +                      const float highlight_alpha = 0.2;
 +                      float i, me_printed;
 +                      string s;
 +                      if (autocvar__hud_configure)
 +                      {
 +                              score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
 +                              for (i=0; i<entries; ++i)
 +                              {
 +                                      //simulate my score is lower than all displayed players,
 +                                      //so that I don't appear at all showing pure rankings.
 +                                      //This is to better show the difference between the 2 ranking views
 +                                      if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
 +                                      {
 +                                              rgb = '1 1 0';
 +                                              drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
 +                                              s = GetPlayerName(pl.sv_entnum);
 +                                              score = 7;
 +                                      }
 +                                      else
 +                                      {
 +                                              s = strcat("Player", ftos(i+1));
 +                                              score -= 3;
 +                                      }
 +
 +                                      s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
 +                                      drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
 +                                      drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 +                                      pos_y += height;
 +                              }
 +                              return;
 +                      }
 +
 +                      if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
 +                              HUD_UpdatePlayerTeams();
 +
 +                      for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
 +                      {
 +                              if (pl.team == COLOR_SPECTATOR)
 +                                      continue;
 +
 +                              if (i == entries-1 && !me_printed && pl != me)
 +                              if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
 +                              {
 +                                      for (pl = me.sort_next; pl; pl = pl.sort_next)
 +                                              if (pl.team != COLOR_SPECTATOR)
 +                                                      break;
 +
 +                                      if (pl)
 +                                              rgb = '1 1 0'; //not last but not among the leading players: yellow
 +                                      else
 +                                              rgb = '1 0 0'; //last: red
 +                                      pl = me;
 +                              }
 +
 +                              if (pl == me)
 +                              {
 +                                      if (i == 0)
 +                                              rgb = '0 1 0'; //first: green
 +                                      me_printed = 1;
 +                                      drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
 +                              }
 +                              s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
 +                              drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
 +                              drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 +                              pos_y += height;
 +                      }
 +                      return;
 +              }
                // me vector := [team/connected frags id]
                pl = players.sort_next;
                if(pl == me)
                else
                        distribution_color = eX;
  
 -              drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
 -              if (leader)
 +              string distribution_str;
 +              distribution_str = ftos(distribution);
 +              if (distribution >= 0)
 +              {
 +                      if (distribution > 0)
 +                              distribution_str = strcat("+", distribution_str);
                        HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawfont = hud_bigfont;
 +              }
                drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawfont = hud_font;
 +              drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
        } else { // teamgames
                float max_fragcount;
                max_fragcount = -99;
                        if (score > max_fragcount)
                                max_fragcount = score;
  
 -                      if(tm.team == myteam) {
 +                      if (spectatee_status == -1)
 +                      {
 +                              score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
 +                              if (max_fragcount == score)
 +                                      HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 +                              drawfont = hud_bigfont;
 +                              drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
 +                              drawfont = hud_font;
 +                              ++row;
 +                              if(row >= rows)
 +                              {
 +                                      row = 0;
 +                                      ++column;
 +                              }
 +                      }
 +                      else if(tm.team == myteam) {
                                if (max_fragcount == score)
 -                                      leader = 1;
 -                              if (leader)
                                        HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawfont = hud_bigfont;
                                drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawfont = hud_font;
                        } else {
                                if (max_fragcount == score)
 -                                      leader = 1;
 -                              if (leader)
 -                                      HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 -                              drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, ftos(score), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
 -                              teamnum += 1;
 +                                      HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 +                              drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
 +                              ++rows;
                        }
                }
        }
@@@ -3623,108 -4573,8 +3600,107 @@@ void HUD_Mod_Race(vector pos, vector my
                        strunzone(race_status_name_prev);
                race_status_name_prev = string_null;
        }
-       drawfont = hud_font;
  }
  
 +void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
 +{
 +      float stat, pps_ratio;
 +      string pic;
 +      vector color;
 +      switch(i)
 +      {
 +              case 0:
 +                      stat = getstatf(STAT_DOM_PPS_RED);
 +                      pic = "dom_icon_red";
 +                      color = '1 0 0';
 +                      break;
 +              case 1:
 +                      stat = getstatf(STAT_DOM_PPS_BLUE);
 +                      pic = "dom_icon_blue";
 +                      color = '0 0 1';
 +                      break;
 +              case 2:
 +                      stat = getstatf(STAT_DOM_PPS_YELLOW);
 +                      pic = "dom_icon_yellow";
 +                      color = '1 1 0';
 +                      break;
 +              case 3:
 +                      stat = getstatf(STAT_DOM_PPS_PINK);
 +                      pic = "dom_icon_pink";
 +                      color = '1 0 1';
 +      }
 +      pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
 +
 +      if(mySize_x/mySize_y > aspect_ratio)
 +      {
 +              i = aspect_ratio * mySize_y;
 +              myPos_x = myPos_x + (mySize_x - i) / 2;
 +              mySize_x = i;
 +      }
 +      else
 +      {
 +              i = 1/aspect_ratio * mySize_x;
 +              myPos_y = myPos_y + (mySize_y - i) / 2;
 +              mySize_y = i;
 +      }
 +
 +      if (layout) // show text too
 +      {
 +              //draw the text
 +              color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
 +              if (layout == 2) // average pps
 +                      drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
 +              else // percentage of average pps
 +                      drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
 +      }
 +
 +      //draw the icon
 +      drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 +      if (stat > 0)
 +      {
 +              drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
 +              drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 +              drawresetcliparea();
 +      }
 +}
 +
 +void HUD_Mod_Dom(vector myPos, vector mySize)
 +{
 +      mod_active = 1; // required in each mod function that always shows something
 +      entity tm;
 +      float teams_count;
 +      for(tm = teams.sort_next; tm; tm = tm.sort_next)
 +              if(tm.team != COLOR_SPECTATOR)
 +                      ++teams_count;
 +
 +      float layout = autocvar_hud_panel_modicons_dom_layout;
 +      float rows, columns, aspect_ratio;
 +      rows = mySize_y/mySize_x;
 +      aspect_ratio = (layout) ? 3 : 1;
 +      rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
 +      columns = ceil(teams_count/rows);
 +
 +      drawfont = hud_bigfont;
 +      int i;
 +      float row, column;
 +      for(i=0; i<teams_count; ++i)
 +      {
 +              vector pos, itemSize;
 +              pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
 +              itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
 +
 +              DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
 +
 +              ++row;
 +              if(row >= rows)
 +              {
 +                      row = 0;
 +                      ++column;
 +              }
 +      }
 +      drawfont = hud_font;
 +}
 +
  float mod_prev; // previous state of mod_active to check for a change
  float mod_alpha;
  float mod_change; // "time" when mod_active changed
@@@ -4471,18 -5173,20 +4445,20 @@@ void HUD_Main (void
        // HUD configure visible grid
        if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
        {
 +              hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
 +              hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
 +              hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
 +              hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
                // x-axis
 -              for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
 -              {
 -                      drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
 -              }
 +              for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
 +                      drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
                // y-axis
 -              for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
 -              {
 -                      drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
 -              }
 +              for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
 +                      drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
        }
  
+     current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
        // draw the dock
        if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
        {
Simple merge
Simple merge
Simple merge
index 9a7f6f36036ea0cb28bf479f97ab1ce4c204c854,15fd10b8ff16925903bbd9a7a5332726a9f8088a..7c2f90407722c786570f7262bd056f57aa668377
@@@ -1742,10 -1735,6 +1736,9 @@@ void ClientConnect (void
        else if(autocvar_sv_teamnagger && !(autocvar_bot_vs_human && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
                send_CSQC_teamnagger();
  
-       send_CSQC_cr_maxbullets(self);
 +      if (g_domination)
 +              set_dom_state();
 +
        CheatInitClient();
  
        PlayerStats_AddPlayer(self);