LootLocker Unreal SDK 10.5.0
Game backend SDK for Unreal Engine
Loading...
Searching...
No Matches
LootLockerConfig.h
Go to the documentation of this file.
1// Copyright (c) 2021 LootLocker
2
3#pragma once
4
7
8#include "Runtime/Launch/Resources/Version.h"
9#if ENGINE_MAJOR_VERSION >= 5
10#include <regex>
11#endif
12#include "CoreMinimal.h"
13#include "Logging/LogVerbosity.h"
14#include "LootLockerLogLevel.h"
16
17#include "LootLockerConfig.generated.h"
18
22DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FLootLockerConfigurationUpdateDelegate, const FString&, SettingName);
23
28UENUM(BlueprintType, Category = "LootLocker")
30{
36 NotSet UMETA(Hidden),
37
46 Hotseat UMETA(DisplayName = "Hotseat"),
47
55 SingleSession UMETA(DisplayName = "Single Session"),
56
65 ProfileSwitching UMETA(DisplayName = "Profile Switching"),
66};
67
68UCLASS(Config = Game, DefaultConfig, meta = (DisplayName = "LootLocker SDK Settings"))
69class LOOTLOCKERSDK_API ULootLockerConfig : public UObject
70{
71 GENERATED_BODY()
72public:
73
74 UFUNCTION()
75 static bool IsSemverString(const FString& str)
76 {
77#if ENGINE_MAJOR_VERSION >= 5
78 return std::regex_match(TCHAR_TO_UTF8(*str), SemverPattern);
79#else
80 return true;
81#endif
82 }
83
85
90 static bool IsFileConfigActive();
91
97 static TOptional<FLootLockerFileConfig> ParseFileConfigContent(const FString& Content);
98
103#if ENGINE_MAJOR_VERSION >= 5
104 inline static const FString PreConfigFileName = TEXT("LootLockerPreConfig.bytes");
105#else
106 static const FString PreConfigFileName;
107#endif
108
109#if WITH_EDITOR
110 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override
111 {
112 if (PropertyChangedEvent.GetPropertyName() == "GameVersion")
113 {
114 IsValidGameVersion = IsSemverString(GameVersion);
115 }
116 if (PropertyChangedEvent.GetPropertyName() == "bEnableFileLogging" || PropertyChangedEvent.GetPropertyName() == "LogFileName")
117 {
118 if (bEnableFileLogging)
119 {
120 EnableFileLogging(LogFileName.IsEmpty() ? "LootLockerLog" : LogFileName);
121 }
122 else
123 {
124 DisableFileLogging();
125 }
126 }
127 OnConfigurationUpdated.Broadcast(PropertyChangedEvent.GetPropertyName().ToString());
128 UObject::PostEditChangeProperty(PropertyChangedEvent);
129 }
130#endif //WITH_EDITOR
131 virtual void PostInitProperties() override
132 {
133 IsValidGameVersion = IsSemverString(GameVersion);
134 MigrateSettingsIfNeeded();
135 LoadFileConfig();
136 ApplyFileConfigIfPresent();
137 // File logging is already handled by ApplyFileConfigIfPresent
138 // when a file config is active. So skip it when file config is active.
139 if (!bIsFileConfigLocked)
140 {
141 if(bEnableFileLogging)
142 {
143 EnableFileLogging(LogFileName.IsEmpty() ? "LootLockerLog" : LogFileName);
144 }
145 else
146 {
147 DisableFileLogging();
148 }
149 }
150 UObject::PostInitProperties();
151 }
152
153 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLocker", Meta = (EditCondition = "IsOutdatedSDK", EditConditionHides), Meta = (MultiLine = true), Meta = (DisplayName = "WARNING:"), Transient)
154 FString OutdatedSDKWarning = "This version of LootLocker is no longer updated through fab because of fab guidelines. Please use GitHub releases to update: https://github.com/lootlocker/unreal-sdk/releases";
155 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLocker", Meta = (EditCondition = "bIsFileConfigLocked", EditConditionHides), Meta = (MultiLine = true), Meta = (DisplayName = "INFO:"), Transient)
156 FString FileConfigActiveNotice = "Settings are governed by the pre-configured file config shipped with the plugin and cannot be changed from the editor.";
158 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker", Meta = (DisplayName = "LootLocker API Key", EditCondition = "!bIsFileConfigLocked"))
159 FString LootLockerGameKey = "";
160 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker", Meta = (EditCondition = "!bIsFileConfigLocked"))
161 FString GameVersion = "";
162 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLocker", Meta = (EditCondition = "!IsValidGameVersion", EditConditionHides), Meta = (MultiLine = true), Meta = (DisplayName = "WARNING:"), Transient)
163 FString InvalidGameVersionWarning = "Game version needs to follow a numeric Semantic Versioning pattern: X.Y.Z.B with the sections denoting MAJOR.MINOR.PATCH.BUILD and the last two being optional. Read more at https://docs.lootlocker.com/the-basics/core-concepts/glossary#game-version";
164 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker", Meta = (EditCondition = "!bIsFileConfigLocked"))
165 bool AllowTokenRefresh = true;
167 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker", Meta = (EditCondition = "!bIsFileConfigLocked"))
168 FString DomainKey = "";
174 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker", Meta = (DisplayName = "Use Legacy HTTP Stack", EditCondition = "!bIsFileConfigLocked"))
175 bool bUseLegacyHTTPStack = false;
177 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging", Meta = (EditCondition = "!bIsFileConfigLocked"))
178 bool LogOutsideOfEditor = false;
179 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging", Meta = (DisplayName = "LootLocker Log Level", EditCondition = "!bIsFileConfigLocked"))
180 ELootLockerLogLevel LootLockerLogLevel = ELootLockerLogLevel::Warning;
181
182 UFUNCTION()
183 static bool ShouldLog()
184 {
185#if WITH_EDITOR
186 return true;
187#else
188 return GetDefault<ULootLockerConfig>()->LogOutsideOfEditor;
189#endif
190 }
191
192 // Returns the configured log level from config or ini
193 static ELootLockerLogLevel GetConfiguredLogLevel()
194 {
195 return GetDefault<ULootLockerConfig>()->LootLockerLogLevel;
196 }
201 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
202 static void SetRuntimeLogLevel(ELootLockerLogLevel NewLevel);
206 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
207 static ELootLockerLogLevel GetRuntimeLogLevel();
212 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
213 static void EnableFileLogging(const FString& FileName);
217 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
218 static void DisableFileLogging();
222 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
223 static bool IsFileLoggingEnabled();
227 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
228 static FString GetLogFilePath();
229
230 // ========================================================================
231 // PRESENCE CONFIGURATION ACCESSORS
232 // ========================================================================
233
237 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
238 static bool IsPresenceEnabled();
239
243 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
244 static bool IsPresenceAutoConnectEnabled();
245
249 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
250 static bool IsPresenceAutoDisconnectOnFocusChangeEnabled();
251
255 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
256 static bool IsPresenceEnabledInEditor();
257
258 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging", Meta = (DisplayName = "Enable File Logging", EditCondition = "!bIsFileConfigLocked"))
259 bool bEnableFileLogging = false;
260 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging", Meta = (DisplayName = "Name of LootLocker Log File", EditCondition = "bEnableFileLogging && !bIsFileConfigLocked", EditConditionHides))
261 FString LogFileName = TEXT("LootLockerLog");
262 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLocker|Logging", Meta = (EditCondition = "bEnableFileLogging", EditConditionHides), Meta = (MultiLine = true), Meta = (DisplayName = "Actual Log File (on current device)"), Transient)
263 FString LongLogFilePath = "";
264
265 // ========================================================================
266 // PRESENCE CONFIGURATION
267 // ========================================================================
268
270 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Enable Presence System", EditCondition = "!bIsFileConfigLocked"))
271 bool bEnablePresence = false;
272
274 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Auto-Connect on Session Start", EditCondition = "bEnablePresence && !bIsFileConfigLocked", EditConditionHides))
275 bool bEnablePresenceAutoConnect = true;
276
278 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Auto-Disconnect on Focus Loss", EditCondition = "bEnablePresence && !bIsFileConfigLocked", EditConditionHides))
279 bool bEnablePresenceAutoDisconnectOnFocusChange = true;
280
282 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Enable In Editor", EditCondition = "bEnablePresence && !bIsFileConfigLocked", EditConditionHides))
283 bool bEnablePresenceInEditor = true;
284
285 // ========================================================================
286 // MULTI USER CONFIGURATION
287 // ========================================================================
288
302 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Multi User", Meta = (DisplayName = "Multi User Session Mode", EditCondition = "!bIsFileConfigLocked"))
304private:
305 FString LogFilePath = "";
306 UPROPERTY(Config, VisibleInstanceOnly, Meta = (EditCondition = "false", EditConditionHides), Transient, Category = "LootLocker")
307 bool IsValidGameVersion = true;
308 UPROPERTY(Config, VisibleInstanceOnly, Meta = (EditCondition = "false", EditConditionHides), Transient, Category = "LootLocker")
309 bool bIsFileConfigLocked = false;
310#if ENGINE_MAJOR_VERSION >= 5
311 inline static bool bFileConfigChecked = false;
312 inline static TOptional<FLootLockerFileConfig> FileConfig;
313#else
314 static bool bFileConfigChecked;
315 static TOptional<FLootLockerFileConfig> FileConfig;
316#endif
317 UPROPERTY(Config, VisibleInstanceOnly, Meta = (EditCondition = "false", EditConditionHides), Transient, Category = "LootLocker")
318 bool IsOutdatedSDK
319#ifdef LOOTLOCKER_SHOW_OUTDATED_SDK_MESSAGE
320 = true
321#else
322 = false
323#endif
324 ;
325#if ENGINE_MAJOR_VERSION >= 5
326 inline static const std::regex SemverPattern = std::regex("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?$" );
327#endif
328
333 void MigrateSettingsIfNeeded();
334
335 static void LoadFileConfig();
336 void ApplyFileConfigIfPresent();
337};
338
Definition LootLockerConfig.h:70
static const FString PreConfigFileName
Filename of the pre-config file that the SDK looks for in the plugin's Config directory.
Definition LootLockerConfig.h:106
FLootLockerConfigurationUpdateDelegate OnConfigurationUpdated
Definition LootLockerConfig.h:84
static ELootLockerLogLevel GetConfiguredLogLevel()
Definition LootLockerConfig.h:193
static bool IsFileConfigActive()
Returns true when a pre-configured file config is active and governing settings.
virtual void PostInitProperties() override
Definition LootLockerConfig.h:131
static TOptional< FLootLockerFileConfig > ParseFileConfigContent(const FString &Content)
Parses a pre-config file's raw content (plain JSON or encrypted) into an FLootLockerFileConfig.
void(* FLootLockerConfigurationUpdateDelegate)(const FString &)
Delegate type for configuration update events.
Definition LootLockerConfig.h:22
ELootLockerMultiUserSessionMode
Controls how the SDK handles multiple player sessions when a new authentication succeeds.
Definition LootLockerConfig.h:30
@ ProfileSwitching
Only one player is active at a time, but historical player sessions are retained in a cold cache.
@ SingleSession
Only one player session exists at any given time.
@ Hotseat
Multiple active sessions are allowed simultaneously.
@ NotSet
[Not yet configured] The SDK will automatically set the correct mode the first time the project is lo...