Ejemplo n.º 1
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);
			}
		}
	}
void UDeveloperSettings::ImportConsoleVariableValues()
{
	for (UProperty* Property = GetClass()->PropertyLink; Property; Property = Property->PropertyLinkNext)
	{
		if (!Property->HasAnyPropertyFlags(CPF_Config))
		{
			continue;
		}

		FString CVarName = Property->GetMetaData(DeveloperSettingsConsoleVariableMetaFName);
		if (!CVarName.IsEmpty())
		{
			IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName);
			if (CVar)
			{
				if (Property->ImportText(*CVar->GetString(), Property->ContainerPtrToValuePtr<uint8>(this, 0), PPF_ConsoleVariable, this) == NULL)
				{
					UE_LOG(LogTemp, Error, TEXT("%s import failed for %s on console variable %s (=%s)"), *GetClass()->GetName(), *Property->GetName(), *CVarName, *CVar->GetString());
				}
			}
			else
			{
				UE_LOG(LogTemp, Fatal, TEXT("%s failed to find console variable %s for %s"), *GetClass()->GetName(), *CVarName, *Property->GetName());
			}
		}
	}
}
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
// Try and match the current cvar state against the scalability sections too see if one matches. OutQualityLevel will be set to -1 if none match
static void InferCurrentQualityLevel(const FString& InGroupName, int32& OutQualityLevel, TArray<FString>* OutCVars)
{
	TArray<FString> SectionNames;
	GConfig->GetSectionNames(GScalabilityIni, SectionNames);
	OutQualityLevel = -1;

	for (int32 SectionNameIndex = 0; SectionNameIndex < SectionNames.Num(); ++SectionNameIndex)
	{
		FString GroupName;
		int32 GroupQualityLevel;

		if (SplitSectionName(SectionNames[SectionNameIndex], GroupName, GroupQualityLevel))
		{
			if (GroupName == FString(InGroupName))
			{
				TArray<FString> CVarData;
				GConfig->GetSection(*SectionNames[SectionNameIndex], CVarData, GScalabilityIni);

				bool bAllMatch = true;

				// Check all cvars against current state to see if they match
				for (int32 DataIndex = 0; DataIndex < CVarData.Num(); ++DataIndex)
				{
					const FString& CVarString = CVarData[DataIndex];
					FString CVarName, CVarValue;
					if (CVarString.Split(TEXT("="), &CVarName, &CVarValue))
					{
						IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName);
						if (CVar)
						{
							float CurrentValue = CVar->GetFloat();
							float ValueToCheck = FCString::Atof(*CVarValue);

							if (ValueToCheck != CurrentValue)
							{
								bAllMatch = false;
								break;
							}
						}
					}
				}

				if (bAllMatch)
				{
					OutQualityLevel = FMath::Max(OutQualityLevel, GroupQualityLevel);
					if (OutCVars)
					{
						*OutCVars = CVarData;
					}
				}
			}
		}
	}
}
Ejemplo n.º 5
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.º 7
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 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());
		}
	}
}
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.º 10
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;
}
Ejemplo n.º 11
0
bool UGameEngine::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar )
{
	if( FParse::Command( &Cmd,TEXT("REATTACHCOMPONENTS")) || FParse::Command( &Cmd,TEXT("REREGISTERCOMPONENTS")))
	{
		UE_LOG(LogConsoleResponse, Warning, TEXT("Deprectated command! Please use 'Reattach.Components' instead."));
		return true;
	}
	else if( FParse::Command( &Cmd,TEXT("EXIT")) || FParse::Command(&Cmd,TEXT("QUIT")))
	{
		FString CmdName = FParse::Token(Cmd, 0);
		bool Background = false;
		if (!CmdName.IsEmpty() && !FCString::Stricmp(*CmdName, TEXT("background")))
		{
			Background = true;
		}

		if ( Background && FPlatformProperties::SupportsMinimize() )
		{
			return HandleMinimizeCommand( Cmd, Ar );
		}
		else if ( FPlatformProperties::SupportsQuit() )
		{
			return HandleExitCommand( Cmd, Ar );
		}
		else
		{
			// ignore command on xbox one and ps4 as it will cause a crash
			// ttp:321126
			return true;
		}
	}
	else if( FParse::Command( &Cmd, TEXT("GETMAXTICKRATE") ) )
	{
		return HandleGetMaxTickRateCommand( Cmd, Ar );
	}
	else if( FParse::Command( &Cmd, TEXT("CANCEL") ) )
	{
		return HandleCancelCommand( Cmd, Ar, InWorld );	
	}
	else if ( FParse::Command( &Cmd, TEXT("TOGGLECVAR") ) )
	{
		FString CVarName;
		FParse::Token(Cmd, CVarName, false);

		bool bEnoughParamsSupplied = false;
		IConsoleVariable * CVar = nullptr;

		if (CVarName.Len() > 0)
		{
			CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName);
		}

		if (CVar)
		{
			// values to toggle between
			FString StringVal1, StringVal2;
			
			if (FParse::Token(Cmd, StringVal1, false))
			{
				if (FParse::Token(Cmd, StringVal2, false))
				{
					bEnoughParamsSupplied = true;
					FString CurrentValue = CVar->GetString();

					FString Command(FString::Printf(TEXT("%s %s"), *CVarName, (CurrentValue == StringVal1) ? *StringVal2 : *StringVal1));
					GEngine->Exec(InWorld, *Command);
				}
			}
		}
		else
		{
			Ar.Log(*FString::Printf(TEXT("TOGGLECVAR: cvar '%s' was not found"), *CVarName));
			bEnoughParamsSupplied = true;	// cannot say anything about the rest of parameters
		}
		
		if (!bEnoughParamsSupplied)
		{
			Ar.Log(TEXT("Usage: TOGGLECVAR CVarName Value1 Value2"));
		}

		return true;
	}
#if !UE_BUILD_SHIPPING
	else if( FParse::Command( &Cmd, TEXT("ApplyUserSettings") ) )
	{
		return HandleApplyUserSettingsCommand( Cmd, Ar );
	}
#endif // !UE_BUILD_SHIPPING
	else if( InWorld && InWorld->Exec( InWorld, Cmd, Ar ) )
	{
		return true;
	}
	else if( InWorld && InWorld->GetAuthGameMode() && InWorld->GetAuthGameMode()->ProcessConsoleExec(Cmd,Ar,NULL) )
	{
		return true;
	}
	else
	{
#if UE_BUILD_SHIPPING
		// disallow set of actor properties if network game
		if ((FParse::Command( &Cmd, TEXT("SET")) || FParse::Command( &Cmd, TEXT("SETNOPEC"))))
		{
			FWorldContext &Context = GetWorldContextFromWorldChecked(InWorld);
			if( Context.PendingNetGame != NULL || InWorld->GetNetMode() != NM_Standalone)
			{
				return true;
			}
			// the effects of this cannot be easily reversed, so prevent the user from playing network games without restarting to avoid potential exploits
			GDisallowNetworkTravel = true;
		}
#endif // UE_BUILD_SHIPPING
		if (UEngine::Exec(InWorld, Cmd, Ar))
		{
			return true;
		}
		else if (UPlatformInterfaceBase::StaticExec(Cmd, Ar))
		{
			return true;
		}
	
		return false;
	}
}