Some fixes, polishing and extra features

Handling "install and update" button label
Fixed mod updating
New version detection fixed, highlighting and showing a message in the info section
Showing release information for mods that have a new version available
Added information about mod requirements
Added a button to find the game log
Added a checkbox to run the game unpatched
Added information about using the program
This commit is contained in:
Norbi Peti 2020-06-17 23:56:18 +02:00
parent d219f02a80
commit e69b357da1
11 changed files with 172 additions and 90 deletions

View file

@ -36,9 +36,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="modlist.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Properties\Settings.settings"> <None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View file

@ -28,9 +28,9 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.Windows.Forms.ListViewGroup listViewGroup3 = new System.Windows.Forms.ListViewGroup("Installed", System.Windows.Forms.HorizontalAlignment.Center); System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("Installed", System.Windows.Forms.HorizontalAlignment.Center);
System.Windows.Forms.ListViewGroup listViewGroup4 = new System.Windows.Forms.ListViewGroup("Available", System.Windows.Forms.HorizontalAlignment.Center); System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("Available", System.Windows.Forms.HorizontalAlignment.Center);
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] { System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] {
"Mod", "Mod",
"modtainers", "modtainers",
"1.0", "1.0",
@ -44,9 +44,11 @@
this.status = new System.Windows.Forms.Label(); this.status = new System.Windows.Forms.Label();
this.installbtn = new System.Windows.Forms.Button(); this.installbtn = new System.Windows.Forms.Button();
this.uninstallbtn = new System.Windows.Forms.Button(); this.uninstallbtn = new System.Windows.Forms.Button();
this.modinfobox = new System.Windows.Forms.TextBox();
this.playbtn = new System.Windows.Forms.Button(); this.playbtn = new System.Windows.Forms.Button();
this.settingsbtn = new System.Windows.Forms.Button(); this.settingsbtn = new System.Windows.Forms.Button();
this.findlog = new System.Windows.Forms.Button();
this.unpatched = new System.Windows.Forms.CheckBox();
this.modinfobox = new System.Windows.Forms.RichTextBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// modlist // modlist
@ -63,20 +65,20 @@
this.modTimestamp}); this.modTimestamp});
this.modlist.ForeColor = System.Drawing.Color.Green; this.modlist.ForeColor = System.Drawing.Color.Green;
this.modlist.FullRowSelect = true; this.modlist.FullRowSelect = true;
listViewGroup3.Header = "Installed"; listViewGroup1.Header = "Installed";
listViewGroup3.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center; listViewGroup1.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center;
listViewGroup3.Name = "installed"; listViewGroup1.Name = "installed";
listViewGroup4.Header = "Available"; listViewGroup2.Header = "Available";
listViewGroup4.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center; listViewGroup2.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center;
listViewGroup4.Name = "available"; listViewGroup2.Name = "available";
this.modlist.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] { this.modlist.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] {
listViewGroup3, listViewGroup1,
listViewGroup4}); listViewGroup2});
this.modlist.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.modlist.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.modlist.HideSelection = false; this.modlist.HideSelection = false;
listViewItem2.Group = listViewGroup3; listViewItem1.Group = listViewGroup1;
this.modlist.Items.AddRange(new System.Windows.Forms.ListViewItem[] { this.modlist.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem2}); listViewItem1});
this.modlist.Location = new System.Drawing.Point(12, 12); this.modlist.Location = new System.Drawing.Point(12, 12);
this.modlist.Name = "modlist"; this.modlist.Name = "modlist";
this.modlist.Size = new System.Drawing.Size(491, 468); this.modlist.Size = new System.Drawing.Size(491, 468);
@ -114,9 +116,9 @@
this.status.ForeColor = System.Drawing.Color.Lime; this.status.ForeColor = System.Drawing.Color.Lime;
this.status.Location = new System.Drawing.Point(8, 487); this.status.Location = new System.Drawing.Point(8, 487);
this.status.Name = "status"; this.status.Name = "status";
this.status.Size = new System.Drawing.Size(60, 20); this.status.Size = new System.Drawing.Size(60, 40);
this.status.TabIndex = 1; this.status.TabIndex = 1;
this.status.Text = "Status:"; this.status.Text = "Status:\r\nasd";
// //
// installbtn // installbtn
// //
@ -149,21 +151,6 @@
this.uninstallbtn.UseVisualStyleBackColor = true; this.uninstallbtn.UseVisualStyleBackColor = true;
this.uninstallbtn.Click += new System.EventHandler(this.uninstallbtn_Click); this.uninstallbtn.Click += new System.EventHandler(this.uninstallbtn_Click);
// //
// modinfobox
//
this.modinfobox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.modinfobox.BackColor = System.Drawing.Color.Black;
this.modinfobox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.modinfobox.ForeColor = System.Drawing.Color.Lime;
this.modinfobox.Location = new System.Drawing.Point(509, 122);
this.modinfobox.Multiline = true;
this.modinfobox.Name = "modinfobox";
this.modinfobox.ReadOnly = true;
this.modinfobox.Size = new System.Drawing.Size(262, 358);
this.modinfobox.TabIndex = 4;
this.modinfobox.Text = resources.GetString("modinfobox.Text");
//
// playbtn // playbtn
// //
this.playbtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.playbtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
@ -193,15 +180,54 @@
this.settingsbtn.UseVisualStyleBackColor = true; this.settingsbtn.UseVisualStyleBackColor = true;
this.settingsbtn.Click += new System.EventHandler(this.settingsbtn_Click); this.settingsbtn.Click += new System.EventHandler(this.settingsbtn_Click);
// //
// findlog
//
this.findlog.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.findlog.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Green;
this.findlog.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(40)))), ((int)(((byte)(0)))));
this.findlog.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.findlog.Location = new System.Drawing.Point(666, 522);
this.findlog.Name = "findlog";
this.findlog.Size = new System.Drawing.Size(105, 29);
this.findlog.TabIndex = 7;
this.findlog.Text = "Find game log";
this.findlog.UseVisualStyleBackColor = true;
this.findlog.Click += new System.EventHandler(this.findlog_Click);
//
// unpatched
//
this.unpatched.AutoSize = true;
this.unpatched.Location = new System.Drawing.Point(12, 534);
this.unpatched.Name = "unpatched";
this.unpatched.Size = new System.Drawing.Size(100, 17);
this.unpatched.TabIndex = 8;
this.unpatched.Text = "Run unpatched";
this.unpatched.UseVisualStyleBackColor = true;
this.unpatched.CheckedChanged += new System.EventHandler(this.unpatched_CheckedChanged);
//
// modinfobox
//
this.modinfobox.BackColor = System.Drawing.Color.Black;
this.modinfobox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.modinfobox.ForeColor = System.Drawing.Color.Lime;
this.modinfobox.Location = new System.Drawing.Point(509, 122);
this.modinfobox.Name = "modinfobox";
this.modinfobox.ReadOnly = true;
this.modinfobox.Size = new System.Drawing.Size(263, 358);
this.modinfobox.TabIndex = 9;
this.modinfobox.Text = "";
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black; this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(784, 561); this.ClientSize = new System.Drawing.Size(784, 561);
this.Controls.Add(this.modinfobox);
this.Controls.Add(this.unpatched);
this.Controls.Add(this.findlog);
this.Controls.Add(this.settingsbtn); this.Controls.Add(this.settingsbtn);
this.Controls.Add(this.playbtn); this.Controls.Add(this.playbtn);
this.Controls.Add(this.modinfobox);
this.Controls.Add(this.uninstallbtn); this.Controls.Add(this.uninstallbtn);
this.Controls.Add(this.installbtn); this.Controls.Add(this.installbtn);
this.Controls.Add(this.status); this.Controls.Add(this.status);
@ -225,10 +251,12 @@
private System.Windows.Forms.Label status; private System.Windows.Forms.Label status;
private System.Windows.Forms.Button installbtn; private System.Windows.Forms.Button installbtn;
private System.Windows.Forms.Button uninstallbtn; private System.Windows.Forms.Button uninstallbtn;
private System.Windows.Forms.TextBox modinfobox;
private System.Windows.Forms.Button playbtn; private System.Windows.Forms.Button playbtn;
private System.Windows.Forms.Button settingsbtn; private System.Windows.Forms.Button settingsbtn;
private System.Windows.Forms.ColumnHeader modAuthor; private System.Windows.Forms.ColumnHeader modAuthor;
private System.Windows.Forms.Button findlog;
private System.Windows.Forms.CheckBox unpatched;
private System.Windows.Forms.RichTextBox modinfobox;
} }
} }

