Esempio n. 1
0
//
// Open this viewport's window.
//
void UXViewport::OpenWindow( DWORD InParentWindow, UBOOL IsTemporary, INT NewX, INT NewY, INT OpenX, INT OpenY )
{
	guard(UXViewport::OpenWindow);
	check(Actor);
	check(!HoldCount);
	UXClient* C = GetOuterUXClient();

	if (!XWindow)
		return;

	debugf( TEXT("Opening X viewport.") );

	// Create or update the window.
	SizeX = C->FullscreenViewportX;
	SizeY = C->FullscreenViewportY;
	if (!Mapped)
	{
		XMoveResizeWindow( XDisplay, XWindow, 0, 0, SizeX, SizeY );
		XMapWindow( XDisplay, XWindow );
	}

	// Create rendering device.
	if( !RenDev && !GIsEditor && !ParseParam(appCmdLine(),TEXT("nohard")) )
		TryRenderDevice( TEXT("ini:Engine.Engine.GameRenderDevice"), NewX, NewY, ColorBytes, C->StartupFullscreen );
	check(RenDev);
	UpdateWindowFrame();
	Repaint( 1 );

	unguard;
}
/**
 * Creates the output file
 *
 * @return	TRUE if successful
 */
UBOOL FStatNotifyProvider_File::CreateOutputFile()
{
	const FString PathName = *(appProfilingDir() + TEXT("UE3Stats") PATH_SEPARATOR );
	GFileManager->MakeDirectory( *PathName );
	//warnf( TEXT( "ustats path: %s" ), *PathName );

	FString Filename = CreateProfileFilename( AppendedName, TRUE );
	Filename = PathName + Filename;
	//warnf( TEXT( "ustats Filename: %s" ), *Filename );


#if !CONSOLE
	FString PassedInName;
	// Check for the name passed in on the command line
	if (Parse(appCmdLine(),TEXT("STATFILE="),PassedInName))
	{
		Filename = PathName;
		Filename += PassedInName + AppendedName;
	}
#endif

	//warnf( TEXT( "ustats full: %s" ), *(Filename) );

	// Ask for a file writer
	//@todo -- joeg Create an optimized async file writer ala UC2
	File = GFileManager->CreateFileWriter( *Filename, FILEWRITE_AllowRead );
	ArchiveFilename = Filename;

	return File != NULL;
}
/**
 * Converts a path pointing into the installed directory (C:\Program Files\MyGame\ExampleGame\Config\ExampleEngine.ini)
 * to a path that a least-privileged user can write to (C:\<UserDir>\MyGame\ExampleGame\Config\ExampleEngine.ini)
 *
 * @param AbsolutePath Source path to convert
 *
 * @return Path to the user directory
 */
FString FFileManagerWindows::ConvertAbsolutePathToUserPath(const TCHAR* AbsolutePath)
{
	// if the user directory has been setup, use it
	if (WindowsUserDir.Len() > 0)
	{
		const UBOOL bUseUnpublished = GIsEditor
			|| (appStristr(appCmdLine(), TEXT("Editor")) != NULL)
			|| (appStristr(appCmdLine(), TEXT("CookPackages")) != NULL)
			|| (appStristr(appCmdLine(), TEXT("UseUnpublished")) != NULL);

		const TCHAR* ReplaceBit;
		const TCHAR* UnpublishedPath;
		const TCHAR* PublishedPath;

		// @todo ship: Use GSys->Paths or something for the replacement, instead of hardcoded Content
		FString UserContentPath(AbsolutePath);
		for (INT Path = 0; Path < 2; Path++)
		{
			if (Path == 0)
			{
				ReplaceBit = TEXT("\\CookedPC\\");
				UnpublishedPath = TEXT("\\Unpublished\\CookedPC\\");
				PublishedPath = TEXT("\\Published\\CookedPC\\");
			}
			else
			{
				ReplaceBit = TEXT("\\Content\\");
				UnpublishedPath = TEXT("\\Unpublished\\Content\\");
				PublishedPath = TEXT("\\Published\\Content\\");
			}

			// make sure we aren't using one of the special paths
			if (UserContentPath.InStr(UnpublishedPath, FALSE, TRUE) == INDEX_NONE && UserContentPath.InStr(PublishedPath, FALSE, TRUE) == INDEX_NONE)
			{
				UserContentPath = UserContentPath.Replace(ReplaceBit, bUseUnpublished ? UnpublishedPath : PublishedPath);
			}
		}

		// replace C:\Program Files\MyGame\Binaries with C:\<UserDir>\Binaries
		return UserContentPath.Replace(*WindowsRootDir, *WindowsUserDir, TRUE);
	}
	else
	{
		// in the non-installed (dev) case, just return the original path in all cases
		return AbsolutePath;
	}
}
/**
 * Hidden so that only the factory or derived class can create these
 *
 * @param InProviderName the name of this provider
 * @param InProviderCmdLine	Short name for this provider that may be specified on the app's command line
 */
