]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/View.qc
A lil fix to the mapvoting code, an update to the KH HUD by victim,
[divverent/nexuiz.git] / data / qcsrc / client / View.qc
1 //include "main.qh"\r
2 \r
3 float sbar_alpha_fg;\r
4 float last_weapon;\r
5 float activeweapon;\r
6 float weapontime;\r
7 float sbar_hudselector;\r
8 float teamplay;\r
9 float myteam;\r
10 \r
11 float numteams; // NOTE: This is changed in Sbar_SortFrags, so use it only AFTER that\r
12 \r
13 void CSQC_common_hud(void);\r
14 \r
15 void CSQC_kh_hud(void);\r
16 void CSQC_ctf_hud(void);\r
17 void PostInit(void);\r
18 void CSQC_UpdateView(void)\r
19 {\r
20         if(!postinit)\r
21                 PostInit();\r
22         \r
23         sbar_alpha_fg = cvar("sbar_alpha_fg" );\r
24         sbar_hudselector = cvar("sbar_hudselector");\r
25         activeweapon = getstati(STAT_ACTIVEWEAPON);\r
26         teamplay = cvar("teamplay");\r
27 \r
28         if(last_weapon != activeweapon) {\r
29                 weapontime = time;\r
30                 last_weapon = activeweapon;\r
31         }\r
32 \r
33         // ALWAYS Clear Current Scene First\r
34         R_ClearScene();\r
35 \r
36         // Assign Standard Viewflags\r
37         // Draw the World (and sky)\r
38         R_SetView(VF_DRAWWORLD, 1);\r
39         \r
40         // Draw the Crosshair\r
41         R_SetView(VF_DRAWCROSSHAIR, 1);\r
42         \r
43         // Draw the Engine Status Bar (the default Quake HUD)\r
44         draw_enginesbar = !cvar("sbar_usecsqc");\r
45         R_SetView(VF_DRAWENGINESBAR, draw_enginesbar);\r
46 \r
47         // Set the console size vars\r
48         vid_conwidth = cvar("vid_conwidth");\r
49         vid_conheight = cvar("vid_conheight");\r
50 \r
51         // Update the mouse position\r
52         /*\r
53         mousepos_x = vid_conwidth;\r
54         mousepos_y = vid_conheight;\r
55         mousepos = mousepos*0.5 + getmousepos();\r
56         */\r
57 \r
58         R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);\r
59 \r
60         // Render the Scene\r
61         R_RenderScene();\r
62 \r
63         // Draw the mouse cursor\r
64         // NOTE: drawpic must happen after R_RenderScene for some reason\r
65         //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);\r
66         //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);\r
67         //self = edict_num(player_localnum);\r
68         //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);\r
69         //drawstring('0 8', strcat("ORG: ", vtos(self.origin), " state: ", ftos(self.ctf_state), " HP: ", ftos(self.health)), '8 8 0', '1 1 1', 1, 0);\r
70         // as long as the ctf part isn't in, this is useless\r
71         if(menu_visible)\r
72                 menu_show();\r
73         \r
74         /*if(gametype == GAME_CTF)\r
75         {\r
76                 ctf_view();\r
77         } else */\r
78         if(!draw_enginesbar)\r
79         {\r
80                 CSQC_common_hud();\r
81         }\r
82         \r
83         if(gametype == GAME_ONSLAUGHT)\r
84         {\r
85                 //drawstring('0 0', minimapname, '8 8 0', '1 1 1', 1, 0);\r
86                 //drawsetcliparea(0,0,800,600);\r
87                 ons_view();\r
88                 //drawresetcliparea();\r
89         }\r
90 }\r
91 \r
92 void Sbar_Draw();\r
93 void CSQC_common_hud(void)\r
94 {\r
95         // Sbar_SortFrags(); done in Sbar_Draw\r
96         Sbar_Draw();\r
97 }\r
98 \r
99 // KeyHunt HUD by victim\r
100 void CSQC_kh_hud(void)\r
101 {\r
102         // HUD 0 has the weapons on the right hand side - temporarily shown when needed\r
103         // HUD 1 has the weapons on the bottom - permanently\r
104 \r
105         // use the following two binds to check the icons move correctly\r
106         // bind g "toggle sbar_flagstatus_right; echo Menu right $sbar_flagstatus_right"  // move the icons\r
107         // bind h "toggle sbar_hudselector; echo HUD $sbar_hudselector"  // change the HUD\r
108 \r
109         float kh_keys, kh_keys_status, kh_teams_set;\r
110         float kh_margin_x, kh_margin_y, kh_key_box;\r
111         string kh_carrying, kh_outline;\r
112         vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;\r
113         vector red, blue, yellow, pink;\r
114 \r
115         kh_keys = getstati(STAT_KH_KEYS);\r
116         kh_keys_status = kh_keys / 256;\r
117         kh_teams_set = cvar("_teams_available");  // set in keyhunt.qc\r
118 \r
119         kh_margin_y = 8;\r
120         kh_margin_x = (cvar("sbar_flagstatus_right") * sbar_hudselector * (vid_conwidth - 67)) + 10;\r
121 //      sbar_flagstatus_right 0/1; sbar_hudselector 0/1; screen width - key width + margin\r
122 \r
123         red_pos_x = blue_pos_x = yellow_pos_x = pink_pos_x = kh_margin_x;\r
124 \r
125         kh_key_box = 120;\r
126 \r
127         pink_pos_y = kh_margin_y + 0;  // top\r
128         yellow_pos_y = kh_margin_y + kh_key_box;\r
129         blue_pos_y = kh_margin_y + kh_key_box * 2;\r
130         red_pos_y = kh_margin_y + kh_key_box * 3;  //bottom\r
131 \r
132         red = '1 0 0';\r
133         blue = '0 0 1';\r
134         yellow = '1 1 0';\r
135         pink = '1 0 1';\r
136 \r
137         kh_size = '0 0';  // don't resize the image\r
138 \r
139         kh_carrying = "gfx/sb_kh_full";\r
140         kh_outline = "gfx/sb_kh_outline";\r
141 \r
142 //      drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)\r
143 //      vector position = '0 0';  // 'x y' 0 0 (the origin) is the top left. X 0 - 799, Y 0 - 599\r
144 \r
145 //      vector size = '0 0';  // 'x y' changes the x & y dimensions. '0 0' gives the default pic size\r
146 //      vector rgb = '0 0 0';  // 'r g b' range 0 - 1\r
147 \r
148         if (kh_keys_status & 1)  // red\r
149                 drawpic (red_pos, kh_carrying, kh_size, red, 0.2, 0);  // show 20% alpha key\r
150         else\r
151                 drawpic (red_pos, kh_outline, kh_size, red, 0.4, 0);  // show key outline 40% alpha\r
152 \r
153         if (kh_keys & 1)\r
154                 drawpic (red_pos, kh_carrying, kh_size, red, 1.0, 0);  // show solid key 100% alpha\r
155 \r
156 \r
157         if (kh_keys_status & 2)  // blue\r
158                 drawpic (blue_pos, kh_carrying, kh_size, blue, 0.2, 0);\r
159         else\r
160                 drawpic (blue_pos, kh_outline, kh_size, blue, 0.4, 0);\r
161 \r
162         if (kh_keys & 2)\r
163                 drawpic (blue_pos, kh_carrying, kh_size, blue, 1.0, 0);\r
164 \r
165 \r
166         if (kh_teams_set & 4)  // yellow\r
167         {\r
168                 if (kh_keys_status & 4)\r
169                         drawpic (yellow_pos, kh_carrying, kh_size, yellow, 0.2, 0);\r
170                 else\r
171                         drawpic (yellow_pos, kh_outline, kh_size, yellow, 0.4, 0);\r
172 \r
173                 if (kh_keys & 4)\r
174                         drawpic (yellow_pos, kh_carrying, kh_size, yellow, 1.0, 0);\r
175         }\r
176 \r
177 \r
178         if (kh_teams_set & 8)  // pink\r
179         {\r
180                 if (kh_keys_status & 8)\r
181                         drawpic (pink_pos, kh_carrying, kh_size, pink, 0.2, 0);\r
182                 else\r
183                         drawpic (pink_pos, kh_outline, kh_size, pink, 0.4, 0);\r
184 \r
185                 if (kh_keys & 8)\r
186                         drawpic (pink_pos, kh_carrying, kh_size, pink, 1.0, 0);\r
187         }\r
188 \r
189 }\r