Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Core/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public static void RemoveWhere<K, V>(this Dictionary<K, V> source,
}
}

public static bool IntersectsWith<T>(this IEnumerable<T> source,
IEnumerable<T> other)
=> source.Intersect(other).Any();

/// <summary>
/// Sum a sequence of TimeSpans.
/// Mysteriously not defined standardly.
Expand Down
2 changes: 1 addition & 1 deletion Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
Install the `mono-complete` package or equivalent for your operating system.</value></data>
<data name="NetModuleCacheBadLength" xml:space="preserve"><value>{0}: {1} has length {2}, should be {3}</value></data>
<data name="NetModuleCacheNotValidZIP" xml:space="preserve"><value>{0}: {1} is not a valid ZIP file: {2}</value></data>
<data name="NetModuleCacheMismatchSHA256" xml:space="preserve"><value>{0}: {1} has SHA256 {2}, should be {3}</value></data>
<data name="NetModuleCacheMismatchSHA256" xml:space="preserve"><value>{0}: SHA256 {2} should be {3} for {1}</value></data>
<data name="NetRepoUpdatingBuildMap" xml:space="preserve"><value>Refreshing game version data</value></data>
<data name="NetRepoCheckingForUpdates" xml:space="preserve"><value>Checking for updates</value></data>
<data name="NetRepoAlreadyUpToDate" xml:space="preserve"><value>Already up to date</value></data>
Expand Down
131 changes: 66 additions & 65 deletions GUI/Controls/ManageMods.cs

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions GUI/Dialogs/DownloadsFailedDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 38 additions & 8 deletions GUI/Dialogs/DownloadsFailedDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public DownloadsFailedDialog(
Func<object, object, bool> rowsLinked)
{
InitializeComponent();
if (Platform.IsMono)
{
GridContextMenuStrip.Renderer = new FlatToolStripRenderer();
}
ExplanationLabel.Text = TopLabelMessage;
ModColumn.HeaderText = ModuleColumnHeader;
AbortButton.Text = AbortButtonCaption;
Expand All @@ -66,14 +70,14 @@ public DownloadsFailedDialog(
.ToList();
DownloadsGrid.DataSource = new BindingList<DownloadRow>(rows);
ClientSize = new Size(ClientSize.Width,
ExplanationLabel.Height
+ ExplanationLabel.Padding.Vertical
+ DownloadsGrid.ColumnHeadersHeight
+ (DownloadsGrid.RowCount
* DownloadsGrid.RowTemplate.Height)
+ DownloadsGrid.Margin.Vertical
+ DownloadsGrid.Padding.Vertical
+ BottomButtonPanel.Height);
ExplanationLabel.Height
+ ExplanationLabel.Padding.Vertical
+ DownloadsGrid.ColumnHeadersHeight
+ DownloadsGrid.Rows.OfType<DataGridViewRow>()
.Sum(r => r.Height)
+ DownloadsGrid.Margin.Vertical
+ DownloadsGrid.Padding.Vertical
+ BottomButtonPanel.Height);
}

