예제 #1
0
        private void PostUpdateRepo(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                switch (e.Error)
                {
                case ReinstallModuleKraken rmk:
                    // Re-enable the UI for the install flow
                    Util.Invoke(this, SwitchEnabledState);
                    // Hand off to the full installer flow
                    installWorker.RunWorkerAsync(
                        new KeyValuePair <List <ModChange>, RelationshipResolverOptions>(
                            rmk.Modules
                            .Select(m => new ModChange(m, GUIModChangeType.Update, null))
                            .ToList(),
                            RelationshipResolver.DependsOnlyOpts()
                            )
                        );
                    // Don't mess with the UI, let the install flow control it
                    return;
                }
            }

            var resultPair = e.Result as KeyValuePair <RepoUpdateResult, Dictionary <string, bool> >?;
            RepoUpdateResult?         result     = resultPair?.Key;
            Dictionary <string, bool> oldModules = resultPair?.Value;

            switch (result)
            {
            case RepoUpdateResult.NoChanges:
                AddStatusMessage(Properties.Resources.MainRepoUpToDate);
                HideWaitDialog(true);
                // Load rows if grid empty, otherwise keep current
                if (ManageMods.ModGrid.Rows.Count < 1)
                {
                    ManageMods.UpdateModsList();
                }
                break;

            case RepoUpdateResult.Failed:
                AddStatusMessage(Properties.Resources.MainRepoFailed);
                HideWaitDialog(false);
                break;

            case RepoUpdateResult.Updated:
            default:
                ManageMods.UpdateModsList(oldModules);
                AddStatusMessage(Properties.Resources.MainRepoSuccess);
                ShowRefreshQuestion();
                HideWaitDialog(true);
                UpgradeNotification();
                break;
            }

            tabController.HideTab("WaitTabPage");
            Util.Invoke(this, SwitchEnabledState);
            Util.Invoke(this, RecreateDialogs);
            Util.Invoke(this, ManageMods.ModGrid.Select);
        }
예제 #2
0
파일: Main.cs 프로젝트: mioackerman/CKAN
        private void CompatibleGameVersionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CompatibleGameVersionsDialog dialog = new CompatibleGameVersionsDialog(
                Instance.manager.CurrentInstance,
                !actuallyVisible
                );

            if (dialog.ShowDialog() != DialogResult.Cancel)
            {
                // This takes a while, so don't do it if they cancel out
                ManageMods.UpdateModsList();
            }
        }
예제 #3
0
파일: MainRepo.cs 프로젝트: zxasqwsss/CKAN
        private void PostUpdateRepo(object sender, RunWorkerCompletedEventArgs e)
        {
            var resultPair = e.Result as KeyValuePair <RepoUpdateResult, Dictionary <string, bool> >?;
            RepoUpdateResult?         result     = resultPair?.Key;
            Dictionary <string, bool> oldModules = resultPair?.Value;

            switch (result)
            {
            case RepoUpdateResult.NoChanges:
                AddStatusMessage(Properties.Resources.MainRepoUpToDate);
                HideWaitDialog(true);
                // Load rows if grid empty, otherwise keep current
                if (ManageMods.ModGrid.Rows.Count < 1)
                {
                    ManageMods.UpdateModsList();
                }
                break;

            case RepoUpdateResult.Failed:
                AddStatusMessage(Properties.Resources.MainRepoFailed);
                HideWaitDialog(false);
                break;

            case RepoUpdateResult.Updated:
            default:
                ManageMods.UpdateModsList(oldModules);
                AddStatusMessage(Properties.Resources.MainRepoSuccess);
                ShowRefreshQuestion();
                HideWaitDialog(true);
                UpgradeNotification();
                break;
            }

            tabController.HideTab("WaitTabPage");
            Util.Invoke(this, SwitchEnabledState);
            Util.Invoke(this, RecreateDialogs);
            Util.Invoke(this, ManageMods.ModGrid.Select);
        }
