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