void UDeveloperSettings::ExportValuesToConsoleVariables(UProperty* PropertyThatChanged)
{
	check(PropertyThatChanged);
	FString CVarName = PropertyThatChanged->GetMetaData(DeveloperSettingsConsoleVariableMetaFName);
	if (!CVarName.IsEmpty())
	{
		IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName);
		if (CVar && (CVar->GetFlags() & ECVF_ReadOnly) == 0)
		{
			UByteProperty* ByteProperty = Cast<UByteProperty>(PropertyThatChanged);
			if (ByteProperty != NULL && ByteProperty->Enum != NULL)
			{
				CVar->Set(ByteProperty->GetPropertyValue_InContainer(this), ECVF_SetByProjectSetting);
			}
			else if (UBoolProperty* BoolProperty = Cast<UBoolProperty>(PropertyThatChanged))
			{
				CVar->Set((int32)BoolProperty->GetPropertyValue_InContainer(this), ECVF_SetByProjectSetting);
			}
			else if (UIntProperty* IntProperty = Cast<UIntProperty>(PropertyThatChanged))
			{
				CVar->Set(IntProperty->GetPropertyValue_InContainer(this), ECVF_SetByProjectSetting);
			}
			else if (UFloatProperty* FloatProperty = Cast<UFloatProperty>(PropertyThatChanged))
			{
				CVar->Set(FloatProperty->GetPropertyValue_InContainer(this), ECVF_SetByProjectSetting);
			}
		}
		else
		{
			UE_LOG(LogInit, Warning, TEXT("CVar named '%s' marked up in %s was not found or is set to read-only"), *CVarName, *GetClass()->GetName());
		}
	}
}
Ejemplo n.º 2
0
	static void OnEntry(const TCHAR *Key, const TCHAR* Value)
	{
		IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(Key);

		if(CVar)
		{
			// Set if the variable exists.

			// to be more compatible with non console variable boolean system settings we allow verbal values

			if(FCString::Stricmp(Value, TEXT("True")) == 0
			|| FCString::Stricmp(Value, TEXT("Yes")) == 0
			|| FCString::Stricmp(Value, TEXT("On")) == 0)
			{
				CVar->Set(1);
			}
			else
			if(FCString::Stricmp(Value, TEXT("False")) == 0
			|| FCString::Stricmp(Value, TEXT("No")) == 0
			|| FCString::Stricmp(Value, TEXT("Off")) == 0)
			{
				CVar->Set(0);
			}
			else
			{
				CVar->Set(Value);
			}
		}
	}