예제 #4
0
        private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)
        {
            tabController.SetTabLock(false);

            if (e.Error != null)
            {
                switch (e.Error)
                {
                case DependencyNotSatisfiedKraken exc:
                    currentUser.RaiseMessage(Properties.Resources.MainInstallDepNotSatisfied, exc.parent, exc.module);
                    break;

                case ModuleNotFoundKraken exc:
                    currentUser.RaiseMessage(Properties.Resources.MainInstallNotFound, exc.module);
                    break;

                case BadMetadataKraken exc:
                    currentUser.RaiseMessage(Properties.Resources.MainInstallBadMetadata, exc.module, exc.Message);
                    break;

                case FileExistsKraken exc:
                    if (exc.owningModule != null)
                    {
                        currentUser.RaiseMessage(
                            Properties.Resources.MainInstallFileExists,
                            exc.filename, exc.installingModule, exc.owningModule,
                            Meta.GetVersion()
                            );
                    }
                    else
                    {
                        currentUser.RaiseMessage(
                            Properties.Resources.MainInstallUnownedFileExists,
                            exc.installingModule, exc.filename
                            );
                    }
                    currentUser.RaiseMessage(Properties.Resources.MainInstallGameDataReverted);
                    break;

                case InconsistentKraken exc:
                    currentUser.RaiseMessage(exc.InconsistenciesPretty);
                    break;

                case CancelledActionKraken exc:
                    currentUser.RaiseMessage(exc.Message);
                    installCanceled = true;
                    break;

                case MissingCertificateKraken exc:
                    currentUser.RaiseMessage(exc.ToString());
                    break;

                case DownloadThrottledKraken exc:
                    string msg = exc.ToString();
                    currentUser.RaiseMessage(msg);
                    if (YesNoDialog(string.Format(Properties.Resources.MainInstallOpenSettingsPrompt, msg),
                                    Properties.Resources.MainInstallOpenSettings,
                                    Properties.Resources.MainInstallNo))
                    {
                        // Launch the URL describing this host's throttling practices, if any
                        if (exc.infoUrl != null)
                        {
                            Utilities.ProcessStartURL(exc.infoUrl.ToString());
                        }
                        // Now pretend they clicked the menu option for the settings
                        Enabled = false;
                        new SettingsDialog(currentUser).ShowDialog();
                        Enabled = true;
                    }
                    break;

                case ModuleDownloadErrorsKraken exc:
                    currentUser.RaiseMessage(exc.ToString());
                    currentUser.RaiseError(exc.ToString());
                    break;

                case DirectoryNotFoundKraken exc:
                    currentUser.RaiseMessage("\r\n{0}", exc.Message);
                    break;

                case ModuleIsDLCKraken exc:
                    string dlcMsg = string.Format(Properties.Resources.MainInstallCantInstallDLC, exc.module.name);
                    currentUser.RaiseMessage(dlcMsg);
                    currentUser.RaiseError(dlcMsg);
                    break;
                }

                FailWaitDialog(
                    Properties.Resources.MainInstallErrorInstalling,
                    Properties.Resources.MainInstallKnownError,
                    Properties.Resources.MainInstallFailed,
                    false
                    );
            }
            else
            {
                // The Result property throws if InstallMods threw (!!!)
                KeyValuePair <bool, ModChanges> result = (KeyValuePair <bool, ModChanges>)e.Result;
                if (!installCanceled)
                {
                    // Rebuilds the list of GUIMods
                    ManageMods.UpdateModsList(null);

                    if (modChangedCallback != null)
                    {
                        foreach (var mod in result.Value)
                        {
                            modChangedCallback(mod.Mod, mod.ChangeType);
                        }
                    }

                    // install successful
                    AddStatusMessage(Properties.Resources.MainInstallSuccess);
                    HideWaitDialog(true);
                }
                else
                {
                    // User cancelled the installation
                    if (result.Key)
                    {
                        FailWaitDialog(
                            Properties.Resources.MainInstallCancelTooLate,
                            Properties.Resources.MainInstallCancelAfterInstall,
                            Properties.Resources.MainInstallProcessComplete,
                            true
                            );
                    }
                    else
                    {
                        FailWaitDialog(
                            Properties.Resources.MainInstallProcessCanceled,
                            Properties.Resources.MainInstallCanceledManually,
                            Properties.Resources.MainInstallInstallCanceled,
                            false
                            );
                    }
                }
            }

            Util.Invoke(this, () => Enabled = true);
            Util.Invoke(menuStrip1, () => menuStrip1.Enabled = true);
        }
