Fix deletion, delete from list, improve patch detection
This commit is contained in:
parent
f522432208
commit
faa88157bb
4 changed files with 37 additions and 17 deletions
|
@ -250,6 +250,8 @@ You may also want to verify the game's files by right clicking the game in Steam
|
||||||
return;
|
return;
|
||||||
if (MessageBox.Show("Validating the game's files is useful if the game doesn't start even without mods. Make sure to click Refresh once Steam finished verifying the game. The Steam window that shows the progress might open in the background. Note that you will need to patch the game again using the Play button in order to use mods.\n\nContinue?", "Verify game files", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
if (MessageBox.Show("Validating the game's files is useful if the game doesn't start even without mods. Make sure to click Refresh once Steam finished verifying the game. The Steam window that shows the progress might open in the background. Note that you will need to patch the game again using the Play button in order to use mods.\n\nContinue?", "Verify game files", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
||||||
return;
|
return;
|
||||||
|
string exe = GetExe();
|
||||||
|
File.Delete(GamePath($@"\{exe.Replace(".exe", "")}_Data\Managed\IllusionInjector.dll")); //Used to check if game is patched
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
Process.Start("steam://validate/1078000/");
|
Process.Start("steam://validate/1078000/");
|
||||||
else
|
else
|
||||||
|
|
|
@ -122,22 +122,35 @@ namespace GCMM
|
||||||
|
|
||||||
public void UninstallMod(ModInfo mod)
|
public void UninstallMod(ModInfo mod)
|
||||||
{
|
{
|
||||||
LoadFileList(mod);
|
try
|
||||||
if (mod.ModFiles.Count == 0) //A single DLL
|
|
||||||
File.Delete(GamePath(@"\Plugins\" + mod.Name + ".dll"));
|
|
||||||
else //A ZIP
|
|
||||||
{
|
{
|
||||||
foreach (string file in mod.ModFiles)
|
LoadFileList(mod);
|
||||||
|
if (mod.ModFiles.Count == 0) //A single DLL
|
||||||
|
File.Delete(GamePath(@"\Plugins\" + mod.Name + ".dll"));
|
||||||
|
else //A ZIP
|
||||||
{
|
{
|
||||||
File.Delete(file);
|
foreach (string file in mod.ModFiles)
|
||||||
var parent = Directory.GetParent(file);
|
{
|
||||||
if (!parent.EnumerateFiles().Any())
|
File.Delete(file);
|
||||||
parent.Delete(); //May delete the Plugins dir if empty
|
var parent = Directory.GetParent(file);
|
||||||
|
if (!parent.EnumerateFileSystemInfos().Any())
|
||||||
|
parent.Delete(); //May delete the Plugins dir if empty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File.Delete(mod.Name + ".json");
|
||||||
|
mod.Version = null; //Not installed
|
||||||
|
if (mod.Author != null)
|
||||||
|
AddUpdateModInList(mod); //Update list
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mods.Remove(mod.Name);
|
||||||
|
modlist.Items[mod.Name].Remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File.Delete(mod.Name + ".json");
|
catch (Exception e) when (e is UnauthorizedAccessException || e is IOException)
|
||||||
mod.Version = null; //Not installed
|
{
|
||||||
AddUpdateModInList(mod); //Update list
|
MessageBox.Show("Could not remove mod files! Make sure the game isn't running.\n" + e.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAPI()
|
public async Task UpdateAPI()
|
||||||
|
|
|
@ -175,12 +175,17 @@ namespace GCMM
|
||||||
|
|
||||||
public void CheckUninstalledMods(HashSet<string> installed)
|
public void CheckUninstalledMods(HashSet<string> installed)
|
||||||
{
|
{
|
||||||
|
List<string> delete = new List<string>();
|
||||||
foreach (string name in mods.Keys.Except(installed))
|
foreach (string name in mods.Keys.Except(installed))
|
||||||
{
|
{
|
||||||
var mod = mods[name];
|
var mod = mods[name];
|
||||||
mod.Version = null;
|
mod.Version = null;
|
||||||
AddUpdateModInList(mod);
|
if (mod.Author != null)
|
||||||
|
AddUpdateModInList(mod);
|
||||||
|
else
|
||||||
|
delete.Add(name);
|
||||||
}
|
}
|
||||||
|
delete.ForEach(name => { mods.Remove(name); modlist.Items[name].Remove(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,12 @@ namespace GCMM
|
||||||
playbtn.Text = pnp;
|
playbtn.Text = pnp;
|
||||||
return GameState.NoPatcher;
|
return GameState.NoPatcher;
|
||||||
}
|
}
|
||||||
if (gcipa.Updatable)
|
if (gcipa.Updatable && !(gcipa.Version == new Version(1, 0, 0, 0) && gcipa.LatestVersion == new Version(4, 0, 0, 0)))
|
||||||
{
|
{
|
||||||
status.Text = "Status: Patcher outdated\nClicking play will update it";
|
status.Text = "Status: Patcher outdated\nClicking play will update it";
|
||||||
playbtn.Text = pnp;
|
playbtn.Text = pnp;
|
||||||
return GameState.OldPatcher;
|
return GameState.OldPatcher;
|
||||||
}
|
}
|
||||||
string nopatch = "Status: Unpatched\nClicking Play patches it";
|
string nopatch = "Status: Unpatched\nClicking Play patches it";
|
||||||
string gc = GetExe().Replace(".exe", "");
|
string gc = GetExe().Replace(".exe", "");
|
||||||
string backups = GamePath(@"\IPA\Backups\" + gc);
|
string backups = GamePath(@"\IPA\Backups\" + gc);
|
||||||
|
@ -54,7 +54,8 @@ namespace GCMM
|
||||||
}
|
}
|
||||||
if (File.GetLastWriteTime(GamePath($@"\{gc}_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
|
> //If the file was updated at least 2 minutes after patching
|
||||||
Directory.GetLastWriteTime(backup).AddMinutes(2))
|
Directory.GetLastWriteTime(backup).AddMinutes(2)
|
||||||
|
|| !File.Exists(GamePath($@"\{gc}_Data\Managed\IllusionInjector.dll")))
|
||||||
{
|
{
|
||||||
status.Text = nopatch;
|
status.Text = nopatch;
|
||||||
playbtn.Text = pnp;
|
playbtn.Text = pnp;
|
||||||
|
@ -89,7 +90,6 @@ namespace GCMM
|
||||||
EndWork();
|
EndWork();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string releases = "/api/v1/repos/modtainers/GCIPA/releases";
|
|
||||||
this.status.Text = "Status: Patching...";
|
this.status.Text = "Status: Patching...";
|
||||||
using (WebClient client = GetClient())
|
using (WebClient client = GetClient())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue