]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
client: improve server connection status messages
[xonotic/darkplaces.git] / cl_screen.c
index b9b2f64df237b7543ca5696fafecabedf3c2b2be..a313e1e3acd8c9ab7b2a25af94193c7254c65069 100644 (file)
@@ -100,7 +100,7 @@ int jpeg_supported = false;
 
 qbool  scr_initialized;                // ready to draw
 
-static qbool scr_loading = false;  // we are in a loading screen
+qbool scr_loading = false;  // we are in a loading screen
 
 unsigned int        scr_con_current;
 static unsigned int scr_con_margin_bottom;
@@ -1558,6 +1558,9 @@ rtexture_t *loadingscreentexture = NULL; // last framebuffer before loading scre
 static float loadingscreentexture_vertex3f[12];
 static float loadingscreentexture_texcoord2f[8];
 static int loadingscreenpic_number = 0;
+/// User-friendly connection status for the menu and/or loading screen,
+/// colours and \n not supported.
+char cl_connect_status[MAX_QPATH]; // should match size of loadingscreenstack_t msg[]
 
 static void SCR_DrawLoadingScreen(void);
 static void SCR_DrawScreen (void)
@@ -1729,24 +1732,19 @@ static void SCR_DrawScreen (void)
 
        if (scr_loading)
        {
-               loadingscreenstack_t connect_status;
-               qbool show_connect_status = !loadingscreenstack && (cls.connect_trying || cls.state == ca_connected);
-               if (show_connect_status)
+               // connect_status replaces any dummy_status
+               if ((!loadingscreenstack || loadingscreenstack->msg[0] == '\0') && cl_connect_status[0] != '\0')
                {
+                       loadingscreenstack_t connect_status, *og_ptr = loadingscreenstack;
+
                        connect_status.absolute_loading_amount_min = 0;
-                       if (cls.signon > 0)
-                               dpsnprintf(connect_status.msg, sizeof(connect_status.msg), "Connect: Signon stage %i of %i", cls.signon, SIGNONS);
-                       else if (cls.connect_remainingtries > 0)
-                               dpsnprintf(connect_status.msg, sizeof(connect_status.msg), "Connect: Trying...  %i", cls.connect_remainingtries);
-                       else
-                               dpsnprintf(connect_status.msg, sizeof(connect_status.msg), "Connect: Waiting %i seconds for reply", 10 + cls.connect_remainingtries);
+                       strlcpy(connect_status.msg, cl_connect_status, sizeof(cl_connect_status));
                        loadingscreenstack = &connect_status;
+                       SCR_DrawLoadingScreen();
+                       loadingscreenstack = og_ptr;
                }
-
-               SCR_DrawLoadingScreen();
-
-               if (show_connect_status)
-                       loadingscreenstack = NULL;
+               else
+                       SCR_DrawLoadingScreen();
        }
 
        SCR_DrawConsole();
@@ -2231,11 +2229,11 @@ void CL_UpdateScreen(void)
        {
                if(!loadingscreenstack && !cls.connect_trying && (cls.state != ca_connected || cls.signon == SIGNONS))
                        SCR_EndLoadingPlaque();
-               else if (scr_loadingscreen_maxfps.value)
+               else if (scr_loadingscreen_maxfps.value > 0)
                {
                        static float lastupdate;
                        float now = Sys_DirtyTime();
-                       if (now - lastupdate < 1.0f / scr_loadingscreen_maxfps.value)
+                       if (now - lastupdate < min(1.0f / scr_loadingscreen_maxfps.value, 0.1))
                                return;
                        lastupdate = now;
                }
@@ -2325,18 +2323,6 @@ void CL_UpdateScreen(void)
 #endif
 
        qglFlush(); // ensure that the commands are submitted to the GPU before we do other things
-
-       if (!vid_activewindow)
-               VID_SetMouse(false, false, false);
-       else if (key_consoleactive)
-               VID_SetMouse(vid.fullscreen, false, false);
-       else if (key_dest == key_menu_grabbed)
-               VID_SetMouse(true, vid_mouse.integer && !in_client_mouse && !vid_touchscreen.integer, !vid_touchscreen.integer);
-       else if (key_dest == key_menu || scr_loading)
-               VID_SetMouse(vid.fullscreen, vid_mouse.integer && !in_client_mouse && !vid_touchscreen.integer, !vid_touchscreen.integer);
-       else
-               VID_SetMouse(vid.fullscreen, vid_mouse.integer && !cl.csqc_wantsmousemove && cl_prydoncursor.integer <= 0 && (!cls.demoplayback || cl_demo_mousegrab.integer) && !vid_touchscreen.integer, !vid_touchscreen.integer);
-
        VID_Finish();
 }