private void onCommandComplete(ContentManifest manifest, ScenePrereqContentBundlesManifest scenePrereqBundlesManifest, bool requiresUpgrade, bool appUpgradeAvailable) { appService.RequiresUpdate = requiresUpgrade; appService.UpdateAvailable = appUpgradeAvailable; string languageString = Service.Get <Localizer>().LanguageString; if (!Service.IsSet <Content>()) { contentSystem = new Content(manifest, languageString); Service.Set(contentSystem); Service.Set(new BundlePrecacheManager(manifest)); Service.Set(new ScenePrereqContentManager(Service.Get <BundlePrecacheManager>(), scenePrereqBundlesManifest)); currentContentVersion = manifest.ContentVersion; currentContentManifestHash = manifest.ContentManifestHash; } else if (Service.Get <INetworkServicesManager>().IsGameServerConnected()) { cachedContentSystemResponse = new ContentSystemResponse(manifest, scenePrereqBundlesManifest, requiresUpgrade, appUpgradeAvailable); } else if (!requiresUpgrade && (!currentContentVersion.Equals(manifest.ContentVersion) || !currentContentManifestHash.Equals(manifest.ContentManifestHash))) { if (!currentContentVersion.Equals(manifest.ContentVersion)) { currentContentVersion = manifest.ContentVersion; } if (!currentContentManifestHash.Equals(manifest.ContentManifestHash)) { currentContentManifestHash = manifest.ContentManifestHash; } contentSystem.UpdateContentManifest(manifest); Service.Get <BundlePrecacheManager>().SetManifest(manifest); Service.Get <ScenePrereqContentManager>().SetPrereqs(Service.Get <BundlePrecacheManager>(), scenePrereqBundlesManifest); } lastUpdate = DateTime.Now; }
private static void LoadContentManifest() { ContentManifest newManifest = JsonIO.Load <ContentManifest>(PathUtils.GetLocalPath(content_path, "content.json")); bool reloading_manifest = false; if (manifest != null) { reloading_manifest = true; StageNewResources(newManifest); } manifest = newManifest; FillContentMapsFromCurrentManifest(); if (reloading_manifest) { foreach (var new_res_id in newResourcesToAdd) { ConsoleUtils.ShowInfo($"Found new resource to Add: {new_res_id}"); UpdateResourceOnPak(new_res_id); } newResourcesToAdd.Clear(); } }
public ContentSystemResponse(ContentManifest manifest, ScenePrereqContentBundlesManifest scenePrereq, bool requiresUpgrade, bool appUpgradeAvailable) { Manifest = manifest; ScenePrereq = scenePrereq; RequiresUpgrade = requiresUpgrade; AppUpgradeAvailable = appUpgradeAvailable; }
public void initContentAction() { ContentManifest manifest = ContentManifestUtility.FromDefinitionFile("Configuration/embedded_content_manifest"); Content instance = new Content(manifest); Service.Set(instance); }
private bool manifestsAreIdentical(ContentManifest mergedManifest) { bool flag = mockResultingManifest.BaseUri == mergedManifest.BaseUri; bool flag2 = checkAssetsAreIndentical(mergedManifest); bool flag3 = checkAssetsAreIndentical(mergedManifest); return(flag && flag2 && flag3); }
private void onInitializeComplete(ContentManifest manifest, bool requiresAppUgrade = false) { if (timeoutCheck != null && !timeoutCheck.Completed && !timeoutCheck.Cancelled) { timeoutCheck.Cancel(); } manifest.UpdateEntryMaps(); callback(manifest, scenePrereqBundlesManifest, requiresAppUgrade, appUpgradeAvailable); }
protected override IEnumerator setup() { GcsAccessTokenService gcsAccessTokenService = new GcsAccessTokenService(ConfigHelper.GetEnvironmentProperty <string>("GcsServiceAccountName"), new GcsP12AssetFileLoader(ConfigHelper.GetEnvironmentProperty <string>("GcsServiceAccountFile"))); Service.Set((IGcsAccessTokenService)gcsAccessTokenService); string cdnUrl = ContentHelper.GetCdnUrl(); string cpipeMappingFilename = ContentHelper.GetCpipeMappingFilename(); CPipeManifestService cpipeManifestService = new CPipeManifestService(cdnUrl, cpipeMappingFilename, gcsAccessTokenService); Service.Set((ICPipeManifestService)cpipeManifestService); base.gameObject.AddComponent <KeyChainManager>(); GameSettings gameSettings = new GameSettings(); Service.Set(gameSettings); ContentManifest definition = ContentManifestUtility.FromDefinitionFile("Configuration/embedded_content_manifest"); Service.Set(new Content(definition)); Localizer localizer = Localizer.Instance; Service.Set(localizer); NullCPSwrveService cpSwrveService = new NullCPSwrveService(); Service.Set((ICPSwrveService)cpSwrveService); NetworkServicesConfig networkConfig = NetworkController.GenerateNetworkServiceConfig(TestEnvironment); Service.Set((INetworkServicesManager) new NetworkServicesManager(this, networkConfig, offlineMode: false)); CommerceService commerceService = new CommerceService(); commerceService.Setup(); Service.Set(commerceService); Service.Set(new MembershipService(null)); ConnectionManager connectionManager = base.gameObject.AddComponent <ConnectionManager>(); Service.Set(connectionManager); Service.Set(new SessionManager()); Service.Set(new MixLoginCreateService()); Service.Set((CPDataEntityCollection) new CPDataEntityCollectionImpl()); LocalPlayerData localPlayerData = new LocalPlayerData { name = "TestPlayer", tutorialData = new List <sbyte>() }; PlayerId playerId = localPlayerData.id = new PlayerId { id = "999999999999999", type = PlayerId.PlayerIdType.SESSION_ID }; Service.Get <CPDataEntityCollection>().ResetLocalPlayerHandle(); PlayerDataEntityFactory.AddLocalPlayerProfileDataComponents(Service.Get <CPDataEntityCollection>(), localPlayerData); LoginController loginController = new LoginController(); Service.Set(loginController); loginController.SetNetworkConfig(networkConfig); IntegrationTestEx.FailIf(Service.Get <MixLoginCreateService>().NetworkConfigIsNotSet); yield return(null); }
private static List <ResourcePak> BuildPaks(string root_path, ContentManifest manifest) { var paks = new List <ResourcePak>(); foreach (var group in manifest.Content) { var pak = new ResourcePak(group.Key); foreach (var image in group.Value.Images) { var path = new Uri(Path.Combine(root_path, group.Key, image.Value.Path)).LocalPath; var pixmap_data = ContentLoader.LoadPixmapData(path); pak.Resources.Add(image.Value.Id, pixmap_data); } foreach (var font in group.Value.Fonts) { var descr_path = new Uri(Path.Combine(root_path, group.Key, font.Value.Path)).LocalPath; var image_path = new Uri(Path.Combine(root_path, group.Key, font.Value.ImagePath)).LocalPath; var font_data = ContentLoader.LoadFontData(descr_path, image_path); pak.Resources.Add(font.Value.Id, font_data); } foreach (var shader in group.Value.Shaders) { var vs_path = new Uri(Path.Combine(root_path, group.Key, shader.Value.VertexSrcPath)).LocalPath; var fs_path = new Uri(Path.Combine(root_path, group.Key, shader.Value.FragmentSrcPath)).LocalPath; var shader_data = ContentLoader.LoadShaderProgramData(vs_path, fs_path); pak.Resources.Add(shader.Value.Id, shader_data); } foreach (var sfx in group.Value.Effects) { //TODO: } foreach (var song in group.Value.Songs) { //TODO: } foreach (var txt in group.Value.TextFiles) { var txt_path = new Uri(Path.Combine(root_path, group.Key, txt.Value.Path)).LocalPath; var txt_data = ContentLoader.LoadTextFileData(txt_path); pak.Resources.Add(txt.Value.Id, txt_data); } paks.Add(pak); } return(paks); }
private IEnumerator contentManifest_download(ContentManifestDirectoryEntry directoryEntry) { if (directoryEntry == null) { handleFailure(); yield break; } if (string.IsNullOrEmpty(directoryEntry.url)) { handleFailure(); yield break; } string contentManifestUrl = directoryEntry.url; ICPipeManifestService cpipeManifestService = Service.Get <ICPipeManifestService>(); CPipeManifestResponse cpipeManifestResponse = new CPipeManifestResponse(); yield return(cpipeManifestService.LookupAssetUrl(cpipeManifestResponse, contentManifestUrl)); UnityWebRequest www = UnityWebRequest.GetAssetBundle(cpipeManifestResponse.FullAssetUrl, 1u, 0u); Service.Get <LoadingController>().RegisterDownload(www); yield return(www.SendWebRequest()); Service.Get <LoadingController>().UnRegisterDownload(www); AssetBundle contentBundle = ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle; if (www.isNetworkError || contentBundle == null) { Log.LogErrorFormatted(this, "Failed to download content bundle from CDN: {0}", www.error); handleFailure(); yield break; } downloadedManifest = ContentHelper.GetContentManifestFromAssetBundle(contentBundle); if (downloadedManifest != null) { checkContentVersionAndManifestHashInManifest(downloadedManifest, directoryEntry); contentManifest_cacheDownloadedToDisk(downloadedManifest); } string[] assetNames = contentBundle.GetAllAssetNames(); for (int i = 0; i < assetNames.Length; i++) { string fileName = Path.GetFileName(assetNames[i]); if (string.Equals(fileName, "ScenesPrereqBundlesManifest.json", StringComparison.OrdinalIgnoreCase)) { TextAsset textAsset = contentBundle.LoadAsset <TextAsset>(assetNames[i]); scenePrereqBundlesManifest = Service.Get <JsonService>().Deserialize <ScenePrereqContentBundlesManifest>(textAsset.text); scenePrereqBundlesManifest_cacheDownloadedToDisk(scenePrereqBundlesManifest); } } contentBundle.Unload(unloadAllLoadedObjects: false); if (downloadedManifest == null) { Log.LogError(this, "Content manifest not found in downloaded bundle! Reverting to the embedded manifest"); handleFailure(); } }
public IEnumerator loadContentManifest() { Stopwatch timer = new Stopwatch(); timer.Start(); yield return(manifestDirectory_download()); timer.Stop(); if (manifestDirectory == null) { Log.LogError(this, "The ContentManifestDirectory downloaded is null! The request to download the directory either was not made or failed to download and deserialize. Reverting to the embedded ContentManifest as no ContentManifestDirectoryEntry is available to reference."); handleFailure(); yield break; } embeddedManifest = manifestService.LoadEmbeddedManifest(); DateTimeOffset contentDate = manifestService.GetContentDate(); Version clientVersion = ClientInfo.ParseClientVersion(ClientInfo.Instance.ClientVersion); Version clientApiVersion = ClientInfo.ParseClientVersion(manifestService.GetClientApiVersionStr()); string platform = manifestService.GetClientPlatform(); string environment = manifestService.GetServerEnvironment().ToString().ToLower(); ContentManifestDirectoryEntry clientDirectoryEntry = manifestDirectory.FindEntry(contentDate, clientVersion, platform, environment); appUpgradeAvailable = manifestDirectory.DoesNewerVersionExist(contentDate, clientVersion, platform, environment); if (clientDirectoryEntry == null) { Log.LogErrorFormatted(this, "No client directory entry available for clientVersion={0}, platform={1}, environment={2}. \nTriggering force upgrade.", clientVersion.ToString(), platform, environment); handleFailure(requiresAppUgrade: true); yield break; } ContentManifestDirectoryEntry contentDirectoryEntry = clientDirectoryEntry; if (!clientVersion.Equals(clientApiVersion)) { contentDirectoryEntry = manifestDirectory.FindEntry(contentDate, clientApiVersion, platform, environment); if (contentDirectoryEntry == null) { Log.LogErrorFormatted(this, "Missing Client API Version: No content available for clientApiVersion={0}, platform={1}, environment={2}. Falling back to embedded content version", clientApiVersion.ToString(), platform, environment); handleFailure(); yield break; } } if (contentDirectoryEntry.IsEmbeddedContent()) { contentManifest = embeddedManifest; checkContentVersionAndManifestHashInManifest(contentManifest, contentDirectoryEntry); } else { yield return(contentManifest_download(contentDirectoryEntry)); contentManifest = ContentManifestUtility.Merge(embeddedManifest, downloadedManifest); } onInitializeComplete(contentManifest); }
protected override IEnumerator setup() { base.gameObject.AddComponent <KeyChainManager>(); GameSettings gameSettings = new GameSettings(); Service.Set(gameSettings); ContentManifest definition = ContentManifestUtility.FromDefinitionFile("Configuration/embedded_content_manifest"); GcsAccessTokenService gcsAccessTokenService = new GcsAccessTokenService(ConfigHelper.GetEnvironmentProperty <string>("GcsServiceAccountName"), new GcsP12AssetFileLoader(ConfigHelper.GetEnvironmentProperty <string>("GcsServiceAccountFile"))); Service.Set((IGcsAccessTokenService)gcsAccessTokenService); string cdnUrl = ContentHelper.GetCdnUrl(); string cpipeMappingFilename = ContentHelper.GetCpipeMappingFilename(); CPipeManifestService cpipeManifestService = new CPipeManifestService(cdnUrl, cpipeMappingFilename, gcsAccessTokenService); Service.Set((ICPipeManifestService)cpipeManifestService); NullCPSwrveService cpSwrveService = new NullCPSwrveService(); Service.Set((ICPSwrveService)cpSwrveService); Content content = new Content(definition); Service.Set(content); networkServicesConfig = NetworkController.GenerateNetworkServiceConfig(Disney.Kelowna.Common.Environment.Environment.LOCAL); ConnectionManager connectionManager = base.gameObject.AddComponent <ConnectionManager>(); Service.Set(connectionManager); initEnvironmentManager(); sessionManager = new SessionManager(); Service.Set(sessionManager); Localizer localizer = Localizer.Instance; Service.Set(localizer); Language language = LocalizationLanguage.GetLanguage(); localizer.Language = language; localizer.LanguageString = LocalizationLanguage.GetLanguageString(language); AppTokensFilePath tokensFilePath = new AppTokensFilePath(Localizer.DEFAULT_TOKEN_LOCATION, Platform.global); bool tokensLoaded = false; Service.Get <Localizer>().LoadTokensFromLocalJSON(tokensFilePath, delegate { Debug.Log("Tokens for " + localizer.LanguageString + " have been loaded."); tokensLoaded = true; }); while (!tokensLoaded) { yield return(null); } mixLoginCreateService = new MixLoginCreateService(); Service.Set(mixLoginCreateService); IntegrationTestEx.FailIf(!mixLoginCreateService.NetworkConfigIsNotSet); mixLoginCreateService.SetNetworkConfig(networkServicesConfig); IntegrationTestEx.FailIf(mixLoginCreateService.NetworkConfigIsNotSet); yield return(null); }
private ContentManifest contentManifest_loadFromCache() { string path = Path.Combine(Application.persistentDataPath, "ContentManifest.txt"); if (File.Exists(path)) { ContentManifest contentManifest = new ContentManifest(); contentManifest.ReadFromFile(path); return(contentManifest); } return(null); }
private bool checkBundleAreIndentical(ContentManifest mergedManifest) { Dictionary <string, ContentManifest.BundleEntry> .Enumerator enumerator = mergedManifest.BundleEntryMap.GetEnumerator(); while (enumerator.MoveNext()) { ContentManifest.BundleEntry value = enumerator.Current.Value; ContentManifest.BundleEntry bundleEntry = mockResultingManifest.BundleEntryMap[enumerator.Current.Key]; if (bundleEntry != value) { return(false); } } return(true); }
private void onInitializeManifestCommandComplete(ContentManifest mergedManifest, ScenePrereqContentBundlesManifest scenePrereqBundlesManifest, bool requiresAppUgrade, bool appUpgradeAvailable) { string text = ExpectedResult.Validate(mergedManifest, requiresAppUgrade); if (!string.IsNullOrEmpty(text)) { Log.LogError(this, text); IntegrationTest.Fail(text); } else { IntegrationTest.Pass(); Log.LogErrorFormatted(this, "ReadManifestDirectoryTest: TEST '{0}' SUCCEEDED.", ExpectedResult.TestName); } doneWaiting(); }
protected override IEnumerator setup() { manifest = generateManifest(); IGcsAccessTokenService gcsAccessTokenService = new GcsAccessTokenService(ConfigHelper.GetEnvironmentProperty <string>("GcsServiceAccountName"), new GcsP12AssetFileLoader(ConfigHelper.GetEnvironmentProperty <string>("GcsServiceAccountFile"))); Service.Set(gcsAccessTokenService); ICPipeManifestService instance = new CPipeManifestService(ContentHelper.GetCdnUrl(), ContentHelper.GetCpipeMappingFilename(), gcsAccessTokenService); Service.Set(instance); Content instance2 = new Content(manifest); Service.Set(instance2); Content.BundleManager.UnmountFrameCount = 4; Content.BundleManager.MonitorFrameFrequency = 1; yield break; }
protected override IEnumerator runTest() { string payload = string.Format("{0}?dl=json:mock-json-res&x=txt", "Configuration/embedded_content_manifest"); ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); DeviceManager deviceManager = new DeviceManager(); deviceManager.Mount(new MockJsonResourceDevice(deviceManager)); deviceManager.Mount(new JsonDevice(deviceManager)); ContentManifest contentManifest = deviceManager.LoadImmediate <ContentManifest>(entry.DeviceList, ref entry); IntegrationTestEx.FailIf(contentManifest == null); if (contentManifest != null) { } IntegrationTest.Pass(); yield break; }
public string Validate(ContentManifest mergedManifest, bool requiresAppUgrade) { if (RequiresAppUgrade != requiresAppUgrade) { return($"'{TestName}': RequiresAppUgrade was expected to be '{RequiresAppUgrade}' but was '{requiresAppUgrade}'!"); } if (AssetEntriesSize != mergedManifest.AssetEntryMap.Count) { return($"'{TestName}': The Asset Entries Count was expected to be '{AssetEntriesSize}' but was '{mergedManifest.AssetEntryMap.Count}'!"); } if (BundleEntriesSize != mergedManifest.BundleEntryMap.Count) { return($"'{TestName}': The Bundle Entries Count was expected to be '{BundleEntriesSize}' but was '{mergedManifest.BundleEntryMap.Count}'!"); } if (BaseUri != mergedManifest.BaseUri) { return($"'{TestName}': The Base URI was expected to be '{BaseUri}' but was '{mergedManifest.BaseUri}'!"); } return(null); }
private void checkContentVersionAndManifestHashInManifest(ContentManifest manifest, ContentManifestDirectoryEntry directoryEntry) { if (manifest == null || directoryEntry == null) { Log.LogErrorFormatted(this, "Can't check on manifest since one of the parameters is null manifest={0}, directoryEntry={1}\t", manifest, directoryEntry); return; } if (string.IsNullOrEmpty(manifest.ContentManifestHash) && !string.IsNullOrEmpty(directoryEntry.url)) { string text = (manifest.ContentManifestHash = Path.GetFileNameWithoutExtension(directoryEntry.url)); } if (string.IsNullOrEmpty(manifest.ContentVersion)) { manifest.ContentVersion = directoryEntry.contentVersion; } else if (manifest.ContentVersion != directoryEntry.contentVersion) { manifest.ContentVersion = directoryEntry.contentVersion; } }
private void Awake() { Service.ResetAll(); Service.Set(new EventDispatcher()); Service.Set((JsonService) new LitJsonService()); GameObject gameObject = GameObject.Find("CoroutineRunner"); if (gameObject != null) { UnityEngine.Object.Destroy(gameObject); } gameObject = new GameObject("CoroutineRunner"); gameObject.AddComponent <CoroutineRunner>(); ContentManifest manifest = ContentManifestUtility.FromDefinitionFile("Configuration/embedded_content_manifest"); Content instance = new Content(manifest); Service.Set(instance); ErrorsMap errorsMap = new ErrorsMap(); errorsMap.LoadErrorJson("Errors/errors.json"); Service.Set(errorsMap); }
public void AddLoadingStep(ContentManifest manifest) { loader.AddStep(manifest); }
private static void StageNewResources(ContentManifest newManifest) { foreach (var new_group in newManifest.Content) { if (!manifest.Content.TryGetValue(new_group.Key, out _)) { foreach (var img_manifest in new_group.Value.Images) { newResourcesToAdd.Add(img_manifest.Key); } foreach (var fnt_manifest in new_group.Value.Fonts) { newResourcesToAdd.Add(fnt_manifest.Key); } foreach (var sha_manifest in new_group.Value.Shaders) { newResourcesToAdd.Add(sha_manifest.Key); } foreach (var sfx_manifest in new_group.Value.Effects) { newResourcesToAdd.Add(sfx_manifest.Key); } foreach (var sng_manifest in new_group.Value.Songs) { newResourcesToAdd.Add(sng_manifest.Key); } foreach (var txt_manifest in new_group.Value.TextFiles) { newResourcesToAdd.Add(txt_manifest.Key); } } else { foreach (var img_manifest in new_group.Value.Images) { if (!manifest.Content[new_group.Key].Images.TryGetValue(img_manifest.Key, out _)) { newResourcesToAdd.Add(img_manifest.Key); } } foreach (var fnt_manifest in new_group.Value.Fonts) { if (!manifest.Content[new_group.Key].Fonts.TryGetValue(fnt_manifest.Key, out _)) { newResourcesToAdd.Add(fnt_manifest.Key); } } foreach (var sha_manifest in new_group.Value.Shaders) { if (!manifest.Content[new_group.Key].Shaders.TryGetValue(sha_manifest.Key, out _)) { newResourcesToAdd.Add(sha_manifest.Key); } } foreach (var sfx_manifest in new_group.Value.Effects) { if (!manifest.Content[new_group.Key].Effects.TryGetValue(sfx_manifest.Key, out _)) { newResourcesToAdd.Add(sfx_manifest.Key); } } foreach (var sng_manifest in new_group.Value.Songs) { if (!manifest.Content[new_group.Key].Songs.TryGetValue(sng_manifest.Key, out _)) { newResourcesToAdd.Add(sng_manifest.Key); } } foreach (var txt_manifest in new_group.Value.Songs) { if (!manifest.Content[new_group.Key].TextFiles.TryGetValue(txt_manifest.Key, out _)) { newResourcesToAdd.Add(txt_manifest.Key); } } } } }
public void AddLoadingStep(ContentManifest manifest) { loader.AddStep(manifest); }
private void contentManifest_cacheDownloadedToDisk(ContentManifest manifestToBeCached) { string path = Path.Combine(Application.persistentDataPath, "ContentManifest.txt"); manifestToBeCached.WriteToFile(path); }
protected override IEnumerator setup() { mockResultingManifest = new ContentManifest(Resources.Load <TextAsset>("fixtures/mock_content_manifest")); yield break; }
private void onInitializeManifestCommandComplete(ContentManifest mergedManifest, ScenePrereqContentBundlesManifest scenePrereqBundlesManifest, bool requiresAppUgrade, bool appUpgradeAvailable) { IntegrationTest.Assert(manifestsAreIdentical(mergedManifest)); doneWaiting(); }
/// <summary> /// Adds a step to the content loader which loads the specified content manifest /// into the content manager's asset cache. /// </summary> /// <param name="manifest">The content manifest to load.</param> public void AddStep(ContentManifest manifest) { Contract.Require(manifest, nameof(manifest)); AddStepInternal(() => { content.Load(manifest); }); }