From cb4473de584a9fd1c56951e052b334d577258979 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 3 Oct 2020 15:41:31 +0200 Subject: [PATCH] Check GCMM updates while we're at it --- GCMM/MainForm.cs | 1 + GCMM/MainModList.cs | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/GCMM/MainForm.cs b/GCMM/MainForm.cs index d508bea..8bd90ca 100644 --- a/GCMM/MainForm.cs +++ b/GCMM/MainForm.cs @@ -24,6 +24,7 @@ namespace GCMM private readonly Dictionary mods = new Dictionary(); 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 diff --git a/GCMM/MainModList.cs b/GCMM/MainModList.cs index 7c97f20..39f11c5 100644 --- a/GCMM/MainModList.cs +++ b/GCMM/MainModList.cs @@ -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 FetchModInfo(ModInfo mod, bool preview, bool desc)