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