diff --git a/CHANGELIST.md b/CHANGELIST.md index ee4b1b63..bde8489b 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -36,6 +36,7 @@ - Handle Redump password changing better - Refine options window bindings - Refine options window bindings further +- Refine info window bindings further ### 2.6.6 (2023-10-04) diff --git a/MPF.UI.Core/ElementConverter.cs b/MPF.UI.Core/ElementConverter.cs index e106be6e..8feb0014 100644 --- a/MPF.UI.Core/ElementConverter.cs +++ b/MPF.UI.Core/ElementConverter.cs @@ -13,10 +13,14 @@ namespace MPF.UI.Core { switch (value) { + case DiscCategory discCategory: + return new Element(discCategory); case InternalProgram internalProgram: return new Element(internalProgram); case RedumpSystem redumpSystem: return new RedumpSystemComboBoxItem(redumpSystem); + case Region region: + return new Element(region); // Null values are treated as a system value default: @@ -33,10 +37,14 @@ namespace MPF.UI.Core switch (element) { + case Element dcElement: + return dcElement.Value; case Element ipElement: return ipElement.Value; case RedumpSystemComboBoxItem rsElement: return rsElement.Value; + case Element reValue: + return reValue.Value; default: return null; } diff --git a/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs b/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs index 63febd9b..dab5c26a 100644 --- a/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs +++ b/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs @@ -3,7 +3,6 @@ using System.Linq; using MPF.Core.Data; using MPF.Core.UI.ComboBoxItems; using MPF.Core.Utilities; -using MPF.UI.Core.Windows; using SabreTools.RedumpLib.Data; namespace MPF.UI.Core.ViewModels @@ -204,60 +203,24 @@ namespace MPF.UI.Core.ViewModels /// Load the current contents of the base SubmissionInfo to the UI /// /// TODO: Convert selected list item to binding - internal void Load(DiscInformationWindow parent) + internal void Load() { - parent.CategoryComboBox.SelectedIndex = Categories.FindIndex(r => r == SubmissionInfo.CommonDiscInfo.Category); - parent.RegionComboBox.SelectedIndex = Regions.FindIndex(r => r == SubmissionInfo.CommonDiscInfo.Region); if (SubmissionInfo.CommonDiscInfo.Languages != null) Languages.ForEach(l => l.IsChecked = SubmissionInfo.CommonDiscInfo.Languages.Contains(l)); if (SubmissionInfo.CommonDiscInfo.LanguageSelection != null) LanguageSelections.ForEach(ls => ls.IsChecked = SubmissionInfo.CommonDiscInfo.LanguageSelection.Contains(ls)); - - // Comment Fields - if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields != null) - { - // Additional Information - if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.PostgapType)) - parent.PostgapTypeCheckBox.IsChecked = SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.PostgapType] != null; - if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.VCD)) - parent.VCDCheckBox.IsChecked = SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.VCD] != null; - } } /// /// Save the current contents of the UI to the base SubmissionInfo /// /// TODO: Convert selected list item to binding - internal void Save(DiscInformationWindow parent) + internal void Save() { - SubmissionInfo.CommonDiscInfo.Category = (parent.CategoryComboBox.SelectedItem as Element)?.Value ?? DiscCategory.Games; - SubmissionInfo.CommonDiscInfo.Region = (parent.RegionComboBox.SelectedItem as Element)?.Value ?? Region.World; SubmissionInfo.CommonDiscInfo.Languages = Languages.Where(l => l.IsChecked).Select(l => l?.Value).ToArray(); if (!SubmissionInfo.CommonDiscInfo.Languages.Any()) SubmissionInfo.CommonDiscInfo.Languages = new Language?[] { null }; SubmissionInfo.CommonDiscInfo.LanguageSelection = LanguageSelections.Where(ls => ls.IsChecked).Select(ls => ls?.Value).ToArray(); - - // Initialize the dictionaries, if needed - if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields == null) -#if NET48 - SubmissionInfo.CommonDiscInfo.CommentsSpecialFields = new Dictionary(); -#else - SubmissionInfo.CommonDiscInfo.CommentsSpecialFields = new Dictionary(); -#endif - if (SubmissionInfo.CommonDiscInfo.ContentsSpecialFields == null) -#if NET48 - SubmissionInfo.CommonDiscInfo.ContentsSpecialFields = new Dictionary(); -#else - SubmissionInfo.CommonDiscInfo.ContentsSpecialFields = new Dictionary(); -#endif - - #region Comment Fields - - // Additional Information - SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.PostgapType] = parent.PostgapTypeCheckBox.IsChecked?.ToString(); - SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.VCD] = parent.VCDCheckBox.IsChecked?.ToString(); - - #endregion } /// diff --git a/MPF.UI.Core/Windows/DiscInformationWindow.xaml b/MPF.UI.Core/Windows/DiscInformationWindow.xaml index 5239dff3..3d08e688 100644 --- a/MPF.UI.Core/Windows/DiscInformationWindow.xaml +++ b/MPF.UI.Core/Windows/DiscInformationWindow.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="clr-namespace:MPF.UI.Core.UserControls" + xmlns:core="clr-namespace:MPF.UI.Core" xmlns:redump="clr-namespace:SabreTools.RedumpLib.Data;assembly=SabreTools.RedumpLib" xmlns:windows="clr-namespace:MPF.UI.Core.Windows" mc:Ignorable="d" @@ -11,6 +12,9 @@ WindowStartupLocation="CenterOwner" ResizeMode="CanMinimize" SizeToContent="Height" BorderBrush="DarkGray" BorderThickness="2"> + + + @@ -93,7 +97,8 @@ private void OnAcceptClick(object sender, RoutedEventArgs e) { - DiscInformationViewModel.Save(this); + DiscInformationViewModel.Save(); DialogResult = true; Close(); }