FStatNotifyProvider::FStatNotifyProvider( const TCHAR* InProviderName, const TCHAR* InProviderCmdLine ) :
	ProviderName(InProviderName),
	bIsEnabled(FALSE),
	CurrentFrame((DWORD)-1)
{
	if (GConfig != NULL)
	{
		// Figure out if this provider is enabled or not
		GConfig->GetBool(TEXT("StatNotifyProviders"),ProviderName,bIsEnabled,
			GEngineIni);
	}
	// Check to see if the provider was listed on the commandline
	if( ParseParam( appCmdLine(), ProviderName ) ||
		( InProviderCmdLine != NULL && ParseParam( appCmdLine(), InProviderCmdLine ) ) )
	{
		bIsEnabled = TRUE;
	}
}
/**
 * Tells the parent class to open the file and then writes the opening data to it
 */
UBOOL FStatNotifyProvider_CSV::Init(void)
{
	UBOOL bOk = FStatNotifyProvider_File::Init();
	if (bOk && ParseParam(appCmdLine(),TEXT("CSVStats")))
	{
		// CSV stat provider starts capturing immediately!
		bOk = CreateOutputFile();
	}
	return bOk;
}
Esempio n. 6
0
/**
 * Constructor, initializing all member variables. It also reads .ini settings and caches them and creates the
 * database connection object and attempts to connect if bUseTaskPerfTracking is set.
 */
FTaskPerfTracker::FTaskPerfTracker()
: FTaskDatabase()
, bUseTaskPerfTracking(FALSE)
, TimeSpentTalkingWithDB(0)
{
#if !UDK
	// Read the ini settings and store them in the struct to aid debugging.
	GConfig->GetBool(TEXT("TaskPerfTracking"), TEXT("bUseTaskPerfTracking"	), bUseTaskPerfTracking, GEngineIni);

	// Only do work if task tracking is enabled.
	if( bUseTaskPerfTracking )
	{
		// only attempt to get the data when we want to use the TaskPerfTracking
		verify(GConfig->GetString( TEXT("TaskPerfTracking"), TEXT("ConnectionString"), ConnectionString, GEngineIni ));
		verify(GConfig->GetString( TEXT("TaskPerfTracking"), TEXT("RemoteConnectionIP"), RemoteConnectionIP, GEngineIni ));
		verify(GConfig->GetString( TEXT("TaskPerfTracking"), TEXT("RemoteConnectionStringOverride"), RemoteConnectionStringOverride, GEngineIni ));

		// Track time spent talking with DB to ensure we don't introduce nasty stalls.
		SCOPE_SECONDS_COUNTER(TimeSpentTalkingWithDB);

		// Create the connection object; needs to be deleted via "delete".
		Connection			= FDataBaseConnection::CreateObject();

		// Try to open connection to DB - this is a synchronous operation.
		if( Connection->Open( *ConnectionString, *RemoteConnectionIP, *RemoteConnectionStringOverride ) == TRUE )
		{
			warnf(NAME_DevDataBase,TEXT("Connection to \"%s\" or \"%s\" succeeded"), *ConnectionString, *RemoteConnectionIP);

			// Create format string for calling procedure.
			FormatString = FString(TEXT("EXEC BEGINRUN "));
#if _DEBUG
			FormatString += TEXT(" @ConfigName='DEBUG', ");
#elif FINAL_RELEASE_DEBUGCONSOLE
			FormatString += TEXT(" @ConfigName='FINAL_RELEASE_DEBUGCONSOLE', ");
#elif FINAL_RELEASE
			FormatString += TEXT(" @ConfigName='FINAL_RELEASE', ");
#else
			FormatString += TEXT(" @ConfigName='RELEASE', ");
#endif
			FormatString += FString(TEXT("@GameName='")) + GGameName + TEXT("', @MachineName='") + appComputerName() + TEXT("', ");
			FormatString += FString(TEXT("@CmdLine='")) + appCmdLine() + TEXT("', @UserName='******', ");		
			FormatString += FString(TEXT("@TaskDescription='%s', @TaskParameter='%s', @Changelist=")) + appItoa(GBuiltFromChangeList);
		}
		// Connection failed :(
		else
		{
			warnf(NAME_DevDataBase,TEXT("Connection to \"%s\" or \"%s\" failed"), *ConnectionString, *RemoteConnectionIP);
			// Only delete object - no need to close as connection failed.
			delete Connection;
			Connection = NULL;
		}
	}
#endif	//#if !UDK
}
/**
 * Tells the parent class to open the file and then writes the opening
 * XML data to it
 */
