Sorting, apply to all, fixes

Sorting mods when (un)installing
Added Apply to all checkbox to a custom message box that replaces the one that shows up when the mod files already exist without the mod manager knowing about it
Removing IPA.zip after unzipping
Fix deleting files when their folder doesn't exist
This commit is contained in:
Norbi Peti 2020-10-04 01:08:19 +02:00
parent cb4473de58
commit c3c9ee0a16
7 changed files with 2061 additions and 2 deletions

128
GCMM/CustomMessageBox.Designer.cs generated Normal file
View file

@ -0,0 +1,128 @@
namespace GCMM
{
partial class CustomMessageBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomMessageBox));
this.content = new System.Windows.Forms.Label();
this.yesbtn = new System.Windows.Forms.Button();
this.nobtn = new System.Windows.Forms.Button();
this.applyToAll = new System.Windows.Forms.CheckBox();
this.panel1 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// content
//
this.content.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.content.Location = new System.Drawing.Point(12, 13);
this.content.Name = "content";
this.content.Size = new System.Drawing.Size(367, 55);
this.content.TabIndex = 0;
this.content.Text = "Text";
//
// yesbtn
//
this.yesbtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.yesbtn.Location = new System.Drawing.Point(216, 106);
this.yesbtn.Name = "yesbtn";
this.yesbtn.Size = new System.Drawing.Size(75, 23);
this.yesbtn.TabIndex = 1;
this.yesbtn.Text = "Yes";
this.yesbtn.UseVisualStyleBackColor = true;
//
// nobtn
//
this.nobtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.nobtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.nobtn.Location = new System.Drawing.Point(297, 106);
this.nobtn.Name = "nobtn";
this.nobtn.Size = new System.Drawing.Size(75, 23);
this.nobtn.TabIndex = 2;
this.nobtn.Text = "No";
this.nobtn.UseVisualStyleBackColor = true;
//
// applyToAll
//
this.applyToAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.applyToAll.AutoSize = true;
this.applyToAll.Location = new System.Drawing.Point(12, 83);
this.applyToAll.Name = "applyToAll";
this.applyToAll.Size = new System.Drawing.Size(77, 17);
this.applyToAll.TabIndex = 4;
this.applyToAll.Text = "Apply to all";
this.applyToAll.UseVisualStyleBackColor = true;
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.panel1.Controls.Add(this.content);
this.panel1.Location = new System.Drawing.Point(1, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(382, 80);
this.panel1.TabIndex = 5;
//
// CustomMessageBox
//
this.AcceptButton = this.yesbtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ControlLight;
this.ClientSize = new System.Drawing.Size(384, 141);
this.ControlBox = false;
this.Controls.Add(this.panel1);
this.Controls.Add(this.applyToAll);
this.Controls.Add(this.nobtn);
this.Controls.Add(this.yesbtn);
this.ForeColor = System.Drawing.SystemColors.ControlText;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CustomMessageBox";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label content;
private System.Windows.Forms.Button yesbtn;
private System.Windows.Forms.Button nobtn;
private System.Windows.Forms.CheckBox applyToAll;
private System.Windows.Forms.Panel panel1;
}
}

47
GCMM/CustomMessageBox.cs Normal file
View file

@ -0,0 +1,47 @@
using GCMM.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GCMM
{
public partial class CustomMessageBox : Form
{
public bool ApplyToAll { get; private set; }
public CustomMessageBox()
{
InitializeComponent();
yesbtn.Click += (sender, e) =>
{
DialogResult = DialogResult.Yes;
ApplyToAll = applyToAll.Checked;
Close();
};
nobtn.Click += (sender, e) =>
{
DialogResult = DialogResult.No;
ApplyToAll = applyToAll.Checked;
Close();
};
/*cancelbtn.Click += (sender, e) =>
{
DialogResult = DialogResult.Cancel;
Close();
};*/
}
public CustomMessageBox(string message, string caption) : this()
{
content.Text = message;
Text = caption;
}
}
}

1870
GCMM/CustomMessageBox.resx Normal file

File diff suppressed because it is too large Load diff

View file

@ -84,6 +84,7 @@
this.modlist.Location = new System.Drawing.Point(12, 47); this.modlist.Location = new System.Drawing.Point(12, 47);
this.modlist.Name = "modlist"; this.modlist.Name = "modlist";
this.modlist.Size = new System.Drawing.Size(491, 433); this.modlist.Size = new System.Drawing.Size(491, 433);
this.modlist.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.modlist.TabIndex = 0; this.modlist.TabIndex = 0;
this.modlist.UseCompatibleStateImageBehavior = false; this.modlist.UseCompatibleStateImageBehavior = false;
this.modlist.View = System.Windows.Forms.View.Details; this.modlist.View = System.Windows.Forms.View.Details;

