Пример #1
0
void StatsReport::OnCommand( const char *command )
{
	if ( StringHasPrefix( command, "CategoryButton" ) )
	{
		int nCategory = command[ Q_strlen( "CategoryButton" ) ] - '0';
		SetStatCategory( nCategory );
	}

	BaseClass::OnCommand(command);
}
Пример #2
0
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
int CDmxEditApp::Main()
{
	// This bit of hackery allows us to access files on the harddrive
	g_pFullFileSystem->AddSearchPath( "", "LOCAL", PATH_ADD_TO_HEAD ); 

	if ( CommandLine()->CheckParm( "-h" ) || CommandLine()->CheckParm( "-help" ) )
	{
		PrintHelp();
		return 0;
	}

	if ( CommandLine()->CheckParm( "-wiki" ) )
	{
		PrintHelp( true );
		return 0;
	}

	CUtlStringMap< CUtlString > setVars;
	CUtlString sGame;

	const int nParamCount = CommandLine()->ParmCount();
	for ( int i = 0; i < nParamCount - 1; ++i )
	{
		const char *pCmd = CommandLine()->GetParm( i );
		const char *pArg = CommandLine()->GetParm( i + 1 );

		if ( StringHasPrefix( pCmd, "-s" ) )
		{
			const char *const pEquals = strchr( pArg, '=' );
			if ( !pEquals )
			{
				Warning( "Warning: Invalid command line args, no ='s in -set argument: %s %s\n", pCmd, pArg );
			}

			char buf[ BUFSIZ ];
			Q_strncpy( buf, pArg, pEquals - pArg + 1 );

			const CUtlString sKey( buf );
			CUtlString sVal( pEquals + 1 );

			if ( !isdigit( *sVal.Get() ) && *sVal.Get() != '-' && *sVal.Get() != '"' )
			{
				CUtlString sqVal( "\"" );
				sqVal += sVal;
				sqVal += "\"";
				sVal = sqVal;
			}

			setVars[ sKey ] = sVal;

			if ( !Q_stricmp( sKey.Get(), "game" ) && sGame.IsEmpty() )
			{
				sGame = sKey;
			}

			++i;
		}
		else if ( StringHasPrefix( pCmd, "-g" ) )
		{
			if ( *pArg == '"' )
			{
				sGame = pArg;
			}
			else
			{
				sGame = ( "\"" );
				sGame += pArg;
				sGame += "\"";
			}
		}
		else if ( StringHasPrefix( pCmd, "-nop4" ) )
		{
			// Don't issue warning on -nop4
		}
		else if ( StringHasPrefix( pCmd, "-" ) )
		{
			Warning( "Warning: Unknown command line argument: %s\n", pCmd );
		}
	}

	// Do Perforce Stuff
	if ( CommandLine()->FindParm( "-nop4" ) )
		g_p4factory->SetDummyMode( true );

	g_p4factory->SetOpenFileChangeList( "dmxedit" );

	for ( int i = CommandLine()->ParmCount() - 1; i >= 1; --i )
	{
		const char *pParam = CommandLine()->GetParm( i );
		if ( _access( pParam, 04 ) == 0 )
		{
			CDmxEditLua dmxEditLua;
			for ( int i = 0; i < setVars.GetNumStrings(); ++i )
			{
				dmxEditLua.SetVar( setVars.String( i ), setVars[ i ] );
			}

			if ( !sGame.IsEmpty() )
			{
				dmxEditLua.SetGame( sGame );
			}

			return dmxEditLua.DoIt( pParam );
		}
	}

	Error( "Cannot find any file to execute from passed command line arguments\n\n" );
	PrintHelp();

	return -1;
}