X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=ee44db91a8f0e6013c027574b975b6fde3f5392b;hp=e49ac603ac201900897fd223e6c8449dcbf0656d;hb=026dde2924af9bca060bc1bea3e194c47e98b4be;hpb=55f87426a3f58e4161eae8a7e8523f165cb9da00 diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index e49ac603ac..ee44db91a8 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -2633,32 +2633,100 @@ void HUD_Vote(void) float mod_active; // is there any active mod icon? -// Clan Arena HUD modicons -void HUD_Mod_CA(vector pos, vector mySize) +void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i) { - mod_active = 1; // CA should never hide the mod icons panel - float redalive, bluealive; - redalive = getstati(STAT_REDALIVE); - bluealive = getstati(STAT_BLUEALIVE); + float stat; + string pic; + vector color; +#ifdef GMQCC + stat = -1; + pic = ""; + color = '0 0 0'; +#endif + switch(i) + { + case 0: + stat = getstati(STAT_REDALIVE); + pic = "player_red.tga"; + color = '1 0 0'; + break; + case 1: + stat = getstati(STAT_BLUEALIVE); + pic = "player_blue.tga"; + color = '0 0 1'; + break; + case 2: + stat = getstati(STAT_YELLOWALIVE); + pic = "player_yellow.tga"; + color = '1 1 0'; + break; + default: + case 3: + stat = getstati(STAT_PINKALIVE); + pic = "player_pink.tga"; + color = '1 0 1'; + break; + } - vector redpos, bluepos; - if(mySize_x > mySize_y) + if(mySize_x/mySize_y > aspect_ratio) { - redpos = pos; - bluepos = pos + eY * 0.5 * mySize_y; - drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + i = aspect_ratio * mySize_y; + myPos_x = myPos_x + (mySize_x - i) / 2; + mySize_x = i; } else { - redpos = pos; - bluepos = pos + eY * 0.5 * mySize_y; - drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(redpos + eY * 0.3 * mySize_y, ftos(redalive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(bluepos + eY * 0.3 * mySize_y, ftos(bluealive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + i = 1/aspect_ratio * mySize_x; + myPos_y = myPos_y + (mySize_y - i) / 2; + mySize_y = i; + } + + if(layout) + { + drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(myPos + eX * 0.7 * mySize_x, ftos(stat), eX * 0.3 * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + } + else + drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL); +} + +// Clan Arena and Freeze Tag HUD modicons +void HUD_Mod_CA(vector myPos, vector mySize) +{ + mod_active = 1; // required in each mod function that always shows something + entity tm; + float teams_count = 0; + for(tm = teams.sort_next; tm; tm = tm.sort_next) + if(tm.team != NUM_SPECTATOR) + ++teams_count; + + float layout; + if(gametype == MAPINFO_TYPE_CA) + layout = autocvar_hud_panel_modicons_ca_layout; + else //if(gametype == MAPINFO_TYPE_FREEZETAG) + layout = autocvar_hud_panel_modicons_freezetag_layout; + float rows, columns, aspect_ratio; + rows = mySize_y/mySize_x; + aspect_ratio = (layout) ? 2 : 1; + rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count); + columns = ceil(teams_count/rows); + + int i; + float row = 0, column = 0; + vector pos, itemSize; + itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows); + for(i=0; i= rows) + { + row = 0; + ++column; + } } } @@ -3272,11 +3340,11 @@ void HUD_Mod_Dom(vector myPos, vector mySize) int i; float row = 0, column = 0; + vector pos, itemSize; + itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows); for(i=0; i