private async Task SaveApplication() { _saveToken.Cancel(); _saveToken = new CancellationTokenSource(); try { ApplicationTuple.Config.EnabledMods = AllMods.Where(x => x.Enabled == true).Select(x => x.Tuple.Config.ModId).ToArray(); await ApplicationTuple.SaveAsync(_saveToken.Token); } catch (TaskCanceledException) { /* Ignored */ } }
/// <summary> /// Allows a user to load a new mod set. /// </summary> public async void LoadModSet() { var dialog = new VistaOpenFileDialog { Title = _xamlLoadModSetTitle.Get(), Filter = Constants.WpfJsonFormat, AddExtension = true, DefaultExt = ".json" }; if ((bool)dialog.ShowDialog()) { ModSet.FromFile(dialog.FileName).ToApplicationConfig(ApplicationTuple.Config); ApplicationTuple.SaveAsync(); // Check for mod updates/dependencies. if (Update.CheckMissingDependencies(out var missingDependencies)) { try { await Update.DownloadNuGetPackagesAsync(missingDependencies, false, false); } catch (Exception) { } } CheckModCompatibility(); OnLoadModSet(); } }
/// <summary> /// Allows a user to load a new mod set. /// </summary> public async void LoadModSet() { var dialog = new VistaOpenFileDialog { Title = Resources.LoadModSetDialogTitle.Get(), Filter = Constants.DialogJsonFilter, AddExtension = true, DefaultExt = ".json" }; if ((bool)dialog.ShowDialog() !) { ModSet.FromFile(dialog.FileName).ToApplicationConfig(ApplicationTuple.Config); await ApplicationTuple.SaveAsync(); // Check for mod updates/dependencies. var deps = Update.CheckMissingDependencies(); if (!deps.AllAvailable) { try { await Update.ResolveMissingPackagesAsync(); } catch (Exception) { /* ignored */ } } EnforceModCompatibility(); OnLoadModSet(); } }