cvar_t scr_conalpha2factor = {CF_CLIENT | CF_ARCHIVE, "scr_conalpha2factor", "0", "opacity of console background gfx/conback2 relative to scr_conalpha; when 0, gfx/conback2 is not drawn"};
cvar_t scr_conalpha3factor = {CF_CLIENT | CF_ARCHIVE, "scr_conalpha3factor", "0", "opacity of console background gfx/conback3 relative to scr_conalpha; when 0, gfx/conback3 is not drawn"};
cvar_t scr_conbrightness = {CF_CLIENT | CF_ARCHIVE, "scr_conbrightness", "1", "brightness of console background (0 = black, 1 = image)"};
-cvar_t scr_conforcewhiledisconnected = {CF_CLIENT, "scr_conforcewhiledisconnected", "1", "forces fullscreen console while disconnected"};
+cvar_t scr_conforcewhiledisconnected = {CF_CLIENT, "scr_conforcewhiledisconnected", "1", "1 forces fullscreen console while disconnected, 2 also forces it when the listen server has started but the client is still loading"};
+cvar_t scr_conheight = {CF_CLIENT | CF_ARCHIVE, "scr_conheight", "0.5", "fraction of screen height occupied by console (reduced as necessary for visibility of loading progress and infobar)"};
cvar_t scr_conscroll_x = {CF_CLIENT | CF_ARCHIVE, "scr_conscroll_x", "0", "scroll speed of gfx/conback in x direction"};
cvar_t scr_conscroll_y = {CF_CLIENT | CF_ARCHIVE, "scr_conscroll_y", "0", "scroll speed of gfx/conback in y direction"};
cvar_t scr_conscroll2_x = {CF_CLIENT | CF_ARCHIVE, "scr_conscroll2_x", "0", "scroll speed of gfx/conback2 in x direction"};
cvar_t scr_loadingscreen_firstforstartup = {CF_CLIENT, "scr_loadingscreen_firstforstartup","0", "remove loading.tga from random scr_loadingscreen_count selection and only display it on client startup, 0 = normal, 1 = firstforstartup"};
cvar_t scr_loadingscreen_barcolor = {CF_CLIENT, "scr_loadingscreen_barcolor", "0 0 1", "rgb color of loadingscreen progress bar"};
cvar_t scr_loadingscreen_barheight = {CF_CLIENT, "scr_loadingscreen_barheight", "8", "the height of the loadingscreen progress bar"};
-cvar_t scr_loadingscreen_maxfps = {CF_CLIENT, "scr_loadingscreen_maxfps", "10", "restrict maximal FPS for loading screen so it will not update very often (this will make lesser loading times on a maps loading large number of models)"};
+cvar_t scr_loadingscreen_maxfps = {CF_CLIENT, "scr_loadingscreen_maxfps", "20", "maximum FPS for loading screen so it will not update very often (this reduces loading time with lots of models)"};
cvar_t scr_infobar_height = {CF_CLIENT, "scr_infobar_height", "8", "the height of the infobar items"};
cvar_t vid_conwidthauto = {CF_CLIENT | CF_ARCHIVE, "vid_conwidthauto", "1", "automatically update vid_conwidth to match aspect ratio"};
cvar_t vid_conwidth = {CF_CLIENT | CF_ARCHIVE, "vid_conwidth", "640", "virtual width of 2D graphics system (note: changes may be overwritten, see vid_conwidthauto)"};
qbool scr_initialized; // ready to draw
-float scr_con_current;
-int scr_con_margin_bottom;
+qbool scr_loading = false; // we are in a loading screen
+
+unsigned int scr_con_current;
+static unsigned int scr_con_margin_bottom;
extern int con_vislines;
*/
void SCR_CenterPrint(const char *str)
{
- strlcpy (scr_centerstring, str, sizeof (scr_centerstring));
+ dp_strlcpy (scr_centerstring, str, sizeof (scr_centerstring));
scr_centertime_off = scr_centertime.value;
scr_centertime_start = cl.time;
}
}
+/*
+============
+SCR_Centerprint_f
+
+Print something to the center of the screen using SCR_Centerprint
+============
+*/
+static void SCR_Centerprint_f (cmd_state_t *cmd)
+{
+ char msg[MAX_INPUTLINE];
+ unsigned int i, c, p;
+ c = Cmd_Argc(cmd);
+ if(c >= 2)
+ {
+ dp_strlcpy(msg, Cmd_Argv(cmd,1), sizeof(msg));
+ for(i = 2; i < c; ++i)
+ {
+ dp_strlcat(msg, " ", sizeof(msg));
+ dp_strlcat(msg, Cmd_Argv(cmd, i), sizeof(msg));
+ }
+ c = (unsigned int)strlen(msg);
+ for(p = 0, i = 0; i < c; ++i)
+ {
+ if(msg[i] == '\\')
+ {
+ if(msg[i+1] == 'n')
+ msg[p++] = '\n';
+ else if(msg[i+1] == '\\')
+ msg[p++] = '\\';
+ else {
+ msg[p++] = '\\';
+ msg[p++] = msg[i+1];
+ }
+ ++i;
+ } else {
+ msg[p++] = msg[i];
+ }
+ }
+ msg[p] = '\0';
+ SCR_CenterPrint(msg);
+ }
+}
static void SCR_DrawCenterString (void)
{
*/
static void SCR_DrawInfobar(void)
{
- int offset = 0;
+ unsigned int offset = 0;
offset += SCR_DrawQWDownload(offset);
offset += SCR_DrawCurlDownload(offset);
if(scr_infobartime_off > 0)
offset += SCR_DrawInfobarString(offset);
+ if(!offset && scr_loading)
+ offset = scr_loadingscreen_barheight.integer;
if(offset != scr_con_margin_bottom)
Con_DPrintf("broken console margin calculation: %d != %d\n", offset, scr_con_margin_bottom);
}
if(Cmd_Argc(cmd) == 3)
{
scr_infobartime_off = atof(Cmd_Argv(cmd, 1));
- strlcpy(scr_infobarstring, Cmd_Argv(cmd, 2), sizeof(scr_infobarstring));
+ dp_strlcpy(scr_infobarstring, Cmd_Argv(cmd, 2), sizeof(scr_infobarstring));
}
else
{
*/
static void SCR_SetUpToDrawConsole (void)
{
- // lines of console to display
- float conlines;
#ifdef CONFIG_MENU
static int framecounter = 0;
#endif
else
key_consoleactive &= ~KEY_CONSOLEACTIVE_FORCED;
-// decide on the height of the console
+ // decide on the height of the console
if (key_consoleactive & KEY_CONSOLEACTIVE_USER)
- conlines = vid_conheight.integer/2; // half screen
+ scr_con_current = vid_conheight.integer * scr_conheight.value;
else
- conlines = 0; // none visible
-
- scr_con_current = conlines;
+ scr_con_current = 0; // none visible
}
/*
*/
void SCR_DrawConsole (void)
{
- scr_con_margin_bottom = SCR_InfobarHeight();
+ // infobar and loading progress are not drawn simultaneously
+ scr_con_margin_bottom = SCR_InfobarHeight() ?: scr_loading * scr_loadingscreen_barheight.integer;
if (key_consoleactive & KEY_CONSOLEACTIVE_FORCED)
{
// full screen
Con_DrawConsole (vid_conheight.integer - scr_con_margin_bottom);
}
else if (scr_con_current)
- Con_DrawConsole (min((int)scr_con_current, vid_conheight.integer - scr_con_margin_bottom));
+ Con_DrawConsole (min(scr_con_current, vid_conheight.integer - scr_con_margin_bottom));
else
con_vislines = 0;
}
Cvar_RegisterVariable (&scr_conscroll3_y);
Cvar_RegisterVariable (&scr_conbrightness);
Cvar_RegisterVariable (&scr_conforcewhiledisconnected);
+ Cvar_RegisterVariable (&scr_conheight);
#ifdef CONFIG_MENU
Cvar_RegisterVariable (&scr_menuforcewhiledisconnected);
#endif
if (Sys_CheckParm ("-noconsole"))
Cvar_SetQuick(&scr_conforcewhiledisconnected, "0");
+ Cmd_AddCommand(CF_CLIENT, "cprint", SCR_Centerprint_f, "print something at the screen center");
Cmd_AddCommand(CF_CLIENT, "sizeup",SCR_SizeUp_f, "increase view size (increases viewsize cvar)");
Cmd_AddCommand(CF_CLIENT, "sizedown",SCR_SizeDown_f, "decrease view size (decreases viewsize cvar)");
Cmd_AddCommand(CF_CLIENT, "screenshot",SCR_ScreenShot_f, "takes a screenshot of the next rendered frame");
if (Cmd_Argc(cmd) == 2)
{
const char *ext;
- strlcpy(filename, Cmd_Argv(cmd, 1), sizeof(filename));
+ dp_strlcpy(filename, Cmd_Argv(cmd, 1), sizeof(filename));
ext = FS_FileExtension(filename);
if (!strcasecmp(ext, "jpg"))
{
{
if(SCR_ScreenShot (filename, buffer1, buffer2, 0, 0, vid.width, vid.height, false, false, false, false, false, true, scr_screenshot_alpha.integer != 0))
{
- strlcpy(filename + strlen(filename) - 3, "tga", 4);
+ dp_strlcpy(filename + strlen(filename) - 3, "tga", 4);
Con_Printf("Wrote %s\n", filename);
}
}
cls.capturevideo.videoframes(newframestepframenum - cls.capturevideo.framestepframe);
cls.capturevideo.framestepframe = newframestepframenum;
- if(cl_capturevideo_printfps.integer)
+ if(cl_capturevideo_printfps.integer && host.realtime > cls.capturevideo.lastfpstime + 1)
{
- char buf[80];
- double t = host.realtime;
- if(t > cls.capturevideo.lastfpstime + 1)
- {
- double fps1 = (cls.capturevideo.frame - cls.capturevideo.lastfpsframe) / (t - cls.capturevideo.lastfpstime + 0.0000001);
- double fps = (cls.capturevideo.frame ) / (t - cls.capturevideo.starttime + 0.0000001);
- dpsnprintf(buf, sizeof(buf), "capturevideo: (%.1fs) last second %.3ffps, total %.3ffps\n", cls.capturevideo.frame / cls.capturevideo.framerate, fps1, fps);
- Sys_Print(buf);
- cls.capturevideo.lastfpstime = t;
- cls.capturevideo.lastfpsframe = cls.capturevideo.frame;
- }
+ double fps1 = (cls.capturevideo.frame - cls.capturevideo.lastfpsframe) / (host.realtime - cls.capturevideo.lastfpstime + 0.0000001);
+ double fps = (cls.capturevideo.frame ) / (host.realtime - cls.capturevideo.starttime + 0.0000001);
+ Sys_Printf("capturevideo: (%.1fs) last second %.3ffps, total %.3ffps\n", cls.capturevideo.frame / cls.capturevideo.framerate, fps1, fps);
+ cls.capturevideo.lastfpstime = host.realtime;
+ cls.capturevideo.lastfpsframe = cls.capturevideo.frame;
}
}
return;
}
- strlcpy (basename, Cmd_Argv(cmd, 1), sizeof (basename));
+ dp_strlcpy (basename, Cmd_Argv(cmd, 1), sizeof (basename));
size = atoi(Cmd_Argv(cmd, 2));
if (size != 128 && size != 256 && size != 512 && size != 1024)
{
int k;
char lmplabel[256], picname[256];
float x, y;
- strlcpy (lmplabel,MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), sizeof (lmplabel));
- strlcpy (picname, MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), sizeof (picname));
+ dp_strlcpy (lmplabel,MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), sizeof (lmplabel));
+ dp_strlcpy (picname, MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), sizeof (picname));
if (gamemode == GAME_NEHAHRA) // LadyHavoc: nasty old legacy junk
{
x = MSG_ReadByte(&cl_message);
if (!cl.showlmps[k].isactive)
break;
cl.showlmps[k].isactive = true;
- strlcpy (cl.showlmps[k].label, lmplabel, sizeof (cl.showlmps[k].label));
- strlcpy (cl.showlmps[k].pic, picname, sizeof (cl.showlmps[k].pic));
+ dp_strlcpy (cl.showlmps[k].label, lmplabel, sizeof (cl.showlmps[k].label));
+ dp_strlcpy (cl.showlmps[k].pic, picname, sizeof (cl.showlmps[k].pic));
cl.showlmps[k].x = x;
cl.showlmps[k].y = y;
cl.num_showlmps = max(cl.num_showlmps, k + 1);
}
loadingscreenstack_t;
static loadingscreenstack_t *loadingscreenstack = NULL;
-static qbool scr_loading = false; // we are in a loading screen
rtexture_t *loadingscreentexture = NULL; // last framebuffer before loading screen, kept for the background
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)
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);
+ dp_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();
s->prev = loadingscreenstack;
loadingscreenstack = s;
- strlcpy(s->msg, msg, sizeof(s->msg));
+ dp_strlcpy(s->msg, msg, sizeof(s->msg));
s->relative_completion = 0;
if(s->prev)
{
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;
}
#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)
- 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();
}