Check GCMM updates while we're at it

This commit is contained in:
Norbi Peti 2020-10-03 15:41:31 +02:00
parent 1f413eebda
commit cb4473de58
2 changed files with 24 additions and 1 deletions

View file

@ -24,6 +24,7 @@ namespace GCMM
private readonly Dictionary<string, ModInfo> mods = new Dictionary<string, ModInfo>();
private readonly ModInfo gcipa = new ModInfo { Author = "modtainers", Name = "GCIPA" };
private readonly ModInfo gcmm = new ModInfo { Author = "NorbiPeti", Name = "GCMM" };
private const string defaultInfo = @"
Gamecraft Mod Manager

View file

@ -2,6 +2,7 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@ -53,6 +54,19 @@ namespace GCMM
catch (BadImageFormatException)
{ //Not a .NET assembly
}
try
{
string mmpath = "GCMM.exe";
if (File.Exists(mmpath))
{
var an = AssemblyName.GetAssemblyName(mmpath);
gcmm.Version = an.Version;
gcmm.LastUpdated = File.GetLastWriteTime(mmpath);
}
}
catch (BadImageFormatException)
{ //Not a .NET assembly
}
return installed;
}
@ -75,7 +89,15 @@ namespace GCMM
AddUpdateModInList(mod);
}
}
await FetchModInfo(gcipa, preview, false);
if (gcmm.LatestVersion == null) //Only check once
{
await FetchModInfo(gcipa, preview, false);
await FetchModInfo(gcmm, preview, false);
if (gcmm.Updatable)
if (MessageBox.Show("There is a GCMM update available! Do you want to download it now? If yes, extract it over this installation.", "Mod Manager update", MessageBoxButtons.YesNo)
== DialogResult.Yes)
Process.Start(gcmm.DownloadURL);
}
}
public async Task<bool> FetchModInfo(ModInfo mod, bool preview, bool desc)