Ejemplo n.º 3
0
void UGameUserSettings::ApplyNonResolutionSettings()
{
	ValidateSettings();

	bool bIsDirty = IsDirty();
	EWindowMode::Type NewWindowMode = GetFullscreenMode();

	{
		IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.FullScreenMode")); 
		CVar->Set(NewWindowMode);
	}

	// Update vsync cvar
	{
		auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VSync")); 
		CVar->Set(IsVSyncEnabled());
	}

	// in init those are loaded earlier, after that we apply consolevariables.ini
	if(GEngine->IsInitialized())
	{
		Scalability::SetQualityLevels(ScalabilityQuality);
	}

	IConsoleManager::Get().CallAllConsoleVariableSinks();
}
Ejemplo n.º 4
0
void UGameUserSettings::RequestResolutionChange(int32 InResolutionX, int32 InResolutionY, EWindowMode::Type InWindowMode, bool bInDoOverrides /* = true */)
{
	if (bInDoOverrides)
	{
		UGameEngine::ConditionallyOverrideSettings(InResolutionX, InResolutionY, InWindowMode);
	}


	{
		IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.FullScreenMode"));
		CVar->Set(InWindowMode);
	}
	FSystemResolution::RequestResolutionChange(InResolutionX, InResolutionY, InWindowMode);
}
void AGameplayDebuggerReplicator::BeginPlay()
{
	Super::BeginPlay();

#if ENABLED_GAMEPLAY_DEBUGGER

	UGameplayDebuggerModuleSettings* Settings = UGameplayDebuggerModuleSettings::StaticClass()->GetDefaultObject<UGameplayDebuggerModuleSettings>();
	if (Role == ROLE_Authority)
	{
		Settings->LoadAnyMissingClasses();

		TArray<UClass *> Results = Settings->GetAllGameplayDebuggerClasses();
		for (UClass* Class : Results)
		{
			UGameplayDebuggerBaseObject* BaseObject = NewObject<UGameplayDebuggerBaseObject>(this, Class, NAME_None, RF_Transient);
			ReplicatedObjects.AddUnique(BaseObject);
		}
	}

	// start with settings categories
	Categories = Settings->GetCategories();

	IConsoleVariable* cvarHighlightSelectedActor = IConsoleManager::Get().FindConsoleVariable(TEXT("ai.gd.HighlightSelectedActor"));
	if (cvarHighlightSelectedActor)
	{
		cvarHighlightSelectedActor->Set(Settings->bHighlightSelectedActor);
	}

	const FInputActionKeyMapping& Mapping = Settings->ActivationAction;
	ActivationKeyDisplayName = Mapping.Key.GetDisplayName().ToString();
	ActivationKeyName = Mapping.Key.GetFName().ToString();

	if (GetNetMode() != ENetMode::NM_DedicatedServer && LocalPlayerOwner && LocalPlayerOwner->InputComponent)
	{
		FInputActionBinding& ActivationKeyPressed = LocalPlayerOwner->InputComponent->BindAction(Mapping.ActionName, IE_Pressed, this, &AGameplayDebuggerReplicator::OnActivationKeyPressed);
		ActivationKeyPressed.bConsumeInput = false;

		FInputActionBinding& ActivationKeyReleased = LocalPlayerOwner->InputComponent->BindAction(Mapping.ActionName, IE_Released, this, &AGameplayDebuggerReplicator::OnActivationKeyReleased);
		ActivationKeyReleased.bConsumeInput = false;

		// register 'Game' show flag for Game or PIE, Simulate doesn't use it
		UDebugDrawService::Register(TEXT("Game"), FDebugDrawDelegate::CreateUObject(this, &AGameplayDebuggerReplicator::DrawDebugDataDelegate));
		if (GIsEditor)
		{
			// register 'DebugAI' show flag for Simulate, Game or PIE don't use DebugAI show flag but 'Game'
			UDebugDrawService::Register(TEXT("DebugAI"), FDebugDrawDelegate::CreateUObject(this, &AGameplayDebuggerReplicator::OnDebugAIDelegate));
		}
	}
#endif //ENABLED_GAMEPLAY_DEBUGGER
}
Ejemplo n.º 6
0
void UGameUserSettings::ApplyResolutionSettings(bool bCheckForCommandLineOverrides)
{
	ValidateSettings();

	EWindowMode::Type NewFullscreenMode = GetFullscreenMode();

	{
		IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.FullScreenMode"));
		CVar->Set(NewFullscreenMode);
	}

	// Request a resolution change
	RequestResolutionChange(ResolutionSizeX, ResolutionSizeY, NewFullscreenMode, bCheckForCommandLineOverrides);
	IConsoleManager::Get().CallAllConsoleVariableSinks();

	SaveSettings();
}
void UDeviceProfileManager::InitializeCVarsForActiveDeviceProfile()
{
	// Find the device profile selector module used in this instance
	FString DeviceProfileSelectionModule;
	GConfig->GetString( TEXT("DeviceProfileManager"), TEXT("DeviceProfileSelectionModule"), DeviceProfileSelectionModule, GEngineIni );

	FString SelectedPlatformDeviceProfileName = GetActiveProfileName();
	UE_LOG(LogInit, Log, TEXT("Applying CVar settings loaded from the selected device profile: [%s]"), *SelectedPlatformDeviceProfileName);

	// Load the device profile config
	FConfigCacheIni::LoadGlobalIniFile(DeviceProfileFileName, TEXT("DeviceProfiles"));

	TArray< FString > AvailableProfiles;
	GConfig->GetSectionNames( DeviceProfileFileName, AvailableProfiles );

	// Look up the ini for this tree as we are far too early to use the UObject system
	AvailableProfiles.Remove( TEXT( "DeviceProfiles" ) );

	// Next we need to create a hierarchy of CVars from the Selected Device Profile, to it's eldest parent
	TMap<FString, FString> CVarsAlreadySetList;
	
	// For each device profile, starting with the selected and working our way up the BaseProfileName tree,
	// Find all CVars and set them 
	FString BaseDeviceProfileName = SelectedPlatformDeviceProfileName;
	bool bReachedEndOfTree = BaseDeviceProfileName.IsEmpty();
	while( bReachedEndOfTree == false ) 
	{
		FString CurrentSectionName = FString::Printf( TEXT("%s %s"), *BaseDeviceProfileName, *UDeviceProfile::StaticClass()->GetName() );
		
		// Check the profile was available.
		bool bProfileExists = AvailableProfiles.Contains( CurrentSectionName );
		if( bProfileExists )
		{
			TArray< FString > CurrentProfilesCVars;
			GConfig->GetArray( *CurrentSectionName, TEXT("CVars"), CurrentProfilesCVars, DeviceProfileFileName );

			// Iterate over the profile and make sure we do not have duplicate CVars
			{
				TMap< FString, FString > ValidCVars;
				for( TArray< FString >::TConstIterator CVarIt(CurrentProfilesCVars); CVarIt; ++CVarIt )
				{
					FString CVarKey, CVarValue;
					if( (*CVarIt).Split( TEXT("="), &CVarKey, &CVarValue ) )
					{
						if( ValidCVars.Find( CVarKey ) )
						{
							ValidCVars.Remove( CVarKey );
						}

						ValidCVars.Add( CVarKey, CVarValue );
					}
				}
				
				// Empty the current list, and replace with the processed CVars. This removes duplicates
				CurrentProfilesCVars.Empty();

				for( TMap< FString, FString >::TConstIterator ProcessedCVarIt(ValidCVars); ProcessedCVarIt; ++ProcessedCVarIt )
				{
					CurrentProfilesCVars.Add( FString::Printf( TEXT("%s=%s"), *ProcessedCVarIt.Key(), *ProcessedCVarIt.Value() ) );
				}

			}

			// Iterate over this profiles cvars and set them if they haven't been already.
			for( TArray< FString >::TConstIterator CVarIt(CurrentProfilesCVars); CVarIt; ++CVarIt )
			{
				FString CVarKey, CVarValue;
				if( (*CVarIt).Split( TEXT("="), &CVarKey, &CVarValue ) )
				{
					if( !CVarsAlreadySetList.Find( CVarKey ) )
					{
						IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarKey);
						if( CVar )
						{
							UE_LOG(LogInit, Log, TEXT("Setting Device Profile CVar: [[%s:%s]]"), *CVarKey, *CVarValue);
							CVar->Set( *CVarValue, ECVF_SetByDeviceProfile);
							CVarsAlreadySetList.Add( CVarKey, CVarValue );
						}
						else
						{
							UE_LOG(LogInit, Warning, TEXT("Failed to find a registered CVar that matches the key: [%s]"), *CVarKey);
						}
					}
				}
			}

			// Get the next device profile name, to look for CVars in, along the tree
			FString NextBaseDeviceProfileName;
			if( GConfig->GetString( *CurrentSectionName, TEXT("BaseProfileName"), NextBaseDeviceProfileName, DeviceProfileFileName ) )
			{
				BaseDeviceProfileName = NextBaseDeviceProfileName;
			}
			else
			{
				BaseDeviceProfileName.Empty();
			}
		}
		
		// Check if we have inevitably reached the end of the device profile tree.
		bReachedEndOfTree = !bProfileExists || BaseDeviceProfileName.IsEmpty();
	}
}
Ejemplo n.º 8
0
FOSVRHMD::FOSVRHMD(TSharedPtr<class OSVREntryPoint, ESPMode::ThreadSafe> entryPoint) :
    mOSVREntryPoint(entryPoint)
{
    static const FName RendererModuleName("Renderer");
    RendererModule = FModuleManager::GetModulePtr<IRendererModule>(RendererModuleName);
    FScopeLock lock(mOSVREntryPoint->GetClientContextMutex());
    auto osvrClientContext = mOSVREntryPoint->GetClientContext();

    // Prevents debugger hangs that sometimes occur with only one monitor.
#if OSVR_UNREAL_DEBUG_FORCED_WINDOWMODE
    FSystemResolution::RequestResolutionChange(1280, 720, EWindowMode::Windowed); // bStereo ? WindowedMirror : Windowed
#endif

    EnablePositionalTracking(true);

    StartCustomPresent();

    // enable vsync
    IConsoleVariable* CVSyncVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VSync"));
    if (CVSyncVar)
    {
        CVSyncVar->Set(false);
    }


    // Uncap fps to enable FPS higher than 62
    GEngine->bSmoothFrameRate = false;

    // check if the client context is ok.
    bool bClientContextOK = entryPoint->IsOSVRConnected();

    // get the display context
    bool bDisplayConfigOK = false;
    if (bClientContextOK)
    {
        bool bFailure = false;

        auto rc = osvrClientGetDisplay(osvrClientContext, &DisplayConfig);
        if (rc == OSVR_RETURN_FAILURE)
        {
            UE_LOG(OSVRHMDLog, Warning, TEXT("Could not create DisplayConfig. Treating this as if the HMD is not connected."));
        }
        else
        {
            auto begin = FDateTime::Now().GetSecond();
            auto end = begin + 3;
            while (!bDisplayConfigOK && FDateTime::Now().GetSecond() < end)
            {
                bDisplayConfigOK = osvrClientCheckDisplayStartup(DisplayConfig) == OSVR_RETURN_SUCCESS;
                if (!bDisplayConfigOK)
                {
                    bFailure = osvrClientUpdate(osvrClientContext) == OSVR_RETURN_FAILURE;
                    if (bFailure)
                    {
                        UE_LOG(OSVRHMDLog, Warning, TEXT("osvrClientUpdate failed during startup. Treating this as \"HMD not connected\""));
                        break;
                    }
                }
                FPlatformProcess::Sleep(0.2f);
            }
            bDisplayConfigOK = bDisplayConfigOK && !bFailure;
            if (!bDisplayConfigOK)
            {
                UE_LOG(OSVRHMDLog, Warning, TEXT("DisplayConfig failed to startup. This could mean that there is nothing mapped to /me/head. Treating this as if the HMD is not connected."));
            }
        }
    }

    bool bDisplayConfigMatchesUnrealExpectations = false;
    if (bDisplayConfigOK)
    {
        bool bSuccess = HMDDescription.Init(osvrClientContext, DisplayConfig);
        if (bSuccess)
        {
            bDisplayConfigMatchesUnrealExpectations = HMDDescription.OSVRViewerFitsUnrealModel(DisplayConfig);
            if (!bDisplayConfigMatchesUnrealExpectations)
            {
                UE_LOG(OSVRHMDLog, Warning, TEXT("The OSVR display config does not match the expectations of Unreal. Possibly incompatible HMD configuration."));
            }
        }
        else
        {
            UE_LOG(OSVRHMDLog, Warning, TEXT("Unable to initialize the HMDDescription. Possible failures during initialization."));
        }
    }

    // our version of connected is that the client context is ok (server is running)
    // and the display config is ok (/me/head exists and received a pose)
    bHmdConnected = bClientContextOK && bDisplayConfigOK && bDisplayConfigMatchesUnrealExpectations;
}