]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/clanarena/cl_clanarena.qc
Merge branch 'master' into terencehill/glowmod_color_fix
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / clanarena / cl_clanarena.qc
1 #include "cl_clanarena.qh"
2
3 #include <client/draw.qh>
4
5 void HUD_Mod_CA_Export(int fh)
6 {
7         HUD_Write_Cvar("hud_panel_modicons_ca_layout");
8 }
9
10 void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
11 {
12         TC(int, layout); TC(int, i);
13         int stat = -1;
14         string pic = "";
15         vector color = '0 0 0';
16         switch(i)
17         {
18                 case 0: stat = STAT(REDALIVE); pic = "player_red"; color = '1 0 0'; break;
19                 case 1: stat = STAT(BLUEALIVE); pic = "player_blue"; color = '0 0 1'; break;
20                 case 2: stat = STAT(YELLOWALIVE); pic = "player_yellow"; color = '1 1 0'; break;
21                 default:
22                 case 3: stat = STAT(PINKALIVE); pic = "player_pink"; color = '1 0 1'; break;
23         }
24
25         if(mySize.x/mySize.y > aspect_ratio)
26         {
27                 i = aspect_ratio * mySize.y;
28                 myPos.x = myPos.x + (mySize.x - i) / 2;
29                 mySize.x = i;
30         }
31         else
32         {
33                 i = 1/aspect_ratio * mySize.x;
34                 myPos.y = myPos.y + (mySize.y - i) / 2;
35                 mySize.y = i;
36         }
37
38         if(layout)
39         {
40                 drawpic_aspect_skin(myPos, pic, vec2(0.5 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
41                 drawstring_aspect(myPos + eX * 0.5 * mySize.x, ftos(stat), vec2(0.5 * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
42         }
43         else
44                 drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
45 }
46
47 void HUD_Mod_CA_Draw(vector myPos, vector mySize, int layout)
48 {
49         int rows, columns;
50         float aspect_ratio;
51         aspect_ratio = (layout) ? 2 : 1;
52         rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
53         columns = ceil(team_count/rows);
54
55         int i;
56         float row = 0, column = 0;
57         vector pos = '0 0 0', itemSize;
58         itemSize = vec2(mySize.x / columns, mySize.y / rows);
59         for(i=0; i<team_count; ++i)
60         {
61                 pos.x = myPos.x + column * itemSize.x;
62                 pos.y = myPos.y + row * itemSize.y;
63
64                 DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
65
66                 ++row;
67                 if(row >= rows)
68                 {
69                         row = 0;
70                         ++column;
71                 }
72         }
73 }
74
75 // Clan Arena and Freeze Tag HUD modicons
76 void HUD_Mod_CA(vector myPos, vector mySize)
77 {
78         mod_active = 1; // required in each mod function that always shows something
79
80         HUD_Mod_CA_Draw(myPos, mySize, autocvar_hud_panel_modicons_ca_layout);
81 }