void UGameUserSettings::PreloadResolutionSettings() { // Note: This preloads resolution settings without loading the user settings object. // When changing this code care must be taken to ensure the window starts at the same resolution as the in game resolution LoadConfigIni(); FString ScriptEngineCategory = TEXT("/Script/Engine.Engine"); FString GameUserSettingsCategory = TEXT("/Script/Engine.GameUserSettings"); GConfig->GetString(*ScriptEngineCategory, TEXT("GameUserSettingsClassName"), GameUserSettingsCategory, GEngineIni); int32 ResolutionX = GetDefaultResolution().X; int32 ResolutionY = GetDefaultResolution().Y; EWindowMode::Type WindowMode = GetDefaultWindowMode(); bool bUseDesktopResolution = false; int32 Version=0; if( GConfig->GetInt(*GameUserSettingsCategory, TEXT("Version"), Version, GGameUserSettingsIni ) && Version == UE_GAMEUSERSETTINGS_VERSION ) { GConfig->GetBool(*GameUserSettingsCategory, TEXT("bUseDesktopResolution"), bUseDesktopResolution, GGameUserSettingsIni ); int32 WindowModeInt = (int32)WindowMode; GConfig->GetInt(*GameUserSettingsCategory, TEXT("FullscreenMode"), WindowModeInt, GGameUserSettingsIni); WindowMode = EWindowMode::ConvertIntToWindowMode(WindowModeInt); GConfig->GetInt(*GameUserSettingsCategory, TEXT("ResolutionSizeX"), ResolutionX, GGameUserSettingsIni); GConfig->GetInt(*GameUserSettingsCategory, TEXT("ResolutionSizeY"), ResolutionY, GGameUserSettingsIni); #if PLATFORM_DESKTOP if (bUseDesktopResolution && ResolutionX == 0 && ResolutionY == 0 && WindowMode != EWindowMode::Windowed) { // Grab display metrics so we can get the primary display output size. FDisplayMetrics DisplayMetrics; FDisplayMetrics::GetDisplayMetrics(DisplayMetrics); ResolutionX = DisplayMetrics.PrimaryDisplayWidth; ResolutionY = DisplayMetrics.PrimaryDisplayHeight; } #endif } { auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.FullScreenMode")); CVar->Set((int32)WindowMode); } RequestResolutionChange(ResolutionX, ResolutionY, WindowMode, false); IConsoleManager::Get().CallAllConsoleVariableSinks(); }
void UGameUserSettings::LoadSettings( bool bForceReload/*=false*/ ) { if ( bForceReload ) { LoadConfigIni( bForceReload ); } LoadConfig(GetClass(), *GGameUserSettingsIni); // Note: Scalability::LoadState() should not be needed as we already loaded the settings earlier (needed so the engine can startup with that before the game is initialized) ScalabilityQuality = Scalability::GetQualityLevels(); // Allow override using command-line settings bool bDetectingResolution = ResolutionSizeX == 0 || ResolutionSizeY == 0; if (bDetectingResolution) { ConfirmVideoMode(); } }