LootLocker Unreal SDK 10.7.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 {
119 {
120 EnableFileLogging(LogFileName.IsEmpty() ? "LootLockerLog" : LogFileName);
121 }
122 else
123 {
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 {
142 {
143 EnableFileLogging(LogFileName.IsEmpty() ? "LootLockerLog" : LogFileName);
144 }
145 else
146 {
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"))
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 }
197
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")
245
249 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
251
255 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
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))
276
278 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Auto-Disconnect on Focus Loss", EditCondition = "bEnablePresence && !bIsFileConfigLocked", EditConditionHides))
280
282 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Enable In Editor", EditCondition = "bEnablePresence && !bIsFileConfigLocked", EditConditionHides))
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
bool bUseLegacyHTTPStack
When true, HTTP requests are routed through the legacy ULootLockerHttpClient stack instead of the new...
Definition LootLockerConfig.h:175
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
FString LootLockerGameKey
API Key used to talk to LootLocker. The API key can be found in Settings > API Keys in the Web Consol...
Definition LootLockerConfig.h:159
FLootLockerConfigurationUpdateDelegate OnConfigurationUpdated
Definition LootLockerConfig.h:84
static ELootLockerLogLevel GetConfiguredLogLevel()
Definition LootLockerConfig.h:193
bool bEnableFileLogging
Definition LootLockerConfig.h:259
static bool IsFileConfigActive()
Returns true when a pre-configured file config is active and governing settings.
FString LongLogFilePath
Definition LootLockerConfig.h:263
static bool IsPresenceEnabledInEditor()
Check if presence is enabled in the editor.
FString OutdatedSDKWarning
Definition LootLockerConfig.h:154
static bool IsFileLoggingEnabled()
Returns true if file logging is enabled and a log file name is set.
bool bEnablePresenceAutoConnect
Whether to automatically connect presence when sessions are established.
Definition LootLockerConfig.h:275
static void DisableFileLogging()
Disables file logging.
static ELootLockerLogLevel GetRuntimeLogLevel()
Gets the current runtime log level (runtime override or config).
bool bEnablePresence
Enable or disable the entire Presence system globally.
Definition LootLockerConfig.h:271
bool bEnablePresenceInEditor
Enable presence features in the editor (for testing purposes).
Definition LootLockerConfig.h:283
static void SetRuntimeLogLevel(ELootLockerLogLevel NewLevel)
Sets the log level at runtime (not persisted).
FString InvalidGameVersionWarning
Definition LootLockerConfig.h:163
bool bEnablePresenceAutoDisconnectOnFocusChange
Whether to automatically disconnect presence when the application loses focus or goes to background.
Definition LootLockerConfig.h:279
FString FileConfigActiveNotice
Definition LootLockerConfig.h:156
static bool IsSemverString(const FString &str)
Definition LootLockerConfig.h:75
bool AllowTokenRefresh
Definition LootLockerConfig.h:165
static FString GetLogFilePath()
Returns the current log file path (may be empty if not enabled).
bool LogOutsideOfEditor
Allow LootLocker to log non error logs outside the editor. This is false by default to avoid log spam...
Definition LootLockerConfig.h:178
virtual void PostInitProperties() override
Definition LootLockerConfig.h:131
FString GameVersion
Definition LootLockerConfig.h:161
ELootLockerMultiUserSessionMode MultiUserSessionMode
Controls how the SDK handles multiple player sessions when a new authentication succeeds.
Definition LootLockerConfig.h:303
static bool ShouldLog()
Definition LootLockerConfig.h:183
FString DomainKey
Domain Key used to talk to LootLocker. The Domain key can be found in Settings > API Keys in the Web ...
Definition LootLockerConfig.h:168
static void EnableFileLogging(const FString &FileName)
Enables file logging to the specified file name.
static bool IsPresenceEnabled()
Check if presence system is enabled globally.
static bool IsPresenceAutoDisconnectOnFocusChangeEnabled()
Check if auto-disconnect on focus change is enabled.
FString LogFileName
Definition LootLockerConfig.h:261
static TOptional< FLootLockerFileConfig > ParseFileConfigContent(const FString &Content)
Parses a pre-config file's raw content (plain JSON or encrypted) into an FLootLockerFileConfig.
static bool IsPresenceAutoConnectEnabled()
Check if auto-connect is enabled for presence.
ELootLockerLogLevel LootLockerLogLevel
Definition LootLockerConfig.h:180
@ Game
Definition LootLockerFeedbackRequestHandler.h:24
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.
Definition LootLockerConfig.h:65
@ SingleSession
Only one player session exists at any given time.
Definition LootLockerConfig.h:55
@ Hotseat
Multiple active sessions are allowed simultaneously.
Definition LootLockerConfig.h:46
@ NotSet
[Not yet configured] The SDK will automatically set the correct mode the first time the project is lo...
Definition LootLockerConfig.h:36