private void QueueDownload(ExtendedMod mod) { var matchingModObject = MissingMods.First(x => x.FileId == mod.FileId && x.ModId == mod.ModId); MissingMods.First(x => x == matchingModObject).IsIndeterminateProcess = true; _downloadClient.QueueDownload(mod, string.Empty); }
private void QueueDownload(ExtendedMod mod) { lock (MissingMods) { MissingMods.ToList().Where(x => x.Md5 == mod.Md5 && x.FileName == mod.FileName).ToList() .ForEach(x => x.IsIndeterminateProcess = true); } _downloadClient.QueueDownload(mod, string.Empty); }
private async Task ValidateMods() { var missingMods = await _validate.GetMissingModsAsync(new List <string>()); await Application.Current.Dispatcher.BeginInvoke((Action) delegate { MissingMods.AddRange(missingMods); }); RemainingMissingModCount = _installBase.ModpackMods.Count; Task.Factory.StartNew(ViewControllerController); }
public static void CheckInstalled() { MissingMods.Clear(); MissingMods.TrimExcess(); foreach (string mod in Mods) { if (!InstalledModsList.Contains(mod)) { MissingMods.Add(mod); MissingMod = true; } } }
private void InitializeAutoDownloader() { if (_apiBase.IsUserPremium() && _apiBase.IsUserLoggedIn()) { var missingMods = MissingMods.ToList(); foreach (var mod in missingMods) { if (!_failedDownloads.Contains(mod)) { QueueDownload(mod); } } } }
private void DownloadUpdate(object sender, ExtendedMod e) { if (e.CurrentDownloadProgress == 100) { _installBase.ModpackMods.Where(x => x.Md5 == e.Md5).ToList() .ForEach(x => x.FilePath = e.FilePath); var matchingMods = MissingMods.Where(x => x.Md5 == e.Md5).ToList(); foreach (var matchingMod in matchingMods) { Application.Current.Dispatcher.BeginInvoke((Action) delegate { _missingModsLocked = true; if (MissingMods.IndexOf(matchingMod) != -1) { MissingMods.RemoveAt(MissingMods.IndexOf(matchingMod)); RemainingMissingModCount--; } _missingModsLocked = false; }); } } else { var missingMods = MissingMods.ToList(); foreach (var matchingMissingMod in missingMods.Where(x => x.Md5 == e.Md5).ToList()) { Application.Current.Dispatcher.BeginInvoke((Action) delegate { _missingModsLocked = true; var index = MissingMods.IndexOf(matchingMissingMod); if (index == -1) { return; } MissingMods[MissingMods.IndexOf(matchingMissingMod)].CurrentDownloadProgress = e.CurrentDownloadProgress; _missingModsLocked = false; }); } } }
private void ViewControllerController() { // Phin would be proud. This will be replaced when I have more time. // That never means anything though. This will be around for a while. while (true) { if (MissingMods.Count() == 0 && _missingModsLocked == false) { _viewController.IncrementCurrentViewIndex(); return; } Thread.Sleep(10); } }
private async void QueueDownload(object caller, PipedData pipedData) { if (!MissingMods.Any(x => x.FileId == pipedData.FileId && x.ModId == pipedData.ModId) || !_apiBase.IsUserLoggedIn()) { return; } var downloadUrl = await _apiEndpoints.GenerateModDownloadLinkAsync(pipedData); var matchingModObject = MissingMods.First(x => x.FileId == pipedData.FileId && x.ModId == pipedData.ModId); MissingMods.First(x => x == matchingModObject).IsIndeterminateProcess = true; if (matchingModObject == null) { return; } _downloadClient.QueueDownload(downloadUrl, matchingModObject); }
private void ValidateModsController() { // Phin would be proud. This will be replaced when I have more time. // That never means anything though. This will be around for a while. var lastAutodownloadsStatus = AutodownloadsEnabled; while (true) { if (MissingMods.Count() == 0 && _missingModsLocked == false) { _viewController.IncrementCurrentViewIndex(); return; } if (AutodownloadsEnabled && !lastAutodownloadsStatus) { lastAutodownloadsStatus = AutodownloadsEnabled; if (_apiBase.IsUserLoggedIn() && _apiBase.IsUserPremium()) { InitializeAutoDownloader(); } else { _dialogController.OpenLogDialog("You must be a Nexus Premium member to use the auto-downloading feature of Automaton."); AutodownloadsEnabled = false; } } if (!AutodownloadsEnabled && lastAutodownloadsStatus) { lastAutodownloadsStatus = AutodownloadsEnabled; _downloadClient.PurgeQueue(); } Thread.Sleep(100); } }
/// <summary> /// Initializes the NXMWorker pipe listener. /// </summary> private void InitializeDownloadHandle() { if (NoMissingMods) { return; } var nexusProtocol = new NexusProtocol(); // Start capturing piped messages from the NXMWorker, handle any progress reports. nexusProtocol.StartRecievingProtocolValues(new Progress <CaptureProtocolValuesProgress>(async x => { var matchingMods = MissingMods.Where(y => y.NexusModId == x.ModId); if (!matchingMods.Any()) { return; } var matchingMod = matchingMods.First(); if (matchingMod != null) { WindowNotificationControls.MoveToFront(); // Start downloading the mod file. await NexusMod.DownloadModFile(matchingMod, x.FileId, new Progress <DownloadModFileProgress>(downloadProgress => { MissingMods[MissingMods.IndexOf(matchingMod)].CurrentDownloadPercentage = downloadProgress.CurrentDownloadPercentage; if (downloadProgress.IsDownloadComplete) { Modpack.UpdateModArchivePaths(matchingMod, downloadProgress.DownloadLocation); MissingMods.Remove(matchingMod); NoMissingMods = MissingMods.Count == 0; } })); } })); }
private async void FindAndValidateModFile(Mod currentMod) { var fileBrowser = new OpenFileDialog() { Title = $"Find {currentMod.ModName} | {currentMod.FileName}", InitialDirectory = "Downloads", Filter = "Mod Archive (*.zip;*.7zip;*.7z;*.rar;*.gzip)|*.zip;*.7zip;*.7z;*.rar;*.gzip", }; if (fileBrowser.ShowDialog() != DialogResult.OK) { return; } var archivePath = fileBrowser.FileName; var validationResult = false; MissingMods.Where(x => x == currentMod).First().IsIndeterminateProcess = true; await Task.Factory.StartNew(() => { validationResult = Validation.IsMatchingModArchive(currentMod, archivePath).Result; }); if (validationResult) { MissingMods.Where(x => x == currentMod).First().IsIndeterminateProcess = false; MissingMods.Remove(currentMod); NoMissingMods = MissingMods.Count == 0; } else { MissingMods.Where(x => x == currentMod).First().IsIndeterminateProcess = false; } // Show in UI }
private async void FindAndValidateMod(ExtendedMod mod) { var possibleArchiveMatch = await _fileSystemBrowser.OpenFileBrowserAsync($"{mod.ModName}|{mod.FileName}|All Matching Extensions|*{Path.GetExtension(mod.FileName)}|All Files|*.*", $"Please select the matching mod archive: {mod.FileName}"); if (string.IsNullOrEmpty(possibleArchiveMatch)) { return; } var filteredMissingMods = _validate.ValidateTargetModArchive(possibleArchiveMatch, MissingMods.ToList()); RemainingMissingModCount = filteredMissingMods.Count; await Application.Current.Dispatcher.BeginInvoke((Action) delegate { _missingModsLocked = true; MissingMods = new RangeObservableCollection <ExtendedMod>(); MissingMods.AddRange(filteredMissingMods); _missingModsLocked = false; }); }