Пример #1
0
 private static bool IsLostAnyAssetsFromJassets(LaunchHandler core, JAssets assets)
 {
     if (assets == null)
     {
         return(false);
     }
     foreach (var item in assets.Objects)
     {
         string path = core.GetAssetsPath(item.Value);
         if (!File.Exists(path))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
        /// <summary>
        /// 获取丢失的资源文件下载任务
        /// </summary>
        /// <param name="source"></param>
        /// <param name="core"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public async static Task <List <DownloadTask> > GetLostAssetsDownloadTaskAsync(DownloadSource source, LaunchHandler core, Version ver)
        {
            List <DownloadTask> tasks  = new List <DownloadTask>();
            JAssets             assets = null;

            string assetsPath = core.GetAssetsIndexPath(ver.Assets);

            if (!File.Exists(assetsPath))
            {
                if (ver.AssetIndex != null)
                {
                    string jsonUrl    = GetDownloadUrl.DoURLReplace(source, ver.AssetIndex.URL);
                    string assetsJson = await APIRequester.HttpGetStringAsync(jsonUrl);

                    assets = core.GetAssetsByJson(assetsJson);
                    tasks.Add(new DownloadTask("资源文件引导", jsonUrl, assetsPath));
                }
                else
                {
                    return(tasks);
                }
            }
            else
            {
                assets = core.GetAssets(ver);
            }
            var lostAssets = GetLostAssets(core, assets);

            foreach (var item in lostAssets)
            {
                DownloadTask task = GetDownloadUrl.GetAssetsDownloadTask(source, item.Value, core);
                if (!tasks.Contains(task))
                {
                    tasks.Add(task);
                }
            }
            return(tasks);
        }
Пример #3
0
        /// <summary>
        /// 获取版本丢失的资源文件
        /// </summary>
        /// <param name="core">所使用的核心</param>
        /// <param name="version">要检查的版本</param>
        /// <returns>返回Key为路径,value为资源文件信息实例的集合</returns>
        public static Dictionary <string, JAssetsInfo> GetLostAssets(LaunchHandler core, JAssets assets)
        {
            Dictionary <string, JAssetsInfo> lostAssets = new Dictionary <string, JAssetsInfo>();

            if (assets == null)
            {
                return(lostAssets);
            }
            foreach (var item in assets.Objects)
            {
                string path = core.GetAssetsPath(item.Value);
                if (lostAssets.ContainsKey(path))
                {
                    continue;
                }
                else if (!File.Exists(path))
                {
                    lostAssets.Add(item.Key, item.Value);
                }
            }
            return(lostAssets);
        }