public void SetData(ModDownload entry) { if (entry == null) { // Download details labelDownloadPublished.Text = null; labelSize.Text = null; labelFileCount.Text = null; // Release details labelReleasePublished.Text = null; linkRelease.Text = null; labelReleaseName.Text = null; labelReleaseTag.Text = null; } else { // Download details labelDownloadPublished.Text = entry.Updated.ToString(CultureInfo.CurrentCulture); labelSize.Text = SizeSuffix.GetSizeSuffix(entry.Size); labelFileCount.Text = entry.FilesToDownload.ToString(); // Release details labelReleasePublished.Text = entry.Published.ToString(CultureInfo.CurrentCulture); linkRelease.Text = entry.ReleaseUrl; labelReleaseName.Text = entry.Name; labelReleaseTag.Text = entry.Version; } linkRelease.Enabled = !string.IsNullOrEmpty(linkRelease.Text); Enabled = entry != null; }
private void SetModDetails(ModDownload entry) { textChangeLog.Text = entry?.Changes.Trim(); modUpdateDetails.SetData(entry); listFiles.BeginUpdate(); listFiles.Items.Clear(); if (entry?.Type == ModDownloadType.Modular) { tabPageFiles.Enabled = true; foreach (ModManifestDiff i in entry.ChangedFiles) { string file = i.State == ModManifestState.Moved ? $"{i.Last.FilePath} -> {i.Current.FilePath}" : i.Current.FilePath; listFiles.Items.Add(new ListViewItem(new[] { i.State.ToString(), file })); } listFiles.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } else { tabPageFiles.Enabled = false; } listFiles.EndUpdate(); }
public void AddDownload(string nxmLink) { Log.Information($@"Queueing nxmlink {nxmLink}"); var dl = new ModDownload(nxmLink); dl.OnInitialized += ModInitialized; dl.OnModDownloaded += ModDownloaded; dl.OnModDownloadError += DownloadError; Downloads.Add(dl); dl.Initialize(); }
// TODO: merge with ^ private void UpdateChecker_DoWorkForced(object sender, DoWorkEventArgs e) { if (!(sender is BackgroundWorker worker)) { throw new Exception("what"); } if (!(e.Argument is List <Tuple <string, ModInfo, List <ModManifestDiff> > > updatableMods) || updatableMods.Count == 0) { return; } var updates = new List <ModDownload>(); var errors = new List <string>(); using (var client = new UpdaterWebClient()) { foreach (Tuple <string, ModInfo, List <ModManifestDiff> > info in updatableMods) { if (worker.CancellationPending) { e.Cancel = true; break; } ModInfo mod = info.Item2; if (!string.IsNullOrEmpty(mod.GitHubRepo)) { if (string.IsNullOrEmpty(mod.GitHubAsset)) { errors.Add($"[{ mod.Name }] GitHubRepo specified, but GitHubAsset is missing."); continue; } ModDownload d = modUpdater.GetGitHubReleases(mod, info.Item1, client, errors); if (d != null) { updates.Add(d); } } else if (!string.IsNullOrEmpty(mod.GameBananaItemType) && mod.GameBananaItemId.HasValue) { ModDownload d = modUpdater.GetGameBananaReleases(mod, info.Item1, errors); if (d != null) { updates.Add(d); } } else if (!string.IsNullOrEmpty(mod.UpdateUrl)) { List <ModManifest> localManifest = info.Item3 .Where(x => x.State == ModManifestState.Unchanged) .Select(x => x.Current).ToList(); ModDownload d = modUpdater.CheckModularVersion(mod, info.Item1, localManifest, client, errors); if (d != null) { updates.Add(d); } } } } e.Result = new Tuple <List <ModDownload>, List <string> >(updates, errors); }