View file

@ -23,12 +23,30 @@ namespace GCMM
} }
private Dictionary<string, ModInfo> mods = new Dictionary<string, ModInfo>(); private Dictionary<string, ModInfo> mods = new Dictionary<string, ModInfo>();
private string defaultInfo = @"
Gamecraft Mod Manager
If you click on a mod it will show some info about it. The install instructions there are for manual installs.
To get started, click on a mod and select Install mod. Most mods need GamecraftModdingAPI as well.
Then, simply click Play. If all goes well, after some time a modded Gamecraft should launch.
After a Gamecraft update there's a good chance that mods will break. If this happens you may get errors when trying to start Gamecraft.
Until updated versions are released, use the ""Run unpatched"" checkbox at the bottom to launch the game without mods.
You don't have to use the mod manager to run the game each time, though it will tell you about mod updates when they come.
However, make sure to click Play each time you want to switch between modded and unmodded.
Disclaimer:
This mod manager and the mods in the list are made by the ExMods developers. We are not associated with Freejam or Gamecraft. Modify Gamecraft at your own risk.
If you encounter an issue while the game is patched, report it to us. If you think it's an issue with the game, test again with the unpatched option checked before reporting to Freejam.
";
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {
modlist.Items.Clear(); modlist.Items.Clear();
UpdateButton(installbtn, false); UpdateButton(installbtn, false);
modinfobox.Text = ""; modinfobox.Text = defaultInfo;
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath)) if (string.IsNullOrWhiteSpace(Settings.Default.GamePath))
{ {
Settings.Default.GamePath = GetGameFolder(); Settings.Default.GamePath = GetGameFolder();
@ -52,7 +70,7 @@ namespace GCMM
{ {
if (playbtn.ForeColor == Color.Green) return; //Disabled if (playbtn.ForeColor == Color.Green) return; //Disabled
if (!BeginWork()) return; if (!BeginWork()) return;
PatchGame(); PatchStartGame();
EndWork(); EndWork();
} }
@ -69,7 +87,7 @@ namespace GCMM
switch (modlist.SelectedItems.Count) switch (modlist.SelectedItems.Count)
{ {
case 0: case 0:
modinfobox.Text = ""; modinfobox.Text = defaultInfo;
UpdateButton(installbtn, false); UpdateButton(installbtn, false);
UpdateButton(uninstallbtn, false); UpdateButton(uninstallbtn, false);
break; break;
@ -78,24 +96,41 @@ namespace GCMM
installbtn.Text = "Install mod"; installbtn.Text = "Install mod";
UpdateButton(installbtn, false); UpdateButton(installbtn, false);
UpdateButton(uninstallbtn, false); UpdateButton(uninstallbtn, false);
bool install = false, update = false;
foreach (ListViewItem item in modlist.SelectedItems) foreach (ListViewItem item in modlist.SelectedItems)
{ {
var mod = mods[item.Name]; var mod = mods[item.Name];
if (modlist.SelectedItems.Count == 1) if (modlist.SelectedItems.Count == 1)
modinfobox.Text = mod.Description?.Replace("\n", Environment.NewLine); {
bool up = mod.Version != null && mod.Version < mod.LatestVersion;
modinfobox.Text = ((up ? "New version available! " + mod.UpdateDetails + "\n\n"
: "") + mod.Description).Replace("\n", Environment.NewLine);
if(up)
{
modinfobox.Select(0, "New version available!".Length);
modinfobox.SelectionColor = Color.Aqua;
modinfobox.DeselectAll();
}
}
else else
modinfobox.Text = modlist.SelectedItems.Count + " mods selected"; modinfobox.Text = modlist.SelectedItems.Count + " mods selected";
if (mod.DownloadURL != null && !(mod.LatestVersion <= mod.Version)) if (mod.DownloadURL != null && !(mod.LatestVersion <= mod.Version))
{ {
UpdateButton(installbtn, true); UpdateButton(installbtn, true);
if (mod.Version != null) if (mod.Version != null)
installbtn.Text = "Update mod"; update = true;
else else
installbtn.Text = "Install mod"; install = true;
} }
if (mod.Version != null) if (mod.Version != null)
UpdateButton(uninstallbtn, true); UpdateButton(uninstallbtn, true);
} }
if (install && update)
installbtn.Text = "Install and update mod";
else if (update)
installbtn.Text = "Update mod";
else
installbtn.Text = "Install mod";
break; break;
} }
} }
@ -106,8 +141,9 @@ namespace GCMM
if (!BeginWork()) return; if (!BeginWork()) return;
foreach (ListViewItem item in modlist.SelectedItems) foreach (ListViewItem item in modlist.SelectedItems)
{ {
if (item.Group.Name == "installed") continue; var mod = mods[item.Name];
await InstallMod(mods[item.Name]); if (item.Group.Name == "installed" && (mod.DownloadURL == null || mod.LatestVersion <= mod.Version)) continue;
await InstallMod(mod);
} }
EndWork(); EndWork();
} }
@ -122,5 +158,18 @@ namespace GCMM
} }
EndWork(); //Update button states EndWork(); //Update button states
} }
private void findlog_Click(object sender, EventArgs e)
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
Process.Start("explorer.exe", "/select,"+Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"Low\Freejam\Gamecraft\Player.log");
}
}
private void unpatched_CheckedChanged(object sender, EventArgs e)
{
CheckIfPatched();
}
} }
} }

