/** * Helper for ApplyNewSettings when the engine is running. Applies the changes needed for the runtime system. * * We can assume the game is running if this code is called. */ void FSystemSettings::ApplySettingsAtRuntime(const FSystemSettingsData& NewSettings, bool bWriteToIni) { // Some of these settings are shared between threads, so we // must flush the rendering thread before changing anything. FlushRenderingCommands(); // Track settings we might have to put back FExposedTextureLODSettings InMemoryTextureLODSettings = TextureLODSettings; // Read settings from .ini. This is necessary because settings which need to wait for a restart // will be on disk but may not be in memory. Therefore, we read from disk before capturing old // values to revert to. LoadFromIni(); // see what settings are actually changing. // Ugly casts because system settings is multi-inherited from all the consituent classes for backwards compatibility // Texture Detail bool bTextureDetailChanged = (const FSystemSettingsDataTextureDetail&)(*this) != (const FSystemSettingsDataTextureDetail&)NewSettings; // Make a copy of the existing settings so we can compare for changes FSystemSettingsData OldData = *this; // Set new settings. Would look prettier if we didn't derive from the Data class... (FSystemSettingsData&)(*this) = NewSettings; // apply any runtime changes that need to be made bool bUpdateTextureStreamingSucceeded = false; if (bTextureDetailChanged) { bUpdateTextureStreamingSucceeded = UTexture::ForceUpdateTextureStreaming(); } // If requested, save the settings to ini. if ( bWriteToIni ) { SaveToIni(); } // If texture detail settings couldn't be applied because we're loading seekfree, // revert the new settings to their previous in-memory values. if ( bTextureDetailChanged && !bUpdateTextureStreamingSucceeded ) { TextureLODSettings = InMemoryTextureLODSettings; } }
/** Initializes and instance with the values from the given IniSection in the engine ini */ void FSystemSettingsData::LoadFromIni( const TCHAR* IniSection, const FString& IniFilename, bool bAllowMissingValues, bool* FoundValues ) { // first, look for a parent section to base off of FString BasedOnSection; if (GConfig->GetString(IniSection, TEXT("BasedOn"), BasedOnSection, IniFilename)) { // recurse with the BasedOn section if it existed, always allowing for missing values LoadFromIni(*BasedOnSection, IniFilename, true, FoundValues); } // Read all console variables from .ini { GConfig->ForEachEntry(FKeyValueSink::CreateStatic(&FSetCVarFromIni::OnEntry), IniSection, IniFilename); IConsoleManager::Get().CallAllConsoleVariableSinks(); } // Read the texture group LOD settings. TextureLODSettings.Initialize( IniFilename, IniSection ); }
/** Initializes and instance with the values from the given IniSection in the engine ini */ void FSystemSettingsData::LoadFromIni( const TCHAR* IniSection, const FString& IniFilename, bool bAllowMissingValues, bool* FoundValues ) { // first, look for a parent section to base off of FString BasedOnSection; if (GConfig->GetString(IniSection, TEXT("BasedOn"), BasedOnSection, IniFilename)) { // recurse with the BasedOn section if it existed, always allowing for missing values LoadFromIni(*BasedOnSection, IniFilename, true, FoundValues); } // Read all console variables from .ini { FSetCVarFromIni Delegate(IniFilename); FKeyValueSink Visitor; Visitor.BindRaw(&Delegate, &FSetCVarFromIni::OnEntry); GConfig->ForEachEntry(Visitor, IniSection, IniFilename); IConsoleManager::Get().CallAllConsoleVariableSinks(); } }
/** * Initializes system settings and included texture LOD settings. * * @param bSetupForEditor Whether to initialize settings for Editor */ void FSystemSettings::Initialize( bool bSetupForEditor ) { TestBitFieldFunctions(); RegisterShowFlagConsoleVariables(); // Load the settings that will be the default for every other compat level, and the editor, and the other split screen levels. FSystemSettingsData DefaultSettings; DefaultSettings.LoadFromIni(GetSectionName(false), GEngineIni, false); bIsEditor = bSetupForEditor; (FSystemSettingsData&)(*this) = DefaultSettings; LoadFromIni(); ApplyOverrides(); IConsoleManager::Get().RegisterConsoleVariableSink_Handle(FConsoleCommandDelegate::CreateRaw(this, &FSystemSettings::CVarSink)); // initialize a critical texture streaming value used by texture loading, etc int32 MinTextureResidentMipCount = 7; GConfig->GetInt(TEXT("TextureStreaming"), TEXT("MinTextureResidentMipCount"), MinTextureResidentMipCount, GEngineIni); UTexture2D::SetMinTextureResidentMipCount(MinTextureResidentMipCount); }
void FSteamVRHMD::Startup() { // load the OpenVR library if (!LoadOpenVRModule()) { return; } // grab a pointer to the renderer module for displaying our mirror window static const FName RendererModuleName("Renderer"); RendererModule = FModuleManager::GetModulePtr<IRendererModule>(RendererModuleName); vr::HmdError HmdErr = vr::HmdError_None; //VRSystem = vr::VR_Init(&HmdErr); VRSystem = (*VRInitFn)(&HmdErr); // make sure that the version of the HMD we're compiled against is correct if ((VRSystem != nullptr) && (HmdErr == vr::HmdError_None)) { //VRSystem = (vr::IVRSystem*)vr::VR_GetGenericInterface(vr::IVRSystem_Version, &HmdErr); //@todo steamvr: verify init error handling VRSystem = (vr::IVRSystem*)(*VRGetGenericInterfaceFn)(vr::IVRSystem_Version, &HmdErr); } // attach to the compositor if ((VRSystem != nullptr) && (HmdErr == vr::HmdError_None)) { //VRCompositor = (vr::IVRCompositor*)vr::VR_GetGenericInterface(vr::IVRCompositor_Version, &HmdErr); VRCompositor = (vr::IVRCompositor*)(*VRGetGenericInterfaceFn)(vr::IVRCompositor_Version, &HmdErr); if ((VRCompositor != nullptr) && (HmdErr == vr::HmdError_None)) { // determine our compositor type vr::Compositor_DeviceType CompositorDeviceType = vr::Compositor_DeviceType_None; if (IsPCPlatform(GMaxRHIShaderPlatform) && !IsOpenGLPlatform(GMaxRHIShaderPlatform)) { CompositorDeviceType = vr::Compositor_DeviceType_D3D11; } else if (IsOpenGLPlatform(GMaxRHIShaderPlatform)) { check(0); //@todo steamvr: use old path for mac and linux until support is added CompositorDeviceType = vr::Compositor_DeviceType_OpenGL; } } } if ((VRSystem != nullptr) && (HmdErr == vr::HmdError_None)) { // grab info about the attached display char Buf[128]; FString DriverId; vr::TrackedPropertyError Error; VRSystem->GetStringTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String, Buf, sizeof(Buf), &Error); if (Error == vr::TrackedProp_Success) { DriverId = FString(UTF8_TO_TCHAR(Buf)); } VRSystem->GetStringTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SerialNumber_String, Buf, sizeof(Buf), &Error); if (Error == vr::TrackedProp_Success) { DisplayId = FString(UTF8_TO_TCHAR(Buf)); } // determine our ideal screen percentage uint32 RecommendedWidth, RecommendedHeight; VRSystem->GetRecommendedRenderTargetSize(&RecommendedWidth, &RecommendedHeight); RecommendedWidth *= 2; int32 ScreenX, ScreenY; uint32 ScreenWidth, ScreenHeight; VRSystem->GetWindowBounds(&ScreenX, &ScreenY, &ScreenWidth, &ScreenHeight); float WidthPercentage = ((float)RecommendedWidth / (float)ScreenWidth) * 100.0f; float HeightPercentage = ((float)RecommendedHeight / (float)ScreenHeight) * 100.0f; float ScreenPercentage = FMath::Max(WidthPercentage, HeightPercentage); //@todo steamvr: move out of here static IConsoleVariable* CScrPercVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.ScreenPercentage")); if (FMath::RoundToInt(CScrPercVar->GetFloat()) != FMath::RoundToInt(ScreenPercentage)) { CScrPercVar->Set(ScreenPercentage); } // disable vsync static IConsoleVariable* CVSyncVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VSync")); CVSyncVar->Set(false); // enforce finishcurrentframe static IConsoleVariable* CFCFVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.finishcurrentframe")); CFCFVar->Set(false); // Grab the chaperone vr::HmdError ChaperoneErr = vr::HmdError_None; //VRChaperone = (vr::IVRChaperone*)vr::VR_GetGenericInterface(vr::IVRChaperone_Version, &ChaperoneErr); VRChaperone = (vr::IVRChaperone*)(*VRGetGenericInterfaceFn)(vr::IVRChaperone_Version, &ChaperoneErr); if ((VRChaperone != nullptr) && (ChaperoneErr == vr::HmdError_None)) { ChaperoneBounds = FChaperoneBounds(VRChaperone); } else { UE_LOG(LogHMD, Warning, TEXT("Failed to initialize Chaperone. Error: %d"), (int32)ChaperoneErr); } // Initialize our controller to device index for (int32 UnrealControllerIndex = 0; UnrealControllerIndex < MAX_STEAMVR_CONTROLLER_PAIRS; ++UnrealControllerIndex ) { for( int32 HandIndex = 0; HandIndex < 2; ++HandIndex ) { UnrealControllerIdAndHandToDeviceIdMap[ UnrealControllerIndex ][ HandIndex ] = INDEX_NONE; } } #if PLATFORM_WINDOWS if (IsPCPlatform(GMaxRHIShaderPlatform) && !IsOpenGLPlatform(GMaxRHIShaderPlatform)) { pD3D11Bridge = new D3D11Bridge(this); } #endif LoadFromIni(); UE_LOG(LogHMD, Log, TEXT("SteamVR initialized. Driver: %s Display: %s"), *DriverId, *DisplayId); } else { UE_LOG(LogHMD, Log, TEXT("SteamVR failed to initialize. Err: %d"), (int32)HmdErr); VRSystem = nullptr; } // share the IVRSystem interface out to the SteamVRController via the module layer SteamVRPlugin->SetVRSystem(VRSystem); }
SMOnlineRoom::SMOnlineRoom(const MString &name, const MString &description, bool allowgamerooms) : m_roomType(ROOMChat), m_allowgamerooms(allowgamerooms), m_state(RS_OPEN), m_maxPlayers(16), m_title(name), m_description(description) { LoadFromIni(); }
bool FSystemSettings::HandleResetCommand( const TCHAR* Cmd , FOutputDevice& Ar ) { // Reset values to defaults from ini. LoadFromIni(); return true; }