[ForbidGUICalls]
Expand All @@ -96,6 +100,13 @@ public DownloadsFailedDialog(
.Select(r => r.Data)
.ToArray();

protected override void OnResize(EventArgs e)
{
ExplanationLabel.MaximumSize = new Size(ClientSize.Width - Padding.Horizontal,
ClientSize.Height - Padding.Vertical);
base.OnResize(e);
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
Expand Down Expand Up @@ -156,6 +167,25 @@ private void DownloadsGrid_CellEndEdit(object sender, DataGridViewCellEventArgs
}
}

private void DownloadsGrid_MouseDown(object? sender, MouseEventArgs e)
{
if (e is { Button: MouseButtons.Right})
{
// Show the context menu
GridContextMenuStrip.Show(Cursor.Position);
}
}

private void CopyErrorToolStripMenuItem_Click(object? sender, EventArgs? e)
{
Clipboard.SetText(string.Join(Environment.NewLine,
DownloadsGrid.Rows
.OfType<DataGridViewRow>()
.Select(r => r.DataBoundItem)
.OfType<DownloadRow>()
.Select(r => r.Error)));
}

private void RetryButton_Click(object? sender, EventArgs? e)
{
Abort = false;
Expand Down
1 change: 1 addition & 0 deletions GUI/Dialogs/DownloadsFailedDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
<data name="RetryColumn.HeaderText" xml:space="preserve"><value>Retry?</value></data>
<data name="SkipColumn.HeaderText" xml:space="preserve"><value>Skip?</value></data>
<data name="ErrorColumn.HeaderText" xml:space="preserve"><value>Error</value></data>
<data name="CopyErrorToolStripMenuItem.Text" xml:space="preserve"><value>Copy errors to clipboard</value></data>
<data name="RetryButton.Text" xml:space="preserve"><value>Retry</value></data>
</root>
1 change: 1 addition & 0 deletions GUI/Main/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions GUI/Main/MainDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;

using CKAN.GUI.Attributes;
using CKAN.Extensions;

namespace CKAN.GUI
{
Expand All @@ -18,7 +19,7 @@ private void ModInfo_OnDownloadClick(GUIMod gmod)
StartDownload(gmod);
}

public void StartDownloads(IEnumerable<GUIMod> modules)
private void StartDownloads(IReadOnlyCollection<GUIMod> modules)
{
ShowWaitDialog();
if (downloader != null)
Expand All @@ -36,9 +37,9 @@ public void StartDownloads(IEnumerable<GUIMod> modules)
}
}

public void StartDownload(GUIMod module)
private void StartDownload(GUIMod module)
{
StartDownloads(Enumerable.Repeat(module, 1));
StartDownloads(new GUIMod[] { module });
}

[ForbidGUICalls]
Expand All @@ -59,7 +60,8 @@ private void CacheMods(object? sender, DoWorkEventArgs? e)
{
try
{
downloader.DownloadModules(modules.Select(m => m.Module));
downloader.DownloadModules(modules.Where(m => !m.IsCached)
.Select(m => m.Module));
done = true;
}
catch (ModuleDownloadErrorsKraken k)
Expand All @@ -70,9 +72,13 @@ private void CacheMods(object? sender, DoWorkEventArgs? e)
dfd = new DownloadsFailedDialog(
Properties.Resources.ModDownloadsFailedMessage,
Properties.Resources.ModDownloadsFailedColHdr,
Properties.Resources.ModDownloadsFailedAbortBtn,
Properties.Resources.ModDownloadsFailedAbortBtnNotInstalling,
k.Exceptions.Select(kvp => new KeyValuePair<object[], Exception>(
modules.Select(m => m.Module).ToArray(), kvp.Value)),
modules.Select(m => m.Module)
.Where(m => (m.download ?? Enumerable.Empty<Uri>())
.IntersectsWith(kvp.Key?.download ?? Enumerable.Empty<Uri>()))
.ToArray(),
kvp.Value)),
(m1, m2) => (m1 as CkanModule)?.download == (m2 as CkanModule)?.download);
dfd.ShowDialog(this);
});
Expand Down
4 changes: 2 additions & 2 deletions GUI/Main/MainExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private void EditModpack_OnSelectedItemsChanged(ListView.SelectedListViewItemCol
{
var ident = first.name;
if (!string.IsNullOrEmpty(ident)
&& ManageMods.mainModList != null
&& ManageMods.mainModList.full_list_of_mod_rows.TryGetValue(ident, out DataGridViewRow? row))
&& ManageMods.MainModList != null
&& ManageMods.MainModList.full_list_of_mod_rows.TryGetValue(ident, out DataGridViewRow? row))
{
ActiveModInfo = row.Tag as GUIMod;
}
Expand Down
4 changes: 2 additions & 2 deletions GUI/Main/MainHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ private void InstallationHistoryToolStripMenuItem_Click(object? sender, EventArg

private void InstallationHistory_Install(CkanModule[] modules)
{
if (CurrentInstance != null && ManageMods.mainModList != null)
if (CurrentInstance != null && ManageMods.MainModList != null)
{
InstallationHistory_Done();
var tuple = ManageMods.mainModList.ComputeFullChangeSetFromUserChangeSet(
var tuple = ManageMods.MainModList.ComputeFullChangeSetFromUserChangeSet(
RegistryManager.Instance(CurrentInstance, repoData).registry,
modules.Select(mod => new ModChange(mod, GUIModChangeType.Install,
ServiceLocator.Container.Resolve<IConfiguration>()))
Expand Down
4 changes: 2 additions & 2 deletions GUI/Main/MainImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ private void ImportModules()
Wait.StartWaiting(
(sender, e) =>
{
if (e != null && Manager?.Cache != null && ManageMods.mainModList != null)
if (e != null && Manager?.Cache != null && ManageMods.MainModList != null)
{
e.Result = ModuleImporter.ImportFiles(
GetFiles(dlg.FileNames),
currentUser,
mod =>
{
if (ManageMods.mainModList
if (ManageMods.MainModList
.full_list_of_mod_rows
.TryGetValue(mod.identifier,
out DataGridViewRow? row)
Expand Down
5 changes: 4 additions & 1 deletion GUI/Main/MainInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using CKAN.IO;
using CKAN.GUI.Attributes;
using CKAN.Configuration;
using CKAN.Extensions;

// Don't warn if we use our own obsolete properties
#pragma warning disable 0618
Expand Down Expand Up @@ -286,7 +287,9 @@ private void InstallMods(object? sender, DoWorkEventArgs? e)
Properties.Resources.ModDownloadsFailedColHdr,
Properties.Resources.ModDownloadsFailedAbortBtn,
k.Exceptions.Select(kvp => new KeyValuePair<object[], Exception>(
fullChangeset.Where(m => m.download == kvp.Key.download).ToArray(),
fullChangeset.Where(m => (m.download ?? Enumerable.Empty<Uri>())
.IntersectsWith(kvp.Key.download ?? Enumerable.Empty<Uri>()))
.ToArray(),
kvp.Value)),
(m1, m2) => (m1 as CkanModule)?.download == (m2 as CkanModule)?.download);
dfd.ShowDialog(this);
Expand Down
2 changes: 1 addition & 1 deletion GUI/Main/MainRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private void OnRefreshTimer(object? sender, ElapsedEventArgs e)

private void UpgradeNotification()
{
if (ManageMods.mainModList?.Modules.Count(mod => mod.HasUpdate) is > 0 and int numUpgradeable)
if (ManageMods.MainModList?.Modules.Count(mod => mod.HasUpdate) is > 0 and int numUpgradeable)
{
Util.Invoke(this, () =>
{
Expand Down
4 changes: 2 additions & 2 deletions GUI/Main/MainTrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ private void UpdateTrayState()

private void UpdateTrayInfo()
{
if (CurrentInstance != null && ManageMods.mainModList != null)
if (CurrentInstance != null && ManageMods.MainModList != null)
{
var count = ManageMods.mainModList.CountModsByFilter(CurrentInstance,
var count = ManageMods.MainModList.CountModsByFilter(CurrentInstance,
GUIModFilter.InstalledUpdateAvailable);
if (count == 0)
{
Expand Down
3 changes: 2 additions & 1 deletion GUI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,10 @@ Or choose "Update repositories on launch" in the settings.</value></data>
<data name="ChangeTypeRemove" xml:space="preserve"><value>Remove</value></data>
<data name="ChangeTypeUpdate" xml:space="preserve"><value>Update</value></data>
<data name="ChangeTypeReplace" xml:space="preserve"><value>Replace</value></data>
<data name="ModDownloadsFailedMessage" xml:space="preserve"><value>The following mods failed to download. You can retry or abort, and if you retry, you can choose to remove some mods (and any mods that depend on them) from the changeset. Mods that share the same download link will automatically be updated to the same choice.</value></data>
<data name="ModDownloadsFailedMessage" xml:space="preserve"><value>The following mods failed to download. You can retry or abort, and if you retry, you can choose to remove some mods (and any mods that depend on them). Mods that share the same download link will automatically be updated to the same choice.</value></data>
<data name="ModDownloadsFailedColHdr" xml:space="preserve"><value>Mod</value></data>
<data name="ModDownloadsFailedAbortBtn" xml:space="preserve"><value>Abort whole changeset</value></data>
<data name="ModDownloadsFailedAbortBtnNotInstalling" xml:space="preserve"><value>Abort download</value></data>
<data name="RepoDownloadsFailedMessage" xml:space="preserve"><value>The following repositories failed to download. You can retry or abort, and if you retry, you can choose to remove some repositories. Note that any repositories you skip will be PERMANENTLY removed from your configuration!</value></data>
<data name="RepoDownloadsFailedColHdr" xml:space="preserve"><value>Repository</value></data>
<data name="RepoDownloadsFailedAbortBtn" xml:space="preserve"><value>Abort whole update</value></data>
Expand Down
Loading