3 float HUD_Radar_Clickable()
5 return hud_panel_radar_mouse && !hud_panel_radar_temp_hidden;
8 void HUD_Radar_Show_Maximized(bool doshow,float clickable)
10 hud_panel_radar_maximized = doshow;
11 hud_panel_radar_temp_hidden = 0;
17 if(autocvar_hud_cursormode)
19 hud_panel_radar_mouse = 1;
22 else if ( hud_panel_radar_mouse )
24 hud_panel_radar_mouse = 0;
26 if(autocvar_hud_cursormode)
31 void HUD_Radar_Hide_Maximized()
33 HUD_Radar_Show_Maximized(false,false);
37 float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary)
39 if(!hud_panel_radar_maximized || !hud_panel_radar_mouse ||
40 autocvar__hud_configure || mv_active)
45 mousepos_x = nPrimary;
46 mousepos_y = nSecondary;
50 if(nPrimary == K_MOUSE1)
52 if(bInputType == 0) // key pressed
53 mouseClicked |= S_MOUSE1;
54 else if(bInputType == 1) // key released
55 mouseClicked -= (mouseClicked & S_MOUSE1);
57 else if(nPrimary == K_MOUSE2)
59 if(bInputType == 0) // key pressed
60 mouseClicked |= S_MOUSE2;
61 else if(bInputType == 1) // key released
62 mouseClicked -= (mouseClicked & S_MOUSE2);
64 else if ( nPrimary == K_ESCAPE && bInputType == 0 )
66 HUD_Radar_Hide_Maximized();
70 // allow console/use binds to work without hiding the map
74 con_keys = strcat(findkeysforcommand("toggleconsole", 0)," ",findkeysforcommand("+use", 0)) ;
75 keys = tokenize(con_keys); // findkeysforcommand returns data for this
76 for (i = 0; i < keys; ++i)
78 if(nPrimary == stof(argv(i)))
82 if ( getstati(STAT_HEALTH) <= 0 )
87 con_keys = findkeysforcommand("+showscores", 0);
88 keys = tokenize(con_keys);
89 for (i = 0; i < keys; ++i)
91 if ( nPrimary == stof(argv(i)) )
93 hud_panel_radar_temp_hidden = bInputType == 0;
99 else if ( bInputType == 0 )
100 HUD_Radar_Hide_Maximized();
108 void HUD_Radar_Mouse()
110 if ( !hud_panel_radar_mouse ) return;
111 if(mv_active) return;
115 HUD_Radar_Hide_Maximized();
119 if(mouseClicked & S_MOUSE2)
121 HUD_Radar_Hide_Maximized();
125 if(!autocvar_hud_cursormode)
127 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
129 mousepos_x = bound(0, mousepos_x, vid_conwidth);
130 mousepos_y = bound(0, mousepos_y, vid_conheight);
133 HUD_Panel_UpdateCvars();
136 panel_size = autocvar_hud_panel_radar_maximized_size;
137 panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
138 panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
139 panel_pos_x = (vid_conwidth - panel_size_x) / 2;
140 panel_pos_y = (vid_conheight - panel_size_y) / 2;
142 if(mouseClicked & S_MOUSE1)
145 if ( mousepos_x < panel_pos_x || mousepos_x > panel_pos_x + panel_size_x ||
146 mousepos_y < panel_pos_y || mousepos_y > panel_pos_y + panel_size_y )
148 HUD_Radar_Hide_Maximized();
151 vector pos = teamradar_texcoord_to_3dcoord(teamradar_2dcoord_to_texcoord(mousepos),view_origin_z);
152 localcmd(sprintf("cmd ons_spawn %f %f %f",pos_x,pos_y,pos_z));
154 HUD_Radar_Hide_Maximized();
159 const vector cursor_size = '32 32 0';
160 drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursor_size, '1 1 1', 0.8, DRAWFLAG_NORMAL);
165 if (!autocvar__hud_configure)
167 if (hud_panel_radar_maximized)
169 if (!hud_draw_maximized) return;
173 if (autocvar_hud_panel_radar == 0) return;
174 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
175 if(radar_panel_modified)
177 panel.update_time = time; // forces reload of panel attributes
178 radar_panel_modified = false;
183 if ( hud_panel_radar_temp_hidden )
186 HUD_Panel_UpdateCvars();
190 if (hud_panel_radar_maximized && !autocvar__hud_configure)
192 panel_size = autocvar_hud_panel_radar_maximized_size;
193 panel_size.x = bound(0.2, panel_size.x, 1) * vid_conwidth;
194 panel_size.y = bound(0.2, panel_size.y, 1) * vid_conheight;
195 panel_pos.x = (vid_conwidth - panel_size.x) / 2;
196 panel_pos.y = (vid_conheight - panel_size.y) / 2;
199 panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
200 if(precache_pic(panel_bg) == "")
201 panel_bg = "gfx/hud/default/border_default"; // fallback
202 if(!radar_panel_modified && panel_bg != panel.current_panel_bg)
203 radar_panel_modified = true;
204 if(panel.current_panel_bg)
205 strunzone(panel.current_panel_bg);
206 panel.current_panel_bg = strzone(panel_bg);
208 switch(hud_panel_radar_maximized_zoommode)
212 f = current_zoomfraction;
215 f = 1 - current_zoomfraction;
225 switch(hud_panel_radar_maximized_rotation)
228 teamradar_angle = view_angles.y - 90;
231 teamradar_angle = 90 * hud_panel_radar_maximized_rotation;
235 if (!hud_panel_radar_maximized && !autocvar__hud_configure)
237 switch(hud_panel_radar_zoommode)
241 f = current_zoomfraction;
244 f = 1 - current_zoomfraction;
254 switch(hud_panel_radar_rotation)
257 teamradar_angle = view_angles.y - 90;
260 teamradar_angle = 90 * hud_panel_radar_rotation;
272 pos += '1 1 0' * panel_bg_padding;
273 mySize -= '2 2 0' * panel_bg_padding;
278 float scale2d, normalsize, bigsize;
280 teamradar_origin2d = pos + 0.5 * mySize;
281 teamradar_size2d = mySize;
283 if(minimapname == "")
286 teamradar_loadcvars();
288 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
289 teamradar_size2d = mySize;
291 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
293 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
294 if((hud_panel_radar_rotation == 0 && !hud_panel_radar_maximized) || (hud_panel_radar_maximized_rotation == 0 && hud_panel_radar_maximized))
296 // max-min distance must fit the radar in any rotation
297 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
301 vector c0, c1, c2, c3, span;
302 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
303 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
304 c2 = rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
305 c3 = rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
307 span.x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
308 span.y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
310 // max-min distance must fit the radar in x=x, y=y
312 teamradar_size2d.x * scale2d / (1.05 * span.x),
313 teamradar_size2d.y * scale2d / (1.05 * span.y)
317 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
318 if(bigsize > normalsize)
319 normalsize = bigsize;
323 + (1 - f) * normalsize;
324 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
326 + (1 - f) * view_origin);
335 draw_teamradar_background(hud_panel_radar_foreground_alpha);
337 for(tm = world; (tm = find(tm, classname, "radarlink")); )
338 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
342 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
344 if ( hud_panel_radar_mouse )
346 if ( tm.team == myteam+1 )
348 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(tm.origin));
349 if ( vlen(mousepos-coord) < 8 )
351 brightcolor_x = min(1,tm.teamradar_color_x*1.5);
352 brightcolor_y = min(1,tm.teamradar_color_y*1.5);
353 brightcolor_z = min(1,tm.teamradar_color_z*1.5);
354 drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
357 entity icon = RadarIcons_from(tm.teamradar_icon);
358 draw_teamradar_icon(tm.origin, icon, tm, spritelookupcolor(tm, icon.netname, tm.teamradar_color), panel_fg_alpha);
360 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
362 color2 = GetPlayerColor(tm.sv_entnum);
363 //if(color == NUM_SPECTATOR || color == color2)
364 draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2));
366 draw_teamradar_player(view_origin, view_angles, '1 1 1');
370 if ( hud_panel_radar_mouse )
372 string message = "Click to select teleport destination";
374 if ( getstati(STAT_HEALTH) <= 0 )
376 message = "Click to select spawn location";
379 drawcolorcodedstring(pos + '0.5 0 0' * (mySize_x - stringwidth(message, true, hud_fontsize)) - '0 1 0' * hud_fontsize_y * 2,
380 message, hud_fontsize, hud_panel_radar_foreground_alpha, DRAWFLAG_NORMAL);
382 hud_panel_radar_bottom = pos_y + mySize_y + hud_fontsize_y;