2018-04-13 18:23:45 +02:00
|
|
|
/*
|
|
|
|
cl_scrn.c - refresh screen
|
|
|
|
Copyright (C) 2007 Uncle Mike
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "vgui_draw.h"
|
|
|
|
#include "qfont.h"
|
|
|
|
#include "input.h"
|
2019-11-26 00:47:25 +01:00
|
|
|
#include "library.h"
|
2018-04-13 18:23:45 +02:00
|
|
|
|
2023-05-19 06:02:34 +02:00
|
|
|
CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" );
|
|
|
|
CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" );
|
|
|
|
CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" );
|
|
|
|
CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" );
|
|
|
|
CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" );
|
|
|
|
CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
|
|
|
|
CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" );
|
|
|
|
static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" );
|
|
|
|
CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" );
|
|
|
|
static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" );
|
|
|
|
static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" );
|
|
|
|
static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" );
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
} dirty_t;
|
|
|
|
|
|
|
|
static dirty_t scr_dirty, scr_old_dirty[2];
|
|
|
|
static qboolean scr_init = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
SCR_DrawFPS
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void SCR_DrawFPS( int height )
|
|
|
|
{
|
|
|
|
float calc;
|
|
|
|
rgba_t color;
|
|
|
|
double newtime;
|
|
|
|
static double nexttime = 0, lasttime = 0;
|
|
|
|
static double framerate = 0;
|
|
|
|
static int framecount = 0;
|
|
|
|
static int minfps = 9999;
|
|
|
|
static int maxfps = 0;
|
|
|
|
char fpsstring[64];
|
|
|
|
int offset;
|
|
|
|
|
2023-05-19 06:02:34 +02:00
|
|
|
if( cls.state != ca_active || !cl_showfps.value || cl.background )
|
2020-05-12 01:00:31 +02:00
|
|
|
return;
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
switch( cls.scrshot_action )
|
|
|
|
{
|
|
|
|
case scrshot_normal:
|
|
|
|
case scrshot_snapshot:
|
|
|
|
case scrshot_inactive:
|
|
|
|
break;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
|
|
|
|
newtime = Sys_DoubleTime();
|
|
|
|
if( newtime >= nexttime )
|
|
|
|
{
|
|
|
|
framerate = framecount / (newtime - lasttime);
|
|
|
|
lasttime = newtime;
|
|
|
|
nexttime = Q_max( nexttime + 1.0, lasttime - 1.0 );
|
|
|
|
framecount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
calc = framerate;
|
|
|
|
framecount++;
|
|
|
|
|
|
|
|
if( calc < 1.0f )
|
|
|
|
{
|
|
|
|
Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i spf", (int)(1.0f / calc + 0.5f));
|
|
|
|
MakeRGBA( color, 255, 0, 0, 255 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int curfps = (int)(calc + 0.5f);
|
|
|
|
|
|
|
|
if( curfps < minfps ) minfps = curfps;
|
|
|
|
if( curfps > maxfps ) maxfps = curfps;
|
|
|
|
|
2023-05-19 06:02:34 +02:00
|
|
|
if( cl_showfps.value == 2 )
|
2018-04-13 18:23:45 +02:00
|
|
|
Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max", minfps, curfps, maxfps );
|
|
|
|
else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps );
|
|
|
|
MakeRGBA( color, 255, 255, 255, 255 );
|
2019-07-19 19:23:08 +02:00
|
|
|
}
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
Con_DrawStringLen( fpsstring, &offset, NULL );
|
2019-02-18 19:25:26 +01:00
|
|
|
Con_DrawString( refState.width - offset - 4, height, fpsstring, color );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
2021-03-06 22:03:19 +01:00
|
|
|
/*
|
|
|
|
==============
|
|
|
|
SCR_DrawPos
|
|
|
|
|
|
|
|
Draw local player position, angles and velocity
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void SCR_DrawPos( void )
|
|
|
|
{
|
|
|
|
static char msg[MAX_SYSPATH];
|
|
|
|
float speed;
|
|
|
|
cl_entity_t *ent;
|
|
|
|
rgba_t color;
|
|
|
|
|
2023-05-19 06:02:34 +02:00
|
|
|
if( cls.state != ca_active || !cl_showpos.value || cl.background )
|
2021-03-06 22:03:19 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
ent = CL_GetLocalPlayer();
|
|
|
|
speed = VectorLength( cl.simvel );
|
|
|
|
|
|
|
|
Q_snprintf( msg, MAX_SYSPATH,
|
|
|
|
"pos: %.2f %.2f %.2f\n"
|
|
|
|
"ang: %.2f %.2f %.2f\n"
|
|
|
|
"velocity: %.2f",
|
|
|
|
cl.simorg[0], cl.simorg[1], cl.simorg[2],
|
|
|
|
// should we use entity angles or viewangles?
|
|
|
|
// view isn't always bound to player
|
|
|
|
ent->angles[0], ent->angles[1], ent->angles[2],
|
|
|
|
speed );
|
|
|
|
|
|
|
|
MakeRGBA( color, 255, 255, 255, 255 );
|
|
|
|
|
|
|
|
Con_DrawString( refState.width / 2, 4, msg, color );
|
|
|
|
}
|
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
/*
|
|
|
|
==============
|
|
|
|
SCR_NetSpeeds
|
|
|
|
|
|
|
|
same as r_speeds but for network channel
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void SCR_NetSpeeds( void )
|
|
|
|
{
|
|
|
|
static char msg[MAX_SYSPATH];
|
2023-02-04 19:59:29 +01:00
|
|
|
int x, y;
|
2018-04-13 18:23:45 +02:00
|
|
|
float time = cl.mtime[0];
|
|
|
|
static int min_svfps = 100;
|
|
|
|
static int max_svfps = 0;
|
|
|
|
int cur_svfps = 0;
|
|
|
|
static int min_clfps = 100;
|
|
|
|
static int max_clfps = 0;
|
|
|
|
int cur_clfps = 0;
|
|
|
|
rgba_t color;
|
2023-02-03 06:51:16 +01:00
|
|
|
cl_font_t *font = Con_GetCurFont();
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
if( !host.allow_console )
|
|
|
|
return;
|
|
|
|
|
2023-05-19 06:02:34 +02:00
|
|
|
if( !net_speeds.value || cls.state != ca_active )
|
2018-04-13 18:23:45 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
// prevent to get too big values at max
|
|
|
|
if( cl_serverframetime() > 0.0001f )
|
|
|
|
{
|
|
|
|
cur_svfps = Q_rint( 1.0f / cl_serverframetime( ));
|
|
|
|
if( cur_svfps < min_svfps ) min_svfps = cur_svfps;
|
|
|
|
if( cur_svfps > max_svfps ) max_svfps = cur_svfps;
|
|
|
|
}
|
|
|
|
|
|
|
|
// prevent to get too big values at max
|
|
|
|
if( cl_clientframetime() > 0.0001f )
|
|
|
|
{
|
|
|
|
cur_clfps = Q_rint( 1.0f / cl_clientframetime( ));
|
|
|
|
if( cur_clfps < min_clfps ) min_clfps = cur_clfps;
|
|
|
|
if( cur_clfps > max_clfps ) max_clfps = cur_clfps;
|
|
|
|
}
|
|
|
|
|
2021-06-05 17:57:16 +02:00
|
|
|
Q_snprintf( msg, sizeof( msg ),
|
|
|
|
"Updaterate: ^1%2i min, ^3%2i cur, ^2%2i max\n"
|
|
|
|
"Client FPS: ^1%i min, ^3%3i cur, ^2%3i max\n"
|
|
|
|
"Game Time: %02d:%02d\n"
|
|
|
|
"Total received from server: %s\n"
|
|
|
|
"Total sent to server: %s\n",
|
|
|
|
min_svfps, cur_svfps, max_svfps,
|
|
|
|
min_clfps, cur_clfps, max_clfps,
|
|
|
|
(int)(time / 60.0f ), (int)fmod( time, 60.0f ),
|
|
|
|
Q_memprint( cls.netchan.total_received ),
|
|
|
|
Q_memprint( cls.netchan.total_sended )
|
|
|
|
);
|
2018-04-13 18:23:45 +02:00
|
|
|
|
2023-02-03 06:51:16 +01:00
|
|
|
x = refState.width - 320 * font->scale;
|
2018-04-13 18:23:45 +02:00
|
|
|
y = 384;
|
|
|
|
|
|
|
|
MakeRGBA( color, 255, 255, 255, 255 );
|
2023-02-04 19:59:29 +01:00
|
|
|
CL_DrawString( x, y, msg, color, font, FONT_DRAW_RESETCOLORONLF );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_RSpeeds
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_RSpeeds( void )
|
|
|
|
{
|
2018-06-09 00:28:35 +02:00
|
|
|
char msg[2048];
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
if( !host.allow_console )
|
|
|
|
return;
|
|
|
|
|
2019-03-15 19:23:59 +01:00
|
|
|
if( ref.dllFuncs.R_SpeedsMessage( msg, sizeof( msg )))
|
2018-04-13 18:23:45 +02:00
|
|
|
{
|
2023-02-04 19:59:29 +01:00
|
|
|
int x, y;
|
2018-04-13 18:23:45 +02:00
|
|
|
rgba_t color;
|
2023-02-03 06:51:16 +01:00
|
|
|
cl_font_t *font = Con_GetCurFont();
|
2018-04-13 18:23:45 +02:00
|
|
|
|
2023-02-03 06:51:16 +01:00
|
|
|
x = refState.width - 340 * font->scale;
|
2018-04-13 18:23:45 +02:00
|
|
|
y = 64;
|
|
|
|
|
|
|
|
MakeRGBA( color, 255, 255, 255, 255 );
|
2023-02-04 19:59:29 +01:00
|
|
|
CL_DrawString( x, y, msg, color, font, FONT_DRAW_RESETCOLORONLF );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_MakeLevelShot
|
|
|
|
|
|
|
|
creates levelshot at next frame
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_MakeLevelShot( void )
|
|
|
|
{
|
|
|
|
if( cls.scrshot_request != scrshot_plaque )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// make levelshot at nextframe()
|
|
|
|
Cbuf_AddText( "levelshot\n" );
|
|
|
|
}
|
|
|
|
|
2019-03-06 14:23:33 +01:00
|
|
|
/*
|
|
|
|
===============
|
|
|
|
VID_WriteOverviewScript
|
|
|
|
|
|
|
|
Create overview script file
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void VID_WriteOverviewScript( void )
|
|
|
|
{
|
|
|
|
ref_overview_t *ov = &clgame.overView;
|
|
|
|
string filename;
|
|
|
|
file_t *f;
|
|
|
|
|
|
|
|
Q_snprintf( filename, sizeof( filename ), "overviews/%s.txt", clgame.mapname );
|
|
|
|
|
|
|
|
f = FS_Open( filename, "w", false );
|
|
|
|
if( !f ) return;
|
|
|
|
|
|
|
|
FS_Printf( f, "// overview description file for %s.bsp\n\n", clgame.mapname );
|
|
|
|
FS_Print( f, "global\n{\n" );
|
|
|
|
FS_Printf( f, "\tZOOM\t%.2f\n", ov->flZoom );
|
|
|
|
FS_Printf( f, "\tORIGIN\t%.2f\t%.2f\t%.2f\n", ov->origin[0], ov->origin[1], ov->origin[2] );
|
|
|
|
FS_Printf( f, "\tROTATED\t%i\n", ov->rotated ? 1 : 0 );
|
|
|
|
FS_Print( f, "}\n\nlayer\n{\n" );
|
|
|
|
FS_Printf( f, "\tIMAGE\t\"overviews/%s.bmp\"\n", clgame.mapname );
|
|
|
|
FS_Printf( f, "\tHEIGHT\t%.2f\n", ov->zFar ); // ???
|
|
|
|
FS_Print( f, "}\n" );
|
|
|
|
|
|
|
|
FS_Close( f );
|
|
|
|
}
|
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_MakeScreenShot
|
|
|
|
|
|
|
|
create a requested screenshot type
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_MakeScreenShot( void )
|
|
|
|
{
|
|
|
|
qboolean iRet = false;
|
|
|
|
int viewsize;
|
|
|
|
|
|
|
|
if( cls.envshot_viewsize > 0 )
|
|
|
|
viewsize = cls.envshot_viewsize;
|
2023-05-19 06:02:34 +02:00
|
|
|
else viewsize = cl_envshot_size.value;
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
switch( cls.scrshot_action )
|
|
|
|
{
|
|
|
|
case scrshot_normal:
|
2019-02-18 19:25:26 +01:00
|
|
|
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_SCREENSHOT );
|
2018-04-13 18:23:45 +02:00
|
|
|
break;
|
|
|
|
case scrshot_snapshot:
|
2019-02-18 19:25:26 +01:00
|
|
|
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_SNAPSHOT );
|
2018-04-13 18:23:45 +02:00
|
|
|
break;
|
|
|
|
case scrshot_plaque:
|
2019-02-18 19:25:26 +01:00
|
|
|
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_LEVELSHOT );
|
2018-04-13 18:23:45 +02:00
|
|
|
break;
|
|
|
|
case scrshot_savegame:
|
2019-02-18 19:25:26 +01:00
|
|
|
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_MINISHOT );
|
2018-04-13 18:23:45 +02:00
|
|
|
break;
|
|
|
|
case scrshot_envshot:
|
2019-02-18 19:25:26 +01:00
|
|
|
iRet = ref.dllFuncs.VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, false );
|
2018-04-13 18:23:45 +02:00
|
|
|
break;
|
|
|
|
case scrshot_skyshot:
|
2019-02-18 19:25:26 +01:00
|
|
|
iRet = ref.dllFuncs.VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, true );
|
2018-04-13 18:23:45 +02:00
|
|
|
break;
|
|
|
|
case scrshot_mapshot:
|
2019-02-18 19:25:26 +01:00
|
|
|
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_MAPSHOT );
|
2019-03-06 14:23:33 +01:00
|
|
|
if( iRet )
|
|
|
|
VID_WriteOverviewScript(); // store overview script too
|
2018-04-13 18:23:45 +02:00
|
|
|
break;
|
|
|
|
case scrshot_inactive:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// report
|
|
|
|
if( iRet )
|
|
|
|
{
|
2020-05-12 01:00:31 +02:00
|
|
|
// snapshots don't writes message about image
|
2018-04-13 18:23:45 +02:00
|
|
|
if( cls.scrshot_action != scrshot_snapshot )
|
2018-10-04 08:08:48 +02:00
|
|
|
Con_Reportf( "Write %s\n", cls.shotname );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
2018-10-04 08:08:48 +02:00
|
|
|
else Con_Printf( S_ERROR "Unable to write %s\n", cls.shotname );
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
cls.envshot_vieworg = NULL;
|
|
|
|
cls.scrshot_action = scrshot_inactive;
|
|
|
|
cls.envshot_disable_vis = false;
|
|
|
|
cls.envshot_viewsize = 0;
|
|
|
|
cls.shotname[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_DrawPlaque
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_DrawPlaque( void )
|
|
|
|
{
|
2023-05-19 06:02:34 +02:00
|
|
|
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background )
|
2018-04-13 18:23:45 +02:00
|
|
|
{
|
2023-05-19 06:02:34 +02:00
|
|
|
int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name.string, NULL, 0, TF_IMAGE );
|
2019-02-18 19:25:26 +01:00
|
|
|
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
|
|
|
|
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
|
2018-04-13 18:23:45 +02:00
|
|
|
if( !cl.background ) CL_DrawHUD( CL_LOADING );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_BeginLoadingPlaque
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_BeginLoadingPlaque( qboolean is_background )
|
|
|
|
{
|
2020-05-12 01:00:31 +02:00
|
|
|
float oldclear = 0;;
|
2018-04-13 18:23:45 +02:00
|
|
|
S_StopAllSounds( true );
|
|
|
|
cl.audio_prepped = false; // don't play ambients
|
2019-06-17 06:05:36 +02:00
|
|
|
cl.video_prepped = false;
|
2020-01-11 17:01:55 +01:00
|
|
|
|
|
|
|
if( !Host_IsDedicated() )
|
2023-05-19 04:55:06 +02:00
|
|
|
oldclear = gl_clear.value;
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
|
|
|
|
{
|
2019-10-06 06:43:57 +02:00
|
|
|
UI_SetActiveMenu( false );
|
2019-12-23 04:32:33 +01:00
|
|
|
if( cls.state == ca_disconnected && !(GameState->curstate == STATE_RUNFRAME && GameState->nextstate != STATE_RUNFRAME) )
|
2018-04-13 18:23:45 +02:00
|
|
|
SCR_UpdateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( cls.state == ca_disconnected || cls.disable_screen )
|
|
|
|
return; // already set
|
|
|
|
|
|
|
|
if( cls.key_dest == key_console )
|
|
|
|
return;
|
|
|
|
|
2020-01-11 17:01:55 +01:00
|
|
|
if( !Host_IsDedicated() )
|
2023-05-19 04:55:06 +02:00
|
|
|
gl_clear.value = 0.0f;
|
2020-01-11 17:01:55 +01:00
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
if( is_background ) IN_MouseSavePos( );
|
|
|
|
cls.draw_changelevel = !is_background;
|
|
|
|
SCR_UpdateScreen();
|
|
|
|
cls.disable_screen = host.realtime;
|
|
|
|
cl.background = is_background; // set right state before svc_serverdata is came
|
2020-01-11 17:01:55 +01:00
|
|
|
|
|
|
|
if( !Host_IsDedicated() )
|
2023-05-19 04:55:06 +02:00
|
|
|
gl_clear.value = oldclear;
|
2020-01-12 00:39:30 +01:00
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
// SNDDMA_LockSound();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_EndLoadingPlaque
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_EndLoadingPlaque( void )
|
|
|
|
{
|
|
|
|
cls.disable_screen = 0.0f;
|
|
|
|
Con_ClearNotify();
|
|
|
|
// SNDDMA_UnlockSound();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SCR_AddDirtyPoint
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void SCR_AddDirtyPoint( int x, int y )
|
|
|
|
{
|
|
|
|
if( x < scr_dirty.x1 ) scr_dirty.x1 = x;
|
|
|
|
if( x > scr_dirty.x2 ) scr_dirty.x2 = x;
|
|
|
|
if( y < scr_dirty.y1 ) scr_dirty.y1 = y;
|
|
|
|
if( y > scr_dirty.y2 ) scr_dirty.y2 = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_DirtyScreen
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_DirtyScreen( void )
|
|
|
|
{
|
|
|
|
SCR_AddDirtyPoint( 0, 0 );
|
2019-02-18 19:25:26 +01:00
|
|
|
SCR_AddDirtyPoint( refState.width - 1, refState.height - 1 );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_TileClear
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_TileClear( void )
|
|
|
|
{
|
|
|
|
int i, top, bottom, left, right;
|
|
|
|
dirty_t clear;
|
|
|
|
|
2023-05-19 06:02:34 +02:00
|
|
|
if( scr_viewsize.value >= 120 )
|
2018-04-13 18:23:45 +02:00
|
|
|
return; // full screen rendering
|
|
|
|
|
|
|
|
// erase rect will be the union of the past three frames
|
|
|
|
// so tripple buffering works properly
|
|
|
|
clear = scr_dirty;
|
|
|
|
|
|
|
|
for( i = 0; i < 2; i++ )
|
|
|
|
{
|
|
|
|
if( scr_old_dirty[i].x1 < clear.x1 )
|
|
|
|
clear.x1 = scr_old_dirty[i].x1;
|
|
|
|
if( scr_old_dirty[i].x2 > clear.x2 )
|
|
|
|
clear.x2 = scr_old_dirty[i].x2;
|
|
|
|
if( scr_old_dirty[i].y1 < clear.y1 )
|
|
|
|
clear.y1 = scr_old_dirty[i].y1;
|
|
|
|
if( scr_old_dirty[i].y2 > clear.y2 )
|
|
|
|
clear.y2 = scr_old_dirty[i].y2;
|
|
|
|
}
|
|
|
|
|
|
|
|
scr_old_dirty[1] = scr_old_dirty[0];
|
|
|
|
scr_old_dirty[0] = scr_dirty;
|
|
|
|
|
|
|
|
scr_dirty.x1 = 9999;
|
|
|
|
scr_dirty.x2 = -9999;
|
|
|
|
scr_dirty.y1 = 9999;
|
|
|
|
scr_dirty.y2 = -9999;
|
|
|
|
|
|
|
|
if( clear.y2 <= clear.y1 )
|
|
|
|
return; // nothing disturbed
|
|
|
|
|
2018-10-04 08:08:48 +02:00
|
|
|
top = clgame.viewport[1];
|
|
|
|
bottom = top + clgame.viewport[3] - 1;
|
|
|
|
left = clgame.viewport[0];
|
|
|
|
right = left + clgame.viewport[2] - 1;
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
if( clear.y1 < top )
|
2020-05-12 01:00:31 +02:00
|
|
|
{
|
2018-04-13 18:23:45 +02:00
|
|
|
// clear above view screen
|
|
|
|
i = clear.y2 < top-1 ? clear.y2 : top - 1;
|
2019-02-24 16:45:27 +01:00
|
|
|
ref.dllFuncs.R_DrawTileClear( cls.tileImage, clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1 );
|
2018-04-13 18:23:45 +02:00
|
|
|
clear.y1 = top;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( clear.y2 > bottom )
|
2020-05-12 01:00:31 +02:00
|
|
|
{
|
2018-04-13 18:23:45 +02:00
|
|
|
// clear below view screen
|
|
|
|
i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1;
|
2019-02-24 16:45:27 +01:00
|
|
|
ref.dllFuncs.R_DrawTileClear( cls.tileImage, clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1 );
|
2018-04-13 18:23:45 +02:00
|
|
|
clear.y2 = bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( clear.x1 < left )
|
|
|
|
{
|
|
|
|
// clear left of view screen
|
|
|
|
i = clear.x2 < left - 1 ? clear.x2 : left - 1;
|
2019-02-24 16:45:27 +01:00
|
|
|
ref.dllFuncs.R_DrawTileClear( cls.tileImage, clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1 );
|
2018-04-13 18:23:45 +02:00
|
|
|
clear.x1 = left;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( clear.x2 > right )
|
2020-05-12 01:00:31 +02:00
|
|
|
{
|
2018-04-13 18:23:45 +02:00
|
|
|
// clear left of view screen
|
|
|
|
i = clear.x1 > right + 1 ? clear.x1 : right + 1;
|
2019-02-24 16:45:27 +01:00
|
|
|
ref.dllFuncs.R_DrawTileClear( cls.tileImage, i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1 );
|
2018-04-13 18:23:45 +02:00
|
|
|
clear.x2 = right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_UpdateScreen
|
|
|
|
|
|
|
|
This is called every frame, and can also be called explicitly to flush
|
|
|
|
text to the screen.
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void SCR_UpdateScreen( void )
|
|
|
|
{
|
|
|
|
if( !V_PreRender( )) return;
|
|
|
|
|
|
|
|
switch( cls.state )
|
|
|
|
{
|
|
|
|
case ca_disconnected:
|
|
|
|
Con_RunConsole ();
|
|
|
|
break;
|
|
|
|
case ca_connecting:
|
|
|
|
case ca_connected:
|
|
|
|
case ca_validate:
|
|
|
|
SCR_DrawPlaque();
|
|
|
|
break;
|
|
|
|
case ca_active:
|
|
|
|
Con_RunConsole ();
|
|
|
|
V_RenderView();
|
|
|
|
break;
|
|
|
|
case ca_cinematic:
|
|
|
|
SCR_DrawCinematic();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Host_Error( "SCR_UpdateScreen: bad cls.state\n" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_PostRender();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_LoadCreditsFont
|
|
|
|
|
|
|
|
INTERNAL RESOURCE
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_LoadCreditsFont( void )
|
|
|
|
{
|
2023-01-25 00:37:30 +01:00
|
|
|
cl_font_t *const font = &cls.creditsFont;
|
2022-12-29 23:58:26 +01:00
|
|
|
qboolean success = false;
|
2023-05-19 05:49:14 +02:00
|
|
|
float scale = hud_fontscale.value;
|
2022-12-29 23:58:26 +01:00
|
|
|
dword crc = 0;
|
2018-04-17 02:54:07 +02:00
|
|
|
|
|
|
|
// replace default gfx.wad textures by current charset's font
|
|
|
|
if( !CRC32_File( &crc, "gfx.wad" ) || crc == 0x49eb9f16 )
|
|
|
|
{
|
2022-12-29 23:58:26 +01:00
|
|
|
string charsetFnt;
|
|
|
|
|
|
|
|
if( Q_snprintf( charsetFnt, sizeof( charsetFnt ),
|
|
|
|
"creditsfont_%s.fnt", Cvar_VariableString( "con_charset" )) > 0 )
|
|
|
|
{
|
|
|
|
if( FS_FileExists( charsetFnt, false ))
|
2023-02-03 06:51:16 +01:00
|
|
|
success = Con_LoadVariableWidthFont( charsetFnt, font, scale, kRenderTransAdd, TF_FONT );
|
2022-12-29 23:58:26 +01:00
|
|
|
}
|
2018-04-17 02:54:07 +02:00
|
|
|
}
|
|
|
|
|
2023-01-27 17:07:26 +01:00
|
|
|
if( !success )
|
2023-02-03 06:51:16 +01:00
|
|
|
success = Con_LoadVariableWidthFont( "gfx/creditsfont.fnt", font, scale, kRenderTransAdd, TF_FONT );
|
2023-01-27 17:07:26 +01:00
|
|
|
|
|
|
|
if( !success )
|
2023-02-03 06:51:16 +01:00
|
|
|
success = Con_LoadFixedWidthFont( "gfx/conchars", font, scale, kRenderTransAdd, TF_FONT );
|
2023-01-25 00:37:30 +01:00
|
|
|
|
|
|
|
// copy font size for client.dll
|
|
|
|
if( success )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
clgame.scrInfo.iCharHeight = cls.creditsFont.charHeight;
|
|
|
|
|
|
|
|
for( i = 0; i < ARRAYSIZE( cls.creditsFont.charWidths ); i++ )
|
|
|
|
clgame.scrInfo.charWidths[i] = cls.creditsFont.charWidths[i];
|
|
|
|
}
|
2023-01-27 17:07:26 +01:00
|
|
|
else Con_DPrintf( S_ERROR "failed to load HUD font\n" );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_InstallParticlePalette
|
|
|
|
|
|
|
|
INTERNAL RESOURCE
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_InstallParticlePalette( void )
|
|
|
|
{
|
|
|
|
rgbdata_t *pic;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// first check 'palette.lmp' then 'palette.pal'
|
2018-06-12 11:14:56 +02:00
|
|
|
pic = FS_LoadImage( DEFAULT_INTERNAL_PALETTE, NULL, 0 );
|
|
|
|
if( !pic ) pic = FS_LoadImage( DEFAULT_EXTERNAL_PALETTE, NULL, 0 );
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
// NOTE: imagelib required this fakebuffer for loading internal palette
|
|
|
|
if( !pic ) pic = FS_LoadImage( "#valve.pal", (byte *)&i, 768 );
|
|
|
|
|
|
|
|
if( pic )
|
|
|
|
{
|
|
|
|
for( i = 0; i < 256; i++ )
|
|
|
|
{
|
|
|
|
clgame.palette[i].r = pic->palette[i*4+0];
|
|
|
|
clgame.palette[i].g = pic->palette[i*4+1];
|
|
|
|
clgame.palette[i].b = pic->palette[i*4+2];
|
|
|
|
}
|
|
|
|
FS_FreeImage( pic );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-12 11:14:56 +02:00
|
|
|
// someone deleted internal palette from code...
|
2018-04-13 18:23:45 +02:00
|
|
|
for( i = 0; i < 256; i++ )
|
|
|
|
{
|
|
|
|
clgame.palette[i].r = i;
|
|
|
|
clgame.palette[i].g = i;
|
|
|
|
clgame.palette[i].b = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SCR_RegisterTextures
|
|
|
|
|
|
|
|
INTERNAL RESOURCE
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SCR_RegisterTextures( void )
|
|
|
|
{
|
|
|
|
// register gfx.wad images
|
|
|
|
|
|
|
|
if( FS_FileExists( "gfx/paused.lmp", false ))
|
2019-03-15 19:23:59 +01:00
|
|
|
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
|
2018-04-13 18:23:45 +02:00
|
|
|
else if( FS_FileExists( "gfx/pause.lmp", false ))
|
2019-03-15 19:23:59 +01:00
|
|
|
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
if( FS_FileExists( "gfx/lambda.lmp", false ))
|
|
|
|
{
|
2023-05-19 06:02:34 +02:00
|
|
|
if( cl_allow_levelshots.value )
|
2019-03-15 19:23:59 +01:00
|
|
|
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
|
|
|
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
else if( FS_FileExists( "gfx/loading.lmp", false ))
|
|
|
|
{
|
2023-05-19 06:02:34 +02:00
|
|
|
if( cl_allow_levelshots.value )
|
2019-03-15 19:23:59 +01:00
|
|
|
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
|
|
|
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
2020-05-12 01:00:31 +02:00
|
|
|
|
2019-03-15 19:23:59 +01:00
|
|
|
cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SCR_SizeUp_f
|
|
|
|
|
|
|
|
Keybinding command
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void SCR_SizeUp_f( void )
|
|
|
|
{
|
2023-05-19 06:02:34 +02:00
|
|
|
Cvar_SetValue( "viewsize", Q_min( scr_viewsize.value + 10, 120 ));
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SCR_SizeDown_f
|
|
|
|
|
|
|
|
Keybinding command
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void SCR_SizeDown_f( void )
|
|
|
|
{
|
2023-05-19 06:02:34 +02:00
|
|
|
Cvar_SetValue( "viewsize", Q_max( scr_viewsize.value - 10, 30 ));
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_VidInit
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void SCR_VidInit( void )
|
|
|
|
{
|
2019-11-28 15:43:06 +01:00
|
|
|
if( !ref.initialized ) // don't call VidInit too soon
|
|
|
|
return;
|
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
memset( &clgame.ds, 0, sizeof( clgame.ds )); // reset a draw state
|
|
|
|
memset( &gameui.ds, 0, sizeof( gameui.ds )); // reset a draw state
|
|
|
|
memset( &clgame.centerPrint, 0, sizeof( clgame.centerPrint ));
|
|
|
|
|
|
|
|
// update screen sizes for menu
|
2018-04-24 04:50:10 +02:00
|
|
|
if( gameui.globals )
|
|
|
|
{
|
2019-02-18 19:25:26 +01:00
|
|
|
gameui.globals->scrWidth = refState.width;
|
|
|
|
gameui.globals->scrHeight = refState.height;
|
2018-04-24 04:50:10 +02:00
|
|
|
}
|
2018-04-13 18:23:45 +02:00
|
|
|
|
2022-11-10 17:56:31 +01:00
|
|
|
// notify vgui about screen size change
|
|
|
|
if( clgame.hInstance )
|
|
|
|
{
|
|
|
|
VGui_Startup( refState.width, refState.height );
|
|
|
|
}
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
CL_ClearSpriteTextures(); // now all hud sprites are invalid
|
2020-05-12 01:00:31 +02:00
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
// vid_state has changed
|
|
|
|
if( gameui.hInstance ) gameui.dllFuncs.pfnVidInit();
|
|
|
|
if( clgame.hInstance ) clgame.dllFuncs.pfnVidInit();
|
|
|
|
|
|
|
|
// restart console size
|
|
|
|
Con_VidInit ();
|
2023-10-22 05:48:10 +02:00
|
|
|
Touch_NotifyResize();
|
2018-04-13 18:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_Init
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void SCR_Init( void )
|
|
|
|
{
|
|
|
|
if( scr_init ) return;
|
|
|
|
|
2023-05-19 06:02:34 +02:00
|
|
|
Cvar_RegisterVariable( &scr_centertime );
|
|
|
|
Cvar_RegisterVariable( &cl_levelshot_name );
|
|
|
|
Cvar_RegisterVariable( &cl_allow_levelshots );
|
|
|
|
Cvar_RegisterVariable( &scr_loading );
|
|
|
|
Cvar_RegisterVariable( &scr_download );
|
|
|
|
Cvar_RegisterVariable( &cl_testlights );
|
|
|
|
Cvar_RegisterVariable( &cl_envshot_size );
|
|
|
|
Cvar_RegisterVariable( &v_dark );
|
|
|
|
Cvar_RegisterVariable( &scr_viewsize );
|
|
|
|
Cvar_RegisterVariable( &net_speeds );
|
|
|
|
Cvar_RegisterVariable( &cl_showfps );
|
|
|
|
Cvar_RegisterVariable( &cl_showpos );
|
2020-05-12 01:00:31 +02:00
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
// register our commands
|
|
|
|
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
|
2018-06-19 15:22:30 +02:00
|
|
|
Cmd_AddCommand( "loadsky", CL_SetSky_f, "set new skybox by basename" );
|
2018-04-13 18:23:45 +02:00
|
|
|
Cmd_AddCommand( "viewpos", SCR_Viewpos_f, "prints current player origin" );
|
|
|
|
Cmd_AddCommand( "sizeup", SCR_SizeUp_f, "screen size up to 10 points" );
|
|
|
|
Cmd_AddCommand( "sizedown", SCR_SizeDown_f, "screen size down to 10 points" );
|
|
|
|
|
|
|
|
if( !UI_LoadProgs( ))
|
|
|
|
{
|
2019-11-26 00:47:25 +01:00
|
|
|
Con_Printf( S_ERROR "can't initialize gameui DLL: %s\n", COM_GetLibraryError() ); // there is non fatal for us
|
2018-04-13 18:23:45 +02:00
|
|
|
host.allow_console = true; // we need console, because menu is missing
|
|
|
|
}
|
|
|
|
|
2018-06-12 11:14:56 +02:00
|
|
|
SCR_VidInit();
|
2018-04-13 18:23:45 +02:00
|
|
|
SCR_LoadCreditsFont ();
|
|
|
|
SCR_RegisterTextures ();
|
2018-06-12 11:14:56 +02:00
|
|
|
SCR_InstallParticlePalette ();
|
2018-04-13 18:23:45 +02:00
|
|
|
SCR_InitCinematic();
|
|
|
|
CL_InitNetgraph();
|
|
|
|
|
|
|
|
if( host.allow_console && Sys_CheckParm( "-toconsole" ))
|
|
|
|
Cbuf_AddText( "toggleconsole\n" );
|
|
|
|
else UI_SetActiveMenu( true );
|
|
|
|
|
|
|
|
scr_init = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCR_Shutdown( void )
|
|
|
|
{
|
|
|
|
if( !scr_init ) return;
|
|
|
|
|
|
|
|
Cmd_RemoveCommand( "timerefresh" );
|
|
|
|
Cmd_RemoveCommand( "skyname" );
|
|
|
|
Cmd_RemoveCommand( "viewpos" );
|
|
|
|
UI_SetActiveMenu( false );
|
|
|
|
UI_UnloadProgs();
|
|
|
|
|
|
|
|
scr_init = false;
|
2018-04-14 00:49:14 +02:00
|
|
|
}
|