Example #1
0
/* 
================== 
R_ScreenShotTGA_f

screenshot
screenshot [silent]
screenshot [levelshot]
screenshot [filename]

Doesn't print the pacifier message if there is a second arg
================== 
*/  
void R_ScreenShotTGA_f (void) {
#ifndef _XBOX
	char		checkname[MAX_OSPATH];
	int			len;
	static	int	lastNumber = -1;
	qboolean	silent;

	if ( !strcmp( Cmd_Argv(1), "levelshot" ) ) {
		R_LevelShot();
		return;
	}
	if ( !strcmp( Cmd_Argv(1), "silent" ) ) {
		silent = qtrue;
	} else {
		silent = qfalse;
	}

	if ( Cmd_Argc() == 2 && !silent ) {
		// explicit filename
		Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", Cmd_Argv( 1 ) );
	} else {
		// scan for a free filename

		// if we have saved a previous screenshot, don't scan
		// again, because recording demo avis can involve
		// thousands of shots
		if ( lastNumber == -1 ) {
			// scan for a free number
			for ( lastNumber = 0 ; lastNumber <= 9999 ; lastNumber++ ) {
				R_ScreenshotFilename( lastNumber, checkname, ".tga" );

				len = FS_ReadFile( checkname, NULL );
				if ( len <= 0 ) {
					break;	// file doesn't exist
				}
			}
		} else {
			R_ScreenshotFilename( lastNumber, checkname, ".tga" );
		}

		if ( lastNumber == 10000 ) {
			VID_Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); 
			return;
 		}

		lastNumber++;
	}


	R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );

	if ( !silent ) {
		VID_Printf (PRINT_ALL, "Wrote %s\n", checkname);
	}
#endif
} 
Example #2
0
void R_ScreenShotPNG_f (void) {
	char	checkname[MAX_OSPATH];
	static	int	lastNumber = -1;
	qboolean	silent;
	qboolean	levelshot;

	if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) {
		R_LevelShot( ST_PNG, ".png" );
		levelshot = qtrue;
	} else {
		levelshot = qfalse;
	}

	if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) {
		silent = qtrue;
	} else {
		silent = qfalse;
	}

	if ( levelshot ) {
		sprintf( checkname, "levelshots/%s.png", tr.world->baseName );
	} else if ( ri.Cmd_Argc() == 2 && !silent ) {
		// explicit filename
		Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.png", ri.Cmd_Argv( 1 ) );
	} else {
		// scan for a free filename

		// if we have saved a previous screenshot, don't scan
		// again, because recording demo avis can involve
		// thousands of shots
		if ( lastNumber == -1 ) {
			lastNumber = 0;
		}
		// scan for a free number
		for ( ; lastNumber <= 9999 ; lastNumber++ ) {
			R_ScreenshotFilename( lastNumber, checkname, ".png" );

      if (!ri.FS_FileExists( checkname ))
      {
        break; // file doesn't exist
      }
		}

		if ( lastNumber >= 9999 ) {
			ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); 
			return;
 		}

		lastNumber++;
	}

	R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, ST_PNG );

	if ( !silent ) {
		ri.Printf (PRINT_ALL, "Wrote %s\n", checkname);
	}
}
Example #3
0
/*
 * R_ScreenShot_f
 *
 * screenshot
 * screenshot [silent]
 * screenshot [levelshot]
 * screenshot [filename]
 *
 * Doesn't print the pacifier message if there is a second arg
 */
