UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DeviceProfileManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 DeviceProfileManager.h: Declares the FDeviceProfileManager class.
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
11#include "UObject/Object.h"
13#include "CoreGlobals.h"
14#include "HAL/IConsoleManager.h"
15#include "DeviceProfileManager.generated.h"
16
17class UDeviceProfile;
18
19// Delegate used to refresh the UI when the profiles change
21
22// Delegate used to notify systems when the active device profile changes
24
25#if ALLOW_OTHER_PLATFORM_CONFIG
26// Delegate used to notify systems when the preview device profile changes
28#endif
29
30// Delegate used to notify systems pre reapply device profiles
32// Delegate used to notify systems post reapplied device profiles
34
46
50 UCLASS( config=DeviceProfiles, transient , MinimalAPI)
52{
53public:
54
56
57
61 static ENGINE_API void InitializeCVarsForActiveDeviceProfile(bool bPushSettings = false, bool bIsDeviceProfilePreview = false, bool bForceReload = false);
62
67 ENGINE_API void ReapplyDeviceProfile(bool bForceReload = false, TSet<FString>* ModifiedCVars=nullptr);
68
75 ENGINE_API bool DoActiveProfilesReference(const TSet<FString>& DeviceProfilesToQuery);
76
85 ENGINE_API UDeviceProfile* CreateProfile(const FString& ProfileName, const FString& ProfileType, const FString& ParentName=TEXT(""), const TCHAR* ConfigPlatform=nullptr);
86
95 ENGINE_API bool HasLoadableProfileName(const FString& ProfileName, FName OptionalPlatformName = FName());
96
104 ENGINE_API TArray<FString> GetLoadableProfileNames(FName OptionalPlatformName = FName()) const;
105
111 ENGINE_API void DeleteProfile( UDeviceProfile* Profile );
112
121 ENGINE_API UDeviceProfile* FindProfile(const FString& ProfileName, bool bCreateProfileOnFail = true, FName OptionalPlatformName = FName());
122
126 ENGINE_API void SetOverrideDeviceProfile(UDeviceProfile* DeviceProfile);
127
131 ENGINE_API void RestoreDefaultDeviceProfile();
132
133#if ALLOW_OTHER_PLATFORM_CONFIG
140
145
150#endif
151
155 ENGINE_API void LoadProfiles();
156
162 ENGINE_API FOnDeviceProfileManagerUpdated& OnManagerUpdated();
163
169 ENGINE_API FOnActiveDeviceProfileChanged& OnActiveDeviceProfileChanged();
170
176 ENGINE_API FWillReapplyDeviceProfiles& WillReapplyDeviceProfiles();
177
183 ENGINE_API FOnReapplyDeviceProfiles& OnReapplyDeviceProfiles();
184
188 ENGINE_API void GetProfileConfigFiles(OUT TArray<FString>& OutConfigFiles);
189
193 ENGINE_API void SaveProfiles(bool bSaveToDefaults = false);
194
200 ENGINE_API UDeviceProfile* GetActiveProfile() const;
201
207 ENGINE_API UDeviceProfile* GetPreviewDeviceProfile() const;
208
215 ENGINE_API void GetAllPossibleParentProfiles(const UDeviceProfile* ChildProfile, OUT TArray<UDeviceProfile*>& PossibleParentProfiles) const;
216
222 ENGINE_API const FString GetActiveDeviceProfileName();
223
234 ENGINE_API const FString GetActiveDeviceProfileMatchedFragmentsString(bool bEnabledOnly, bool bIncludeTags, bool bAlphaSort);
235
242 UE_DEPRECATED(4.25, "Use either GetActiveDeviceProfileName to have the current active device profile or GetPlatformDeviceProfileName to have the default one. Note, GetActiveDeviceProfileName will fallback on GetPlatformDeviceProfileName, if there is no active device profile ")
243 static ENGINE_API const FString GetActiveProfileName();
244
251 static ENGINE_API const FString GetPlatformDeviceProfileName();
252
254 static ENGINE_API bool GetScalabilityCVar(const FString& CvarName, int32& OutValue);
255 static ENGINE_API bool GetScalabilityCVar(const FString& CvarName, float& OutValue);
256
261 ENGINE_API void ChangeTaggedFragmentState(FName FragmentTag, bool bNewState);
262
267 ENGINE_API const FSelectedFragmentProperties* GetActiveDeviceProfileFragmentByTag(FName& FragmentTag) const;
268
269
271 {
272 DPM_SetCVars,
273 DPM_CacheValues,
274 DPM_CacheValuesIgnoreMatchingRules, // GatherDeviceProfileCVars will not return any matching rules cvars. Used when entire matching rules state is applied later (see GetAllReferencedDeviceProfileCVars).
275 DPM_SetCVarsForSingleDP,
276 DPM_SetCVarsForSingleFragment,
277 };
278
282 static ENGINE_API TMap<FName, FString> GatherDeviceProfileCVars(const FString& DeviceProfileName, EDeviceProfileMode GatherMode);
283
287 static ENGINE_API TMap<FName, TSet<FString>> GetAllReferencedDeviceProfileCVars(UDeviceProfile* DeviceProfile);
288
293 TArray<TTuple<FName, FString>> GetDPChain(const FString& DeviceProfileName, FConfigCacheIni* ConfigSystem);
294
295private:
301 ENGINE_API void SetActiveDeviceProfile( UDeviceProfile* DeviceProfile );
302
306 ENGINE_API void HandleDeviceProfileOverrideChange();
307
309 ENGINE_API bool AreProfilesTheSame(UDeviceProfile* Profile1, UDeviceProfile* Profile2) const;
310
312 ENGINE_API bool AreTextureGroupsTheSame(UDeviceProfile* Profile1, UDeviceProfile* Profile2) const;
313
318 static ENGINE_API void SetDeviceProfileCVars(const FString& DeviceProfileName);
319
320
322 static ENGINE_API TArray<FSelectedFragmentProperties> FindMatchingFragments(const FString& ParentDP, class FConfigCacheIni* PreviewConfigSystem);
323
325 static ENGINE_API TArray<FString> FindAllReferencedFragmentsFromMatchedRules(const FString& ParentDP, FConfigCacheIni* ConfigSystem);
326
328 static ENGINE_API const FString FragmentPropertyArrayToFragmentString(const TArray<FSelectedFragmentProperties>& FragmentProperties, bool bEnabledOnly, bool bIncludeTags, bool bAlphaSort);
329
331 static ENGINE_API class IDeviceProfileSelectorModule* GetDeviceProfileSelectorModule();
332
333#if ALLOW_OTHER_PLATFORM_CONFIG && WITH_EDITOR
336#endif
337public:
338
341
342 virtual void PostCDOContruct() override
343 {
344 Get(true); // get this taken care of now
345 }
346
347
348public:
349
350 // Holds the collection of managed profiles.
351 UPROPERTY( EditAnywhere, Category=Properties )
353
354private:
355 // Cached copy of profiles at load
356 UPROPERTY()
357 TArray< TObjectPtr<UDeviceProfile> > BackupProfiles;
358
359 // Holds a delegate to be invoked profiles are updated.
360 FOnDeviceProfileManagerUpdated ManagerUpdatedDelegate;
361
362 // Holds a delegate to be invoked when the active deviceprofile changes
363 FOnActiveDeviceProfileChanged ActiveDeviceProfileChangedDelegate;
364
365#if ALLOW_OTHER_PLATFORM_CONFIG
366 // Holds a delegate to be invoked when the preview deviceprofile changes
368#endif
369
370 // Holds a delegate to be invoked pre reapply device profiles
371 FWillReapplyDeviceProfiles PreReapplyDeviceProfilesDelegate;
372 // Holds a delegate to be invoked post reapply device profiles
373 FOnReapplyDeviceProfiles PostReapplyDeviceProfilesDelegate;
374
375 // Holds the selected device profile
376 UDeviceProfile* ActiveDeviceProfile;
377
378 // Add to profile to get load time backup
379 static ENGINE_API FString BackupSuffix;
380
381 // Original values of all the CVars modified by the DP.
382 // Used to undo the DP before applying new state.
383 static ENGINE_API TMap<FString, FPushedCVarSetting> PushedSettings;
384
385 // Holds the device profile that has been overridden, null no override active.
386 UDeviceProfile* BaseDeviceProfile = nullptr;
387
388 // Holds the device profile that we are previewing.
389 UDeviceProfile* PreviewDeviceProfile = nullptr;
390
391 // Stores any scalability group settings set by the active device profile.
392 static ENGINE_API TMap<FString, FString> DeviceProfileScalabilityCVars;
393
394 // Stores any scalability group settings set by the preview device profile.
395 static ENGINE_API TMap<FString, FString> PreviewDeviceProfileScalabilityCVars;
396
397 // The list of fragments that have been selected by the active profile.
398 static ENGINE_API TArray<FSelectedFragmentProperties> PlatformFragmentsSelected;
399};
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define OUT
Definition Platform.h:897
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:23
EConsoleVariableFlags
Definition IConsoleManager.h:54
@ ECVF_Default
Definition IConsoleManager.h:61
@ ECVF_SetByMask
Definition IConsoleManager.h:140
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition ConfigCacheIni.h:1240
Definition NameTypes.h:617
Definition IDeviceProfileSelectorModule.h:20
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition DeviceProfileManager.h:52
TArray< TObjectPtr< UDeviceProfile > > Profiles
Definition DeviceProfileManager.h:352
static ENGINE_API class UDeviceProfileManager * DeviceProfileManagerSingleton
Definition DeviceProfileManager.h:339
static ENGINE_API UDeviceProfileManager & Get(bool bFromPostCDOContruct=false)
Definition DeviceProfileManager.cpp:71
EDeviceProfileMode
Definition DeviceProfileManager.h:271
virtual void PostCDOContruct() override
Definition DeviceProfileManager.h:342
Definition DeviceProfile.h:22
Definition Object.h:95
Definition DeviceProfileManager.h:36
FPushedCVarSetting(const FString &InValue, EConsoleVariableFlags InFlags)
Definition DeviceProfileManager.h:38
FString Value
Definition DeviceProfileManager.h:43
FPushedCVarSetting()
Definition DeviceProfileManager.h:37
EConsoleVariableFlags SetBy
Definition DeviceProfileManager.h:44
Definition DeviceProfileMatching.h:15
Definition ObjectPtr.h:488