Esempio n. 1
0
        private async Task ShowModUpdateDialog()
        {
            try
            {
                try
                {
                    Enabled = false;

                    _checkForUpdatesCancel?.Cancel();

                    PluginLoader.CancelReload();
                    SideloaderModLoader.CancelReload();

                    await PluginLoader.Plugins.LastOrDefaultAsync().Timeout(TimeSpan.FromSeconds(30));

                    await SideloaderModLoader.Zipmods.LastOrDefaultAsync().Timeout(TimeSpan.FromSeconds(30));

                    var updateSources = GetUpdateSources();
                    if (!updateSources.Any())
                    {
                        throw new IOException("No update sources are available");
                    }
                    ModUpdateProgressDialog.StartUpdateDialog(this, updateSources);
                }
                catch (Exception ex)
                {
                    var errorMsg = "Failed to start update - " + ex.ToStringDemystified();
                    Console.WriteLine(errorMsg);
                    MessageBox.Show(errorMsg, "Update failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                SideloaderModLoader.StartReload();
                PluginLoader.StartReload();

                var contentWindows = GetWindows <DockContent>().OfType <IContentWindow>().ToList();
                foreach (var window in contentWindows)
                {
                    window.RefreshList();
                }

                updateSideloaderModpackToolStripMenuItem.BackColor = DefaultBackColor;
                updateSideloaderModpackToolStripMenuItem.ForeColor = DefaultForeColor;
            }
            finally
            {
                Enabled = true;
            }
        }