mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-11 23:57:57 +00:00
engine: client: add generic handler for simple types of screenshots commands
This commit is contained in:
parent
02c5890c2f
commit
b3d8fb03bf
@ -157,32 +157,12 @@ void CL_PlayCDTrack_f( void )
|
||||
CL_ScreenshotGetName
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_ScreenshotGetName( int lastnum, char *filename, size_t size )
|
||||
static qboolean CL_ScreenshotGetName( const char *fmt, int lastnum, char *filename, size_t size )
|
||||
{
|
||||
if( lastnum < 0 || lastnum > 9999 )
|
||||
{
|
||||
Con_Printf( S_ERROR "unable to write screenshot\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return Q_snprintf( filename, size, "scrshots/%s_shot%04d.png", clgame.mapname, lastnum ) > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SnapshotGetName
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_SnapshotGetName( int lastnum, char *filename, size_t size )
|
||||
{
|
||||
if( lastnum < 0 || lastnum > 9999 )
|
||||
{
|
||||
Con_Printf( S_ERROR "unable to write snapshot\n" );
|
||||
FS_AllowDirectPaths( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
return Q_snprintf( filename, size, "../%s_%04d.png", clgame.mapname, lastnum ) > 0;
|
||||
return Q_snprintf( filename, size, fmt, clgame.mapname, lastnum ) > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -192,127 +172,6 @@ static qboolean CL_SnapshotGetName( int lastnum, char *filename, size_t size )
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
/*
|
||||
==================
|
||||
CL_ScreenShot_f
|
||||
|
||||
normal screenshot
|
||||
==================
|
||||
*/
|
||||
void CL_ScreenShot_f( void )
|
||||
{
|
||||
int i;
|
||||
string checkname;
|
||||
|
||||
if( CL_IsDevOverviewMode() == 1 )
|
||||
{
|
||||
// special case for write overview image and script file
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
|
||||
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
|
||||
}
|
||||
else
|
||||
{
|
||||
// scan for a free filename
|
||||
for( i = 0; i < 9999; i++ )
|
||||
{
|
||||
if( !CL_ScreenshotGetName( i, checkname, sizeof( checkname )))
|
||||
return; // no namespace
|
||||
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
break;
|
||||
}
|
||||
|
||||
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
|
||||
cls.scrshot_action = scrshot_normal; // build new frame for screenshot
|
||||
}
|
||||
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SnapShot_f
|
||||
|
||||
save screenshots into root dir
|
||||
==================
|
||||
*/
|
||||
void CL_SnapShot_f( void )
|
||||
{
|
||||
int i;
|
||||
string checkname;
|
||||
|
||||
if( CL_IsDevOverviewMode() == 1 )
|
||||
{
|
||||
// special case for write overview image and script file
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
|
||||
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
|
||||
}
|
||||
else
|
||||
{
|
||||
FS_AllowDirectPaths( true );
|
||||
|
||||
// scan for a free filename
|
||||
for( i = 0; i < 9999; i++ )
|
||||
{
|
||||
if( !CL_SnapshotGetName( i, checkname, sizeof( checkname )))
|
||||
return; // no namespace
|
||||
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
break;
|
||||
}
|
||||
|
||||
FS_AllowDirectPaths( false );
|
||||
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
|
||||
cls.scrshot_action = scrshot_snapshot; // build new frame for screenshot
|
||||
}
|
||||
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_EnvShot_f
|
||||
|
||||
cubemap view
|
||||
==================
|
||||
*/
|
||||
void CL_EnvShot_f( void )
|
||||
{
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "envshot <shotname>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
|
||||
cls.scrshot_action = scrshot_envshot; // build new frame for envshot
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SkyShot_f
|
||||
|
||||
skybox view
|
||||
==================
|
||||
*/
|
||||
void CL_SkyShot_f( void )
|
||||
{
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "skyshot <shotname>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ),"gfx/env/%s", Cmd_Argv( 1 ));
|
||||
cls.scrshot_action = scrshot_skyshot; // build new frame for skyshot
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_LevelShot_f
|
||||
@ -355,23 +214,100 @@ void CL_LevelShot_f( void )
|
||||
else cls.scrshot_action = scrshot_inactive; // disable - not needs
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SaveShot_f
|
||||
|
||||
mini-pic in loadgame menu
|
||||
==================
|
||||
*/
|
||||
void CL_SaveShot_f( void )
|
||||
static scrshot_t CL_GetScreenshotTypeFromString( const char *string )
|
||||
{
|
||||
if( !Q_stricmp( string, "snapshot" ))
|
||||
return scrshot_snapshot;
|
||||
|
||||
if( !Q_stricmp( string, "screenshot" ))
|
||||
return scrshot_normal;
|
||||
|
||||
if( !Q_stricmp( string, "saveshot" ))
|
||||
return scrshot_savegame;
|
||||
|
||||
if( !Q_stricmp( string, "envshot" ))
|
||||
return scrshot_envshot;
|
||||
|
||||
if( !Q_stricmp( string, "skyshot" ))
|
||||
return scrshot_skyshot;
|
||||
|
||||
return scrshot_inactive;
|
||||
}
|
||||
|
||||
void CL_GenericShot_f( void )
|
||||
{
|
||||
const char *argv0 = Cmd_Argv( 0 );
|
||||
scrshot_t type;
|
||||
|
||||
type = CL_GetScreenshotTypeFromString( argv0 );
|
||||
|
||||
if( type == scrshot_normal || type == scrshot_snapshot )
|
||||
{
|
||||
if( CL_IsDevOverviewMode() == 1 )
|
||||
type = scrshot_mapshot;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "saveshot <savename>\n" );
|
||||
Con_Printf( S_USAGE "%s <shotname>\n", argv0 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case scrshot_envshot:
|
||||
case scrshot_skyshot:
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
|
||||
break;
|
||||
case scrshot_savegame:
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
|
||||
break;
|
||||
case scrshot_mapshot:
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
|
||||
break;
|
||||
case scrshot_normal:
|
||||
case scrshot_snapshot:
|
||||
{
|
||||
const char *fmt;
|
||||
string checkname;
|
||||
int i;
|
||||
|
||||
if( type == scrshot_snapshot )
|
||||
{
|
||||
fmt = "../%s_%04d.png";
|
||||
FS_AllowDirectPaths( true );
|
||||
}
|
||||
else fmt = "scrshots/%s_shot%04d.png";
|
||||
|
||||
for( i = 0; i < 9999; i++ )
|
||||
{
|
||||
if( !CL_ScreenshotGetName( fmt, i, checkname, sizeof( checkname )))
|
||||
{
|
||||
Con_Printf( S_ERROR "unable to write %s\n", argv0 );
|
||||
FS_AllowDirectPaths( false );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
|
||||
cls.scrshot_action = scrshot_savegame; // build new frame for saveshot
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
break;
|
||||
}
|
||||
|
||||
FS_AllowDirectPaths( false );
|
||||
|
||||
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
|
||||
break;
|
||||
}
|
||||
case scrshot_inactive:
|
||||
case scrshot_plaque:
|
||||
default:
|
||||
return; // shouldn't happen
|
||||
}
|
||||
|
||||
cls.scrshot_action = type; // build new frame for saveshot
|
||||
cls.envshot_vieworg = NULL;
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2981,12 +2981,12 @@ static void CL_InitLocal( void )
|
||||
Cmd_AddRestrictedCommand ("quit", CL_Quit_f, "quit from game" );
|
||||
Cmd_AddRestrictedCommand ("exit", CL_Quit_f, "quit from game" );
|
||||
|
||||
Cmd_AddCommand ("screenshot", CL_ScreenShot_f, "takes a screenshot of the next rendered frame" );
|
||||
Cmd_AddCommand ("snapshot", CL_SnapShot_f, "takes a snapshot of the next rendered frame" );
|
||||
Cmd_AddCommand ("envshot", CL_EnvShot_f, "takes a six-sides cubemap shot with specified name" );
|
||||
Cmd_AddCommand ("skyshot", CL_SkyShot_f, "takes a six-sides envmap (skybox) shot with specified name" );
|
||||
Cmd_AddCommand ("screenshot", CL_GenericShot_f, "takes a screenshot of the next rendered frame" );
|
||||
Cmd_AddCommand ("snapshot", CL_GenericShot_f, "takes a snapshot of the next rendered frame" );
|
||||
Cmd_AddCommand ("envshot", CL_GenericShot_f, "takes a six-sides cubemap shot with specified name" );
|
||||
Cmd_AddCommand ("skyshot", CL_GenericShot_f, "takes a six-sides envmap (skybox) shot with specified name" );
|
||||
Cmd_AddCommand ("levelshot", CL_LevelShot_f, "same as \"screenshot\", used for create plaque images" );
|
||||
Cmd_AddCommand ("saveshot", CL_SaveShot_f, "used for create save previews with LoadGame menu" );
|
||||
Cmd_AddCommand ("saveshot", CL_GenericShot_f, "used for create save previews with LoadGame menu" );
|
||||
|
||||
Cmd_AddCommand ("connect", CL_Connect_f, "connect to a server by hostname" );
|
||||
Cmd_AddCommand ("reconnect", CL_Reconnect_f, "reconnect to current level" );
|
||||
|
@ -705,7 +705,6 @@ extern convar_t cl_fixmodelinterpolationartifacts;
|
||||
//=============================================================================
|
||||
|
||||
void CL_SetLightstyle( int style, const char* s, float f );
|
||||
void CL_RunLightStyles( void );
|
||||
void CL_DecayLights( void );
|
||||
dlight_t *CL_GetDynamicLight( int number );
|
||||
dlight_t *CL_GetEntityLight( int number );
|
||||
@ -716,12 +715,8 @@ dlight_t *CL_GetEntityLight( int number );
|
||||
// cl_cmds.c
|
||||
//
|
||||
void CL_Quit_f( void );
|
||||
void CL_ScreenShot_f( void );
|
||||
void CL_SnapShot_f( void );
|
||||
void CL_GenericShot_f( void );
|
||||
void CL_PlayCDTrack_f( void );
|
||||
void CL_EnvShot_f( void );
|
||||
void CL_SkyShot_f( void );
|
||||
void CL_SaveShot_f( void );
|
||||
void CL_LevelShot_f( void );
|
||||
void CL_SetSky_f( void );
|
||||
void SCR_Viewpos_f( void );
|
||||
|
Loading…
Reference in New Issue
Block a user