private static void UpdateResourceOnManifest(string new_res_id, string old_id, string new_path) { if (resourceManifestMap.TryGetValue(old_id, out ResourceManifest res_manifest)) { string pak = resourcePakMap[old_id]; switch (res_manifest) { case ImageManifest _: var img_extension = Path.GetExtension(new_path); if (img_extension != ".png") { throw new Exception($"[Renamed File] Unsupported Image File : {new_path}"); } var img_manifest = new ImageManifest() { Id = new_res_id, Path = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path) }; manifest.Content[pak].Images.Remove(old_id); manifest.Content[pak].Images.Add(new_res_id, img_manifest); break; case ShaderManifest _: var sha_manifest = new ShaderManifest() { Id = new_res_id }; var extension_sha = Path.GetExtension(new_path); if (extension_sha == ".vs") { sha_manifest.VertexSrcPath = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path); } else if (extension_sha == ".fs") { sha_manifest.FragmentSrcPath = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path); } else { throw new Exception($"[Renamed File] Unrecognized Shader File : {new_path}"); } manifest.Content[pak].Shaders.Remove(old_id); manifest.Content[pak].Shaders.Add(new_res_id, sha_manifest); break; case FontManifest _: var fnt_manifest = new FontManifest { Id = new_res_id }; var extension_fnt = Path.GetExtension(new_path); if (extension_fnt == ".fnt") { fnt_manifest.Path = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path); } else if (extension_fnt == ".png") { fnt_manifest.ImagePath = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path); } else { throw new Exception($"[Renamed File] Unrecognized Font File : {new_path}"); } manifest.Content[pak].Fonts.Remove(old_id); manifest.Content[pak].Fonts.Add(new_res_id, fnt_manifest); break; case EffectManifest _: var sfx_extension = Path.GetExtension(new_path); if (sfx_extension != ".wav") { throw new Exception($"[Renamed File] Unsupported Sfx File : {new_path}"); } var sfx_manifest = new EffectManifest { Id = new_res_id, Path = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path) }; manifest.Content[pak].Effects.Remove(old_id); manifest.Content[pak].Effects.Add(new_res_id, sfx_manifest); break; case SongManifest _: var sng_extension = Path.GetExtension(new_path); if (sng_extension != ".ogg") { throw new Exception($"[Renamed File] Unsupported Song File : {new_path}"); } var sng_manifest = new SongManifest { Id = new_res_id, Path = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path) }; manifest.Content[pak].Songs.Remove(old_id); manifest.Content[pak].Songs.Add(new_res_id, sng_manifest); break; case TextFileManifest _: var txt_extension = Path.GetExtension(new_path); if (txt_extension != ".txt") { throw new Exception($"[Renamed File] Unsupported Txt File : {new_path}"); } var txt_manifest = new TextFileManifest { Id = new_res_id, Path = PathUtils.GetLocalNormalizedRelativePath(Path.Combine(content_path, pak), new_path) }; manifest.Content[pak].TextFiles.Remove(old_id); manifest.Content[pak].TextFiles.Add(new_res_id, txt_manifest); break; } SaveContentManifest(); FillContentMapsFromCurrentManifest(); ConsoleUtils.ShowInfo($"Renamed Resource from {old_id} to {new_res_id} on Pak {pak}"); } }
public Task PutManifestAsync(string name, string reference, ImageManifest manifest, CancellationToken cancellationToken = new CancellationToken()) { throw new NotImplementedException(); }
internal GetImageManifestResult(string mediaType, ImageManifest manifest, string content) { Manifest = manifest; Content = content; MediaType = mediaType; }