/// <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); }