示例#1
0
 private void UpdateRomFromXml(ProgramSupportFiles supportFiles)
 {
     if ((Rom == null) && (supportFiles.Rom != Rom))
     {
         _rom = supportFiles.Rom;
     }
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of ProgramDescription.
        /// </summary>
        /// <param name="crc">The CRC of the program.</param>
        /// <param name="rom">The ROM file or files.</param>
        /// <param name="programInfo">Additional information about the program.</param>
        public ProgramDescription(uint crc, IRom rom, IProgramInformation programInfo)
        {
            _crc         = crc;
            _rom         = rom;
            _programInfo = new UserSpecifiedProgramInformation(programInfo);
            _xmlVendor   = new MetadataString()
            {
                Text = _programInfo.Vendor
            };
            _name    = _programInfo.GetNameForCrc(crc);
            _xmlName = new MetadataString()
            {
                Text = _name
            };
            _shortName    = programInfo.ShortName;
            _xmlShortName = new MetadataString()
            {
                Text = _shortName
            };
            _programFiles = new ProgramSupportFiles(rom);
            var allIncompatibilities = _programInfo.Crcs.Select(c => c.Incompatibilities);
            var crcData = _programInfo.Crcs.First(c => c.Crc == crc);
            var romSpecificIncompatibilities = crcData.Incompatibilities;

            if ((romSpecificIncompatibilities != IncompatibilityFlags.None) || (allIncompatibilities.Distinct().Count() > 1))
            {
                var incompatibilities = _programInfo.Features.ToIncompatibilityFlags();
                if (romSpecificIncompatibilities != incompatibilities)
                {
                    _features = romSpecificIncompatibilities.ApplyFlagsToProgramFeatures(_programInfo.Features.Clone());
                }
                else
                {
                    _features = programInfo.Features;
                }
            }
            else
            {
                _features = programInfo.Features;
            }
        }
示例#3
0
 /// <summary>
 /// Get an enumerable of the file paths for desired support files.
 /// </summary>
 /// <param name="files">The program support files whose file paths are to be enumerated.</param>
 /// <param name="kinds">The kinds of files to include in the enumeration.</param>
 /// <param name="inclusionFlags">Flags to determine which files to include, such as alternate values.</param>
 /// <returns>An enumerable of the files that were requested.</returns>
 /// <remarks>If the <paramref name="kinds"/> argument is <c>null</c> or empty, the function behaves as if it contains the
 /// <see cref="ProgramFileKind.Rom"/> and <see cref="ProgramFileKind.CfgFile"/> values.</remarks>
 public static IEnumerable <string> GetSupportFilePaths(this ProgramSupportFiles files, IEnumerable <ProgramFileKind> kinds, ProgramSupportFilesInclusionFlags inclusionFlags)
 {
     if ((kinds == null) || !kinds.Any())
     {
         kinds = new[] { ProgramFileKind.Rom, ProgramFileKind.CfgFile };
     }
     if (kinds.Contains(ProgramFileKind.Rom))
     {
         if (!string.IsNullOrEmpty(files.RomImagePath))
         {
             yield return(files.RomImagePath);
         }
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.AlternateRomImagePaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.CfgFile))
     {
         if (!string.IsNullOrEmpty(files.RomConfigurationFilePath))
         {
             yield return(files.RomConfigurationFilePath);
         }
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.AlternateRomConfigurationFilePaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.LuigiFile))
     {
         if (!string.IsNullOrEmpty(files.DefaultLtoFlashDataPath))
         {
             yield return(files.DefaultLtoFlashDataPath);
         }
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             // Access to full list of these is not public
         }
     }
     if (kinds.Contains(ProgramFileKind.ManualText))
     {
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.ManualPaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(files.DefaultManualTextPath))
             {
                 yield return(files.DefaultManualTextPath);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.Box))
     {
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.BoxImagePaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(files.DefaultBoxImagePath))
             {
                 yield return(files.DefaultBoxImagePath);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.Label))
     {
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.LabelImagePaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(files.DefaultLabelImagePath))
             {
                 yield return(files.DefaultLabelImagePath);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.Overlay))
     {
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.OverlayImagePaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(files.DefaultOverlayImagePath))
             {
                 yield return(files.DefaultOverlayImagePath);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.ManualCover))
     {
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.ManualCoverImagePaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(files.DefaultManualImagePath))
             {
                 yield return(files.DefaultManualImagePath);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.SaveData))
     {
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             foreach (var alternate in files.SaveDataPaths.Where(p => !string.IsNullOrEmpty(p)))
             {
                 yield return(alternate);
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(files.DefaultSaveDataPath))
             {
                 yield return(files.DefaultSaveDataPath);
             }
         }
     }
     if (kinds.Contains(ProgramFileKind.Vignette))
     {
         if (!string.IsNullOrEmpty(files.DefaultVignettePath))
         {
             yield return(files.DefaultVignettePath);
         }
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             // Access to full list of these is not public
         }
     }
     if (kinds.Contains(ProgramFileKind.GenericSupportFile))
     {
         if (!string.IsNullOrEmpty(files.DefaultReservedDataPath))
         {
             yield return(files.DefaultReservedDataPath);
         }
         if (inclusionFlags.HasFlag(ProgramSupportFilesInclusionFlags.Alternates))
         {
             // Access to full list of these is not public
         }
     }
 }