View file

@ -117,18 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="modinfobox.Text" xml:space="preserve">
<value>This update is backwards compatible with mods that work with GamecraftModdingAPI v1.0 and later but adds support for Gamecraft's 2020.06.11.18.50 update.
To get started, follow the install guide: https://www.exmods.org/guides/install.html
Changelog
- Added some simulation (time running) functionality
- Added some player hand information
- Improved API to play in-game audio
In other news, we broke the 100 commit mark! The project is 7 months old, so that works out to just under 1 commit every 2 days, which adds about 5KB of code.</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>

View file

@ -46,7 +46,7 @@ namespace GCMM
if (!pluginOnly && modFound) break; if (!pluginOnly && modFound) break;
} }
if (!modFound && !pluginOnly) if (!modFound && !pluginOnly)
if (MessageBox.Show("The mod was not found in the downloaded archive. It likely means it's using a different name for the dll file. The mod manager will not be able to detect this mod as installed if you continue. Do you want to continue?", "Mod not found in archive", MessageBoxButtons.YesNo) == DialogResult.No) if (MessageBox.Show("The mod was not found in the downloaded archive. It likely means it's using a different name for the dll file. The mod manager will not be able to track this mod if you continue. Do you want to continue?", "Mod not found in archive", MessageBoxButtons.YesNo) == DialogResult.No)
return; return;
ExtractMod(archive, pluginOnly ? plugins.FullName : Settings.Default.GamePath, mod); ExtractMod(archive, pluginOnly ? plugins.FullName : Settings.Default.GamePath, mod);
} }