UBOOL FStatNotifyProvider_XML::Init(void)
{
	UBOOL bOk = FStatNotifyProvider_File::Init();
	if (bOk && ParseParam(appCmdLine(),TEXT("XMLStats")))
	{
		// XML stat provider starts capturing immediately!
		bOk = CreateOutputFile();
		if( bOk	)
		{
			// Create the opening element
			WriteString("<StatFile SecondsPerCycle=\"%e\">\r\n",GSecondsPerCycle);
		}
	}
	return bOk;
}
/**
 * Creates the file that is going to be written to
 */
UBOOL FStatNotifyProvider_BinaryFile::Init(void)
{
	if( !FStatNotifyProvider_File::Init() )
	{
		return FALSE;
	}

	// NOTE: Binary stats capture doesn't start capturing until the user enters "Stat StartFile"

	if( ParseParam( appCmdLine(), TEXT( "StartStatsFile" ) ) )
	{
		// Start capturing right away!
		StartWritingStatsFile();
	}

	return TRUE;
}
Esempio n. 9
0
/**
 * Static function creating appropriate database connection object.
 *
 * @return	instance of platform specific database connection object
 */
FDataBaseConnection* FDataBaseConnection::CreateObject()
{
	if( ParseParam( appCmdLine(), TEXT("NODATABASE") ) )
	{
		return NULL;
	}
#if USE_ADO_INTEGRATION
	if( !GIsCOMInitialized )
	{
		// Initialize COM. We only want to do this once and not override settings of previous calls.
		CoInitialize( NULL );
		GIsCOMInitialized = TRUE;
	}
	return new FADODataBaseConnection();
#elif USE_REMOTE_INTEGRATION
	return new FRemoteDatabaseConnection();
#else
	return new FDataBaseConnection();
#endif
}
Esempio n. 10
0
void VEngine::Init()
{
	InitStaticData();

	if( ParseParam(appCmdLine(), TEXT("FIXEDSEED")) )
	{
		appRandInit(0);
	}
	else
	{
		appRandInit(appCycles());
	}

	// Init client
	_GameClient = Cast<VWindowClient>(VObject::StaticConstructObject(_GameViewportClass));
	_GameClient->Init();

	// Init GameViewport
	VGameViewportClientPtr ViewportClient = NULL;
	if( _GameClient )
	{
		ViewportClient = Cast<VGameViewportClient>(VObject::StaticConstructObject(_GameClientClass));
		_GameViewport = ViewportClient;
	}

	if( ViewportClient )
	{
		FString Error;
		if( !ViewportClient->Init(Error) )
		{
			appErrorf(TEXT("%s"), Error.c_str());
			return;
		}

		FViewport* Viewport = _GameClient->CreateViewport(ViewportClient, TEXT("Product"), 800, 600, FALSE);
		_GameViewport->SetViewport(Viewport);
	}

	GLog->Log(NAME_Init, TEXT("Game engine initialized"));
}
Esempio n. 11
0
void USetupDefinition::Init()
{
	guard(USetupDefinition::Init);

	// Figure out source folder.
	SrcPath = appBaseDir();
	if( SrcPath.Right(1)==PATH_SEPARATOR )
		SrcPath = SrcPath.LeftChop( 1 );
	while( SrcPath.Len() && SrcPath.Right(1)!=PATH_SEPARATOR )
		SrcPath = SrcPath.LeftChop( 1 );
	if( SrcPath.Len() )
		SrcPath = SrcPath.LeftChop( 1 );

	// See if installing a packed .umod file.
	FString Token;
	const TCHAR* Cmd = appCmdLine();
	ParseToken( Cmd, Token, 0 );
	if( Token==TEXT("install") || (Token==TEXT("") && MasterProduct==TEXT("")) )
	{
		// Installing.
		if( Token==TEXT("install") )
		{
			// Verify that the specified module exists.
			ParseToken( Cmd, Token, 0 );
			GFileManager = new FFileManagerArc(GFileManager,*Token,1);
			GFileManager->Init(0);
			Token = TEXT("");
			ParseToken( Cmd, Token, 0 );

			// Reload config from the new filer manager.
			GConfig->Flush(1,MANIFEST_FILE MANIFEST_EXT);
			LoadConfig();
			LoadLocalized();
		}

		// Detach configuration file so we can modify it locally.
		GConfig->Detach( *ConfigFile );
		Manifest = 1;
	}
	else if( Token==TEXT("reallyuninstall") )
	{
		// Running uninstaller from temp folder.
		ParseToken( Cmd, Product, 0 );
		Parse( appCmdLine(), TEXT("PATH="), DestPath );
		if( DestPath.Right(1)==PATH_SEPARATOR )
			DestPath = DestPath.LeftChop( 1 );
		while( DestPath.Len() && DestPath.Right(1)!=PATH_SEPARATOR )
			DestPath = DestPath.LeftChop( 1 );
		Uninstalling = 1;
	}
	else if( Token==TEXT("uninstall") || (Token==TEXT("") && MasterProduct!=TEXT("")) )
	{
		// Running uninstaller for the first time.
		NoRun = 1;
		if( Token==TEXT("uninstall") )
			ParseToken( Cmd, Product, 0 );
		else
			Product = MasterProduct;
		PerformUninstallCopy();
	}
	else appErrorf(TEXT("Setup: Unknown disposition"));

	// Validate everything.
	if( !appAtoi(*Version) && !Uninstalling && !NoRun )
		appErrorf( TEXT("Setup: Missing version number") );

	// Determine whether known to be installed.
	Exists
	=	GetRegisteredProductFolder( Product, RegistryFolder )
	&&	GFileManager->FileSize(*(RegistryFolder*TEXT("System")*SETUP_INI))>0;

	// If this is a mod, find required product's path.
	FolderExists = Exists;
	if( !Exists && !Uninstalling && !NoRun )
	{
		FString RequiredProduct, FindFolder;
		for( TArray<FString>::TIterator It(Requires); It; ++It )
			if(	GConfig->GetString(**It, TEXT("Product"), RequiredProduct, *ConfigFile) )
			{
				if( RequiredProduct==TEXT("Unreal Tournament") )
					RequiredProduct = TEXT("UnrealTournament");
				if( GetRegisteredProductFolder(RequiredProduct, FindFolder)
				&&	GFileManager->FileSize(*(FindFolder*TEXT("System")*SETUP_INI)) )
				{
					RegistryFolder = FindFolder;
					FolderExists   = 1;
					break;
				}
			}
	}

	// Figure language.
	FString Str;
	if( GConfig->GetString(TEXT("Engine.Engine"),TEXT("Language"),Str,*(RegistryFolder*TEXT("System\\Default.ini"))) )
		UObject::SetLanguage( *Str );
	LanguageChange();

	unguard;
}
void FFileManagerWindows::Init(UBOOL Startup)
{
	// a shipped PC game will always run as if installed
#if SHIPPING_PC_GAME && !UDK
	// shipping PC game 
	bIsRunningInstalled = TRUE;
#else
	// for development, use a commandline param (-installed)
	bIsRunningInstalled = ParseParam(appCmdLine(),TEXT("installed"));
#endif

	// Allow overriding use of My Documents folder with -NOHOMEDIR
	if( ParseParam(appCmdLine(),TEXT("NOHOMEDIR") ) )
	{
		bIsRunningInstalled = FALSE;
	}

	if (bIsRunningInstalled)
	{
		debugf( TEXT( " ... running in INSTALLED mode" ) );

		TCHAR UserPath[MAX_PATH];
		// get the My Documents directory
		HRESULT Ret = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, UserPath);

		// get the per-game directory name to use inside the My Documents directory 
		FString DefaultIniContents;
		// load the DefaultEngine.ini config file into a string for later parsing (ConvertAbsolutePathToUserPath will use
		// original location since WindowsUserDir hasn't been set yet)
		// can't use GDefaultEngineIni, because that may be something that doesn't have the tag
		if (!appLoadFileToString(DefaultIniContents, *(appGameConfigDir() + TEXT("DefaultEngine.ini")), this))
		{
			// appMsgf won't write to a log if GWarn is NULL, which it should be at this point
			appMsgf(AMT_OK, TEXT("Failed to find default engine .ini file to retrieve My Documents subdirectory to use. Force quitting."));
			exit(1);
			return;
		}

		#define MYDOC_KEY_NAME TEXT("MyDocumentsSubDirName=")

		// find special key in the .ini file (can't use GConfig because it can't be used yet until after filemanager is made)
		INT KeyLocation = DefaultIniContents.InStr(MYDOC_KEY_NAME, FALSE, TRUE);
		if (KeyLocation == INDEX_NONE)
		{
			// appMsgf won't write to a log if GWarn is NULL, which it should be at this point
			appMsgf(AMT_OK, TEXT("Failed to find %s key in DefaultEngine.ini. Force quitting."), MYDOC_KEY_NAME);
			exit(1);
			return;
		}

		// skip over the key to get the value (skip key and = sign) and everything after it
		FString ValueAndLeftover = DefaultIniContents.Mid(KeyLocation + appStrlen(MYDOC_KEY_NAME));
		
		// now chop off this string at an end of line
		TArray<FString> Tokens;
		ValueAndLeftover.ParseIntoArray(&Tokens, TEXT("\r\n"), TRUE);

		// make the base user dir path
		WindowsUserDir = FString(UserPath) 
							+ TEXT("\\My Games\\") 
							+ Tokens(0) 
#if DEMOVERSION
							+ TEXT(" Demo")
#endif
							+ TEXT("\\");

		// find out our executable path
		WindowsRootDir = appBaseDir();
		// strip off the Binaries directory
		WindowsRootDir = WindowsRootDir.Left(WindowsRootDir.InStr(TEXT("\\Binaries\\"), TRUE, TRUE) + 1);

		// Now that the root directory has been set, create directories at startup.
		// Note this must come after the above because MakeDirectory calls
		// ConvertAbsolutePathToUserPath which uses WindowsRootDir and WindowsUserDir.
		#define DIRSTOCREATATSTARTUP_KEY_NAME TEXT("DirsToCreateAtStartup=")
		INT FindStartPos = INDEX_NONE;
		while ( TRUE )
		{
			// find special key in the .ini file (can't use GConfig because it can't be used yet until after filemanager is made)
			const INT KeyLocation = DefaultIniContents.InStr(DIRSTOCREATATSTARTUP_KEY_NAME, FALSE, TRUE, FindStartPos);
			if (KeyLocation == INDEX_NONE)
			{
				break;
			}
			// Advance the find pos because we're doing a multi find.
			FindStartPos = KeyLocation + appStrlen(DIRSTOCREATATSTARTUP_KEY_NAME);

			// skip over the key to get the value (skip key and = sign) and everything after it
			FString ValueAndLeftover = DefaultIniContents.Mid(KeyLocation + appStrlen(DIRSTOCREATATSTARTUP_KEY_NAME));
			
			// now chop off this string at an end of line
			TArray<FString> Tokens;
			ValueAndLeftover.ParseIntoArray(&Tokens, TEXT("\r\n"), TRUE);

			// Create the directory.
			MakeDirectory( *Tokens(0), TRUE );
		}
	}

	FFileManagerGeneric::Init(Startup);
}