]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'master' into Mario/ons_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 9e6861ebd06e7d05a4a0fabfc4c305dc4433c3c3..a85fca68884ab9b187c40a5014e5fd0073e6f2ac 100644 (file)
@@ -1870,6 +1870,167 @@ void HUD_Timer(void)
 
 // Radar (#6)
 //
+
+float HUD_Radar_Clickable()
+{
+       return hud_panel_radar_mouse && !hud_panel_radar_temp_hidden;
+}
+
+void HUD_Radar_Show_Maximized(float show,float clickable)
+{
+       hud_panel_radar_maximized = show;
+       hud_panel_radar_temp_hidden = 0;
+       
+       if ( show )
+       {
+               if (clickable)
+               {
+                       if(autocvar_hud_cursormode)
+                               setcursormode(1);
+                       hud_panel_radar_mouse = 1; 
+               }
+       }
+       else if ( hud_panel_radar_mouse )
+       {
+               hud_panel_radar_mouse = 0;
+               mouseClicked = 0;
+               if(autocvar_hud_cursormode)
+               if(!mv_active)
+                       setcursormode(0);
+       }
+}
+void HUD_Radar_Hide_Maximized()
+{
+       HUD_Radar_Show_Maximized(false,false);
+}
+
+
+float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary)
+{
+       if(!hud_panel_radar_maximized || !hud_panel_radar_mouse || 
+               autocvar__hud_configure || mv_active)
+               return false;
+
+       if(bInputType == 3)
+       {
+               mousepos_x = nPrimary;
+               mousepos_y = nSecondary;
+               return true;
+       }
+
+       if(nPrimary == K_MOUSE1)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE1;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE1);
+       }
+       else if(nPrimary == K_MOUSE2)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE2;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE2);
+       }
+       else if ( nPrimary == K_ESCAPE && bInputType == 0 )
+       {
+               HUD_Radar_Hide_Maximized();
+       }
+       else
+       {
+               // allow console/use binds to work without hiding the map
+               string con_keys;
+               float keys;
+               float i;
+               con_keys = strcat(findkeysforcommand("toggleconsole", 0)," ",findkeysforcommand("+use", 0)) ;
+               keys = tokenize(con_keys); // findkeysforcommand returns data for this
+               for (i = 0; i < keys; ++i)
+               {
+                       if(nPrimary == stof(argv(i)))
+                               return false;
+               }
+               
+               if ( getstati(STAT_HEALTH) <= 0 )
+               {
+                       // Show scoreboard
+                       if ( bInputType < 2 )
+                       {
+                               con_keys = findkeysforcommand("+showscores", 0);
+                               keys = tokenize(con_keys);
+                               for (i = 0; i < keys; ++i)
+                               {
+                                       if ( nPrimary == stof(argv(i)) )
+                                       {
+                                               hud_panel_radar_temp_hidden = bInputType == 0;
+                                               return false;
+                                       }
+                               }
+                       }
+               }
+               else if ( bInputType == 0 )
+                       HUD_Radar_Hide_Maximized();
+               
+               return false;
+       }
+
+       return true;
+}
+
+void HUD_Radar_Mouse()
+{
+       if ( !hud_panel_radar_mouse ) return;
+       if(mv_active) return;
+       
+       if ( intermission )
+       {
+               HUD_Radar_Hide_Maximized();
+               return;
+       }
+       
+       if(mouseClicked & S_MOUSE2)
+       {
+               HUD_Radar_Hide_Maximized();
+               return;
+       }
+       
+       if(!autocvar_hud_cursormode)
+       {
+               mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
+
+               mousepos_x = bound(0, mousepos_x, vid_conwidth);
+               mousepos_y = bound(0, mousepos_y, vid_conheight);
+       }
+
+       HUD_Panel_UpdateCvars();
+       
+       
+       panel_size = autocvar_hud_panel_radar_maximized_size;
+       panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
+       panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
+       panel_pos_x = (vid_conwidth - panel_size_x) / 2;
+       panel_pos_y = (vid_conheight - panel_size_y) / 2;
+               
+       if(mouseClicked & S_MOUSE1)
+       {
+               // click outside
+               if ( mousepos_x < panel_pos_x || mousepos_x > panel_pos_x + panel_size_x ||
+                        mousepos_y < panel_pos_y || mousepos_y > panel_pos_y + panel_size_y )
+               {
+                       HUD_Radar_Hide_Maximized();
+                       return;
+               }
+               vector pos = teamradar_texcoord_to_3dcoord(teamradar_2dcoord_to_texcoord(mousepos),view_origin_z);
+               localcmd(sprintf("cmd ons_spawn %f %f %f",pos_x,pos_y,pos_z));
+               
+               HUD_Radar_Hide_Maximized();
+               return;
+       }
+       
+
+       const vector cursorsize = '32 32 0';
+       drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+}
+
 void HUD_Radar(void)
 {
        if (!autocvar__hud_configure)
@@ -1889,6 +2050,9 @@ void HUD_Radar(void)
                        }
                }
        }
+       
+       if ( hud_panel_radar_temp_hidden )
+               return;
 
        HUD_Panel_UpdateCvars();
 
@@ -2043,8 +2207,27 @@ void HUD_Radar(void)
 
        for(tm = world; (tm = find(tm, classname, "radarlink")); )
                draw_teamradar_link(tm.origin, tm.velocity, tm.team);
+       
+       vector coord;
+       vector brightcolor;
        for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
+       {
+               if ( hud_panel_radar_mouse )
+               if ( tm.health > 0 )
+               if ( tm.team == myteam+1 )
+               {
+                       coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(tm.origin));
+                       if ( vlen(mousepos-coord) < 8 )
+                       {
+                               brightcolor_x = min(1,tm.teamradar_color_x*1.5);
+                               brightcolor_y = min(1,tm.teamradar_color_y*1.5);
+                               brightcolor_z = min(1,tm.teamradar_color_z*1.5);
+                               drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
+                       }
+               }
+               
                draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
+       }
        for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
        {
                color2 = GetPlayerColor(tm.sv_entnum);
@@ -2054,6 +2237,21 @@ void HUD_Radar(void)
        draw_teamradar_player(view_origin, view_angles, '1 1 1');
 
        drawresetcliparea();
+       
+       if ( hud_panel_radar_mouse )
+       {                       
+               string message = "Click to select teleport destination";
+               
+               if ( getstati(STAT_HEALTH) <= 0 )
+               {
+                       message = "Click to select spawn location";
+               }
+               
+               drawcolorcodedstring(pos + '0.5 0 0' * (mySize_x - stringwidth(message, TRUE, hud_fontsize)) - '0 1 0' * hud_fontsize_y * 2,
+                                                        message, hud_fontsize, hud_panel_radar_foreground_alpha, DRAWFLAG_NORMAL);
+               
+               hud_panel_radar_bottom = pos_y + mySize_y + hud_fontsize_y;
+       }
 }
 
 // Score (#7)
@@ -4237,8 +4435,16 @@ void HUD_CenterPrint (void)
                hud_fade_alpha = 1 - autocvar__menu_alpha;
        }
        HUD_Panel_UpdateCvars();
-
-       if(scoreboard_fade_alpha)
+       
+       if ( HUD_Radar_Clickable() )
+       {
+               if (hud_panel_radar_bottom >= 0.96 * vid_conheight)
+                       return;
+               
+               panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
+               panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom);
+       }
+       else if(scoreboard_fade_alpha)
        {
                hud_fade_alpha = hud_fade_alpha_save;