diff --git a/CHANGELIST.md b/CHANGELIST.md new file mode 100644 index 00000000..a5b9d8d4 --- /dev/null +++ b/CHANGELIST.md @@ -0,0 +1,62 @@ +### 1.06 (2018-06-15) + +- Fixed not being able to use the `/c2` flag properly +- Fixed times when the ability to start dumping was improperly allowed +- Added full support for XBOX and XBOX360 (XDG1, XDG2) dumping through DIC (using a Kreon, or presumably a 0800) + +### 1.05a (2018-06-14) + +- Fixed some ordering and nullability issues +- Added automatic fields for PS1, PS2, Saturn + +### 1.05 (2018-06-14) + +- Miscellaneous fixes around custom parameter validation, dump information accuracy, settings window, and TODO cleanup +- Add many more supported platforms, mostly arcade (based on publicly available information) +- Add floppy disk dumping support +- Add optional disc eject on completion +- Add subdump for Sega Saturn +- Fully support newest version of DIC including all new flags and commands +- PlayStation and Saturn discs still don't have all internal information automatically generated + +### 1.04b (2018-06-13) + +- Added subIntention reading +- Fixed extra extensions being appended +- Fixed internationalization error (number formatting) +- Fixed "Custom Input" not working + +### 1.04a (2018-06-13) + +- Fixed issue with empty trays +- Added settings dialog + +### 1.04 (2018-06-13) + +- Behind-the-scenes fixes and formatting +- Better checks for external programs +- Automatically changing disc information +- Custom parameters (and parameter validation) +- Automatic drive speed selection +- Automatic submission information creation +- Add ability to stop a dump from the UI + +### 1.03 (2018-06-08) + +- edccchk now run on all CD-Roms +- Discs unsupported by Windows are now regonized +- Extra \ when accepting default save has been removed. + +### 1.02b (2018-05-18) + +- Added missing DLL + +### 1.02 (2018-05-18) + +- Fixed XBOX One and PS4 Drive Speed issue. +- Started implementing DiscImageCreator Path selection. +- Conforming my naming for objects and variable + +### 1.01d (2018-05-18) + +-Combine IBM PC-CD options, misc fixes. \ No newline at end of file diff --git a/Constants.cs b/Constants.cs index 73e38029..547a2f84 100644 --- a/Constants.cs +++ b/Constants.cs @@ -7,6 +7,7 @@ { public const string StartDumping = "Start Dumping"; public const string StopDumping = "Stop Dumping"; + public const string FloppyDriveString = "<>"; } /// diff --git a/DICUI.csproj b/DICUI.csproj index 7a651289..06d2929f 100644 --- a/DICUI.csproj +++ b/DICUI.csproj @@ -91,6 +91,8 @@ Designer + + diff --git a/Enumerations.cs b/Enumerations.cs index eec36b7d..b9e6646c 100644 --- a/Enumerations.cs +++ b/Enumerations.cs @@ -1,9 +1,9 @@ namespace DICUI { /// - /// Known disc types + /// Known media types /// - public enum DiscType + public enum MediaType { // Generic Optical Formats NONE = 0, @@ -15,16 +15,16 @@ LaserDisc, // Special Optical Formats - CED, GameCubeGameDisc, WiiOpticalDisc, WiiUOpticalDisc, UMD, - + // Non-Optical Formats Floppy, - Cassette, Cartridge, + Cassette, + CED, } /// diff --git a/External/IOrderedDictionary.cs b/External/IOrderedDictionary.cs new file mode 100644 index 00000000..17fc4c37 --- /dev/null +++ b/External/IOrderedDictionary.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Collections.Specialized; + +namespace DICUI.External +{ + // Adapted from https://www.codeproject.com/Articles/18615/OrderedDictionary-T-A-generic-implementation-of-IO + public interface IOrderedDictionary : IOrderedDictionary, IDictionary + { + } +} diff --git a/External/OrderedDictionary.cs b/External/OrderedDictionary.cs new file mode 100644 index 00000000..839aa576 --- /dev/null +++ b/External/OrderedDictionary.cs @@ -0,0 +1,326 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; + +namespace DICUI.External +{ + // Adapted from https://www.codeproject.com/Articles/18615/OrderedDictionary-T-A-generic-implementation-of-IO + public class OrderedDictionary : IOrderedDictionary + { + private List> _list; + private Dictionary _dictionary; + + #region Interface properties + + public int Count { get; } + + int ICollection.Count => Count; + int ICollection>.Count => Count; + + ICollection IDictionary.Keys => _dictionary.Keys; + ICollection IDictionary.Keys => _dictionary.Keys; + + ICollection IDictionary.Values => _dictionary.Values; + ICollection IDictionary.Values => _dictionary.Values; + + bool IDictionary.IsReadOnly => false; + bool ICollection>.IsReadOnly => false; + + bool IDictionary.IsFixedSize => false; + + object ICollection.SyncRoot => new object(); + + bool ICollection.IsSynchronized => true; + + public TValue this[int index] + { + get + { + return _list[index].Value; + } + set + { + if (index >= Count || index < 0) + throw new ArgumentOutOfRangeException("index", + "'index' must be non-negative and less than" + + " the size of the collection"); + + TKey key = _list[index].Key; + + _list[index] = new KeyValuePair(key, value); + _dictionary[key] = value; + } + } + + object IOrderedDictionary.this[int index] + { + get + { + return _list[index].Value; + } + set + { + if (index >= Count || index < 0) + throw new ArgumentOutOfRangeException("index", + "'index' must be non-negative and less than" + + " the size of the collection"); + + var valueObj = (TValue)value; + if (valueObj == null) + throw new ArgumentException($"Value must be of type {typeof(TValue)}"); + + TKey key = _list[index].Key; + + _list[index] = new KeyValuePair(key, valueObj); + _dictionary[key] = valueObj; + } + } + + object IDictionary.this[object key] + { + get + { + var keyObj = (TKey)key; + if (keyObj == null) + throw new ArgumentException($"Key must be of type {typeof(TKey)}"); + + return _dictionary[keyObj]; + } + set + { + var keyObj = (TKey)key; + if (keyObj == null) + throw new ArgumentException($"Key must be of type {typeof(TKey)}"); + + var valueObj = (TValue)value; + if (valueObj == null) + throw new ArgumentException($"Value must be of type {typeof(TValue)}"); + + if (_dictionary.ContainsKey(keyObj)) + { + _dictionary[keyObj] = valueObj; + _list[IndexOfKey(keyObj)] = new KeyValuePair(keyObj, valueObj); + } + else + { + Add(keyObj, valueObj); + } + } + } + + TValue IDictionary.this[TKey key] + { + get + { + return _dictionary[key]; + } + set + { + if (_dictionary.ContainsKey(key)) + { + _dictionary[key] = value; + _list[IndexOfKey(key)] = new KeyValuePair(key, value); + } + else + { + Add(key, value); + } + } + } + + #endregion + + public OrderedDictionary() + { + _list = new List>(); + _dictionary = new Dictionary(); + Count = 0; + } + + public int Add(TKey key, TValue value) + { + _dictionary.Add(key, value); + _list.Add(new KeyValuePair(key, value)); + return Count - 1; + } + + public void Insert(int index, TKey key, TValue value) + { + if (index > Count || index < 0) + throw new ArgumentOutOfRangeException("index"); + + _dictionary.Add(key, value); + _list.Insert(index, new KeyValuePair(key, value)); + } + + void IOrderedDictionary.RemoveAt(int index) + { + if (index >= Count || index < 0) + throw new ArgumentOutOfRangeException("index", + "'index' must be non-negative and less than " + + "the size of the collection"); + + TKey key = _list[index].Key; + + _list.RemoveAt(index); + _dictionary.Remove(key); + } + + public bool Remove(TKey key) + { + if (null == key) + throw new ArgumentNullException("key"); + + int index = IndexOfKey(key); + if (index >= 0) + { + if (_dictionary.Remove(key)) + { + _list.RemoveAt(index); + return true; + } + } + return false; + } + + public bool ContainsKey(TKey key) + { + return _dictionary.ContainsKey(key); + } + + private int IndexOfKey(TKey key) + { + return _list.FindIndex(kvp => kvp.Key.Equals(key)); + } + + #region Interface methods + + IDictionaryEnumerator IOrderedDictionary.GetEnumerator() + { + return _dictionary.GetEnumerator(); + } + + void IOrderedDictionary.Insert(int index, object key, object value) + { + var keyObj = (TKey)key; + if (keyObj == null) + throw new ArgumentException($"Key must be of type {typeof(TKey)}"); + + var valueObj = (TValue)value; + if (valueObj == null) + throw new ArgumentException($"Value must be of type {typeof(TValue)}"); + + Insert(index, keyObj, valueObj); + } + + bool IDictionary.Contains(object key) + { + var keyObj = (TKey)key; + if (keyObj == null) + throw new ArgumentException($"Key must be of type {typeof(TKey)}"); + + return _dictionary.ContainsKey(keyObj); + } + + void IDictionary.Add(object key, object value) + { + var keyObj = (TKey)key; + if (keyObj == null) + throw new ArgumentException($"Key must be of type {typeof(TKey)}"); + + var valueObj = (TValue)value; + if (valueObj == null) + throw new ArgumentException($"Value must be of type {typeof(TValue)}"); + + Add(keyObj, valueObj); + } + + void IDictionary.Clear() + { + _dictionary.Clear(); + _list.Clear(); + } + + IDictionaryEnumerator IDictionary.GetEnumerator() + { + return _dictionary.GetEnumerator(); + } + + void IDictionary.Remove(object key) + { + var keyObj = (TKey)key; + if (keyObj == null) + throw new ArgumentException($"Key must be of type {typeof(TKey)}"); + + Remove(keyObj); + } + + void ICollection.CopyTo(Array array, int index) + { + var arrayObj = array as KeyValuePair[]; + if (arrayObj == null) + throw new ArgumentException($"Key must be of type {typeof(KeyValuePair[])}"); + + _list.CopyTo(arrayObj, index); + } + + bool IDictionary.ContainsKey(TKey key) + { + return ContainsKey(key); + } + + void IDictionary.Add(TKey key, TValue value) + { + Add(key, value); + } + + bool IDictionary.Remove(TKey key) + { + return Remove(key); + } + + bool IDictionary.TryGetValue(TKey key, out TValue value) + { + return _dictionary.TryGetValue(key, out value); + } + + void ICollection>.Add(KeyValuePair item) + { + Add(item.Key, item.Value); + } + + void ICollection>.Clear() + { + _dictionary.Clear(); + _list.Clear(); + } + + bool ICollection>.Contains(KeyValuePair item) + { + return _list.Contains(item); + } + + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) + { + _list.CopyTo(array, arrayIndex); + } + + bool ICollection>.Remove(KeyValuePair item) + { + return Remove(item.Key); + } + + IEnumerator> IEnumerable>.GetEnumerator() + { + return _list.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return _list.GetEnumerator(); + } + + #endregion + } +} diff --git a/MainWindow.xaml b/MainWindow.xaml index 443e83bf..05f52e06 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -42,9 +42,9 @@ - private void PopulateSystems() { - _systems = Utilities.Validation.CreateListOfSystems(); + _systems = Utilities.Validation.CreateListOfSystems() + .Select(i => new KeyValuePair(i.Key, i.Value)) + .ToList(); cmb_SystemType.ItemsSource = _systems; - cmb_SystemType.DisplayMemberPath = "Item1"; + cmb_SystemType.DisplayMemberPath = "Key"; cmb_SystemType.SelectedIndex = 0; cmb_SystemType_SelectionChanged(null, null); @@ -177,9 +183,11 @@ namespace DICUI private void PopulateDrives() { // Populate the list of drives and add it to the combo box - _drives = Utilities.Validation.CreateListOfDrives(); + _drives = Utilities.Validation.CreateListOfDrives() + .Select(i => new KeyValuePair(i.Key, i.Value)) + .ToList(); cmb_DriveLetter.ItemsSource = _drives; - cmb_DriveLetter.DisplayMemberPath = "Item1"; + cmb_DriveLetter.DisplayMemberPath = "Key"; cmb_DriveLetter.SelectedIndex = 0; cmb_DriveLetter_SelectionChanged(null, null); @@ -225,29 +233,29 @@ namespace DICUI { btn_StartStop.Content = UIElements.StopDumping; - // Populate all tuples - var driveLetterTuple = cmb_DriveLetter.SelectedItem as Tuple; - var systemTypeTuple = cmb_SystemType.SelectedValue as Tuple; - var discTypeTuple = cmb_DiscType.SelectedValue as Tuple; + // Populate all KVPs + var driveKvp = cmb_DriveLetter.SelectedItem as KeyValuePair?; + var systemKvp = cmb_SystemType.SelectedValue as KeyValuePair?; + var mediaKvp = cmb_MediaType.SelectedValue as KeyValuePair?; // Get the currently selected options string dicPath = _options.dicPath; string psxtPath = _options.psxtPath; string subdumpPath = _options.subdumpPath; - char driveLetter = driveLetterTuple.Item1; - bool isFloppy = driveLetterTuple.Item3; + char driveLetter = (char)driveKvp?.Key; + bool isFloppy = (driveKvp?.Value == UIElements.FloppyDriveString); string outputDirectory = txt_OutputDirectory.Text; string outputFilename = txt_OutputFilename.Text; - string systemName = systemTypeTuple.Item1; - KnownSystem? system = systemTypeTuple.Item2; - DiscType? type = discTypeTuple.Item2; + string systemName = systemKvp?.Key; + KnownSystem? system = systemKvp?.Value; + MediaType? type = mediaKvp?.Value; string customParameters = txt_Parameters.Text; // Validate that everything is good if (string.IsNullOrWhiteSpace(customParameters) || !Utilities.Validation.ValidateParameters(customParameters) - || (isFloppy ^ type == DiscType.Floppy)) + || (isFloppy ^ type == MediaType.Floppy)) { lbl_Status.Content = "Error! Current configuration is not supported!"; btn_StartStop.Content = UIElements.StartDumping; @@ -263,6 +271,11 @@ namespace DICUI outputFilename = Path.GetFileName(path); } + // Replace characters where needed + // TODO: Investigate why the `&` replacement is needed + outputDirectory = outputDirectory.Replace('.', '_').Replace('&', '_'); + outputFilename = new StringBuilder(outputFilename.Replace('&', '_')).Replace('.', '_', 0, outputFilename.LastIndexOf('.')).ToString(); + // Validate that the required program exits if (!File.Exists(dicPath)) { @@ -421,8 +434,8 @@ namespace DICUI CancelDumping(); - var driveTuple = cmb_DriveLetter.SelectedItem as Tuple; - if (driveTuple.Item3) + var driveKvp = cmb_DriveLetter.SelectedItem as KeyValuePair?; + if (driveKvp?.Value == UIElements.FloppyDriveString) { return; } @@ -434,7 +447,7 @@ namespace DICUI StartInfo = new ProcessStartInfo() { FileName = _options.dicPath, - Arguments = DICCommands.Eject + " " + driveTuple.Item1, + Arguments = DICCommands.Eject + " " + driveKvp?.Key, CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true, @@ -450,15 +463,15 @@ namespace DICUI /// private void EnsureDiscInformation() { - var systemTuple = cmb_SystemType.SelectedItem as Tuple; - var discTypeTuple = cmb_DiscType.SelectedItem as Tuple; + var systemKvp = cmb_SystemType.SelectedItem as KeyValuePair?; + var mediaKvp = cmb_MediaType.SelectedItem as KeyValuePair?; // If we're on a separator, go to the next item - if (systemTuple.Item2 == null) - systemTuple = cmb_SystemType.Items[++cmb_SystemType.SelectedIndex] as Tuple; + if (systemKvp?.Value == null) + systemKvp = cmb_SystemType.Items[++cmb_SystemType.SelectedIndex] as KeyValuePair?; - var selectedSystem = systemTuple.Item2; - var selectedDiscType = discTypeTuple != null ? discTypeTuple.Item2 : DiscType.NONE; + var selectedSystem = systemKvp?.Value; + var selectedMediaType = mediaKvp != null ? mediaKvp?.Value : MediaType.NONE; // No system chosen, update status if (selectedSystem == KnownSystem.NONE) @@ -469,52 +482,52 @@ namespace DICUI else if (selectedSystem != KnownSystem.Custom) { // If we're on an unsupported type, update the status accordingly - switch (selectedDiscType) + switch (selectedMediaType) { - case DiscType.NONE: + case MediaType.NONE: lbl_Status.Content = "Please select a valid disc type"; btn_StartStop.IsEnabled = false; break; - case DiscType.GameCubeGameDisc: - case DiscType.GDROM: - lbl_Status.Content = string.Format("{0} discs are partially supported by DIC", discTypeTuple.Item1); + case MediaType.GameCubeGameDisc: + case MediaType.GDROM: + lbl_Status.Content = string.Format("{0} discs are partially supported by DIC", mediaKvp?.Key); btn_StartStop.IsEnabled = (_drives.Count > 0 ? true : false); break; - case DiscType.HDDVD: - case DiscType.LaserDisc: - case DiscType.CED: - case DiscType.UMD: - case DiscType.WiiOpticalDisc: - case DiscType.WiiUOpticalDisc: - case DiscType.Cartridge: - case DiscType.Cassette: - lbl_Status.Content = string.Format("{0} discs are not currently supported by DIC", discTypeTuple.Item1); + case MediaType.HDDVD: + case MediaType.LaserDisc: + case MediaType.CED: + case MediaType.UMD: + case MediaType.WiiOpticalDisc: + case MediaType.WiiUOpticalDisc: + case MediaType.Cartridge: + case MediaType.Cassette: + lbl_Status.Content = string.Format("{0} discs are not currently supported by DIC", mediaKvp?.Key); btn_StartStop.IsEnabled = false; break; - case DiscType.DVD: + case MediaType.DVD: if (selectedSystem == KnownSystem.MicrosoftXBOX360XDG3) { - lbl_Status.Content = string.Format("{0} discs are not currently supported by DIC", discTypeTuple.Item1); + lbl_Status.Content = string.Format("{0} discs are not currently supported by DIC", mediaKvp?.Key); btn_StartStop.IsEnabled = false; } else { - lbl_Status.Content = string.Format("{0} ready to dump", discTypeTuple.Item1); + lbl_Status.Content = string.Format("{0} ready to dump", mediaKvp?.Key); btn_StartStop.IsEnabled = (_drives.Count > 0 ? true : false); } break; default: - lbl_Status.Content = string.Format("{0} ready to dump", discTypeTuple.Item1); + lbl_Status.Content = string.Format("{0} ready to dump", mediaKvp?.Key); btn_StartStop.IsEnabled = (_drives.Count > 0 ? true : false); break; } } // If we're in a type that doesn't support drive speeds - switch (selectedDiscType) + switch (selectedMediaType) { - case DiscType.Floppy: - case DiscType.BluRay: + case MediaType.Floppy: + case MediaType.BluRay: cmb_DriveSpeed.IsEnabled = false; break; default: @@ -552,21 +565,21 @@ namespace DICUI cmb_DriveLetter.IsEnabled = true; // Populate with the correct params for inputs (if we're not on the default option) - if (selectedSystem != KnownSystem.NONE && selectedDiscType != DiscType.NONE) + if (selectedSystem != KnownSystem.NONE && selectedMediaType != MediaType.NONE) { - var driveletter = cmb_DriveLetter.SelectedValue as Tuple; + var driveletter = cmb_DriveLetter.SelectedValue as KeyValuePair?; // If drive letter is invalid, skip this if (driveletter == null) return; - string discType = Converters.KnownSystemAndDiscTypeToBaseCommand(selectedSystem, selectedDiscType); - List defaultParams = Converters.KnownSystemAndDiscTypeToParameters(selectedSystem, selectedDiscType); - txt_Parameters.Text = discType - + " " + driveletter.Item1 + string command = Converters.KnownSystemAndMediaTypeToBaseCommand(selectedSystem, selectedMediaType); + List defaultParams = Converters.KnownSystemAndMediaTypeToParameters(selectedSystem, selectedMediaType); + txt_Parameters.Text = command + + " " + driveletter?.Key + " \"" + Path.Combine(txt_OutputDirectory.Text, txt_OutputFilename.Text) + "\" " - + (selectedDiscType != DiscType.Floppy - && selectedDiscType != DiscType.BluRay + + (selectedMediaType != MediaType.Floppy + && selectedMediaType != MediaType.BluRay && selectedSystem != KnownSystem.MicrosoftXBOX && selectedSystem != KnownSystem.MicrosoftXBOX360XDG2 && selectedSystem != KnownSystem.MicrosoftXBOX360XDG3 @@ -581,14 +594,14 @@ namespace DICUI /// private void GetOutputNames() { - var driveTuple = cmb_DriveLetter.SelectedItem as Tuple; - var systemTuple = cmb_SystemType.SelectedItem as Tuple; - var discTuple = cmb_DiscType.SelectedItem as Tuple; + var driveKvp = cmb_DriveLetter.SelectedItem as KeyValuePair?; + var systemKvp = cmb_SystemType.SelectedItem as KeyValuePair?; + var mediaKvp = cmb_MediaType.SelectedItem as KeyValuePair?; - if (driveTuple != null && systemTuple != null && discTuple != null) + if (driveKvp != null && (driveKvp?.Value != UIElements.FloppyDriveString) && systemKvp != null && mediaKvp != null) { - txt_OutputDirectory.Text = Path.Combine(_options.defaultOutputPath, driveTuple.Item2); - txt_OutputFilename.Text = driveTuple.Item2 + Converters.DiscTypeToExtension(discTuple.Item2); + txt_OutputDirectory.Text = Path.Combine(_options.defaultOutputPath, driveKvp?.Value); + txt_OutputFilename.Text = driveKvp?.Value + Converters.MediaTypeToExtension(mediaKvp?.Value); } else { @@ -603,8 +616,8 @@ namespace DICUI private void SetSupportedDriveSpeed() { // Get the drive letter from the selected item - var selected = cmb_DriveLetter.SelectedItem as Tuple; - if (selected == null || selected.Item3) + var selected = cmb_DriveLetter.SelectedItem as KeyValuePair?; + if (selected == null || (selected?.Value == UIElements.FloppyDriveString)) { return; } @@ -616,7 +629,7 @@ namespace DICUI return; } - char driveLetter = selected.Item1; + char driveLetter = (char)selected?.Key; childProcess = new Process() { StartInfo = new ProcessStartInfo() diff --git a/Options.cs b/Options.cs index 0119735c..5878f50c 100644 --- a/Options.cs +++ b/Options.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using System.Configuration; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace DICUI { diff --git a/README.md b/README.md index b0af119a..e6c51c80 100644 --- a/README.md +++ b/README.md @@ -1,111 +1,30 @@ # DICUI -Disc Image Creator UI in C# + +DiscImageCreator UI in C# This is a community project, so if you have some time and knowledge to give, we'll be glad to add you to the contributor of this project :) -We are using Disc Image Creator, created by Sarami, and we would like to thanks him for his great software. +We are using DiscImageCreator, created by Sarami, and we would like to thanks him for his great software. The latest release of DIC can be found on [the GitHub page](https://github.com/saramibreak/DiscImageCreator) -You can get the latest code and released on his github right here: -https://github.com/saramibreak/DiscImageCreator --------------------------------------------------------------------------- -Currently working on the project: - -ReignStumble - Co-Lead Programmer - -darksabre76 - Co-Lead Programmer - -Jakz - Contributer - -NHellFire - Contributer - -Dizzzy - Concept/Ideas/Beta tester - -## Changelist +## Releases Download the latest release here: [https://github.com/reignstumble/DICUI/releases](https://github.com/reignstumble/DICUI/releases) --------------------------------------------------------------------------- -2018-06-15 --------------------------------------------------------------------------- +## Changelist -Version 1.06 released: +A list of all changes can now be found [here](https://github.com/reignstumble/DICUI/blob/master/CHANGELIST.md). -- Fixed not being able to use the `/c2` flag properly -- Fixed times when the ability to start dumping was improperly allowed -- Added full support for XBOX and XBOX360 (XDG1, XDG2) dumping through DIC (using a Kreon, or presumably a 0800) +## Contributors --------------------------------------------------------------------------- -2018-06-14 --------------------------------------------------------------------------- +Here are the talented people who have contributed to the project so far: -Version 1.05a released: +**ReignStumble** - Project Lead / UI Design -- Fixed some ordering and nullability issues -- Added automatic fields for PS1, PS2, Saturn +**darksabre76** - Project Co-Lead / Backend Design -Version 1.05 released: +**Jakz** - Feature Contributor -- Miscellaneous fixes around custom parameter validation, dump information accuracy, settings window, and TODO cleanup -- Add many more supported platforms, mostly arcade (based on publicly available information) -- Add floppy disk dumping support -- Add optional disc eject on completion -- Add subdump for Sega Saturn -- Fully support newest version of DIC including all new flags and commands +**NHellFire** - Feature Contributor -**Known Issues:** - -- PlayStation and Saturn discs still don't have all internal information automatically generated - --------------------------------------------------------------------------- -2018-06-13 --------------------------------------------------------------------------- - -Version 1.04b released: - -- Added subIntention reading -- Fixed extra extensions being appended -- Fixed internationalization error (number formatting) -- Fixed "Custom Input" not working - -Version 1.04a released: - -- Fixed issue with empty trays -- Added settings dialog - -Version 1.04 released: - -- Behind-the-scenes fixes and formatting -- Better checks for external programs -- Automatically changing disc information -- Custom parameters (and parameter validation) -- Automatic drive speed selection -- Automatic submission information creation -- Add ability to stop a dump from the UI - --------------------------------------------------------------------------- -2018-06-08 --------------------------------------------------------------------------- - -Version 1.03 released: - -- edccchk now run on all CD-Roms -- Discs unsupported by Windows are now regonized -- Extra \ when accepting default save has been removed. - --------------------------------------------------------------------------- -2018-05-18 --------------------------------------------------------------------------- - -Version 1.02b released: - -- Fixed XBOX One and PS4 Drive Speed issue. (1.02) -- Started implementing DiscImageCreator Path selection. (1.02) -- Conforming my naming for objects and variable. (1.02) -- Added missing DLL (1.02b) - --------------------------------------------------------------------------- -2018-05-14 --------------------------------------------------------------------------- - -Version 1.01d released +**Dizzzy** - Concept/Ideas/Beta tester diff --git a/Utilities/Converters.cs b/Utilities/Converters.cs index 5674c7b0..26145877 100644 --- a/Utilities/Converters.cs +++ b/Utilities/Converters.cs @@ -1,42 +1,43 @@ using System; using System.Collections.Generic; using System.Linq; +using DICUI.External; namespace DICUI.Utilities { public static class Converters { /// - /// Get the DiscType associated with a given base command + /// Get the MediaType associated with a given base command /// /// String value to check - /// DiscType if possible, null on error + /// MediaType if possible, null on error /// This takes the "safe" route by assuming the larger of any given format - public static DiscType? BaseCommmandToDiscType(string baseCommand) + public static MediaType? BaseCommmandToMediaType(string baseCommand) { switch (baseCommand) { case DICCommands.CompactDisc: - return DiscType.CD; + return MediaType.CD; case DICCommands.GDROM: case DICCommands.Swap: - return DiscType.GDROM; + return MediaType.GDROM; case DICCommands.DigitalVideoDisc: case DICCommands.XBOX: - return DiscType.DVD; + return MediaType.DVD; case DICCommands.BluRay: - return DiscType.BluRay; + return MediaType.BluRay; // Non-optical case DICCommands.Floppy: - return DiscType.Floppy; + return MediaType.Floppy; default: return null; } } /// - /// Get the most common known system for a given DiscType + /// Get the most common known system for a given MediaType /// /// String value to check /// KnownSystem if possible, null on error @@ -63,100 +64,100 @@ namespace DICUI.Utilities /// /// Get the default extension for a given disc type /// - /// DiscType value to check + /// MediaType value to check /// Valid extension (with leading '.'), null on error - public static string DiscTypeToExtension(DiscType? type) + public static string MediaTypeToExtension(MediaType? type) { switch (type) { - case DiscType.CD: - case DiscType.GDROM: - case DiscType.Cartridge: + case MediaType.CD: + case MediaType.GDROM: + case MediaType.Cartridge: return ".bin"; - case DiscType.DVD: - case DiscType.HDDVD: - case DiscType.BluRay: - case DiscType.WiiOpticalDisc: - case DiscType.UMD: + case MediaType.DVD: + case MediaType.HDDVD: + case MediaType.BluRay: + case MediaType.WiiOpticalDisc: + case MediaType.UMD: return ".iso"; - case DiscType.LaserDisc: - case DiscType.GameCubeGameDisc: + case MediaType.LaserDisc: + case MediaType.GameCubeGameDisc: return ".raw"; - case DiscType.WiiUOpticalDisc: + case MediaType.WiiUOpticalDisc: return ".wud"; - case DiscType.Floppy: + case MediaType.Floppy: return ".img"; - case DiscType.Cassette: + case MediaType.Cassette: return ".wav"; - case DiscType.NONE: - case DiscType.CED: + case MediaType.NONE: + case MediaType.CED: default: return null; } } /// - /// Get the string representation of the DiscType enum values + /// Get the string representation of the MediaType enum values /// - /// DiscType value to convert + /// MediaType value to convert /// String representing the value, if possible - public static string DiscTypeToString(DiscType? type) + public static string MediaTypeToString(MediaType? type) { switch (type) { - case DiscType.CD: + case MediaType.CD: return "CD-ROM"; - case DiscType.DVD: + case MediaType.DVD: return "DVD"; - case DiscType.GDROM: + case MediaType.GDROM: return "GD-ROM"; - case DiscType.HDDVD: + case MediaType.HDDVD: return "HD-DVD"; - case DiscType.BluRay: + case MediaType.BluRay: return "BluRay"; - case DiscType.LaserDisc: + case MediaType.LaserDisc: return "LaserDisc"; - case DiscType.CED: + case MediaType.CED: return "CED"; - case DiscType.GameCubeGameDisc: + case MediaType.GameCubeGameDisc: return "GameCube Game"; - case DiscType.WiiOpticalDisc: + case MediaType.WiiOpticalDisc: return "Wii Optical"; - case DiscType.WiiUOpticalDisc: + case MediaType.WiiUOpticalDisc: return "Wii U Optical"; - case DiscType.UMD: + case MediaType.UMD: return "UMD"; - case DiscType.Cartridge: + case MediaType.Cartridge: return "Cartridge"; - case DiscType.Cassette: + case MediaType.Cassette: return "Cassette Tape"; - case DiscType.Floppy: + case MediaType.Floppy: return "Floppy Disk"; - case DiscType.NONE: + case MediaType.NONE: default: return "Unknown"; } } /// - /// Get the DIC command to be used for a given DiscType + /// Get the DIC command to be used for a given MediaType /// - /// DiscType value to check + /// MediaType value to check /// String containing the command, null on error - public static string KnownSystemAndDiscTypeToBaseCommand(KnownSystem? sys, DiscType? type) + public static string KnownSystemAndMediaTypeToBaseCommand(KnownSystem? sys, MediaType? type) { switch (type) { - case DiscType.CD: + case MediaType.CD: if (sys == KnownSystem.MicrosoftXBOX) { return DICCommands.XBOX; } return DICCommands.CompactDisc; - case DiscType.DVD: + case MediaType.DVD: if (sys == KnownSystem.MicrosoftXBOX || sys == KnownSystem.MicrosoftXBOX360XDG2 || sys == KnownSystem.MicrosoftXBOX360XDG3) @@ -164,25 +165,25 @@ namespace DICUI.Utilities return DICCommands.XBOX; } return DICCommands.DigitalVideoDisc; - case DiscType.GDROM: + case MediaType.GDROM: return DICCommands.GDROM; - case DiscType.HDDVD: + case MediaType.HDDVD: return null; - case DiscType.BluRay: + case MediaType.BluRay: return DICCommands.BluRay; // Special Formats - case DiscType.GameCubeGameDisc: + case MediaType.GameCubeGameDisc: return DICCommands.DigitalVideoDisc; - case DiscType.WiiOpticalDisc: + case MediaType.WiiOpticalDisc: return null; - case DiscType.WiiUOpticalDisc: + case MediaType.WiiUOpticalDisc: return null; - case DiscType.UMD: + case MediaType.UMD: return null; // Non-optical - case DiscType.Floppy: + case MediaType.Floppy: return DICCommands.Floppy; default: @@ -194,13 +195,13 @@ namespace DICUI.Utilities /// Get list of default parameters for a given system and disc type /// /// KnownSystem value to check - /// DiscType value to check + /// MediaType value to check /// List of strings representing the parameters - public static List KnownSystemAndDiscTypeToParameters(KnownSystem? sys, DiscType? type) + public static List KnownSystemAndMediaTypeToParameters(KnownSystem? sys, MediaType? type) { - // First check to see if the combination of system and disctype is valid - List> validTypes = Validation.GetValidDiscTypes(sys); - if (!validTypes.Select(i => i.Item2).Contains(type)) + // First check to see if the combination of system and MediaType is valid + var validTypes = Validation.GetValidMediaTypes(sys); + if (!validTypes.ContainsKey(MediaTypeToString(type))) { return null; } @@ -209,7 +210,7 @@ namespace DICUI.Utilities List parameters = new List(); switch (type) { - case DiscType.CD: + case MediaType.CD: parameters.Add(DICFlags.C2Opcode); parameters.Add("20"); switch (sys) @@ -228,33 +229,33 @@ namespace DICUI.Utilities break; } break; - case DiscType.DVD: + case MediaType.DVD: // Currently no defaults set break; - case DiscType.GDROM: + case MediaType.GDROM: parameters.Add(DICFlags.C2Opcode); parameters.Add("20"); break; - case DiscType.HDDVD: + case MediaType.HDDVD: break; - case DiscType.BluRay: + case MediaType.BluRay: // Currently no defaults set break; // Special Formats - case DiscType.GameCubeGameDisc: + case MediaType.GameCubeGameDisc: parameters.Add(DICFlags.Raw); break; - case DiscType.WiiOpticalDisc: + case MediaType.WiiOpticalDisc: // Currently no defaults set break; - case DiscType.WiiUOpticalDisc: + case MediaType.WiiUOpticalDisc: // Currently no defaults set break; - case DiscType.UMD: + case MediaType.UMD: break; // Non-optical - case DiscType.Floppy: + case MediaType.Floppy: // Currently no defaults set break; } diff --git a/Utilities/DumpInformation.cs b/Utilities/DumpInformation.cs index 027c0cbd..a564f13f 100644 --- a/Utilities/DumpInformation.cs +++ b/Utilities/DumpInformation.cs @@ -52,9 +52,9 @@ namespace DICUI.Utilities /// /// Base directory to use /// Base filename to use - /// DiscType value to check + /// MediaType value to check /// - public static bool FoundAllFiles(string outputDirectory, string outputFilename, DiscType? type) + public static bool FoundAllFiles(string outputDirectory, string outputFilename, MediaType? type) { // First, sanitized the output filename to strip off any potential extension outputFilename = Path.GetFileNameWithoutExtension(outputFilename); @@ -63,8 +63,8 @@ namespace DICUI.Utilities string combinedBase = Path.Combine(outputDirectory, outputFilename); switch (type) { - case DiscType.CD: - case DiscType.GDROM: // TODO: Verify GD-ROM outputs this + case MediaType.CD: + case MediaType.GDROM: // TODO: Verify GD-ROM outputs this return File.Exists(combinedBase + ".c2") && File.Exists(combinedBase + ".ccd") && File.Exists(combinedBase + ".cue") @@ -85,13 +85,13 @@ namespace DICUI.Utilities && File.Exists(combinedBase + "_subIntention.txt") && File.Exists(combinedBase + "_subReadable.txt") && File.Exists(combinedBase + "_volDesc.txt"); - case DiscType.DVD: - case DiscType.HDDVD: - case DiscType.BluRay: - case DiscType.GameCubeGameDisc: - case DiscType.WiiOpticalDisc: - case DiscType.WiiUOpticalDisc: - case DiscType.UMD: + case MediaType.DVD: + case MediaType.HDDVD: + case MediaType.BluRay: + case MediaType.GameCubeGameDisc: + case MediaType.WiiOpticalDisc: + case MediaType.WiiUOpticalDisc: + case MediaType.UMD: return File.Exists(combinedBase + ".dat") && File.Exists(combinedBase + "_cmd.txt") && File.Exists(combinedBase + "_disc.txt") @@ -99,7 +99,7 @@ namespace DICUI.Utilities && File.Exists(combinedBase + "_mainError.txt") && File.Exists(combinedBase + "_mainInfo.txt") && File.Exists(combinedBase + "_volDesc.txt"); - case DiscType.Floppy: + case MediaType.Floppy: return File.Exists(combinedBase + ".dat") && File.Exists(combinedBase + "_cmd.txt") && File.Exists(combinedBase + "_disc.txt"); @@ -115,11 +115,11 @@ namespace DICUI.Utilities /// Base directory to use /// Base filename to use /// KnownSystem value to check - /// DiscType value to check + /// MediaType value to check /// Drive letter to check /// Dictionary containing mapped output values, null on error /// TODO: Make sure that all special formats are accounted for - public static Dictionary ExtractOutputInformation(string outputDirectory, string outputFilename, KnownSystem? sys, DiscType? type, char driveLetter) + public static Dictionary ExtractOutputInformation(string outputDirectory, string outputFilename, KnownSystem? sys, MediaType? type, char driveLetter) { // First, sanitized the output filename to strip off any potential extension outputFilename = Path.GetFileNameWithoutExtension(outputFilename); @@ -138,7 +138,7 @@ namespace DICUI.Utilities { Template.DiscNumberField, Template.OptionalValue }, { Template.DiscTitleField, Template.OptionalValue }, { Template.SystemField, Converters.KnownSystemToString(sys) }, - { Template.MediaTypeField, Converters.DiscTypeToString(type) }, + { Template.MediaTypeField, Converters.MediaTypeToString(type) }, { Template.CategoryField, "Games" }, { Template.RegionField, "World (CHANGE THIS)" }, { Template.LanguagesField, "Klingon (CHANGE THIS)" }, @@ -151,11 +151,11 @@ namespace DICUI.Utilities { Template.DATField, GetDatfile(combinedBase + ".dat") }, }; - // Now we want to do a check by DiscType and extract all required info + // Now we want to do a check by MediaType and extract all required info switch (type) { - case DiscType.CD: - case DiscType.GDROM: // TODO: Verify GD-ROM outputs this + case MediaType.CD: + case MediaType.GDROM: // TODO: Verify GD-ROM outputs this mappings[Template.MasteringRingField] = Template.RequiredIfExistsValue; mappings[Template.MasteringSIDField] = Template.RequiredIfExistsValue; mappings[Template.MouldSIDField] = Template.RequiredIfExistsValue; @@ -206,9 +206,9 @@ namespace DICUI.Utilities } break; - case DiscType.DVD: - case DiscType.HDDVD: - case DiscType.BluRay: + case MediaType.DVD: + case MediaType.HDDVD: + case MediaType.BluRay: string layerbreak = GetLayerbreak(combinedBase + "_disc.txt"); // If we have a single-layer disc @@ -216,10 +216,10 @@ namespace DICUI.Utilities { switch (type) { - case DiscType.DVD: + case MediaType.DVD: mappings[Template.MediaTypeField] += "-5"; break; - case DiscType.BluRay: + case MediaType.BluRay: mappings[Template.MediaTypeField] += "-25"; break; } @@ -235,10 +235,10 @@ namespace DICUI.Utilities { switch (type) { - case DiscType.DVD: + case MediaType.DVD: mappings[Template.MediaTypeField] += "-9"; break; - case DiscType.BluRay: + case MediaType.BluRay: mappings[Template.MediaTypeField] += "-50"; break; } @@ -772,10 +772,10 @@ namespace DICUI.Utilities /// /// Information dictionary that should contain normalized values /// KnownSystem value to check - /// DiscType value to check + /// MediaType value to check /// List of strings representing each line of an output file, null on error /// TODO: Get full list of customizable stuff for other systems - public static List FormatOutputData(Dictionary info, KnownSystem? sys, DiscType? type) + public static List FormatOutputData(Dictionary info, KnownSystem? sys, MediaType? type) { // Check to see if the inputs are valid if (info == null) @@ -809,11 +809,11 @@ namespace DICUI.Utilities output.Add("Ringcode Information:"); switch (type) { - case DiscType.CD: - case DiscType.GDROM: - case DiscType.DVD: - case DiscType.HDDVD: - case DiscType.BluRay: + case MediaType.CD: + case MediaType.GDROM: + case MediaType.DVD: + case MediaType.HDDVD: + case MediaType.BluRay: // If we have a dual-layer disc if (info.ContainsKey(Template.LayerbreakField)) { @@ -847,8 +847,8 @@ namespace DICUI.Utilities } switch (type) { - case DiscType.CD: - case DiscType.GDROM: + case MediaType.CD: + case MediaType.GDROM: output.Add(Template.ErrorCountField + ": " + info[Template.ErrorCountField]); break; } @@ -870,8 +870,8 @@ namespace DICUI.Utilities } switch (type) { - case DiscType.DVD: - case DiscType.BluRay: + case MediaType.DVD: + case MediaType.BluRay: // If we have a dual-layer disc if (info.ContainsKey(Template.LayerbreakField)) { @@ -905,8 +905,8 @@ namespace DICUI.Utilities } switch (type) { - case DiscType.CD: - case DiscType.GDROM: + case MediaType.CD: + case MediaType.GDROM: output.Add(Template.CuesheetField + ":"); output.Add(""); output.AddRange(info[Template.CuesheetField].Split('\n')); output.Add(""); output.Add(Template.WriteOffsetField + ": " + info[Template.WriteOffsetField]); output.Add(""); diff --git a/Utilities/Validation.cs b/Utilities/Validation.cs index 6f436578..c5882391 100644 --- a/Utilities/Validation.cs +++ b/Utilities/Validation.cs @@ -4,118 +4,117 @@ using System.IO; using System.Linq; using System.Management; using System.Text.RegularExpressions; +using DICUI.External; namespace DICUI.Utilities { public static class Validation { /// - /// Get a list of valid DiscTypes for a given system matched to their respective names + /// Get a list of valid MediaTypes for a given system matched to their respective names /// /// KnownSystem value to check - /// DiscTypes matched to enums, if possible + /// MediaTypes matched to enums, if possible /// - /// This returns a List of Tuples whose structure is as follows: - /// Item 1: Printable name - /// Item 2: DiscType mapping /// If something has a "string, null" value, it should be assumed that it is a separator /// - public static List> GetValidDiscTypes(KnownSystem? sys) + public static OrderedDictionary GetValidMediaTypes(KnownSystem? sys) { - List types = new List(); + var types = new List(); + var typesDict = new OrderedDictionary(); switch (sys) { #region Consoles case KnownSystem.BandaiPlaydiaQuickInteractiveSystem: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.BandaiApplePippin: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.CommodoreAmigaCD32: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.CommodoreAmigaCDTV: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.MattelHyperscan: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.MicrosoftXBOX: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); break; case KnownSystem.MicrosoftXBOX360XDG2: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); break; case KnownSystem.MicrosoftXBOX360XDG3: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); - types.Add(DiscType.HDDVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); + types.Add(MediaType.HDDVD); break; case KnownSystem.MicrosoftXBOXOne: - types.Add(DiscType.BluRay); + types.Add(MediaType.BluRay); break; case KnownSystem.NECPCEngineTurboGrafxCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NECPCFX: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NintendoGameCube: - types.Add(DiscType.GameCubeGameDisc); + types.Add(MediaType.GameCubeGameDisc); break; case KnownSystem.NintendoWii: - types.Add(DiscType.WiiOpticalDisc); + types.Add(MediaType.WiiOpticalDisc); break; case KnownSystem.NintendoWiiU: - types.Add(DiscType.WiiUOpticalDisc); + types.Add(MediaType.WiiUOpticalDisc); break; case KnownSystem.Panasonic3DOInteractiveMultiplayer: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.PhilipsCDi: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SegaCDMegaCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SegaDreamcast: - types.Add(DiscType.GDROM); + types.Add(MediaType.GDROM); break; case KnownSystem.SegaSaturn: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SNKNeoGeoCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SonyPlayStation: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SonyPlayStation2: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); break; case KnownSystem.SonyPlayStation3: - types.Add(DiscType.BluRay); + types.Add(MediaType.BluRay); break; case KnownSystem.SonyPlayStation4: - types.Add(DiscType.BluRay); + types.Add(MediaType.BluRay); break; case KnownSystem.SonyPlayStationPortable: - types.Add(DiscType.UMD); + types.Add(MediaType.UMD); break; case KnownSystem.VMLabsNuon: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.VTechVFlashVSmilePro: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.ZAPiTGamesGameWaveFamilyEntertainmentSystem: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; #endregion @@ -123,32 +122,32 @@ namespace DICUI.Utilities #region Computers case KnownSystem.AcornArchimedes: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.AppleMacintosh: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); - types.Add(DiscType.Floppy); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); + types.Add(MediaType.Floppy); break; case KnownSystem.CommodoreAmigaCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.FujitsuFMTowns: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.IBMPCCompatible: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); - types.Add(DiscType.Floppy); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); + types.Add(MediaType.Floppy); break; case KnownSystem.NECPC88: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NECPC98: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SharpX68000: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; #endregion @@ -156,169 +155,169 @@ namespace DICUI.Utilities #region Arcade case KnownSystem.AmigaCUBOCD32: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.AmericanLaserGames3DO: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.Atari3DO: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.Atronic: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.AUSCOMSystem1: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.BallyGameMagic: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.CapcomCPSystemIII: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.GlobalVRVarious: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.GlobalVRVortek: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.GlobalVRVortekV3: - types.Add(DiscType.DVD); // TODO: Confirm + types.Add(MediaType.DVD); // TODO: Confirm break; case KnownSystem.ICEPCHardware: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.IncredibleTechnologiesEagle: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.IncredibleTechnologiesVarious: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); break; case KnownSystem.KonamiFirebeat: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.KonamiGVSystem: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.KonamiM2: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.KonamiPython: - types.Add(DiscType.DVD); // TODO: Confirm + types.Add(MediaType.DVD); // TODO: Confirm break; case KnownSystem.KonamiPython2: - types.Add(DiscType.DVD); // TODO: Confirm + types.Add(MediaType.DVD); // TODO: Confirm break; case KnownSystem.KonamiSystem573: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.KonamiTwinkle: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.KonamiVarious: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); break; case KnownSystem.MeritIndustriesBoardwalk: - types.Add(DiscType.CD); // TODO: Confirm + types.Add(MediaType.CD); // TODO: Confirm break; case KnownSystem.MeritIndustriesMegaTouchAurora: - types.Add(DiscType.CD); // TODO: Confirm + types.Add(MediaType.CD); // TODO: Confirm break; case KnownSystem.MeritIndustriesMegaTouchForce: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); break; case KnownSystem.MeritIndustriesMegaTouchION: - types.Add(DiscType.CD); - types.Add(DiscType.DVD); + types.Add(MediaType.CD); + types.Add(MediaType.DVD); break; case KnownSystem.MeritIndustriesMegaTouchMaxx: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.MeritIndustriesMegaTouchXL: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NamcoCapcomSystem256: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.NamcoCapcomTaitoSystem246: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.NamcoSegaNintendoTriforce: - types.Add(DiscType.GDROM); + types.Add(MediaType.GDROM); break; case KnownSystem.NamcoSystem12: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NamcoSystem357: - types.Add(DiscType.DVD); - types.Add(DiscType.BluRay); + types.Add(MediaType.DVD); + types.Add(MediaType.BluRay); break; case KnownSystem.NewJatreCDi: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NichibutsuHighRateSystem: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NichibutsuSuperCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.NichibutsuXRateSystem: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.PhotoPlayVarious: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.RawThrillsVarious: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.SegaChihiro: - types.Add(DiscType.GDROM); + types.Add(MediaType.GDROM); break; case KnownSystem.SegaEuropaR: - types.Add(DiscType.DVD); // TODO: Confirm + types.Add(MediaType.DVD); // TODO: Confirm break; case KnownSystem.SegaLindbergh: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.SegaNaomi: - types.Add(DiscType.GDROM); + types.Add(MediaType.GDROM); break; case KnownSystem.SegaNaomi2: - types.Add(DiscType.GDROM); + types.Add(MediaType.GDROM); break; case KnownSystem.SegaNu: - types.Add(DiscType.DVD); - types.Add(DiscType.BluRay); + types.Add(MediaType.DVD); + types.Add(MediaType.BluRay); break; case KnownSystem.SegaRingEdge: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.SegaRingEdge2: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.SegaRingWide: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.SegaSTV: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SegaSystem32: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.SeibuCATSSystem: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.TABAustriaQuizard: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.TandyMemorexVisualInformationSystem: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.TsunamiTsuMoMultiGameMotionSystem: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; #endregion @@ -326,51 +325,57 @@ namespace DICUI.Utilities #region Others case KnownSystem.AudioCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.BDVideo: - types.Add(DiscType.BluRay); + types.Add(MediaType.BluRay); break; case KnownSystem.DVDVideo: - types.Add(DiscType.DVD); + types.Add(MediaType.DVD); break; case KnownSystem.EnhancedCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.HDDVDVideo: - types.Add(DiscType.HDDVD); + types.Add(MediaType.HDDVD); break; case KnownSystem.PalmOS: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.PhilipsCDiDigitalVideo: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.PhotoCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.PlayStationGameSharkUpdates: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.TaoiKTV: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.TomyKissSite: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; case KnownSystem.VideoCD: - types.Add(DiscType.CD); + types.Add(MediaType.CD); break; #endregion case KnownSystem.NONE: default: - types.Add(DiscType.NONE); + types.Add(MediaType.NONE); break; } - return types.Select(i => new Tuple(Converters.DiscTypeToString(i), i)).ToList(); + // Populate the dictionary + foreach (var type in types) + { + typesDict.Add(Converters.MediaTypeToString(type), type); + } + + return typesDict; } /// @@ -378,15 +383,12 @@ namespace DICUI.Utilities /// /// Systems matched to enums, if possible /// - /// This returns a List of Tuples whose structure is as follows: - /// Item 1: Printable name - /// Item 2: KnownSystem mapping /// If something has a "string, null" value, it should be assumed that it is a separator /// /// TODO: Figure out a way that the sections can be generated more automatically - public static List> CreateListOfSystems() + public static OrderedDictionary CreateListOfSystems() { - List> mapping = new List>(); + var systemsDict = new OrderedDictionary(); foreach (KnownSystem system in Enum.GetValues(typeof(KnownSystem))) { @@ -395,29 +397,29 @@ namespace DICUI.Utilities { // Consoles section case KnownSystem.BandaiPlaydiaQuickInteractiveSystem: - mapping.Add(new Tuple("---------- Consoles ----------", null)); + systemsDict.Add("---------- Consoles ----------", null); break; // Computers section case KnownSystem.AcornArchimedes: - mapping.Add(new Tuple("---------- Computers ----------", null)); + systemsDict.Add("---------- Computers ----------", null); break; // Arcade section case KnownSystem.AmigaCUBOCD32: - mapping.Add(new Tuple("---------- Arcade ----------", null)); + systemsDict.Add("---------- Arcade ----------", null); break; // Other section case KnownSystem.AudioCD: - mapping.Add(new Tuple("---------- Others ----------", null)); + systemsDict.Add("---------- Others ----------", null); break; } - mapping.Add(new Tuple(Converters.KnownSystemToString(system), system)); + systemsDict.Add(Converters.KnownSystemToString(system), system); } - return mapping; + return systemsDict; } /// @@ -427,15 +429,11 @@ namespace DICUI.Utilities /// /// https://stackoverflow.com/questions/3060796/how-to-distinguish-between-usb-and-floppy-devices?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa /// https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx - /// This returns a List of Tuples whose structure is as follows: - /// Item 1: Drive letter - /// Item 2: Volume label - /// Item 3: (True for floppy drive, false otherwise) /// - public static List> CreateListOfDrives() + public static OrderedDictionary CreateListOfDrives() { // Get the floppy drives - List> floppyDrives = new List>(); + var floppyDrives = new List>(); try { ManagementObjectSearcher searcher = @@ -449,7 +447,7 @@ namespace DICUI.Utilities if (mediaType != null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22))) { char devId = queryObj["DeviceID"].ToString()[0]; - floppyDrives.Add(new Tuple(devId, "FLOPPY", true)); + floppyDrives.Add(new KeyValuePair(devId, UIElements.FloppyDriveString)); } } } @@ -459,14 +457,23 @@ namespace DICUI.Utilities } // Get the optical disc drives - List> discDrives = DriveInfo.GetDrives() + List> discDrives = DriveInfo.GetDrives() .Where(d => d.DriveType == DriveType.CDRom && d.IsReady) - .Select(d => new Tuple(d.Name[0], d.VolumeLabel, false)) + .Select(d => new KeyValuePair(d.Name[0], d.VolumeLabel)) .ToList(); - // Add the two lists together, order, and return + // Add the two lists together and order floppyDrives.AddRange(discDrives); - return floppyDrives.OrderBy(i => i.Item1).ToList(); + floppyDrives = floppyDrives.OrderBy(i => i.Key).ToList(); + + // Add to the ordered dictionary and return + var drivesDict = new OrderedDictionary(); + foreach (var drive in floppyDrives) + { + drivesDict.Add(drive.Key, drive.Value); + } + + return drivesDict; } /// @@ -1011,12 +1018,12 @@ namespace DICUI.Utilities /// Determine the base flags to use for checking a commandline /// /// Parameters as a string to check - /// Output nullable DiscType containing the found DiscType, if possible + /// Output nullable MediaType containing the found MediaType, if possible /// Output nullable KnownSystem containing the found KnownSystem, if possible /// Output string containing the found drive letter /// Output string containing the found path /// False on error (and all outputs set to null), true otherwise - public static bool DetermineFlags(string parameters, out DiscType? type, out KnownSystem? system, out string letter, out string path) + public static bool DetermineFlags(string parameters, out MediaType? type, out KnownSystem? system, out string letter, out string path) { // Populate all output variables with null type = null; system = null; letter = null; path = null; @@ -1035,7 +1042,7 @@ namespace DICUI.Utilities .Select(m => m.Value) .ToList(); - type = Converters.BaseCommmandToDiscType(parts[0]); + type = Converters.BaseCommmandToMediaType(parts[0]); system = Converters.BaseCommandToKnownSystem(parts[0]); // Determine what the commandline should look like given the first item @@ -1065,20 +1072,20 @@ namespace DICUI.Utilities // Special case for GameCube/Wii if (parts.Contains(DICFlags.Raw)) { - type = DiscType.GameCubeGameDisc; + type = MediaType.GameCubeGameDisc; system = KnownSystem.NintendoGameCube; } // Special case for PlayStation else if (parts.Contains(DICFlags.NoFixSubQLibCrypt) || parts.Contains(DICFlags.ScanAntiMod)) { - type = DiscType.CD; + type = MediaType.CD; system = KnownSystem.SonyPlayStation; } // Special case for Saturn else if (parts.Contains(DICFlags.SeventyFour)) { - type = DiscType.CD; + type = MediaType.CD; system = KnownSystem.SegaSaturn; }