Beispiel #1
0
        private void AutoDetectGameLocation_OnChecked(object sender, RoutedEventArgs e)
        {
            _settings.GameLocation = App.Current.SteamAppLocator.AppLocation;

            // If it wasn't set revert since it can't be found automatically
            if (string.IsNullOrEmpty(_settings.GameLocation))
            {
                _settings.AutoDetectGameLocation = false;
                var dialogue = new AlertDialogue("Couldn't detect game folder",
                                                 "Hey! It seems we couldn't auto-detect your game folder. Please set it manually!");
                App.Current.QueueDialog(dialogue);
            }
        }
        public static void UpdateMod(Mod mod, Version versionNumber)
        {
            App.RunInBackgroundThread(() =>
            {
                List <ModOperation.ModOperation> ops = new();

                // Check that the requested version won't cause any issues
                var notSatisfied = new List <string>();
                foreach (var dependents in mod.InstalledDirectDependents)
                {
                    if (!dependents.Installed.Dependencies[mod.Guid].IsSatisfied(versionNumber))
                    {
                        notSatisfied.Add(dependents.ToString());
                    }
                }

                foreach ((string key, Range value) in mod.Versions[versionNumber].Dependencies)
                {
                    var dependency = ModRepository.Instance.Mods[key];

                    // If for some reason the user doesn't have a dependency installed, skip this because it will be installed later.
                    if (!dependency.IsInstalled)
                    {
                        continue;
                    }

                    if (!value.IsSatisfied(dependency.InstalledVersion))
                    {
                        notSatisfied.Add(dependency.ToString());
                    }
                }

                if (notSatisfied.Count == 0)
                {
                    ExecuteOperations(EnumerateInstallDependencies(mod, versionNumber).Concat(new ModOperation.ModOperation[]
                    {
                        new UninstallModOperation(mod),
                        new InstallModOperation(mod, versionNumber)
                    }));
                }
                else
                {
                    App.RunInMainThread(() =>
                    {
                        string op    = mod.InstalledVersion < versionNumber ? "updated" : "downgraded";
                        var dialogue = new AlertDialogue("Error", $"This mod cannot be {op} because one or more installed mods are not compatible with the selected version:\n" + string.Join(", ", notSatisfied));
                        App.Current.QueueDialog(dialogue);
                    });
                }
            });
        }
        private void App_OnLoadCompleted(object sender, NavigationEventArgs e)
        {
            if (Settings.FirstRun)
            {
                Settings.FirstRun = false;
                var dialogue = new AlertDialogue("Disclaimer", "You are about to mod your game. By continuing, you acknowledge that you may encounter issues and that these issues are NOT to be reported to the developer of the game. Please instead report all issues to the mod authors who can be contacted via their mod's source URL or in the main H3 Discord.");
                QueueDialog(dialogue);

                if (!string.IsNullOrWhiteSpace(Settings.GameLocation))
                {
                    var secondDialogue = new CleanInstallDialogue();
                    QueueDialog(secondDialogue);
                }
            }
        }