From: terencehill Date: Sat, 25 Dec 2010 15:07:54 +0000 (+0100) Subject: Merge branch 'master' into terencehill/newpanelhud X-Git-Tag: xonotic-v0.5.0~339 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=9971f28f796f51a9c05702a9d4ae382e4e4f0796 Merge branch 'master' into terencehill/newpanelhud Conflicts: qcsrc/client/hud.qc qcsrc/server/cl_client.qc --- 9971f28f796f51a9c05702a9d4ae382e4e4f0796 diff --cc qcsrc/client/hud.qc index 2590a9a65,2b3db644e..d1fa437d7 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@@ -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) @@@ -1295,14 -2310,14 +1290,13 @@@ } 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= 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; @@@ -2743,32 -3718,19 +2729,30 @@@ 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= 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") { diff --cc qcsrc/server/cl_client.qc index 9a7f6f360,15fd10b8f..7c2f90407 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@@ -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(); + if (g_domination) + set_dom_state(); - send_CSQC_cr_maxbullets(self); + CheatInitClient(); PlayerStats_AddPlayer(self);