LootLocker Unreal SDK 10.4.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"
15
16#include "LootLockerConfig.generated.h"
17
21DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FLootLockerConfigurationUpdateDelegate, const FString&, SettingName);
22
23UCLASS(Config = Game, DefaultConfig, meta = (DisplayName = "LootLocker SDK Settings"))
24class LOOTLOCKERSDK_API ULootLockerConfig : public UObject
25{
26 GENERATED_BODY()
27public:
28
29 UFUNCTION()
30 static bool IsSemverString(const FString& str)
31 {
32#if ENGINE_MAJOR_VERSION >= 5
33 return std::regex_match(TCHAR_TO_UTF8(*str), SemverPattern);
34#else
35 return true;
36#endif
37 }
38
40
41#if WITH_EDITOR
42 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override
43 {
44 if (PropertyChangedEvent.GetPropertyName() == "GameVersion")
45 {
46 IsValidGameVersion = IsSemverString(GameVersion);
47 }
48 if (PropertyChangedEvent.GetPropertyName() == "bEnableFileLogging" || PropertyChangedEvent.GetPropertyName() == "LogFileName")
49 {
50 if (bEnableFileLogging)
51 {
52 EnableFileLogging(LogFileName.IsEmpty() ? "LootLockerLog" : LogFileName);
53 }
54 else
55 {
56 DisableFileLogging();
57 }
58 }
59 OnConfigurationUpdated.Broadcast(PropertyChangedEvent.GetPropertyName().ToString());
60 UObject::PostEditChangeProperty(PropertyChangedEvent);
61 }
62#endif //WITH_EDITOR
63 virtual void PostInitProperties() override
64 {
65 IsValidGameVersion = IsSemverString(GameVersion);
66 if(bEnableFileLogging)
67 {
68 EnableFileLogging(LogFileName.IsEmpty() ? "LootLockerLog" : LogFileName);
69 }
70 else
71 {
72 DisableFileLogging();
73 }
74 UObject::PostInitProperties();
75 }
76
77 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLocker", Meta = (EditCondition = "IsOutdatedSDK", EditConditionHides), Meta = (MultiLine = true), Meta = (DisplayName = "WARNING:"), Transient)
78 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";
80 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker", Meta = (DisplayName = "LootLocker API Key"))
81 FString LootLockerGameKey = "";
82 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker")
83 FString GameVersion = "";
84 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLocker", Meta = (EditCondition = "!IsValidGameVersion", EditConditionHides), Meta = (MultiLine = true), Meta = (DisplayName = "WARNING:"), Transient)
85 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";
86 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker")
87 bool AllowTokenRefresh = true;
89 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker")
90 FString DomainKey = "";
96 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker", Meta = (DisplayName = "Use Legacy HTTP Stack"))
97 bool bUseLegacyHTTPStack = false;
99 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging")
100 bool LogOutsideOfEditor = false;
101 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging", Meta = (DisplayName = "LootLocker Log Level"))
102 ELootLockerLogLevel LootLockerLogLevel;
103
104 UFUNCTION()
105 static bool ShouldLog()
106 {
107#if WITH_EDITOR
108 return true;
109#else
110 return GetDefault<ULootLockerConfig>()->LogOutsideOfEditor;
111#endif
112 }
113
114 // Returns the configured log level from config or ini
115 static ELootLockerLogLevel GetConfiguredLogLevel()
116 {
117 return GetDefault<ULootLockerConfig>()->LootLockerLogLevel;
118 }
123 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
124 static void SetRuntimeLogLevel(ELootLockerLogLevel NewLevel);
128 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
129 static ELootLockerLogLevel GetRuntimeLogLevel();
134 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
135 static void EnableFileLogging(const FString& FileName);
139 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
140 static void DisableFileLogging();
144 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
145 static bool IsFileLoggingEnabled();
149 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
150 static FString GetLogFilePath();
151
152 // ========================================================================
153 // PRESENCE CONFIGURATION ACCESSORS
154 // ========================================================================
155
159 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
160 static bool IsPresenceEnabled();
161
165 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
166 static bool IsPresenceAutoConnectEnabled();
167
171 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
172 static bool IsPresenceAutoDisconnectOnFocusChangeEnabled();
173
177 UFUNCTION(BlueprintCallable, Category = "LootLocker|Presence")
178 static bool IsPresenceEnabledInEditor();
179
180 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging", Meta = (DisplayName = "Enable File Logging"))
181 bool bEnableFileLogging = false;
182 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Logging", Meta = (DisplayName = "Name of LootLocker Log File", EditCondition = "bEnableFileLogging", EditConditionHides))
183 FString LogFileName = TEXT("LootLockerLog");
184 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLocker|Logging", Meta = (EditCondition = "bEnableFileLogging", EditConditionHides), Meta = (MultiLine = true), Meta = (DisplayName = "Actual Log File (on current device)"), Transient)
185 FString LongLogFilePath = "";
186
187 // ========================================================================
188 // PRESENCE CONFIGURATION
189 // ========================================================================
190
192 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Enable Presence System"))
193 bool bEnablePresence = false;
194
196 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Auto-Connect on Session Start", EditCondition = "bEnablePresence", EditConditionHides))
197 bool bEnablePresenceAutoConnect = true;
198
200 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Auto-Disconnect on Focus Loss", EditCondition = "bEnablePresence", EditConditionHides))
201 bool bEnablePresenceAutoDisconnectOnFocusChange = true;
202
204 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLocker|Presence", Meta = (DisplayName = "Enable In Editor", EditCondition = "bEnablePresence", EditConditionHides))
205 bool bEnablePresenceInEditor = true;
206private:
207 FString LogFilePath = "";
208 UPROPERTY(Config, VisibleInstanceOnly, Meta = (EditCondition = "false", EditConditionHides), Transient, Category = "LootLocker")
209 bool IsValidGameVersion = true;
210 UPROPERTY(Config, VisibleInstanceOnly, Meta = (EditCondition = "false", EditConditionHides), Transient, Category = "LootLocker")
211 bool IsOutdatedSDK
212#ifdef LOOTLOCKER_SHOW_OUTDATED_SDK_MESSAGE
213 = true
214#else
215 = false
216#endif
217 ;
218#if ENGINE_MAJOR_VERSION >= 5
219 inline static const std::regex SemverPattern = std::regex("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?$" );
220#endif
221
222public:
224private:
225};
Definition LootLockerConfig.h:25
FLootLockerConfigurationUpdateDelegate OnConfigurationUpdated
Definition LootLockerConfig.h:39
static ELootLockerLogLevel GetConfiguredLogLevel()
Definition LootLockerConfig.h:115
virtual void PostInitProperties() override
Definition LootLockerConfig.h:63
void(* FLootLockerConfigurationUpdateDelegate)(const FString &)
Delegate type for configuration update events.
Definition LootLockerConfig.h:21