コード例 #1
0
ファイル: GetLost.cs プロジェクト: Icetebe/ICELauncher
        /// <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>();

            try
            {
                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);
            }
            catch
            {
                return(lostAssets);
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取assets下载任务
        /// </summary>
        /// <param name="source">下载源</param>
        /// <param name="assets">assets实例</param>
        /// <param name="core">所使用的核心</param>
        /// <returns>下载任务</returns>
        public static DownloadTask GetAssetsDownloadTask(DownloadSource source, JAssetsInfo assets, LaunchHandler core)
        {
            string from = GetAssetsDownloadURL(source, assets);
            string to   = core.GetAssetsPath(assets);

            return(new DownloadTask("游戏资源文件" + assets.Hash, from, to));
        }
コード例 #3
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);
 }
コード例 #4
0
ファイル: GetLost.cs プロジェクト: Icetebe/ICELauncher
        public static async Task <bool> IsLostAssetsAsync(DownloadSource source, LaunchHandler core, Version ver)
        {
            string assetsPath = core.GetAssetsIndexPath(ver.Assets);

            if (!File.Exists(assetsPath))
            {
                if (ver.AssetIndex == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                var assets = await core.GetAssetsAsync(ver);

                return(await Task.Factory.StartNew(() =>
                {
                    foreach (var item in assets.Objects)
                    {
                        if (File.Exists(core.GetAssetsPath(item.Value)))
                        {
                            continue;
                        }
                        else
                        {
                            return true;
                        }
                    }
                    return false;
                }));
            }
        }