View file

@ -53,16 +53,20 @@ namespace GCMM
AddUpdateModInList(mod); AddUpdateModInList(mod);
} }
}*/ }*/
foreach (string line in File.ReadLines("modlist.txt")) using (var client = GetClient())
{ {
var sp = line.Split('\t'); string str = await client.DownloadStringTaskAsync("https://exmods.org/mods/modlist.tsv");
var mod = new ModInfo foreach (string line in str.Split('\n'))
{ {
Author = sp[0], var sp = line.Split('\t');
Name = sp[1] var mod = new ModInfo
}; {
if (await FetchModInfo(mod)) //If it's actually a mod Author = sp[0].Trim(),
AddUpdateModInList(mod); Name = sp[1].Trim()
};
if (await FetchModInfo(mod)) //If it's actually a mod
AddUpdateModInList(mod);
}
} }
} }
@ -81,6 +85,7 @@ namespace GCMM
var ver = release["tag_name"].ToString().Replace("v", "").Split('.').Select(str => int.Parse(str)).ToArray(); var ver = release["tag_name"].ToString().Replace("v", "").Split('.').Select(str => int.Parse(str)).ToArray();
int getver(byte i) => ver.Length > i ? ver[i] : 0; //By default it sets values not present to -1, but we need them to be 0 int getver(byte i) => ver.Length > i ? ver[i] : 0; //By default it sets values not present to -1, but we need them to be 0
mod.LatestVersion = new Version(getver(0), getver(1), getver(2), getver(3)); mod.LatestVersion = new Version(getver(0), getver(1), getver(2), getver(3));
mod.UpdateDetails = release["name"] + "\n\n" + release["body"].ToString();
try try
{ {
var obj = JObject.Parse(await client.DownloadStringTaskAsync("/api/v1/repos/" + mod.Author + "/" + mod.Name + "/contents/README.md")); var obj = JObject.Parse(await client.DownloadStringTaskAsync("/api/v1/repos/" + mod.Author + "/" + mod.Name + "/contents/README.md"));
@ -97,10 +102,11 @@ namespace GCMM
{ {
if (mods.ContainsKey(mod.Name) ^ modlist.Items.ContainsKey(mod.Name)) //The ListView's keys aren't case sensitive if (mods.ContainsKey(mod.Name) ^ modlist.Items.ContainsKey(mod.Name)) //The ListView's keys aren't case sensitive
throw new InvalidOperationException("The mod isn't present in one of the two places: " + mod.Name); throw new InvalidOperationException("The mod isn't present in one of the two places: " + mod.Name);
ListViewItem item;
if (modlist.Items.ContainsKey(mod.Name)) if (modlist.Items.ContainsKey(mod.Name))
{ {
var omod = mods[mod.Name]; var omod = mods[mod.Name];
var item = modlist.Items[mod.Name]; item = modlist.Items[mod.Name];
var items = item.SubItems; var items = item.SubItems;
omod.Author = mod.Author ?? omod.Author; omod.Author = mod.Author ?? omod.Author;
omod.Version = mod.Version ?? omod.Version; omod.Version = mod.Version ?? omod.Version;
@ -108,20 +114,22 @@ namespace GCMM
omod.LastUpdated = mod.LastUpdated == default ? omod.LastUpdated : mod.LastUpdated; omod.LastUpdated = mod.LastUpdated == default ? omod.LastUpdated : mod.LastUpdated;
omod.Description = mod.Description ?? omod.Description; omod.Description = mod.Description ?? omod.Description;
omod.DownloadURL = mod.DownloadURL ?? omod.DownloadURL; omod.DownloadURL = mod.DownloadURL ?? omod.DownloadURL;
omod.UpdateDetails = mod.UpdateDetails ?? omod.UpdateDetails;
items[1].Text = omod.Author ?? ""; items[1].Text = omod.Author ?? "";
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"];
if (mod.Version != mod.LatestVersion) mod = omod;
items[2].ForeColor = Color.Red;
} }
else else
{ {
mods.Add(mod.Name, mod); mods.Add(mod.Name, mod);
var item = new ListViewItem(new[] { mod.Name, mod.Author ?? "", (mod.Version ?? mod.LatestVersion)?.ToString() ?? "", mod.LastUpdated.ToString() }, modlist.Groups[mod.Installed ? "installed" : "available"]); item = new ListViewItem(new[] { mod.Name, mod.Author ?? "", (mod.Version ?? mod.LatestVersion)?.ToString() ?? "", mod.LastUpdated.ToString() }, modlist.Groups[mod.Installed ? "installed" : "available"]);
item.Name = mod.Name; item.Name = mod.Name;
modlist.Items.Add(item); modlist.Items.Add(item);
} }
if (mod.LatestVersion != null && mod.Version != null && mod.Version < mod.LatestVersion)
item.ForeColor = Color.Blue;
} }
public void RemoveModFromList(ModInfo mod) public void RemoveModFromList(ModInfo mod)

View file

@ -22,7 +22,7 @@ namespace GCMM
status.Text = "Status: Patcher missing\nClicking Play will install it"; status.Text = "Status: Patcher missing\nClicking Play will install it";
return null; return null;
} }
string nopatch = "Status: Unpatched\nClicking Play patches it"; string nopatch = "Status: Unpatched" + (unpatched.Checked ? "" : "\nClicking Play patches it");
if (!Directory.Exists(Settings.Default.GamePath + @"\IPA\Backups\Gamecraft")) if (!Directory.Exists(Settings.Default.GamePath + @"\IPA\Backups\Gamecraft"))
{ {
status.Text = nopatch; status.Text = nopatch;
@ -41,11 +41,11 @@ namespace GCMM
status.Text = nopatch; status.Text = nopatch;
return false; return false;
} }
status.Text = "Status: Patched"; status.Text = "Status: Patched" + (unpatched.Checked ? "\nClicking Play unpatches it" : "");
return true; return true;
} }
public async void PatchGame() public async void PatchStartGame()
{ {
if (!CheckIfPatched().HasValue) if (!CheckIfPatched().HasValue)
{ {
@ -65,14 +65,17 @@ namespace GCMM
bool? status = CheckIfPatched(); bool? status = CheckIfPatched();
if (!status.HasValue) //Make sure it actually worked if (!status.HasValue) //Make sure it actually worked
return; return;
if (!status.Value) if (!status.Value ^ unpatched.Checked)
{ {
var psi = new ProcessStartInfo(Settings.Default.GamePath + @"\IPA.exe", "Gamecraft.exe --nowait"); var psi = new ProcessStartInfo(Settings.Default.GamePath + @"\IPA.exe", "Gamecraft.exe "
psi.UseShellExecute = false; + (unpatched.Checked ? "--revert " : "") + "--nowait")
psi.RedirectStandardError = true; {
psi.RedirectStandardOutput = true; UseShellExecute = false,
psi.WorkingDirectory = Settings.Default.GamePath; RedirectStandardError = true,
psi.CreateNoWindow = true; RedirectStandardOutput = true,
WorkingDirectory = Settings.Default.GamePath,
CreateNoWindow = true
};
var process = Process.Start(psi); var process = Process.Start(psi);
process.BeginErrorReadLine(); process.BeginErrorReadLine();
process.BeginOutputReadLine(); process.BeginOutputReadLine();

View file

@ -71,16 +71,18 @@ namespace GCMM
{ {
Action act = () => Action act = () =>
{ {
if ((sender as Process).ExitCode != 0) if (((sender as Process)?.ExitCode ?? 0) != 0)
{ {
status.Text = "Status: Patching failed"; status.Text = "Status: Patching failed";
return; return;
} }
if (CheckIfPatched() ?? false) if ((CheckIfPatched() ?? false) || unpatched.Checked)
Process.Start("steam://run/1078000/"); Process.Start("steam://run/1078000/");
}; };
if (InvokeRequired) if (InvokeRequired)
Invoke(act); Invoke(act);
else
act();
} }
public WebClient GetClient() public WebClient GetClient()

View file

@ -26,5 +26,6 @@ namespace GCMM
public bool Installed => Version != null; public bool Installed => Version != null;
public string DownloadURL { get; set; } public string DownloadURL { get; set; }
public HashSet<string> ModFiles { get; set; } public HashSet<string> ModFiles { get; set; }
public string UpdateDetails { get; set; }
} }
} }

15
GCMM/README.md Normal file
View file

@ -0,0 +1,15 @@
# Gamecraft Mod Manager
A manager that handles everything needed to use mods for Gamecraft.
## Features
* Download and run GCIPA if needed
* List, install and uninstall mods
* Keep track of files added by mods and remove them when the mod is uninstalled
## Mod requirements
* For a mod to be listed, it needs to have a regular release (so not a prerelease) with exactly 1 attached asset.
* That asset can be either a dll if the mod doesn't have any other files, or a zip archive.
* If the zip contains a folder named Plugins, the manager will unzip it to Gamecraft's directory instead of the Plugins directory.
* The mod dll must use the same name as the repository, including casing. The manager will rename single dlls automatically but can't handle zipped mods with different names.
* The release tag must be the same as the assembly version of the mod with an optional `v` prefix.
* Add the mod to the list at https://git.exmods.org/ExMods/html-site/src/branch/master/site/mods/modlist.tsv

View file

@ -1,9 +0,0 @@
NGnius GamecraftRichPresenceMod
SnakesOnAGame GamecraftScripting
NGnius Pixi
modtainers GamecraftModdingAPI
ExtraCommands extracommands
NorbiPeti GCDC
NorbiPeti GCMC
NorbiPeti BlockMod
NGnius leadercraft