+void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, 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 (cvar("hud_panel_modicons_dom_layout")) // show text too
+ {
+ //draw the text
+ drawfont = hud_bigfont;
+ color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
+ if (cvar("hud_panel_modicons_dom_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);
+ drawfont = hud_font;
+ }
+
+ //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)
+{
+ entity tm;
+ float teams_count;
+ for(tm = teams.sort_next; tm; tm = tm.sort_next)
+ if(tm.team != COLOR_SPECTATOR)
+ ++teams_count;
+
+ float rows, columns, aspect_ratio;
+ rows = mySize_y/mySize_x;
+ aspect_ratio = (cvar("hud_panel_modicons_dom_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, size;
+ pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
+ size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+
+ DrawDomItem(pos, size, aspect_ratio, i);
+
+ ++row;
+ if(row >= rows)
+ {
+ row = 0;
+ ++column;
+ }
+ }
+ drawfont = hud_font;
+}
+