Unreal access to the PixoVR Platform
Loading...
Searching...
No Matches
PPlatformCoreSettings.cpp
Go to the documentation of this file.
1// Copyright 2023 PixoVR Corp. All Rights Reserved.
2
4
5#if WITH_EDITORONLY_DATA
6#include "GeneralProjectSettings.h"
7#include "AndroidRuntimeSettings.h"
9#endif
10
11DEFINE_LOG_CATEGORY_STATIC(LogPPlatformCoreSettings, Log, All);
12
13#define Log(pmt, ...) UE_LOG(LogPPlatformCoreSettings, Log, TEXT(pmt), ##__VA_ARGS__)
14#define Warn(pmt, ...) UE_LOG(LogPPlatformCoreSettings, Warning, TEXT(pmt), ##__VA_ARGS__)
15#define Error(pmt, ...) UE_LOG(LogPPlatformCoreSettings, Error, TEXT(pmt), ##__VA_ARGS__)
16#define Fatal(pmt, ...) UE_LOG(LogPPlatformCoreSettings, Fatal, TEXT(pmt), ##__VA_ARGS__)
17
18UPPlatformCoreSettings::UPPlatformCoreSettings(const FObjectInitializer& ObjectInitializer)
19 : Super(ObjectInitializer)
20{
21 ConfigURL = TEXT("https://module.pixovr.com/");
22 ConfigSection = TEXT("");
23
24 ProtocolVersion = TEXT("1.0");
25 PlatformName = TEXT("");
26 IconURL = TEXT("");
27 Region = TEXT("NA");
28 bDevMode = false;
29
30 PlatformURL = TEXT("https://module.pixovr.com/");
31 ModuleId = -1;
32 ModuleVersion = TEXT("1.00.00");
33 bSyncVersion = true;
34
35 ModuleListURLFormat = TEXT("{platform_url}/org/{org_id}/modules");
36
37 bIsMultiplayerEnabled = false;
38 bServerVersionMatchModule = false;
39 ServerMatchVersion = ModuleVersion;
40 MatchmakingURL = TEXT("wss://match.apex.pixovr.com/matchmake");
41
42 bIsVoiceChatEnabled = false;
43 VoiceServerURL = TEXT("https://gateway.odin.4players.io");
44 VoiceAccessKey = TEXT("");
45 VoiceTokenAudience = TEXT("Default");
46}
47
48bool UPPlatformCoreSettings::CheckVersionString(FString VersionString) const
49{
50 TArray<FString> ModuleVersionArray;
51 return GetModuleVersionArray(VersionString, ModuleVersionArray);
52}
53
54bool UPPlatformCoreSettings::GetModuleVersionArray(FString Version, TArray<FString>& ModuleVersionArray) const
55{
56 int VersionPartCount = Version.ParseIntoArray(ModuleVersionArray, TEXT("."));
57
58 if (VersionPartCount != 3)
59 {
60 return false;
61 }
62
63 if (ModuleVersionArray[0].Len() <= 0 || ModuleVersionArray[0].StartsWith("0") || !ModuleVersionArray[0].IsNumeric())
64 {
65 return false;
66 }
67
68 if (ModuleVersionArray[1].Len() != 2 || !ModuleVersionArray[1].IsNumeric())
69 {
70 return false;
71 }
72
73 if (ModuleVersionArray[2].Len() != 2 || !ModuleVersionArray[2].IsNumeric())
74 {
75 return false;
76 }
77
78 return true;
79}
80
81#if WITH_EDITORONLY_DATA
82void UPPlatformCoreSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
83{
84 if (PropertyChangedEvent.Property != nullptr)
85 {
86 const FName PropertyName(PropertyChangedEvent.Property->GetFName());
87 if (PropertyName == GET_MEMBER_NAME_CHECKED(UPPlatformCoreSettings, ModuleVersion) ||
88 PropertyName == GET_MEMBER_NAME_CHECKED(UPPlatformCoreSettings, bSyncVersion))
89 {
90 TArray<FString> ModuleVersionParts;
91 if (GetModuleVersionArray(ModuleVersion, ModuleVersionParts))
92 {
93 if (bSyncVersion)
94 {
95 UpdateVersion(ModuleVersionParts);
96 }
97
99 {
101 }
102 }
103 else
104 {
105 Error("Module Version %s is invalid.", *ModuleVersion);
106 }
107 }
108
109 if (PropertyName == GET_MEMBER_NAME_CHECKED(UPPlatformCoreSettings, ServerMatchVersion))
110 {
112 {
114 {
115 Error("Module Version %s is invalid.", *ServerMatchVersion);
116 }
117 }
118 else
119 {
121 }
122 }
123
124 if (PropertyName == GET_MEMBER_NAME_CHECKED(UPPlatformCoreSettings, ConfigSection))
125 {
126 if (PropertyChangedEvent.ChangeType == EPropertyChangeType::ValueSet)
127 {
128 Log("Checking for the configuration section %s for changes.", *ConfigSection);
129 if (UPPlatformCoreSubsystem* PlatformCoreSubsystem = GEngine->GetEngineSubsystem<UPPlatformCoreSubsystem>())
130 {
131 if (!PlatformCoreSubsystem->GetSettingsFromRegion(ConfigSection))
132 {
133 Error("\"%s\" is an invalid configuration section.");
134 }
135 }
136 }
137 }
138
139 if (PropertyChangedEvent.ChangeType == EPropertyChangeType::ValueSet)
140 {
141 OnSettingsChanged.Broadcast(this);
142 OnStaticSettingsChanged.Broadcast(this);
143 }
144 }
145
146 Super::PostEditChangeProperty(PropertyChangedEvent);
147}
148
149void UPPlatformCoreSettings::UpdateVersion(const TArray<FString>& VersionParts)
150{
151 int MajorVerison = FCString::Atoi(*VersionParts[0]);
152 int MinorVersion = FCString::Atoi(*VersionParts[1]);
153 int PatchVersion = FCString::Atoi(*VersionParts[2]);
154
155 FString FullVersion = FString::Printf(TEXT("%i.%.2i.%.2i"), MajorVerison, MinorVersion, PatchVersion);
156
157 if (UGeneralProjectSettings* Settings = GetMutableDefault<UGeneralProjectSettings>())
158 {
159 Settings->ProjectVersion = FullVersion;
160 Settings->UpdateSinglePropertyInConfigFile(Settings->GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UGeneralProjectSettings, ProjectVersion)), Settings->GetDefaultConfigFilename());
161 }
162
163 if (UAndroidRuntimeSettings* Settings = GetMutableDefault<UAndroidRuntimeSettings>())
164 {
165 Settings->VersionDisplayName = FullVersion;
166 Settings->UpdateSinglePropertyInConfigFile(Settings->GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UAndroidRuntimeSettings, VersionDisplayName)), Settings->GetDefaultConfigFilename());
167
168 FString AndroidVersionNumber = FString::Printf(TEXT("%i%.2i%.2i"), MajorVerison, MinorVersion, PatchVersion);
169 Settings->StoreVersion = FCString::Atoi(*AndroidVersionNumber);
170 Settings->UpdateSinglePropertyInConfigFile(Settings->GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UAndroidRuntimeSettings, StoreVersion)), Settings->GetDefaultConfigFilename());
171 }
172}
173#endif
174
175#undef Fatal
176#undef Error
177#undef Warn
178#undef Log
DEFINE_LOG_CATEGORY_STATIC(LogPPlatformCoreSettings, Log, All)
#define Log(pmt,...)
#define Error(pmt,...)
#define Log(pmt,...)
UCLASS(config = Game, defaultconfig)
FOnPlatformSettingsChanged OnSettingsChanged
UPROPERTY(BlueprintAssignable, Category = "Apex|Event")
bool bSyncVersion
UPROPERTY(Config, EditAnywhere, Category = "PixoVR Platform|Core Platform", meta = (DisplayName = "Sy...
FOnStaticPlatformSettingsChanged OnStaticSettingsChanged
FString ServerMatchVersion
UPROPERTY(Config, EditAnywhere, Category = "PixoVR Platform|Multiplayer", meta = (DisplayName = "Serv...
bool GetModuleVersionArray(FString Version, TArray< FString > &ModuleVersionArray) const
FString ModuleVersion
UPROPERTY(Config, EditAnywhere, Category = "PixoVR Platform|Core Platform", meta = (DisplayName = "Mo...
FString ConfigSection
UPROPERTY(Config, EditAnywhere, Category = "PixoVR Platform", meta = (Tooltip = "The settings configu...
bool bServerVersionMatchModule
UPROPERTY(Config, EditAnywhere, Category = "PixoVR Platform|Multiplayer", meta = (InlineEditCondition...
bool CheckVersionString(FString VersionString) const
UCLASS(BlueprintType, Blueprintable, DisplayName = "PixoVR Platfor Core Subsystem")