60 Log(
"Finding all non-ufs assets.");
62 TArray<FString> JsonFiles;
63 FString PlatformConfig =
PluginContent() / TEXT(
"PPlatformConfigurations/PlatformConfig.json");
65 if (IFileManager::Get().FileExists(*PlatformConfig))
68 FString ConfigJsonString;
69 FFileHelper::LoadFileToString(ConfigJsonString, *PlatformConfig);
72 TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(ConfigJsonString);
76 Log(
"Deserialized the JSON config.");
82 Log(
"Failed to deserialize the JSON config.");
96 TArray<FString> ConfigKeys;
99 Settings->SelectableSections.Empty();
100 Settings->SelectableSections = ConfigKeys;
102 if (Settings->ConfigSection.IsEmpty())
104 Settings->ConfigSection = ConfigKeys[0];
121 Warn(
"No JSON loaded.");
127 const TSharedPtr<FJsonObject>* RegionSettings;
130 Log(
"Found the region. Loading into settings.");
131 Settings->ProtocolVersion = (*RegionSettings)->GetStringField(
"protocol");
132 Settings->PlatformName = (*RegionSettings)->GetStringField(
"name");
133 Settings->IconURL = (*RegionSettings)->GetStringField(
"icon");
134 Settings->Region = (*RegionSettings)->GetStringField(
"region");
135 Settings->bDevMode = (*RegionSettings)->GetBoolField(
"dev");
136 const TSharedPtr<FJsonObject>* Services;
137 if ((*RegionSettings)->TryGetObjectField(
"services", Services))
139 const TSharedPtr<FJsonObject>* PlatformSetting;
140 if ((*Services)->TryGetObjectField(
"platform", PlatformSetting))
142 Settings->PlatformURL = (*PlatformSetting)->GetStringField(
"platform_url");
145 const TSharedPtr<FJsonObject>* ExtendedPlatformSetting;
146 if ((*Services)->TryGetObjectField(
"extended_platform", ExtendedPlatformSetting))
148 Settings->ModuleListURLFormat = (*ExtendedPlatformSetting)->GetStringField(
"module_list_url");
151 const TSharedPtr<FJsonObject>* MultiplayerSetting;
152 if ((*Services)->TryGetObjectField(
"multiplayer", MultiplayerSetting))
154 Settings->MatchmakingURL = (*MultiplayerSetting)->GetStringField(
"matchmaker_url");
157 const TSharedPtr<FJsonObject>* VoiceSetting;
158 if ((*Services)->TryGetObjectField(
"voice", VoiceSetting))
160 Settings->VoiceServerURL = (*VoiceSetting)->GetStringField(
"voice_url");
161 FString VoiceAccessKey;
162 if ((*VoiceSetting)->TryGetStringField(
"voice_access_key", VoiceAccessKey))
164 Settings->VoiceAccessKey = VoiceAccessKey;
166 FString VoiceTokenAudience;
167 if ((*VoiceSetting)->TryGetStringField(
"voice_token_audience", VoiceTokenAudience))
169 Settings->VoiceTokenAudience = VoiceTokenAudience;
174 Settings->OnSettingsChanged.Broadcast(Settings);
175 Settings->OnStaticSettingsChanged.Broadcast(Settings);
181 Log(
"Failed to find region %s.", *Region);
188 static const FString DefaultGamePath = FString::Printf(TEXT(
"%sDefaultGame.ini"), *FPaths::SourceConfigDir());
191 bool bDoesContainConfig =
false;
192 Log(
"Checking in the package properties...");
194 if (UProjectPackagingSettings* Settings = GetMutableDefault<UProjectPackagingSettings>())
196 bDoesContainConfig = Settings->DirectoriesToAlwaysStageAsNonUFS.ContainsByPredicate([
this](
const FDirectoryPath& InValue) ->
bool {
197 if (InValue.Path.Contains(
"PPlatformConfigurations"))
199 Log(
"Found the platform config already in the ini file.");
205 if (!bDoesContainConfig)
207 Log(
"Did not find the config file. Adding it to the packaging step.");
209 FString PlatformConfigPathAbs =
PluginContent() / TEXT(
"PPlatformConfigurations/PlatformConfig.json");
210 if (!IFileManager::Get().FileExists(*PlatformConfigPathAbs))
212 Fatal(
"%s does not exist! Make sure you have all of the files and that they are in the correct place.", *PlatformConfigPath);
215 Log(
"Inserting %s into the DirectoriesToAlwaysStageAsUFS array.");
216 FDirectoryPath AddedDirectoryPath;
217 AddedDirectoryPath.Path = PlatformConfigPath;
219 Settings->DirectoriesToAlwaysStageAsNonUFS.Add(AddedDirectoryPath);
220 Settings->UpdateSinglePropertyInConfigFile(
221 Settings->GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UProjectPackagingSettings, DirectoriesToAlwaysStageAsNonUFS)),
222 Settings->GetDefaultConfigFilename());