View file

@ -75,6 +75,7 @@ namespace GCMM
LoadFileList(mod); LoadFileList(mod);
DirectoryInfo di = Directory.CreateDirectory(destinationDirectoryName); DirectoryInfo di = Directory.CreateDirectory(destinationDirectoryName);
string destinationDirectoryFullPath = di.FullName; string destinationDirectoryFullPath = di.FullName;
bool? skipExisting = null;
foreach (ZipArchiveEntry file in archive.Entries) foreach (ZipArchiveEntry file in archive.Entries)
{ {
@ -96,7 +97,16 @@ namespace GCMM
&& !mod.ModFiles.Contains(completeFileName) // OR it's known to be part of the mod already && !mod.ModFiles.Contains(completeFileName) // OR it's known to be part of the mod already
&& file.FullName != "Plugins/" + mod.Name + ".dll") // OR it's the plugin's DLL (dll->zip release) && file.FullName != "Plugins/" + mod.Name + ".dll") // OR it's the plugin's DLL (dll->zip release)
{ {
if (MessageBox.Show("The mod zip contains a file that exists as part of the game. Do you want to skip this file?\n" + file.FullName + "\nOnly choose No if it's part of a previous installation of the mod.", "File is part of the game", MessageBoxButtons.YesNo) == DialogResult.Yes) if (!skipExisting.HasValue)
{
var mbox = new CustomMessageBox("The mod zip contains a file that exists as part of the game. Do you want to skip this file?\n" + file.FullName + "\nOnly choose No if it's part of a previous installation of the mod.", "File is part of the game");
var result = mbox.ShowDialog(this);
if (mbox.ApplyToAll)
skipExisting = result == DialogResult.Yes;
if (result == DialogResult.Yes)
continue;
}
else if (skipExisting.Value)
continue; continue;
} }
@ -131,6 +141,7 @@ namespace GCMM
{ {
foreach (string file in mod.ModFiles) foreach (string file in mod.ModFiles)
{ {
if (!File.Exists(file)) continue; //If the folders don't exist then it errors
File.Delete(file); File.Delete(file);
var parent = Directory.GetParent(file); var parent = Directory.GetParent(file);
if (!parent.EnumerateFileSystemInfos().Any()) if (!parent.EnumerateFileSystemInfos().Any())

View file

@ -94,7 +94,7 @@ namespace GCMM
await FetchModInfo(gcipa, preview, false); await FetchModInfo(gcipa, preview, false);
await FetchModInfo(gcmm, preview, false); await FetchModInfo(gcmm, preview, false);
if (gcmm.Updatable) if (gcmm.Updatable)
if (MessageBox.Show("There is a GCMM update available! Do you want to download it now? If yes, extract it over this installation.", "Mod Manager update", MessageBoxButtons.YesNo) if (MessageBox.Show("There is a GCMM update available! Do you want to download it now? If yes, extract it over this installation.\n\n" + gcmm.UpdateDetails, "Mod Manager update", MessageBoxButtons.YesNo)
== DialogResult.Yes) == DialogResult.Yes)
Process.Start(gcmm.DownloadURL); Process.Start(gcmm.DownloadURL);
} }
@ -180,6 +180,7 @@ namespace GCMM
items[2].Text = (omod.Version ?? omod.LatestVersion)?.ToString(); items[2].Text = (omod.Version ?? omod.LatestVersion)?.ToString();
items[3].Text = omod.LastUpdated.ToString(); items[3].Text = omod.LastUpdated.ToString();
item.Group = omod.Installed ? modlist.Groups["installed"] : modlist.Groups["available"]; item.Group = omod.Installed ? modlist.Groups["installed"] : modlist.Groups["available"];
modlist.Sort();
mod = omod; mod = omod;
} }
else else

View file

@ -98,6 +98,7 @@ namespace GCMM
using (var fs = new FileStream("IPA.zip", FileMode.Open)) using (var fs = new FileStream("IPA.zip", FileMode.Open))
using (var za = new ZipArchive(fs)) using (var za = new ZipArchive(fs))
za.ExtractToDirectory(Settings.Default.GamePath, true); //Overwrite files that were left from a previous install of the patcher za.ExtractToDirectory(Settings.Default.GamePath, true); //Overwrite files that were left from a previous install of the patcher
File.Delete("IPA.zip");
} }
} }
GetInstalledMods(); //Update patcher state, should be fine for this rare event GetInstalledMods(); //Update patcher state, should be fine for this rare event