예제 #5
0
파일: Main.cs 프로젝트: mioackerman/CKAN
        /// <summary>
        /// React to switching to a new game instance
        /// </summary>
        /// <param name="allowRepoUpdate">true if a repo update is allowed if needed (e.g. on initial load), false otherwise</param>
        private void CurrentInstanceUpdated(bool allowRepoUpdate)
        {
            CurrentInstance.Scan();
            Util.Invoke(this, () =>
            {
                Text = $"CKAN {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()}    --    {CurrentInstance.GameDir().Replace('/', Path.DirectorySeparatorChar)}";
                StatusInstanceLabel.Text = string.Format(
                    Properties.Resources.StatusInstanceLabelText,
                    CurrentInstance.Name,
                    CurrentInstance.game.ShortName,
                    CurrentInstance.Version()?.ToString()
                    );
            });

            configuration = GUIConfiguration.LoadOrCreateConfiguration(
                Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml")
                );

            if (CurrentInstance.CompatibleVersionsAreFromDifferentGameVersion)
            {
                new CompatibleGameVersionsDialog(CurrentInstance, !actuallyVisible)
                .ShowDialog();
            }

            (RegistryManager.Instance(CurrentInstance).registry as Registry)
            ?.BuildTagIndex(ManageMods.mainModList.ModuleTags);

            bool repoUpdateNeeded = configuration.RefreshOnStartup ||
                                    !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable();

            if (allowRepoUpdate)
            {
                // If not allowing, don't do anything
                if (repoUpdateNeeded)
                {
                    // Update the filters after UpdateRepo() completed.
                    // Since this happens with a backgroundworker, Filter() is added as callback for RunWorkerCompleted.
                    // Remove it again after it ran, else it stays there and is added again and again.
                    void filterUpdate(object sender, RunWorkerCompletedEventArgs e)
                    {
                        ManageMods.Filter(
                            (GUIModFilter)configuration.ActiveFilter,
                            ManageMods.mainModList.ModuleTags.Tags.GetOrDefault(configuration.TagFilter),
                            ManageMods.mainModList.ModuleLabels.LabelsFor(CurrentInstance.Name)
                            .FirstOrDefault(l => l.Name == configuration.CustomLabelFilter)
                            );
                        m_UpdateRepoWorker.RunWorkerCompleted -= filterUpdate;
                    }

                    m_UpdateRepoWorker.RunWorkerCompleted += filterUpdate;

                    ManageMods.ModGrid.Rows.Clear();
                    UpdateRepo();
                }
                else
                {
                    ManageMods.UpdateModsList();
                    ManageMods.Filter(
                        (GUIModFilter)configuration.ActiveFilter,
                        ManageMods.mainModList.ModuleTags.Tags.GetOrDefault(configuration.TagFilter),
                        ManageMods.mainModList.ModuleLabels.LabelsFor(CurrentInstance.Name)
                        .FirstOrDefault(l => l.Name == configuration.CustomLabelFilter)
                        );
                }
            }
            ManageMods.InstanceUpdated(CurrentInstance);
        }
예제 #6
0
        /// <summary>
        /// React to switching to a new game instance
        /// </summary>
        /// <param name="allowRepoUpdate">true if a repo update is allowed if needed (e.g. on initial load), false otherwise</param>
        private void CurrentInstanceUpdated(bool allowRepoUpdate)
        {
            log.Debug("Current instance updated, scanning");
            CurrentInstance.Scan();
            Util.Invoke(this, () =>
            {
                Text = $"CKAN {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()}    --    {CurrentInstance.GameDir().Replace('/', Path.DirectorySeparatorChar)}";
                StatusInstanceLabel.Text = string.Format(
                    Properties.Resources.StatusInstanceLabelText,
                    CurrentInstance.Name,
                    CurrentInstance.game.ShortName,
                    CurrentInstance.Version()?.ToString()
                    );
            });

            if (CurrentInstance.CompatibleVersionsAreFromDifferentGameVersion)
            {
                new CompatibleGameVersionsDialog(CurrentInstance, !actuallyVisible)
                .ShowDialog();
            }

            // This will throw RegistryInUseKraken if locked by another process
            var regMgr   = RegistryManager.Instance(CurrentInstance);
            var registry = regMgr.registry;

            if (!string.IsNullOrEmpty(regMgr.previousCorruptedMessage) &&
                !string.IsNullOrEmpty(regMgr.previousCorruptedPath))
            {
                errorDialog.ShowErrorDialog(Properties.Resources.MainCorruptedRegistry,
                                            regMgr.previousCorruptedPath, regMgr.previousCorruptedMessage,
                                            Path.Combine(Path.GetDirectoryName(regMgr.previousCorruptedPath) ?? "", regMgr.LatestInstalledExportFilename()));
                regMgr.previousCorruptedMessage = null;
                regMgr.previousCorruptedPath    = null;
            }
            registry.BuildTagIndex(ManageMods.mainModList.ModuleTags);

            configuration = GUIConfiguration.LoadOrCreateConfiguration(
                Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml"));

            bool repoUpdateNeeded = configuration.RefreshOnStartup ||
                                    !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable();

            if (allowRepoUpdate)
            {
                // If not allowing, don't do anything
                if (repoUpdateNeeded)
                {
                    // Update the filters after UpdateRepo() completed.
                    // Since this happens with a backgroundworker, Filter() is added as callback for RunWorkerCompleted.
                    // Remove it again after it ran, else it stays there and is added again and again.
                    void filterUpdate(object sender, RunWorkerCompletedEventArgs e)
                    {
                        SetupDefaultSearch();
                        m_UpdateRepoWorker.RunWorkerCompleted -= filterUpdate;
                    }

                    m_UpdateRepoWorker.RunWorkerCompleted += filterUpdate;

                    ManageMods.ModGrid.Rows.Clear();
                    UpdateRepo();
                }
                else
                {
                    SetupDefaultSearch();
                    ManageMods.UpdateModsList();
                }
            }
            ManageMods.InstanceUpdated(CurrentInstance);
        }