private async void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) { if (await SelfUpdater.CheckForUpdatesAndShowDialog() == null) { MessageBox.Show("No KKManager updates were found. Check log for more information.", "Check for updates", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += (sender, arg) => Console.WriteLine("UNHANDLED EXCEPTION: " + arg.ExceptionObject); AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException; using (LogWriter.StartLogging()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); const string guidValueName = "-guid:"; var silentInstallGuids = args.Where(x => x.StartsWith(guidValueName)).Select(x => x.Substring(guidValueName.Length).Trim(' ', '"')).ToArray(); args = args.Where(x => !x.StartsWith("-")).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); if (args.Length == 0) { MessageBox.Show("Not enough arguments - the following arguments are supported:\n" + "Path to game root directory. This is mandatory and has to be the 1st argument.\n" + "One or more links to update sources. If no update source links are provided then UpdateSources file is used.\n\n" + "You can also add -guid:UPDATE_GUID arguments to not show the mod selection screen, and instead automatically install mods with the specified GUIDs.", "Invalid arguments", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { var gameDir = new DirectoryInfo(args[0]); if (!gameDir.Exists) { throw new IOException("Directory doesn't exist"); } InstallDirectoryHelper.Initialize(gameDir); } catch (Exception e) { MessageBox.Show($"Error opening game directory: {args[0]}\n\n{e}", "Invalid arguments", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine(e); return; } if (SelfUpdater.CheckForUpdatesAndShowDialog().Result == true) { return; } var updateSources = GetUpdateSources(args.Skip(1).ToArray()); if (updateSources == null || !updateSources.Any()) { return; } var window = ModUpdateProgressDialog.CreateUpdateDialog(updateSources, silentInstallGuids); window.Icon = Icon.ExtractAssociatedIcon(typeof(Program).Assembly.Location); Application.Run(window); } }
private async Task CheckForUpdates() { try { var _ = SelfUpdater.CheckForUpdatesAndShowDialog(); var updateSources = GetUpdateSources(); if (updateSources.Any()) { var results = await UpdateSourceManager.GetUpdates(_checkForUpdatesCancel.Token, updateSources); var updates = results.Count(item => !item.UpToDate); _checkForUpdatesCancel.Token.ThrowIfCancellationRequested(); if (updates > 0) { SetStatusText($"Found {updates} mod updates!"); updateSideloaderModpackToolStripMenuItem.BackColor = Color.Lime; } else { SetStatusText("No mod updates were found"); updateSideloaderModpackToolStripMenuItem.ForeColor = Color.Gray; } } } catch (OperationCanceledException) { } catch (OutdatedVersionException ex) { ex.ShowKkmanOutdatedMessage(); } catch (Exception ex) { Console.WriteLine($"Crash during update check: {ex.Message}\nat {ex.Demystify().TargetSite}"); } }