private void UpdateViewForListOption(Constraint ct, int value) { IEnumerable <OptionValue> values = _selectedOption.Option.Values; if (ct.Require.Any()) { value = ct.Require[0]; CompatibilityNote = $"{ResourceHelper.Get(StringKey.ThisOptionCannotBeChangedDueToCompatibility)} ({string.Join(", ", ct.ParticipatingMods.Values)})"; ComboBoxIsEnabled = false; } else if (ct.Forbid.Any()) { var remove = values.Where(v => ct.Forbid.Contains(v.Value)); CompatibilityNote = string.Format(ResourceHelper.Get(StringKey.TheFollowingValuesHaveBeenRemovedDueToCompatibility), string.Join(", ", remove.Select(o => o.Name)), string.Join(", ", ct.ParticipatingMods.Values)); values = values.Except(remove); if (!values.Any(v => v.Value == value)) { value = values.First().Value; } ComboBoxIsEnabled = true; } else { CompatibilityNote = string.Empty; ComboBoxIsEnabled = true; } CheckBoxVisibility = Visibility.Hidden; ComboBoxVisibility = Visibility.Visible; DropdownOptions.Clear(); DropdownOptions = values.Select(v => new OptionValueViewModel(v)).ToList(); DropdownSelectedIndex = DropdownOptions.FindIndex(m => m.OptionValue.Value == value); }
private void UpdateViewForListOption(Constraint ct, int value) { IEnumerable <OptionValue> values = _selectedOption.Option.Values; if (ct.Require.Any()) { value = ct.Require[0]; CompatibilityNote = $"This option cannot be changed due to compatibility with other mods ({string.Join(", ", ct.ParticipatingMods.Values)})"; ComboBoxIsEnabled = false; } else if (ct.Forbid.Any()) { var remove = values.Where(v => ct.Forbid.Contains(v.Value)); CompatibilityNote = $"The following values: {string.Join(", ", remove.Select(o => o.Name))} have been removed due to compatibility with other mods ({string.Join(", ", ct.ParticipatingMods.Values)})"; values = values.Except(remove); if (!values.Any(v => v.Value == value)) { value = values.First().Value; } ComboBoxIsEnabled = true; } else { CompatibilityNote = string.Empty; ComboBoxIsEnabled = true; } CheckBoxVisibility = Visibility.Hidden; ComboBoxVisibility = Visibility.Visible; DropdownOptions.Clear(); DropdownOptions = values.Select(v => new OptionValueViewModel(v)).ToList(); DropdownSelectedIndex = DropdownOptions.FindIndex(m => m.OptionValue.Value == value); }