Skip to content

Commit a2e187a

Browse files
authored
Merge branch 'development' into fix/platform-config-decoupling
2 parents 9b1e8f9 + 33a7ef1 commit a2e187a

File tree

1 file changed

+104
-13
lines changed

1 file changed

+104
-13
lines changed

com.playeveryware.eos/Runtime/Core/Config/PlatformConfig.cs

Lines changed: 104 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -412,32 +412,118 @@ protected virtual void MigrateNonOverrideableConfigValues(EOSConfig overrideValu
412412

413413
MigratePlatformFlags(overrideValuesFromFieldMember, mainNonOverrideableConfig);
414414

415-
integratedPlatformManagementFlags = IntegratedPlatformManagementFlags.Disabled;
416-
integratedPlatformManagementFlags |= mainNonOverrideableConfig.integratedPlatformManagementFlags;
415+
// If there are no Integrated Platform Management Flags in the original config, apply a set of default per-platform IMPFs
416+
if ((int)mainNonOverrideableConfig.integratedPlatformManagementFlags == 0 || mainNonOverrideableConfig.integratedPlatformManagementFlags == IntegratedPlatformManagementFlags.Disabled)
417+
{
418+
integratedPlatformManagementFlags = GetDefaultIntegratedPlatformManagementFlags();
419+
}
420+
else
421+
{
422+
integratedPlatformManagementFlags = mainNonOverrideableConfig.integratedPlatformManagementFlags;
423+
}
417424

418425
ProductConfig productConfig = Get<ProductConfig>();
419426
string compDeploymentString = mainNonOverrideableConfig.deploymentID?.ToLower();
420427

421-
foreach(Named<Deployment> dep in productConfig.Environments.Deployments)
428+
// If the compDeploymentString is explicitly set, then seek that out and use it
429+
if (!string.IsNullOrEmpty(compDeploymentString))
422430
{
423-
if (!string.IsNullOrEmpty(compDeploymentString) && !compDeploymentString.Equals(dep.Value.DeploymentId.ToString("N").ToLowerInvariant()))
431+
Deployment? foundDeployment = null;
432+
433+
foreach (Named<Deployment> dep in productConfig.Environments.Deployments)
424434
{
425-
continue;
435+
if (!compDeploymentString.Equals(dep.Value.DeploymentId.ToString("N").ToLowerInvariant()))
436+
{
437+
continue;
438+
}
439+
440+
foundDeployment = dep.Value;
441+
break;
426442
}
427443

428-
deployment = dep.Value;
429-
break;
444+
// If we didn't find a matching deployment, log about it
445+
if (foundDeployment.HasValue)
446+
{
447+
deployment = foundDeployment.Value;
448+
}
449+
else
450+
{
451+
Debug.LogWarning($"The previous config explicitly identified "
452+
+ $"'{compDeploymentString}' as the Deployment GUID, but "
453+
+ "could not find a deployment with that id in the config. "
454+
+ "You must set the Deployment in the EOS Configuration window.");
455+
}
456+
}
457+
else if (productConfig.Environments.Deployments.Count == 1)
458+
{
459+
// If compDeploymentString wasn't explicitly set, and there was exactly
460+
// one defined deployment, then intuitively use that.
461+
462+
deployment = productConfig.Environments.Deployments[0].Value;
463+
Debug.Log($"The previous config did not explicitly define a " +
464+
$"deployment. There was one defined deployment, automatically " +
465+
$"selecting deployment name '{productConfig.Environments.Deployments[0].Name}' " +
466+
$"with id '{deployment.DeploymentId}'.");
467+
}
468+
else
469+
{
470+
// If there are multiple deployments, we can't auto select one.
471+
// The user will have to set one directly.
472+
Debug.LogWarning($"The previous config did not explicitly define " +
473+
$"a deployment for this platform, and there are more than " +
474+
$"one available deployments. You must set the Deployment in" +
475+
$"the EOS Configuration window for this platform.");
430476
}
431477

432-
foreach (Named<EOSClientCredentials> creds in productConfig.Clients)
478+
string compClientString = mainNonOverrideableConfig.clientID?.ToLowerInvariant();
479+
// If the compClientString is explicitly set, then seek that out and use it
480+
if (!string.IsNullOrEmpty(compClientString))
433481
{
434-
if (!creds.Value.ClientId.Equals(mainNonOverrideableConfig.clientID))
482+
EOSClientCredentials foundCredentials = null;
483+
484+
foreach (Named<EOSClientCredentials> creds in productConfig.Clients)
435485
{
436-
continue;
486+
if (!compClientString.Equals(creds.Value.ClientId.ToLowerInvariant()))
487+
{
488+
continue;
489+
}
490+
491+
foundCredentials = creds.Value;
492+
break;
437493
}
438494

439-
clientCredentials = creds.Value;
440-
break;
495+
// If we didn't find a matching deployment, log about it
496+
if (foundCredentials != null)
497+
{
498+
clientCredentials = foundCredentials;
499+
}
500+
else
501+
{
502+
Debug.LogWarning($"The previous config explicitly identified "
503+
+ $"'{compClientString}' as the Client ID, but "
504+
+ "could not find client credentials with that id in the config. "
505+
+ "You must set the Client Credentials in the EOS Configuration window.");
506+
}
507+
}
508+
else if (productConfig.Clients.Count == 1)
509+
{
510+
// If compClientString wasn't explicitly set, and there was exactly
511+
// one defined client credential, then intuitively use that.
512+
513+
clientCredentials = productConfig.Clients[0].Value;
514+
Debug.Log($"The previous config did not explicitly define " +
515+
$"client credentials. There was one defined client credential, automatically " +
516+
$"selecting client credential name '{productConfig.Clients[0].Name}' " +
517+
$"with id '{clientCredentials.ClientId}'.");
518+
}
519+
else
520+
{
521+
// If there are multiple deployments, we can't auto select one.
522+
// The user will have to set one directly.
523+
Debug.LogWarning($"The previous config did not explicitly define " +
524+
$"client credentials for this platform, and there are more than " +
525+
$"one available client credentials. You must set the " +
526+
$"Client Credentials in the EOS Configuration window for this platform.");
441527
}
442528
}
443529

@@ -533,7 +619,12 @@ protected override void MigrateConfig()
533619
"Plugin -> EOS Configuration to make sure that the " +
534620
"migration was successful.");
535621
}
536-
622+
623+
public virtual IntegratedPlatformManagementFlags GetDefaultIntegratedPlatformManagementFlags()
624+
{
625+
return IntegratedPlatformManagementFlags.Disabled;
626+
}
627+
537628

538629
#endif
539630

0 commit comments

Comments
 (0)