Example #1
0
int main( int argc, char* argv[] )
{
	//string sAppDir = GetUntilLast( argv[0], "\\" );

	/* This is a hacky thing to avoid messing with the command line arguments. Remove for normal usage.	*/
	//argc = 2; argv[1] = "wikiadventure://";
	/* End of hack thing. */

	char czFullName[ MAX_PATH + 1 ];
	GetModuleFileName( NULL, czFullName, MAX_PATH );
	
	g_sAppDir = GetUntilLast( czFullName, "\\" );

	DebugInfo( TypeInfo, string("Application directory: " + g_sAppDir).c_str() );

	// Init the debug log, if it is activated
#ifdef DEBUG_APP_LOG
	pDebugLog = new CDebugLogHandler( g_sAppDir +  "\\Log\\Debug.xml" );
	
	pDebugLog->AddTagTree( "Project" );
	pDebugLog->AddTag( "Name", "WikiDialog Reader" );
	pDebugLog->AddTag( "MainSourceDir", GetUntilLast( __FILE__, "\\" ) );
	pDebugLog->AddTag( "Compiled", COMPILE_TIMESTAMP );

	pDebugLog->AddTagTree( "CmdArguments" );
	for ( int i = 0; i < argc; ++i )
        pDebugLog->AddTag( "CmdArgument", argv[i] );
	pDebugLog->CloseTagTree(); // CmdArguments

	pDebugLog->AddTagTree( "LogEntries" );
#endif

	for ( int i = 0; i < argc; ++i )
		DebugInfo( TypeInfo, string("Command line: " + string(argv[i])).c_str() );

	if ( argc != 2 ) {
		DebugInfo( TypeWarning, "Application is called with an invalid number of arguments." );
		argc = 2; argv[1] = "";
	}

	string sGamePage = GetAfterLast( argv[1], "//" );
	// Remove "/" from text and replace "_" with a space
	sGamePage = ReplaceInText( RemoveFromText( sGamePage, "/" ), "_", " " );

	DebugInfo(TypeInfo, string("Game page: " + sGamePage).c_str() );

	pEngine = new CMyEngine;
	
	LoadGames( sGamePage );

	// Terminate the debug log, if is it activated
#ifdef DEBUG_APP_LOG
	if ( pDebugLog != 0 )
		delete pDebugLog;
#endif

	return 0;
}
Example #2
0
stLoadStatus CImageHandler::LoadNext()
{
	stLoadStatus stReturn;

	stReturn.iNumberLoaded	= m_pImageList->GetCountPopped();
	stReturn.iTotalCount	= m_pImageList->GetCountLoaded();
	stReturn.eObjectLoaded = ImageLoaded;

	if ( m_pImageList->GetCountLeft() == 0 )
	{
		stReturn.sStatus = "Finished!";
		m_bLoadFinished = true;

		if ( m_pImageList != 0 )
			delete m_pImageList;
		m_pImageList = 0;

		return stReturn;
	}

	string sWikiFileName	= GetUntilFirst( m_pImageList->GetTagText(), "|" );
	string sSaveToFileName	= GetAfterLast ( m_pImageList->GetTagText(), "|" );
	
	// Does the image already exist?
	if ( DoesGameMediaExist( pEngine->GetGameDir(), sSaveToFileName ) == false )
	{
		DownloadImage( sWikiFileName, g_sAppDir+ "\\Media\\" + pEngine->GetGameDir() + "\\" + sSaveToFileName );
	}

	m_sLastImage = sSaveToFileName;

	stReturn.sStatus = "Image \"" + sWikiFileName + "\" downloaded";

	m_pImageList->Pop();

	return stReturn;
}
Example #3
0
string CAppTools::GetFileExtension( string file )
{
    return GetAfterLast( file, "." );
}