Don't load each mod data when auto-starting and other fixes

This commit is contained in:
Norbi Peti 2021-01-21 00:59:16 +01:00
parent c11758a427
commit 0a36e1a0c6
4 changed files with 20 additions and 13 deletions

View file

@ -50,10 +50,11 @@ You may also want to verify the game's files by clicking on the Validate game bu
private async void Form1_Load(object sender, EventArgs e)
{
await LoadEverything();
if (mods.Values.All(mod => mod.LatestVersion == null)) //Not (fully) loaded yet
await LoadEverything(true);
}
public async Task LoadEverything()
public async Task LoadEverything(bool evenMods)
{
if (Settings.Default.NeedsUpdate)
{
@ -79,7 +80,7 @@ You may also want to verify the game's files by clicking on the Validate game bu
if (MessageBox.Show("Do you want GCMM to change the game's launch settings so it can ensure the game is patched?\n\n" +
"If you say yes, GCMM will do a quick check before the game is launched and patches if necessary. " +
"This way you (hopefully) won't see crashes after a Gamecraft update.\n\n" +
"Note that this also means that if you (re)move GCMM without disabling this in the settings then you won't be able to launch Gamecraft.",
"Note that this also means that if you (re)move GCMM without disabling this in the settings then you won't be able to launch Gamecraft until you change the launch options in Steam.",
"GCMM auto-patching", MessageBoxButtons.YesNo) == DialogResult.Yes)
DetectConfigLocationAndAutoStart(steamPath, ref user);
else
@ -103,7 +104,7 @@ You may also want to verify the game's files by clicking on the Validate game bu
DeleteEmptyPluginsDir(out bool pexists, out bool dexists);
if (!pexists && dexists)
unpatched.Checked = true; //It will call the event but that won't do anything
await RefreshEverything();
await RefreshEverything(evenMods);
}
private async void playbtn_Click(object sender, EventArgs e)
@ -272,15 +273,16 @@ You may also want to verify the game's files by clicking on the Validate game bu
private async void refreshbtn_Click(object sender, EventArgs e)
{
await RefreshEverything();
await RefreshEverything(true);
}
private async Task RefreshEverything()
private async Task RefreshEverything(bool evenMods)
{
CheckIfPatched(); //Set from placeholder
lastGameUpdateTime = await GetLastGameUpdateTime();
var mods = GetInstalledMods();
await GetAvailableMods();
if (evenMods)
await GetAvailableMods();
CheckUninstalledMods(mods);
CheckIfPatched(); //Check after getting the available mods to show GCIPA updates
}
@ -289,7 +291,11 @@ You may also want to verify the game's files by clicking on the Validate game bu
{
if (CheckNoExe())
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 if auto-patching isn't enabled then 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;
string exe = GetExe();
File.Delete(GamePath($@"\{exe.Replace(".exe", "")}_Data\Managed\IllusionInjector.dll")); //Used to check if game is patched

View file

@ -143,7 +143,7 @@ namespace GCMM
{
string path = (string)key?.GetValue("SteamClientDll");
path = path != null ? Directory.GetParent(path).FullName : null;
return (path, (int)(key.GetValue("ActiveUser") ?? 0));
return (path, (int)(key?.GetValue("ActiveUser") ?? 0));
}
}
@ -168,7 +168,7 @@ namespace GCMM
}
}
else
path += user;
path += "\\" + user;
path += @"\config\localconfig.vdf";
if (path != null && user != 0 && File.Exists(path))
{

View file

@ -29,7 +29,7 @@ namespace GCMM
private static async void DealWithCommandLineAsync(string[] args)
{
var form = new MainForm();
await form.LoadEverything();
await form.LoadEverything(false);
bool? shouldStay = null;
if (args[0] == "-start" && args.Length > 1)
shouldStay = await form.PatchStartGame(args[1]);
@ -45,7 +45,7 @@ namespace GCMM
}
}
else
Application.Exit();
Environment.Exit(0);
}
}
}

View file

@ -1,7 +1,8 @@
{
"profiles": {
"GCMM": {
"commandName": "Project"
"commandName": "Project",
"commandLineArgs": "-start steam:\"\""
}
}
}