Fixes, Patch & Play, automatically install API
This commit is contained in:
parent
b4d64c50d0
commit
9e088c02f0
5 changed files with 29 additions and 6 deletions
|
@ -76,6 +76,7 @@ If you encounter an issue while the game is patched, report it to us. If you thi
|
|||
private async void playbtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (playbtn.ForeColor == Color.Green) return; //Disabled
|
||||
await UpdateAPI();
|
||||
await PatchStartGame(); //It will call EndWork();
|
||||
}
|
||||
|
||||
|
@ -108,15 +109,15 @@ If you encounter an issue while the game is patched, report it to us. If you thi
|
|||
var mod = mods[item.Name];
|
||||
if (modlist.SelectedItems.Count == 1)
|
||||
{
|
||||
bool up = mod.Version != null && mod.Version < mod.LatestVersion;
|
||||
bool up = mod.Updatable;
|
||||
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();
|
||||
//modinfobox.SelectionColor = modinfobox.ForeColor;
|
||||
modinfobox.SelectionColor = Color.Aqua;
|
||||
modinfobox.DeselectAll();
|
||||
modinfobox.SelectionColor = modinfobox.ForeColor;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace GCMM
|
|||
MessageBox.Show("Gamecraft not found. Set the correct path in Settings.");
|
||||
return;
|
||||
}
|
||||
if (mod.Name != "GamecraftModdingAPI")
|
||||
await UpdateAPI();
|
||||
var tmp = Directory.CreateDirectory("temp");
|
||||
var plugins = Directory.CreateDirectory(GamePath(@"\Plugins"));
|
||||
string tmppath = tmp.FullName + Path.DirectorySeparatorChar + mod.Name;
|
||||
|
@ -135,5 +137,16 @@ namespace GCMM
|
|||
mod.Version = null; //Not installed
|
||||
AddUpdateModInList(mod); //Update list
|
||||
}
|
||||
|
||||
public async Task UpdateAPI()
|
||||
{
|
||||
var gcmapi = mods["GamecraftModdingAPI"];
|
||||
if (!gcmapi.Installed || gcmapi.Updatable)
|
||||
{
|
||||
if (MessageBox.Show($"GamecraftModdingAPI will be {(gcmapi.Installed ? "updated" : "installed")} as most mods need it to work. You can uninstall it if you're sure you don't need it.", "API needed", MessageBoxButtons.OKCancel)
|
||||
== DialogResult.OK)
|
||||
await InstallMod(gcmapi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,32 +17,39 @@ namespace GCMM
|
|||
{
|
||||
public bool? CheckIfPatched()
|
||||
{
|
||||
string pnp = unpatched.Checked ? "Play" : "Patch && Play";
|
||||
if (!File.Exists(GamePath(@"\IPA.exe")))
|
||||
{
|
||||
status.Text = "Status: Patcher missing\nClicking Play will install it";
|
||||
playbtn.Text = pnp;
|
||||
return null;
|
||||
}
|
||||
string nopatch = "Status: Unpatched" + (unpatched.Checked ? "" : "\nClicking Play patches it");
|
||||
string backups = GamePath(@"\IPA\Backups\Gamecraft");
|
||||
string gc = GetExe().Replace(".exe", "");
|
||||
string backups = GamePath(@"\IPA\Backups\" + gc);
|
||||
if (!Directory.Exists(backups))
|
||||
{
|
||||
status.Text = nopatch;
|
||||
playbtn.Text = pnp;
|
||||
return false;
|
||||
}
|
||||
string backup = Directory.EnumerateDirectories(backups).OrderByDescending(s => s).FirstOrDefault();
|
||||
if (backup == null)
|
||||
{
|
||||
status.Text = nopatch;
|
||||
playbtn.Text = pnp;
|
||||
return false;
|
||||
}
|
||||
if (File.GetLastWriteTime(GamePath(@"\Gamecraft_Data\Managed\Assembly-CSharp.dll"))
|
||||
if (File.GetLastWriteTime(GamePath($@"\{gc}_Data\Managed\Assembly-CSharp.dll"))
|
||||
> //If the file was updated at least 2 minutes after patching
|
||||
Directory.GetLastWriteTime(backup).AddMinutes(2))
|
||||
{
|
||||
status.Text = nopatch;
|
||||
playbtn.Text = pnp;
|
||||
return false;
|
||||
}
|
||||
status.Text = "Status: Patched" + (unpatched.Checked ? "\nClicking Play unpatches it" : "");
|
||||
playbtn.Text = unpatched.Checked ? "Unpatch && Play" : "Play";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,5 +27,6 @@ namespace GCMM
|
|||
public string DownloadURL { get; set; }
|
||||
public HashSet<string> ModFiles { get; set; }
|
||||
public string UpdateDetails { get; set; }
|
||||
public bool Updatable => Version != null && LatestVersion != null && Version < LatestVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ A manager that handles everything needed to use mods for Gamecraft.
|
|||
* 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
|
||||
* Preview support for the game and mods for it
|
||||
|
||||
## Mod requirements
|
||||
* For a mod to be listed, it needs to have a regular release (so not a prerelease) with exactly 1 recognised attached asset.
|
||||
|
|
Loading…
Reference in a new issue