private async void SaveMods_Click(object sender, RoutedEventArgs e) { var cursor = this.Cursor; try { Application.Current.Dispatcher.Invoke(() => this.Cursor = System.Windows.Input.Cursors.Wait); await Task.Delay(500); string mapString; string totalConversionString; string modIdString; // check if there are any unknown mod types. if (ModDetails.AnyUnknownModTypes) { if (MessageBox.Show(_globalizer.GetResourceString("ModDetails_Save_UnknownLabel"), _globalizer.GetResourceString("ModDetails_Save_UnknownTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } } if (ModDetails.GetModStrings(out mapString, out totalConversionString, out modIdString)) { if (mapString != null) { _profile.ServerMap = mapString; } else if (_profile.ServerMap.Contains('/')) { _profile.ServerMap = string.Empty; } _profile.TotalConversionModId = totalConversionString ?? string.Empty; _profile.ServerModIds = modIdString ?? string.Empty; } await LoadModsFromProfile(); OnSavePerformed(); } catch (Exception ex) { MessageBox.Show(ex.Message, _globalizer.GetResourceString("ModDetails_Save_FailedTitle"), MessageBoxButton.OK, MessageBoxImage.Error); } finally { Application.Current.Dispatcher.Invoke(() => this.Cursor = cursor); } }
private async void SaveMods_Click(object sender, RoutedEventArgs e) { var cursor = this.Cursor; try { Application.Current.Dispatcher.Invoke(() => this.Cursor = System.Windows.Input.Cursors.Wait); await Task.Delay(500); string mapString; string totalConversionString; string modIdString; // check if there are any unknown mod types. if (ModDetails.AnyUnknownModTypes) { if (MessageBox.Show(_globalizer.GetResourceString("ModDetails_Save_UnknownLabel"), _globalizer.GetResourceString("ModDetails_Save_UnknownTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } } if (ModDetails.GetModStrings(out mapString, out totalConversionString, out modIdString)) { if (mapString != null) { _profile.ServerMap = mapString; } else if (_profile.ServerMap.Contains('/')) { _profile.ServerMap = string.Empty; } // check if a total conversion mod was found in the mod list if (string.IsNullOrWhiteSpace(totalConversionString)) { // total conversion mod not found, was it previously set to an official mod? if (!ModUtils.IsOfficialMod(_profile.TotalConversionModId)) { // total conversion was not previoulsly set to an official mod, clear total conversion mod id _profile.TotalConversionModId = string.Empty; } } else { // total conversion mod found, set the found mod id _profile.TotalConversionModId = totalConversionString; } _profile.ServerModIds = modIdString ?? string.Empty; } await LoadModsFromProfile(); OnSavePerformed(); } catch (Exception ex) { MessageBox.Show(ex.Message, _globalizer.GetResourceString("ModDetails_Save_FailedTitle"), MessageBoxButton.OK, MessageBoxImage.Error); } finally { Application.Current.Dispatcher.Invoke(() => this.Cursor = cursor); } }