UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PerQualityLevelProperties.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4FPerQualityLevelProperties.h: Property types that can be overridden on a quality level basis at cook time
5=============================================================================*/
6
7#pragma once
8
10#include "Containers/Map.h"
11#include "Algo/Find.h"
13#include "Scalability.h"
14#include "CoreMinimal.h"
15
16#include "PerQualityLevelProperties.generated.h"
17
18#if WITH_EDITOR
19class UObject;
21#endif
22
23
24UENUM(BlueprintType)
26{
27 Low,
28 Medium,
29 High,
30 Epic,
32 Num
33};
34
36{
37 enum class UE_DEPRECATED(5.1, "Use EPerQualityLevels instead since we need to expose as an ENUM in blueprint.") EQualityLevels : uint8
38 {
39 Low,
40 Medium,
41 High,
42 Epic,
44 Num
45 };
46
49 template<typename _ValueType>
51 template<typename _ValueType>
52 UE_DEPRECATED(5.5, "Use ConvertQualityLevelData.")
53 TMap<int32, _ValueType> ConvertQualtiyLevelData(const TMap<EPerQualityLevels, _ValueType>& Data)
54 {
55 return ConvertQualityLevelData(Data);
56 }
57 template<typename _ValueType>
59 template<typename _ValueType>
60 UE_DEPRECATED(5.5, "Use ConvertQualityLevelData.")
61 TMap<EPerQualityLevels, _ValueType> ConvertQualtiyLevelData(const TMap<int32, _ValueType>& Data)
62 {
63 return ConvertQualityLevelData(Data);
64 }
65
66 template <typename ValueType>
68 {
69 ValueType Default = 0;
71 };
72
73#if WITH_EDITOR
76#endif
77};
78
79template<typename _StructType, typename _ValueType, EName _BasePropertyName>
81{
82 typedef _ValueType ValueType;
84
89
90 _ValueType GetValueForQualityLevel(int32 QualityLevel) const
91 {
93 if (This->PerQuality.Num() == 0 || QualityLevel < 0)
94 {
95 return This->Default;
96 }
97
98 _ValueType* Value = (_ValueType*)This->PerQuality.Find(QualityLevel);
99
100 if (Value)
101 {
102 return *Value;
103 }
104 else
105 {
106 return This->Default;
107 }
108 }
109
110#if WITH_EDITOR
111 int32 GetValueForPlatform(const ITargetPlatform* TargetPlatform) const;
113 void StripQualityLevelForCooking(const TCHAR* InPlatformName = nullptr);
114 UE_DEPRECATED(5.5, "Use StripQualityLevelForCooking")
116 {
118 }
119 bool IsQualityLevelValid(int32 QualityLevel) const;
121 UE_DEPRECATED(5.5, "Use ConvertQualityLevelData")
122 void ConvertQualtiyLevelData(TMap<FName, _ValueType>& PlatformData, TMultiMap<FName, FName>& PerPlatformToQualityLevel, _ValueType Default)
123 {
125 }
126 // Use the CVar set by SetQualityLevelCVarForCooking to convert from PlatformData.
127 // This method will do nothing if bRequireAllPlatformsKnown and some of the keys in PlatformData are unrecognized as either Platform names or PlatformGroup names.
129#endif
130
131 // Set Cvar to be able to scan ini files at cook-time and only have the supported ranges of quality levels relevant to the platform.
132 // Unsupported quality levels will be stripped.
134 {
135#if WITH_EDITOR
136 ScalabilitySection = FString(InSection);
137#endif
138 CVarName = FString(InCVarName);
139 }
140
141 UE_DEPRECATED(5.4, "If no cvar is associated with the property, all quality levels will be keept when cooking. Call SetQualityLevelCVarForCooking to strip unsupported quality levels when cooking")
146
147 _ValueType GetDefault() const
148 {
150 return This->Default;
151 }
152
153 _ValueType GetValue(int32 QualityLevel) const
154 {
155 return GetValueForQualityLevel(QualityLevel);
156 }
157
158 _ValueType GetLowestValue() const
159 {
161 _ValueType Value = This->Default;
162
163 for (const TPair<int32, _ValueType>& Pair : This->PerQuality)
164 {
165 if (Pair.Value < Value)
166 {
167 Value = Pair.Value;
168 }
169 }
170 return Value;
171 }
172
173 /* Load old properties that have been converted to FPerQualityLevel */
175 {
176 if (Tag.Type == _BasePropertyName)
177 {
179 _ValueType OldValue;
180 Ar << OldValue;
181 *This = _StructType(OldValue);
182 return true;
183 }
184 return false;
185 }
186
187 /* Serialization */
189 {
190 Ar << *this;
191 return true;
192 }
193
194 /* Serialization */
196 {
197 Slot << *this;
198 return true;
199 }
200
201#if WITH_EDITOR
202 FString ScalabilitySection;
203#endif
204 FString CVarName;
205
206private:
207
208 /* Make this operator friend so it can access private member SavedValue. */
209 friend FArchive& operator<<(FArchive& Ar, FPerQualityLevelProperty& Property) { Property.StreamArchive(Ar); return Ar; }
210 friend void operator<<(FStructuredArchive::FSlot Slot, FPerQualityLevelProperty& Property) { Property.StreamStructuredArchive(Slot); }
211
212 ENGINE_API void StreamArchive(FArchive& Ar);
213 ENGINE_API void StreamStructuredArchive(FStructuredArchive::FSlot Slot);
214
215#if WITH_EDITOR
224#endif
225
226};
227
228USTRUCT(BlueprintType)
230#if CPP
232#endif
233{
235
236 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = PerQualityLevel)
238
239 UPROPERTY(EditAnywhere, Category = PerQualityLevel)
240 TMap<int32, int32> PerQuality;
241
243 {
244 Default = 0;
245 }
246
251
252 ENGINE_API FString ToString() const;
253 int32 MaxType() const { return MAX_int32; }
254};
255
256template<>
267
268USTRUCT(BlueprintType)
270#if CPP
272#endif
273{
275
276 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = PerQualityLevel)
278
279 UPROPERTY(EditAnywhere, Category = PerQualityLevel)
280 TMap<int32, float> PerQuality;
281
283 {
284 Default = 0.0f;
285 }
286
291
292 ENGINE_API FString ToString() const;
293 float MaxType() const { return UE_MAX_FLT; }
294};
295
296template<>
307
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void Init()
Definition LockFreeList.h:4
@ Num
Definition MetalRHIPrivate.h:234
#define MAX_int32
Definition NumericLimits.h:25
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EPropertyObjectReferenceType
Definition ObjectMacros.h:533
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
EPerQualityLevels
Definition PerQualityLevelProperties.h:26
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
#define UE_MAX_FLT
Definition UnrealMathUtility.h:147
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Archive.h:1208
Definition NameTypes.h:617
Definition StructuredArchiveSlots.h:52
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition Object.h:95
Definition PerQualityLevelProperties.cpp:17
FName QualityLevelToFName(int32 QL)
Definition PerQualityLevelProperties.cpp:47
TMap< int32, _ValueType > ConvertQualityLevelData(const TMap< EPerQualityLevels, _ValueType > &Data)
Definition PerQualityLevelProperties.cpp:22
TMap< int32, _ValueType > ConvertQualtiyLevelData(const TMap< EPerQualityLevels, _ValueType > &Data)
Definition PerQualityLevelProperties.h:53
int32 FNameToQualityLevel(FName QL)
Definition PerQualityLevelProperties.cpp:59
Definition PerQualityLevelProperties.h:273
FPerQualityLevelFloat(float InDefaultValue)
Definition PerQualityLevelProperties.h:287
float MaxType() const
Definition PerQualityLevelProperties.h:293
Definition PerQualityLevelProperties.h:233
FPerQualityLevelInt(int32 InDefaultValue)
Definition PerQualityLevelProperties.h:247
int32 MaxType() const
Definition PerQualityLevelProperties.h:253
Definition PerQualityLevelProperties.h:81
FString CVarName
Definition PerQualityLevelProperties.h:204
_ValueType ValueType
Definition PerQualityLevelProperties.h:82
bool SerializeFromMismatchedTag(const FPropertyTag &Tag, FArchive &Ar)
Definition PerQualityLevelProperties.h:174
bool Serialize(FStructuredArchive::FSlot Slot)
Definition PerQualityLevelProperties.h:195
friend FArchive & operator<<(FArchive &Ar, FPerQualityLevelProperty &Property)
Definition PerQualityLevelProperties.h:209
_ValueType GetLowestValue() const
Definition PerQualityLevelProperties.h:158
~FPerQualityLevelProperty()
Definition PerQualityLevelProperties.h:88
friend void operator<<(FStructuredArchive::FSlot Slot, FPerQualityLevelProperty &Property)
Definition PerQualityLevelProperties.h:210
_ValueType GetValueForQualityLevel(int32 QualityLevel) const
Definition PerQualityLevelProperties.h:90
_ValueType GetValue(int32 QualityLevel) const
Definition PerQualityLevelProperties.h:153
void SetQualityLevelCVarForCooking(const TCHAR *InCVarName, const TCHAR *InSection)
Definition PerQualityLevelProperties.h:133
_StructType StructType
Definition PerQualityLevelProperties.h:83
_ValueType GetDefault() const
Definition PerQualityLevelProperties.h:147
FPerQualityLevelProperty()
Definition PerQualityLevelProperties.h:85
bool Serialize(FArchive &Ar)
Definition PerQualityLevelProperties.h:188
Definition PropertyTag.h:38
Definition PerQualityLevelProperties.h:68
ValueType Default
Definition PerQualityLevelProperties.h:69
TMap< int32, ValueType > PerQuality
Definition PerQualityLevelProperties.h:70
Definition PimplPtr.h:50
Definition StructOpsTypeTraits.h:11
@ WithSerializer
Definition StructOpsTypeTraits.h:23
@ WithSerializeFromMismatchedTag
Definition StructOpsTypeTraits.h:28
static constexpr EPropertyObjectReferenceType WithSerializerObjectReferences
Definition StructOpsTypeTraits.h:41
Definition StructOpsTypeTraits.h:46
Definition Tuple.h:652