]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Merge branch 'master' into terencehill/ft_autorevive_progress
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index 05d2306695076006f86478c26d5852bc74760b77..81d6a634e7f7e7295dbc5ea1eb07af142a98e750 100644 (file)
@@ -1,9 +1,10 @@
 #include "view.qh"
 
 #include "autocvars.qh"
-#include "miscfunctions.qh"
+#include <client/draw.qh>
 #include "announcer.qh"
 #include "hud/_mod.qh"
+#include "main.qh"
 #include "mapvoting.qh"
 #include "shownames.qh"
 #include "hud/panel/scoreboard.qh"
@@ -44,8 +45,6 @@
 #include <lib/warpzone/client.qh>
 #include <lib/warpzone/common.qh>
 
-#define EFMASK_CHEAP (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NODRAW | EF_NOSHADOW | EF_SELECTABLE | EF_TELEPORT_BIT)
-
 float autocvar_cl_viewmodel_scale;
 float autocvar_cl_viewmodel_alpha = 1;
 
@@ -364,6 +363,33 @@ STATIC_INIT(viewmodel) {
        viewmodels[slot] = new(viewmodel);
 }
 
+vector project_3d_to_2d(vector vec)
+{
+       vec = cs_project(vec);
+       if(cs_project_is_b0rked > 0)
+       {
+               vec.x *= vid_conwidth / vid_width;
+               vec.y *= vid_conheight / vid_height;
+       }
+       return vec;
+}
+
+bool projected_on_screen(vector screen_pos)
+{
+       return screen_pos.z >= 0
+               && screen_pos.x >= 0
+               && screen_pos.y >= 0
+               && screen_pos.x < vid_conwidth
+               && screen_pos.y < vid_conheight;
+}
+
+void update_mousepos()
+{
+       mousepos += getmousepos() * autocvar_menu_mouse_speed;
+       mousepos.x = bound(0, mousepos.x, vid_conwidth);
+       mousepos.y = bound(0, mousepos.y, vid_conheight);
+}
+
 float showfps_prevfps;
 float showfps_prevfps_time;
 int showfps_framecounter;
@@ -373,7 +399,8 @@ void fpscounter_update()
        if(!STAT(SHOWFPS))
                return;
 
-       float currentTime = gettime(GETTIME_REALTIME);
+       float currentTime = gettime(GETTIME_FRAMESTART);
+
        showfps_framecounter += 1;
        if(currentTime - showfps_prevfps_time > STAT(SHOWFPS))
        {
@@ -389,7 +416,7 @@ void fpscounter_update()
 
 STATIC_INIT(fpscounter_init)
 {
-       float currentTime = gettime(GETTIME_REALTIME);
+       float currentTime = gettime(GETTIME_FRAMESTART);
        showfps_prevfps_time = currentTime; // we must initialize it to avoid an instant low frame sending
 }
 
@@ -925,9 +952,11 @@ void HUD_Draw(entity this)
        else if(STAT(FROZEN))
        {
                vector col = '0.25 0.90 1';
-               if(STAT(REVIVE_PROGRESS))
-                       col += vec3(STAT(REVIVE_PROGRESS), -STAT(REVIVE_PROGRESS), -STAT(REVIVE_PROGRESS));
-               drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), col, autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
+               float col_fade = max(0, STAT(REVIVE_PROGRESS) * 2 - 1);
+               float alpha_fade = 0.3 + 0.7 * (1 - max(0, STAT(REVIVE_PROGRESS) * 4 - 3));
+               if(col_fade)
+                       col += vec3(col_fade, -col_fade, -col_fade);
+               drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), col, autocvar_hud_colorflash_alpha * alpha_fade, DRAWFLAG_ADDITIVE);
        }
 
        HUD_Scale_Enable();
@@ -953,7 +982,7 @@ void HUD_Draw(entity this)
        if(autocvar_r_letterbox == 0)
                if(autocvar_viewsize < 120)
                {
-                       if(!(ISGAMETYPE(RACE) || ISGAMETYPE(CTS)))
+                       if(!MUTATOR_CALLHOOK(DrawScoreboardAccuracy))
                                Accuracy_LoadLevels();
 
                        HUD_Main();
@@ -1308,9 +1337,17 @@ void View_PostProcessing()
 
 void View_Lock()
 {
-       int lock_type = (!autocvar_hud_cursormode && ((autocvar__hud_configure && spectatee_status <= 0) || intermission > 1 || QuickMenu_IsOpened()));
-       if (lock_type == 0)
-               lock_type = autocvar_cl_lockview;
+       int lock_type = autocvar_cl_lockview;
+
+       if (!autocvar_hud_cursormode
+               && ((autocvar__hud_configure && spectatee_status <= 0)
+                       || intermission > 1
+                       || HUD_Radar_Clickable()
+                       || HUD_MinigameMenu_IsOpened()
+                       || QuickMenu_IsOpened()
+               )
+       )
+               lock_type = 1;
 
        // lock_type 1: lock origin and angles
        // lock_type 2: lock only origin