Example #1
0
        /// <summary>
        /// 获取全部丢失的文件下载任务
        /// </summary>
        /// <param name="source">下载源</param>
        /// <param name="core">使用的核心</param>
        /// <param name="version">检查的版本</param>
        /// <returns></returns>
        public static List <DownloadTask> GetLostDependDownloadTask(DownloadSource source, LaunchHandler core, Version version)
        {
            var lostLibs              = GetLostLibs(core, version);
            var lostNatives           = GetLostNatives(core, version);
            List <DownloadTask> tasks = new List <DownloadTask>();
            string jarPath            = core.GetJarPath(version);

            if (!File.Exists(jarPath))
            {
                if (version.InheritsVersion != null)
                {
                    Version inner = core.GetVersionByID(version.InheritsVersion);
                    tasks.Add(GetDownloadUrl.GetCoreDownloadTask(source, inner, core));
                }
                else
                {
                    tasks.Add(GetDownloadUrl.GetCoreDownloadTask(source, version, core));
                }
            }
            foreach (var item in lostLibs)
            {
                tasks.Add(GetDownloadUrl.GetLibDownloadTask(source, item.Value, core));
            }
            foreach (var item in lostNatives)
            {
                tasks.Add(GetDownloadUrl.GetNativeDownloadTask(source, item.Value, core));
            }
            return(tasks);
        }
Example #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, MCVersion 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 HttpRequesterAPI.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);
                tasks.Add(task);
            }
            return(tasks);
        }
Example #3
0
        /// <summary>
        /// 获取全部丢失的文件下载任务
        /// </summary>
        /// <param name="source">下载源</param>
        /// <param name="core">使用的核心</param>
        /// <param name="version">检查的版本</param>
        /// <returns></returns>
        public async static Task <List <DownloadTask> > GetLostDependDownloadTaskAsync(DownloadSource source, LaunchHandler core, MCVersion version, MetroWindow window)
        {
            var lostLibs              = GetLostLibs(core, version);
            var lostNatives           = GetLostNatives(core, version);
            List <DownloadTask> tasks = new List <DownloadTask>();

            if (IsLostJarCore(core, version))
            {
                if (version.Jar == null)
                {
                    tasks.Add(GetDownloadUrl.GetCoreJarDownloadTask(source, version, core));
                }
            }

            if (version.InheritsVersion != null)
            {
                string innerJsonPath = core.GetJsonPath(version.InheritsVersion);
                string innerJsonStr;
                if (!File.Exists(innerJsonPath))
                {
                    innerJsonStr = await HttpRequesterAPI.HttpGetStringAsync(GetDownloadUrl.GetCoreJsonDownloadURL(source, version.InheritsVersion));

                    if (innerJsonStr == null)
                    {
                        await window.ShowMessageAsync("检查错误", "检查源错误,请切换下载源后重试");

                        return(new List <DownloadTask>());
                    }
                    string jsonFolder = Path.GetDirectoryName(innerJsonPath);
                    if (!Directory.Exists(jsonFolder))
                    {
                        Directory.CreateDirectory(jsonFolder);
                    }
                    File.WriteAllText(innerJsonPath, innerJsonStr);
                }
                else
                {
                    innerJsonStr = File.ReadAllText(innerJsonPath);
                }
                MCVersion innerVer = core.JsonToVersion(innerJsonStr);
                if (innerVer != null)
                {
                    tasks.AddRange(await GetLostDependDownloadTaskAsync(source, core, innerVer, window));
                }
            }
            foreach (var item in lostLibs)
            {
                tasks.Add(GetDownloadUrl.GetLibDownloadTask(source, item));
            }
            foreach (var item in lostNatives)
            {
                tasks.Add(GetDownloadUrl.GetNativeDownloadTask(source, item));
            }
            return(tasks);
        }
Example #4
0
        /// <summary>
        /// 获取丢失的资源文件下载任务
        /// </summary>
        /// <param name="source"></param>
        /// <param name="core"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public static List <DownloadTask> GetLostAssetsDownloadTask(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 = FunctionAPIHandler.HttpGet(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);
        }
 public string DoURLReplace(string url)
 {
     return(GetDownloadUrl.DoURLReplace(Source, url));
 }
Example #6
0
 public DownloadTask Get(manifestObj obj)
 {
     return(GetDownloadUrl.GetForgeDownloadURL(App.Config.MainConfig.Download.DownloadSource,
                                               obj.minecraft.version, obj.minecraft.modLoaders[0].id.Replace("forge-", "")));
 }