private static void downloadConfigs() { fileToDownload.Clear(); HomeUserControl.ChangeDownLoadDescriptor("Étape 11/12 : Vérification des configurations..."); HomeUserControl.ChangeProgressBarValue(0); if (ManifestManager.packageConfigurationJson != null) { foreach (FileProperty file in ManifestManager.packageConfigurationJson.FileProperties) { FileDownloadInformation fileDownloadInformation = new FileDownloadInformation(); string filePath = CommonData.scriptFolder + file.FileName; fileDownloadInformation.outputPath = filePath; fileDownloadInformation.url = CommonData.packageInfoBaseURL + CommonData.packageName + "/scripts/" + file.FileName; if (System.IO.File.Exists(filePath)) { /* Compare size */ if (new FileInfo(filePath).Length != file.FileSize) { /* Size is incorrect, add to download list */ fileToDownload.Add(fileDownloadInformation); } } else { /* add to download list */ fileToDownload.Add(fileDownloadInformation); } } HomeUserControl.ChangeDownLoadDescriptor("Étape 12/12 : Téléchargement des configurations..."); HomeUserControl.ChangeProgressBarValue(0); int currentConfig = 0; fileToDownload.ForEach(delegate(FileDownloadInformation libFile) { /* Create dir if not exist */ if (!Directory.Exists(Path.GetDirectoryName(libFile.outputPath))) { Directory.CreateDirectory(Path.GetDirectoryName(libFile.outputPath)); } /* Download file asset */ webClient.DownloadFile(libFile.url, libFile.outputPath); HomeUserControl.ChangeProgressBarValue(++currentConfig * 100.0 / fileToDownload.Count); }); } InsalledPackage newInstalledPackage = new InsalledPackage(); newInstalledPackage.packageName = CommonData.packageName; newInstalledPackage.packageVersion = CommonData.packageVersion; CommonData.launcherProfileJson.installedPackageVersion.Add(newInstalledPackage); CommonData.saveLauncherProfile(); }
public static bool startDownload() { bool success = false; if (CommonData.launcherProfileJson.installedPackageVersion != null) { InsalledPackage insalledPackage = null; try { insalledPackage = CommonData.launcherProfileJson.installedPackageVersion.Find(x => x.packageName == CommonData.packageName); } catch (Exception) { } if (insalledPackage != null && insalledPackage.packageVersion != CommonData.packageVersion) { /* package version does not correspond to the recorded one, delete files */ try { Directory.Delete(CommonData.packageFolder, true); } catch (Exception) { } } else if (insalledPackage != null) { CommonData.launcherProfileJson.installedPackageVersion.Remove(insalledPackage); } CommonData.saveLauncherProfile(); } else { CommonData.launcherProfileJson.installedPackageVersion = new List <InsalledPackage>(); } /* download necessary files step by step */ try { classPathList.Clear(); nativesToExtract.Clear(); downloadAssets(); if (ManifestManager.forgeVersionJson != null) { downloadForgeLibrairies(); } else if (ManifestManager.newForgeVersionJson != null) { downloadNewForgeLibrairies(); } else if (ManifestManager.forgeV31InstallationProfile != null) { downloadForgeV31Librairies(); } downloadLibraries(); downloadMinecraft(); downloadForgeMods(); downloadConfigs(); success = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } return(success); }