diff --git a/GCMM/GCMM.csproj b/GCMM/GCMM.csproj index 8a462a8..645e151 100644 --- a/GCMM/GCMM.csproj +++ b/GCMM/GCMM.csproj @@ -36,9 +36,6 @@ - - PreserveNewest - SettingsSingleFileGenerator Settings.Designer.cs diff --git a/GCMM/MainForm.Designer.cs b/GCMM/MainForm.Designer.cs index 63f16e5..e9be859 100644 --- a/GCMM/MainForm.Designer.cs +++ b/GCMM/MainForm.Designer.cs @@ -28,9 +28,9 @@ /// private void InitializeComponent() { - System.Windows.Forms.ListViewGroup listViewGroup3 = 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.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] { + System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("Installed", 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 listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] { "Mod", "modtainers", "1.0", @@ -44,9 +44,11 @@ this.status = new System.Windows.Forms.Label(); this.installbtn = 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.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(); // // modlist @@ -63,20 +65,20 @@ this.modTimestamp}); this.modlist.ForeColor = System.Drawing.Color.Green; this.modlist.FullRowSelect = true; - listViewGroup3.Header = "Installed"; - listViewGroup3.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center; - listViewGroup3.Name = "installed"; - listViewGroup4.Header = "Available"; - listViewGroup4.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center; - listViewGroup4.Name = "available"; + listViewGroup1.Header = "Installed"; + listViewGroup1.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center; + listViewGroup1.Name = "installed"; + listViewGroup2.Header = "Available"; + listViewGroup2.HeaderAlignment = System.Windows.Forms.HorizontalAlignment.Center; + listViewGroup2.Name = "available"; this.modlist.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] { - listViewGroup3, - listViewGroup4}); + listViewGroup1, + listViewGroup2}); this.modlist.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.modlist.HideSelection = false; - listViewItem2.Group = listViewGroup3; + listViewItem1.Group = listViewGroup1; this.modlist.Items.AddRange(new System.Windows.Forms.ListViewItem[] { - listViewItem2}); + listViewItem1}); this.modlist.Location = new System.Drawing.Point(12, 12); this.modlist.Name = "modlist"; this.modlist.Size = new System.Drawing.Size(491, 468); @@ -114,9 +116,9 @@ this.status.ForeColor = System.Drawing.Color.Lime; this.status.Location = new System.Drawing.Point(8, 487); 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.Text = "Status:"; + this.status.Text = "Status:\r\nasd"; // // installbtn // @@ -149,21 +151,6 @@ this.uninstallbtn.UseVisualStyleBackColor = true; 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 // this.playbtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom; @@ -193,15 +180,54 @@ this.settingsbtn.UseVisualStyleBackColor = true; 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; 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.playbtn); - this.Controls.Add(this.modinfobox); this.Controls.Add(this.uninstallbtn); this.Controls.Add(this.installbtn); this.Controls.Add(this.status); @@ -225,10 +251,12 @@ private System.Windows.Forms.Label status; private System.Windows.Forms.Button installbtn; private System.Windows.Forms.Button uninstallbtn; - private System.Windows.Forms.TextBox modinfobox; private System.Windows.Forms.Button playbtn; private System.Windows.Forms.Button settingsbtn; private System.Windows.Forms.ColumnHeader modAuthor; + private System.Windows.Forms.Button findlog; + private System.Windows.Forms.CheckBox unpatched; + private System.Windows.Forms.RichTextBox modinfobox; } } diff --git a/GCMM/MainForm.cs b/GCMM/MainForm.cs index 2c831fb..1cca284 100644 --- a/GCMM/MainForm.cs +++ b/GCMM/MainForm.cs @@ -23,12 +23,30 @@ namespace GCMM } private Dictionary mods = new Dictionary(); + 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) { modlist.Items.Clear(); UpdateButton(installbtn, false); - modinfobox.Text = ""; + modinfobox.Text = defaultInfo; if (string.IsNullOrWhiteSpace(Settings.Default.GamePath)) { Settings.Default.GamePath = GetGameFolder(); @@ -52,7 +70,7 @@ namespace GCMM { if (playbtn.ForeColor == Color.Green) return; //Disabled if (!BeginWork()) return; - PatchGame(); + PatchStartGame(); EndWork(); } @@ -69,7 +87,7 @@ namespace GCMM switch (modlist.SelectedItems.Count) { case 0: - modinfobox.Text = ""; + modinfobox.Text = defaultInfo; UpdateButton(installbtn, false); UpdateButton(uninstallbtn, false); break; @@ -78,24 +96,41 @@ namespace GCMM installbtn.Text = "Install mod"; UpdateButton(installbtn, false); UpdateButton(uninstallbtn, false); + bool install = false, update = false; foreach (ListViewItem item in modlist.SelectedItems) { var mod = mods[item.Name]; 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 modinfobox.Text = modlist.SelectedItems.Count + " mods selected"; if (mod.DownloadURL != null && !(mod.LatestVersion <= mod.Version)) { UpdateButton(installbtn, true); if (mod.Version != null) - installbtn.Text = "Update mod"; + update = true; else - installbtn.Text = "Install mod"; + install = true; } if (mod.Version != null) 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; } } @@ -106,8 +141,9 @@ namespace GCMM if (!BeginWork()) return; foreach (ListViewItem item in modlist.SelectedItems) { - if (item.Group.Name == "installed") continue; - await InstallMod(mods[item.Name]); + var mod = mods[item.Name]; + if (item.Group.Name == "installed" && (mod.DownloadURL == null || mod.LatestVersion <= mod.Version)) continue; + await InstallMod(mod); } EndWork(); } @@ -122,5 +158,18 @@ namespace GCMM } 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(); + } } } diff --git a/GCMM/MainForm.resx b/GCMM/MainForm.resx index 6541bf2..292cae0 100644 --- a/GCMM/MainForm.resx +++ b/GCMM/MainForm.resx @@ -117,18 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 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. - diff --git a/GCMM/MainModInstaller.cs b/GCMM/MainModInstaller.cs index 993e77d..575115a 100644 --- a/GCMM/MainModInstaller.cs +++ b/GCMM/MainModInstaller.cs @@ -46,7 +46,7 @@ namespace GCMM if (!pluginOnly && modFound) break; } 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; ExtractMod(archive, pluginOnly ? plugins.FullName : Settings.Default.GamePath, mod); } diff --git a/GCMM/MainModList.cs b/GCMM/MainModList.cs index 6b27bd6..ed3f118 100644 --- a/GCMM/MainModList.cs +++ b/GCMM/MainModList.cs @@ -53,16 +53,20 @@ namespace GCMM AddUpdateModInList(mod); } }*/ - foreach (string line in File.ReadLines("modlist.txt")) + using (var client = GetClient()) { - var sp = line.Split('\t'); - var mod = new ModInfo + string str = await client.DownloadStringTaskAsync("https://exmods.org/mods/modlist.tsv"); + foreach (string line in str.Split('\n')) { - Author = sp[0], - Name = sp[1] - }; - if (await FetchModInfo(mod)) //If it's actually a mod - AddUpdateModInList(mod); + var sp = line.Split('\t'); + var mod = new ModInfo + { + Author = sp[0].Trim(), + 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(); 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.UpdateDetails = release["name"] + "\n\n" + release["body"].ToString(); try { 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 throw new InvalidOperationException("The mod isn't present in one of the two places: " + mod.Name); + ListViewItem item; if (modlist.Items.ContainsKey(mod.Name)) { var omod = mods[mod.Name]; - var item = modlist.Items[mod.Name]; + item = modlist.Items[mod.Name]; var items = item.SubItems; omod.Author = mod.Author ?? omod.Author; omod.Version = mod.Version ?? omod.Version; @@ -108,20 +114,22 @@ namespace GCMM omod.LastUpdated = mod.LastUpdated == default ? omod.LastUpdated : mod.LastUpdated; omod.Description = mod.Description ?? omod.Description; omod.DownloadURL = mod.DownloadURL ?? omod.DownloadURL; + omod.UpdateDetails = mod.UpdateDetails ?? omod.UpdateDetails; items[1].Text = omod.Author ?? ""; items[2].Text = (omod.Version ?? omod.LatestVersion)?.ToString(); items[3].Text = omod.LastUpdated.ToString(); item.Group = omod.Installed ? modlist.Groups["installed"] : modlist.Groups["available"]; - if (mod.Version != mod.LatestVersion) - items[2].ForeColor = Color.Red; + mod = omod; } else { 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; modlist.Items.Add(item); } + if (mod.LatestVersion != null && mod.Version != null && mod.Version < mod.LatestVersion) + item.ForeColor = Color.Blue; } public void RemoveModFromList(ModInfo mod) diff --git a/GCMM/MainPatcher.cs b/GCMM/MainPatcher.cs index ebda246..932d483 100644 --- a/GCMM/MainPatcher.cs +++ b/GCMM/MainPatcher.cs @@ -22,7 +22,7 @@ namespace GCMM status.Text = "Status: Patcher missing\nClicking Play will install it"; 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")) { status.Text = nopatch; @@ -41,11 +41,11 @@ namespace GCMM status.Text = nopatch; return false; } - status.Text = "Status: Patched"; + status.Text = "Status: Patched" + (unpatched.Checked ? "\nClicking Play unpatches it" : ""); return true; } - public async void PatchGame() + public async void PatchStartGame() { if (!CheckIfPatched().HasValue) { @@ -65,14 +65,17 @@ namespace GCMM bool? status = CheckIfPatched(); if (!status.HasValue) //Make sure it actually worked return; - if (!status.Value) + if (!status.Value ^ unpatched.Checked) { - var psi = new ProcessStartInfo(Settings.Default.GamePath + @"\IPA.exe", "Gamecraft.exe --nowait"); - psi.UseShellExecute = false; - psi.RedirectStandardError = true; - psi.RedirectStandardOutput = true; - psi.WorkingDirectory = Settings.Default.GamePath; - psi.CreateNoWindow = true; + var psi = new ProcessStartInfo(Settings.Default.GamePath + @"\IPA.exe", "Gamecraft.exe " + + (unpatched.Checked ? "--revert " : "") + "--nowait") + { + UseShellExecute = false, + RedirectStandardError = true, + RedirectStandardOutput = true, + WorkingDirectory = Settings.Default.GamePath, + CreateNoWindow = true + }; var process = Process.Start(psi); process.BeginErrorReadLine(); process.BeginOutputReadLine(); diff --git a/GCMM/MainUtils.cs b/GCMM/MainUtils.cs index e9cdd1c..168a599 100644 --- a/GCMM/MainUtils.cs +++ b/GCMM/MainUtils.cs @@ -71,16 +71,18 @@ namespace GCMM { Action act = () => { - if ((sender as Process).ExitCode != 0) + if (((sender as Process)?.ExitCode ?? 0) != 0) { status.Text = "Status: Patching failed"; return; } - if (CheckIfPatched() ?? false) + if ((CheckIfPatched() ?? false) || unpatched.Checked) Process.Start("steam://run/1078000/"); }; if (InvokeRequired) Invoke(act); + else + act(); } public WebClient GetClient() diff --git a/GCMM/ModInfo.cs b/GCMM/ModInfo.cs index 9537165..4a7650d 100644 --- a/GCMM/ModInfo.cs +++ b/GCMM/ModInfo.cs @@ -26,5 +26,6 @@ namespace GCMM public bool Installed => Version != null; public string DownloadURL { get; set; } public HashSet ModFiles { get; set; } + public string UpdateDetails { get; set; } } } diff --git a/GCMM/README.md b/GCMM/README.md new file mode 100644 index 0000000..8a5081d --- /dev/null +++ b/GCMM/README.md @@ -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 diff --git a/GCMM/modlist.txt b/GCMM/modlist.txt deleted file mode 100644 index 1b4bc36..0000000 --- a/GCMM/modlist.txt +++ /dev/null @@ -1,9 +0,0 @@ -NGnius GamecraftRichPresenceMod -SnakesOnAGame GamecraftScripting -NGnius Pixi -modtainers GamecraftModdingAPI -ExtraCommands extracommands -NorbiPeti GCDC -NorbiPeti GCMC -NorbiPeti BlockMod -NGnius leadercraft