void
R_ScreenShot_f(void)
{
	char checkname[MAX_OSPATH];
	static int	lastNumber = -1;
	qbool		silent;

	if(!strcmp(ri.cmdargv(1), "levelshot")){
		R_LevelShot();
		return;
	}

	if(!strcmp(ri.cmdargv(1), "silent")){
		silent = qtrue;
	}else{
		silent = qfalse;
	}

	if(ri.cmdargc() == 2 && !silent){
		/* explicit filename */
		Q_sprintf(checkname, MAX_OSPATH, "screenshots/%s.tga", ri.cmdargv(1));
	}else{
		/* scan for a free filename */

		/* if we have saved a previous screenshot, don't scan
		 * again, because recording demo avis can involve
		 * thousands of shots */
		if(lastNumber == -1){
			lastNumber = 0;
		}
		/* scan for a free number */
		for(; lastNumber <= 9999; lastNumber++){
			R_ScreenshotFilename(lastNumber, checkname);

			if(!ri.fsfileexists(checkname)){
				break;	/* file doesn't exist */
			}
		}

		if(lastNumber >= 9999){
			ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n");
			return;
		}

		lastNumber++;
	}

	R_TakeScreenshot(0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qfalse);

	if(!silent){
		ri.Printf (PRINT_ALL, "Wrote %s\n", checkname);
	}
}
Example #4
0
//jpeg  vession
void R_ScreenShot_f (void) {
	char		checkname[MAX_OSPATH];
	static	int	lastNumber = -1;
	qboolean	silent;

	if ( !strcmp( Cmd_Argv(1), "levelshot" ) ) {
		R_LevelShot();
		return;
	}
	if ( !strcmp( Cmd_Argv(1), "silent" ) ) {
		silent = qtrue;
	} else {
		silent = qfalse;
	}

	if ( Cmd_Argc() == 2 && !silent ) {
		// explicit filename
		Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", Cmd_Argv( 1 ) );
	} else {
		// scan for a free filename

		// if we have saved a previous screenshot, don't scan
		// again, because recording demo avis can involve
		// thousands of shots
		if ( lastNumber == -1 ) {
			lastNumber = 0;
		}
		// scan for a free number
		for ( ; lastNumber <= 9999 ; lastNumber++ ) {
			R_ScreenshotFilename( lastNumber, checkname, ".jpg" );

			if (!FS_FileExists( checkname ))
			{
				break; // file doesn't exist
			}
		}

		if ( lastNumber == 10000 ) {
			Com_Printf ( "ScreenShot: Couldn't create a file\n"); 
			return;
 		}

		lastNumber++;
	}


	R_TakeScreenshotJPEG( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );

	if ( !silent ) {
		Com_Printf ( "Wrote %s\n", checkname);
	}
} 
Example #5
0
static bool R_FindAvailableScreenshotFilename( int& lastNumber, char* fileName, const char* Extension ) {
	// scan for a free number
	for (; lastNumber <= 9999; lastNumber++ ) {
		R_ScreenshotFilename( lastNumber, fileName, Extension );

		if ( !FS_FileExists( fileName ) ) {
			//	Next time start scanning here.
			lastNumber++;

			return true;	// file doesn't exist
		}
	}

	common->Printf( "ScreenShot: Couldn't create a file\n" );
	return false;
}
Example #6
0
/*
==================
R_ScreenShot_f

screenshot[JPEG|PNG] [silent | <filename>]
==================
*/
void R_ScreenShot_f( void )
{
	char       checkname[ MAX_OSPATH ];
	int        len;
	static int lastNumber = -1;
	ssFormat_t format;
	qboolean   silent;

	if ( !Q_stricmp( ri.Cmd_Argv( 0 ), "screenshotJPEG" ) )
	{
		format = SSF_JPEG;
	}
	else if ( !Q_stricmp( ri.Cmd_Argv( 0 ), "screenshotPNG" ) )
	{
		format = SSF_PNG;
	}
	else
	{
		format = SSF_TGA;
	}

	if ( !strcmp( ri.Cmd_Argv( 1 ), "silent" ) )
	{
		silent = qtrue;
	}
	else
	{
		silent = qfalse;
	}

	if ( ri.Cmd_Argc() == 2 && !silent )
	{
		// explicit filename
		switch ( format )
		{
			case SSF_TGA:
				Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri.Cmd_Argv( 1 ) );
				break;

			case SSF_JPEG:
				Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpeg", ri.Cmd_Argv( 1 ) );
				break;

			case SSF_PNG:
				Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.png", ri.Cmd_Argv( 1 ) );
				break;
		}
	}
	else
	{
		// scan for a free filename

		// if we have saved a previous screenshot, don't scan
		// again, because recording demo avis can involve
		// thousands of shots
		if ( lastNumber == -1 )
		{
			lastNumber = 0;
		}

		// scan for a free number
		for ( ; lastNumber <= 9999; lastNumber++ )
		{
			switch ( format )
			{
				case SSF_TGA:
					R_ScreenshotFilename( lastNumber, checkname );
					break;

				case SSF_JPEG:
					R_ScreenshotFilenameJPEG( lastNumber, checkname );
					break;

				case SSF_PNG:
					R_ScreenshotFilenamePNG( lastNumber, checkname );
					break;
			}

			len = ri.FS_ReadFile( checkname, NULL );

			if ( len <= 0 )
			{
				break; // file doesn't exist
			}
		}

		if ( lastNumber >= 10000 )
		{
			ri.Printf( PRINT_ALL, "ScreenShot: Couldn't create a file\n" );
			return;
		}

		lastNumber++;
	}

	switch ( format )
	{
		case SSF_TGA:
			R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );
			break;

		case SSF_JPEG:
			R_TakeScreenshotJPEG( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );
			break;

		case SSF_PNG:
			R_TakeScreenshotPNG( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );
			break;
	}

	if ( !silent )
	{
		ri.Printf( PRINT_ALL, "Wrote %s\n", checkname );
	}
}
Example #7
0
void idSessionLocal::HandleNoteCommands( const char *menuCommand ) {
	guiActive = NULL;

	if ( idStr::Icmp( menuCommand,  "note" ) == 0 && mapSpawned ) {

		idFile *file = NULL;
		for ( int tries = 0; tries < 10; tries++ ) {
			file = fileSystem->OpenExplicitFileRead( NOTEDATFILE );
			if ( file != NULL ) {
				break;
			}
			Sys_Sleep( 500 );
		}
		int noteNumber = 1000;
		if ( file ) {
			file->Read( &noteNumber, 4 );
			fileSystem->CloseFile( file );
		}

		int i;
		idStr str, noteNum, shotName, workName, fileName = "viewnotes/";
		idStrList fileList;

		const char *severity = NULL;
		const char *p = guiTakeNotes->State().GetString( "notefile" );
		if ( p == NULL || *p == '\0' ) {
			p = cvarSystem->GetCVarString( "ui_name" );
		}

		bool extended = guiTakeNotes->State().GetBool( "extended" );
		if ( extended ) {
			if ( guiTakeNotes->State().GetInt( "severity" ) == 1 ) {
				severity = "WishList_Viewnotes/";
			} else {
				severity = "MustFix_Viewnotes/";
			}
			fileName += severity;

			const idDecl *mapDecl = declManager->FindType(DECL_ENTITYDEF, mapSpawnData.serverInfo.GetString( "si_map" ), false );
			const idDeclEntityDef *mapInfo = static_cast<const idDeclEntityDef *>(mapDecl);

			if ( mapInfo ) {
				fileName += mapInfo->dict.GetString( "devname" );
			} else {
				fileName += mapSpawnData.serverInfo.GetString( "si_map" );
				fileName.StripFileExtension();
			}

			int count = guiTakeNotes->State().GetInt( "person_numsel" );
			if ( count == 0 ) {
				fileList.Append( fileName + "/Nobody" );
			} else {
				for ( i = 0; i < count; i++ ) {
					int person = guiTakeNotes->State().GetInt( va( "person_sel_%i", i ) );
					workName = fileName + "/";
					workName += guiTakeNotes->State().GetString( va( "person_item_%i", person ), "Nobody" );
					fileList.Append( workName );
				}
			}
		} else {
			fileName += "maps/";
			fileName += mapSpawnData.serverInfo.GetString( "si_map" );
			fileName.StripFileExtension();
			fileList.Append( fileName );
		}

		bool bCon = cvarSystem->GetCVarBool( "con_noPrint" );
		cvarSystem->SetCVarBool( "con_noPrint", true );
		for ( i = 0; i < fileList.Num(); i++ ) {
			workName = fileList[i];
			workName += "/";
			workName += p;
			int workNote = noteNumber;
			R_ScreenshotFilename( workNote, workName, shotName );

			noteNum = shotName;
			noteNum.StripPath();
			noteNum.StripFileExtension();

			if ( severity && *severity ) {
				workName = severity;
				workName += "viewNotes";
			}

			sprintf( str, "recordViewNotes \"%s\" \"%s\" \"%s\"\n", workName.c_str(), noteNum.c_str(), guiTakeNotes->State().GetString( "note" ) );
			
			cmdSystem->BufferCommandText( CMD_EXEC_NOW, str );
			cmdSystem->ExecuteCommandBuffer();

			UpdateScreen();
			renderSystem->TakeScreenshot( renderSystem->GetScreenWidth(), renderSystem->GetScreenHeight(), shotName, 1, NULL );
		}
		noteNumber++;

		for ( int tries = 0; tries < 10; tries++ ) {
			file = fileSystem->OpenExplicitFileWrite( "p:/viewnotes/notenumber.dat" );
			if ( file != NULL ) {
				break;
			}
			Sys_Sleep( 500 );
		}
		if ( file ) {
			file->Write( &noteNumber, 4 );
			fileSystem->CloseFile( file );
		}

		cmdSystem->BufferCommandText( CMD_EXEC_NOW, "closeViewNotes\n" );
		cvarSystem->SetCVarBool( "con_noPrint", bCon );
	}
}