2023-07-30 22:06:48 -04:00
|
|
|
using System;
|
2023-07-30 22:59:04 -04:00
|
|
|
using System.Linq;
|
2023-07-30 22:06:48 -04:00
|
|
|
using SabreTools.Core;
|
|
|
|
|
using SabreTools.Core.Tools;
|
|
|
|
|
using SabreTools.DatItems;
|
|
|
|
|
using SabreTools.DatItems.Formats;
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.DatFiles.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents parsing a Logiqx-derived DAT
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal partial class Logiqx : DatFile
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
// Deserialize the input file
|
2023-09-11 01:20:21 -04:00
|
|
|
var metadataFile = new Serialization.Files.Logiqx().Deserialize(filename);
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
// Convert the header to the internal format
|
|
|
|
|
ConvertHeader(metadataFile, keep);
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
// Convert the game data to the internal format
|
|
|
|
|
ConvertGames(metadataFile?.Game, filename, indexId, statsOnly);
|
|
|
|
|
|
|
|
|
|
// Convert the dir data to the internal format
|
|
|
|
|
ConvertDirs(metadataFile?.Dir, filename, indexId, statsOnly);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
|
|
|
|
catch (Exception ex) when (!throwOnError)
|
|
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
string message = $"'{filename}' - An error occurred during parsing";
|
|
|
|
|
logger.Error(ex, message);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
2023-07-30 22:59:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Converters
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert header information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="datafile">Deserialized model to convert</param>
|
|
|
|
|
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
|
|
|
|
private void ConvertHeader(Models.Logiqx.Datafile? datafile, bool keep)
|
|
|
|
|
{
|
|
|
|
|
// If the datafile is missing, we can't do anything
|
|
|
|
|
if (datafile == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Header.Build ??= datafile.Build;
|
|
|
|
|
Header.Debug ??= datafile.Debug.AsYesNo();
|
|
|
|
|
// SchemaLocation is specifically skipped
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
ConvertHeader(datafile.Header, keep);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// Convert header information
|
2023-07-30 22:06:48 -04:00
|
|
|
/// </summary>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <param name="header">Deserialized model to convert</param>
|
2023-07-30 22:06:48 -04:00
|
|
|
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
2023-07-30 22:59:04 -04:00
|
|
|
private void ConvertHeader(Models.Logiqx.Header? header, bool keep)
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
// If the header is missing, we can't do anything
|
|
|
|
|
if (header == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Header.NoIntroID ??= header.Id;
|
|
|
|
|
Header.Name ??= header.Name;
|
|
|
|
|
Header.Description ??= header.Description;
|
|
|
|
|
Header.RootDir ??= header.RootDir;
|
|
|
|
|
Header.Category ??= header.Category;
|
|
|
|
|
Header.Version ??= header.Version;
|
|
|
|
|
Header.Date ??= header.Date;
|
|
|
|
|
Header.Author ??= header.Author;
|
|
|
|
|
Header.Email ??= header.Email;
|
|
|
|
|
Header.Homepage ??= header.Homepage;
|
|
|
|
|
Header.Url ??= header.Url;
|
|
|
|
|
Header.Comment ??= header.Comment;
|
|
|
|
|
Header.Type ??= header.Type;
|
|
|
|
|
|
|
|
|
|
ConvertSubheader(header.ClrMamePro);
|
|
|
|
|
ConvertSubheader(header.RomCenter);
|
|
|
|
|
|
|
|
|
|
// Handle implied SuperDAT
|
2023-08-10 23:22:14 -04:00
|
|
|
if (header.Name?.Contains(" - SuperDAT") == true && keep)
|
2023-07-30 22:59:04 -04:00
|
|
|
Header.Type ??= "SuperDAT";
|
|
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert subheader information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="clrMamePro">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertSubheader(Models.Logiqx.ClrMamePro? clrMamePro)
|
|
|
|
|
{
|
|
|
|
|
// If the subheader is missing, we can't do anything
|
|
|
|
|
if (clrMamePro == null)
|
2023-07-30 22:06:48 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
Header.HeaderSkipper ??= clrMamePro.Header;
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
if (Header.ForceMerging == MergingFlag.None)
|
2024-03-05 15:24:11 -05:00
|
|
|
Header.ForceMerging = clrMamePro.ForceMerging.AsEnumValue<MergingFlag>();
|
2023-07-30 22:59:04 -04:00
|
|
|
if (Header.ForceNodump == NodumpFlag.None)
|
2024-03-05 15:24:11 -05:00
|
|
|
Header.ForceNodump = clrMamePro.ForceNodump.AsEnumValue<NodumpFlag>();
|
2023-07-30 22:59:04 -04:00
|
|
|
if (Header.ForcePacking == PackingFlag.None)
|
2024-03-05 15:24:11 -05:00
|
|
|
Header.ForcePacking = clrMamePro.ForcePacking.AsEnumValue<PackingFlag>();
|
2023-07-30 22:59:04 -04:00
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert subheader information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="romCenter">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertSubheader(Models.Logiqx.RomCenter? romCenter)
|
|
|
|
|
{
|
|
|
|
|
// If the subheader is missing, we can't do anything
|
|
|
|
|
if (romCenter == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Header.System ??= romCenter.Plugin;
|
|
|
|
|
|
|
|
|
|
if (Header.RomMode == MergingFlag.None)
|
2024-03-05 15:24:11 -05:00
|
|
|
Header.RomMode = romCenter.RomMode.AsEnumValue<MergingFlag>();
|
2023-07-30 22:59:04 -04:00
|
|
|
if (Header.BiosMode == MergingFlag.None)
|
2024-03-05 15:24:11 -05:00
|
|
|
Header.BiosMode = romCenter.BiosMode.AsEnumValue<MergingFlag>();
|
2023-07-30 22:59:04 -04:00
|
|
|
if (Header.SampleMode == MergingFlag.None)
|
2024-03-05 15:24:11 -05:00
|
|
|
Header.SampleMode = romCenter.SampleMode.AsEnumValue<MergingFlag>();
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
Header.LockRomMode ??= romCenter.LockRomMode.AsYesNo();
|
|
|
|
|
Header.LockBiosMode ??= romCenter.LockBiosMode.AsYesNo();
|
|
|
|
|
Header.LockSampleMode ??= romCenter.LockSampleMode.AsYesNo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert dirs information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dirs">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
private void ConvertDirs(Models.Logiqx.Dir[]? dirs, string filename, int indexId, bool statsOnly)
|
|
|
|
|
{
|
|
|
|
|
// If the dir array is missing, we can't do anything
|
|
|
|
|
if (dirs == null || !dirs.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Loop through the dirs and add
|
|
|
|
|
foreach (var dir in dirs)
|
|
|
|
|
{
|
|
|
|
|
ConvertDir(dir, filename, indexId, statsOnly);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// Convert dir information
|
2023-07-30 22:06:48 -04:00
|
|
|
/// </summary>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <param name="dir">Deserialized model to convert</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
2023-07-30 22:06:48 -04:00
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
2023-07-30 22:59:04 -04:00
|
|
|
private void ConvertDir(Models.Logiqx.Dir dir, string filename, int indexId, bool statsOnly)
|
|
|
|
|
{
|
|
|
|
|
// If the game array is missing, we can't do anything
|
|
|
|
|
if (dir.Game == null || !dir.Game.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Loop through the games and add
|
|
|
|
|
foreach (var game in dir.Game)
|
|
|
|
|
{
|
|
|
|
|
ConvertGame(game, filename, indexId, statsOnly, dir.Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert games information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="games">Array of deserialized models to convert</param>
|
2023-07-30 22:06:48 -04:00
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
private void ConvertGames(Models.Logiqx.GameBase[]? games, string filename, int indexId, bool statsOnly)
|
|
|
|
|
{
|
|
|
|
|
// If the game array is missing, we can't do anything
|
|
|
|
|
if (games == null || !games.Any())
|
|
|
|
|
return;
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
// Loop through the games and add
|
|
|
|
|
foreach (var game in games)
|
|
|
|
|
{
|
|
|
|
|
ConvertGame(game, filename, indexId, statsOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert game information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="game">Deserialized model to convert</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
2023-08-10 23:22:14 -04:00
|
|
|
private void ConvertGame(Models.Logiqx.GameBase game, string filename, int indexId, bool statsOnly, string? dirname = null)
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
// If the game is missing, we can't do anything
|
|
|
|
|
if (game == null)
|
2023-07-30 22:06:48 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
// Create the machine for copying information
|
2024-03-09 23:43:43 -05:00
|
|
|
var machine = new Machine();
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.BoardKey, game.Board);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, game.CloneOf);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfIdKey, game.CloneOfId);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, game.Description);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.IdKey, game.Id);
|
|
|
|
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey, game.IsBios.AsYesNo());
|
|
|
|
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey, game.IsDevice.AsYesNo());
|
|
|
|
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsMechanicalKey, game.IsMechanical.AsYesNo());
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey, game.Manufacturer);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, game.Name);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, game.Publisher);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RebuildToKey, game.RebuildTo);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RomKey, game.RomOf);
|
|
|
|
|
machine.SetFieldValue<Runnable>(Models.Metadata.Machine.RunnableKey, game.Runnable.AsEnumValue<Runnable>());
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, game.SampleOf);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey, game.SourceFile);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, game.Year);
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2024-02-28 22:54:56 -05:00
|
|
|
if (!string.IsNullOrEmpty(dirname))
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, $"{dirname}/{machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}");
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2024-02-28 22:54:56 -05:00
|
|
|
#if NETFRAMEWORK
|
|
|
|
|
if (game.Comment != null && game.Comment.Any())
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, string.Join(";", game.Comment));
|
2024-02-28 22:54:56 -05:00
|
|
|
if (game.Category != null && game.Category.Any())
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, string.Join(";", game.Category));
|
2024-02-28 22:54:56 -05:00
|
|
|
#else
|
2023-07-31 12:51:41 -04:00
|
|
|
if (game.Comment != null && game.Comment.Any())
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, string.Join(';', game.Comment));
|
2023-07-31 12:51:41 -04:00
|
|
|
if (game.Category != null && game.Category.Any())
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, string.Join(';', game.Category));
|
2024-02-28 22:54:56 -05:00
|
|
|
#endif
|
2023-07-31 12:51:41 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
if (game.Trurip != null)
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
var trurip = game.Trurip;
|
|
|
|
|
|
|
|
|
|
machine.TitleID = trurip.TitleID;
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, trurip.Publisher);
|
2023-07-30 22:59:04 -04:00
|
|
|
machine.Developer = trurip.Developer;
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, value: trurip.Year);
|
2023-07-30 22:59:04 -04:00
|
|
|
machine.Genre = trurip.Genre;
|
|
|
|
|
machine.Subgenre = trurip.Subgenre;
|
|
|
|
|
machine.Ratings = trurip.Ratings;
|
|
|
|
|
machine.Score = trurip.Score;
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PlayersKey, trurip.Players);
|
2023-07-30 22:59:04 -04:00
|
|
|
machine.Enabled = trurip.Enabled;
|
|
|
|
|
machine.Crc = trurip.CRC.AsYesNo();
|
2024-03-09 23:43:43 -05:00
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey, trurip.Source);
|
|
|
|
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, trurip.CloneOf);
|
2023-07-30 22:59:04 -04:00
|
|
|
machine.RelatedTo = trurip.RelatedTo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if there are any items
|
|
|
|
|
bool containsItems = false;
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
// Loop through each type of item
|
|
|
|
|
ConvertReleases(game.Release, machine, filename, indexId, statsOnly, ref containsItems);
|
|
|
|
|
ConvertBiosSets(game.BiosSet, machine, filename, indexId, statsOnly, ref containsItems);
|
|
|
|
|
ConvertRoms(game.Rom, machine, filename, indexId, statsOnly, ref containsItems);
|
|
|
|
|
ConvertDisks(game.Disk, machine, filename, indexId, statsOnly, ref containsItems);
|
|
|
|
|
ConvertMedia(game.Media, machine, filename, indexId, statsOnly, ref containsItems);
|
|
|
|
|
ConvertDeviceRefs(game.DeviceRef, machine, filename, indexId, statsOnly, ref containsItems);
|
2023-08-01 11:48:28 -04:00
|
|
|
ConvertSamples(game.Sample, machine, filename, indexId, statsOnly, ref containsItems);
|
2023-07-30 22:59:04 -04:00
|
|
|
ConvertArchives(game.Archive, machine, filename, indexId, statsOnly, ref containsItems);
|
2023-08-10 11:35:32 -04:00
|
|
|
ConvertDriver(game.Driver, machine, filename, indexId, statsOnly, ref containsItems);
|
2023-07-30 22:59:04 -04:00
|
|
|
ConvertSoftwareLists(game.SoftwareList, machine, filename, indexId, statsOnly, ref containsItems);
|
|
|
|
|
|
|
|
|
|
// If we had no items, create a Blank placeholder
|
|
|
|
|
if (!containsItems)
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
var blank = new Blank
|
|
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
blank.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(blank, statsOnly);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
2023-07-30 22:59:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert Release information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="releases">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertReleases(Models.Logiqx.Release[]? releases, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the release array is missing, we can't do anything
|
|
|
|
|
if (releases == null || !releases.Any())
|
|
|
|
|
return;
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var release in releases)
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
var item = new Release
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(release.Name);
|
2024-03-09 21:34:26 -05:00
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Release.DateKey, release.Date);
|
|
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.Release.DefaultKey, release.Default?.AsYesNo());
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Release.LanguageKey, release.Language);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Release.RegionKey, release.Region);
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert BiosSet information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="biossets">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertBiosSets(Models.Logiqx.BiosSet[]? biossets, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the biosset array is missing, we can't do anything
|
|
|
|
|
if (biossets == null || !biossets.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var biosset in biossets)
|
|
|
|
|
{
|
|
|
|
|
var item = new BiosSet
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(biosset.Name);
|
2024-03-09 21:34:26 -05:00
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.BiosSet.DefaultKey, biosset.Default?.AsYesNo());
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.BiosSet.DescriptionKey, biosset.Description);
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert Rom information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="roms">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertRoms(Models.Logiqx.Rom[]? roms, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the rom array is missing, we can't do anything
|
|
|
|
|
if (roms == null || !roms.Any())
|
|
|
|
|
return;
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var rom in roms)
|
|
|
|
|
{
|
|
|
|
|
var item = new Rom
|
|
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(rom.Name);
|
2024-03-09 21:34:26 -05:00
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, rom.CRC);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.DateKey, rom.Date);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.HeaderKey, rom.Header);
|
|
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.Rom.InvertedKey, rom.Inverted?.AsYesNo());
|
|
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.Rom.MIAKey, rom.MIA?.AsYesNo());
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.MD5Key, rom.MD5);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.MergeKey, rom.Merge);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.SerialKey, rom.Serial);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, rom.SHA1);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.SHA256Key, rom.SHA256);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.SHA384Key, rom.SHA384);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.SHA512Key, rom.SHA512);
|
|
|
|
|
item.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, NumberHelper.ConvertToInt64(rom.Size));
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.SpamSumKey, rom.SpamSum);
|
|
|
|
|
item.SetFieldValue<ItemStatus?>(Models.Metadata.Rom.StatusKey, rom.Status?.AsEnumValue<ItemStatus>() ?? ItemStatus.NULL);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.xxHash364Key, rom.xxHash364);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Rom.xxHash3128Key, rom.xxHash3128);
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert Disk information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="disks">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertDisks(Models.Logiqx.Disk[]? disks, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the disk array is missing, we can't do anything
|
|
|
|
|
if (disks == null || !disks.Any())
|
|
|
|
|
return;
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var disk in disks)
|
|
|
|
|
{
|
|
|
|
|
var item = new Disk
|
|
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(disk.Name);
|
2024-03-09 21:34:26 -05:00
|
|
|
item.SetFieldValue<ItemStatus>(Models.Metadata.Disk.StatusKey, disk.Status?.AsEnumValue<ItemStatus>() ?? ItemStatus.NULL);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Disk.MD5Key, disk.MD5);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Disk.MergeKey, disk.Merge);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Disk.RegionKey, disk.Region);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Disk.SHA1Key, disk.SHA1);
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
2023-07-30 22:59:04 -04:00
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert Media information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="media">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertMedia(Models.Logiqx.Media[]? media, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the media array is missing, we can't do anything
|
|
|
|
|
if (media == null || !media.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var medium in media)
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
var item = new Media
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:06:48 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(medium.Name);
|
2024-03-09 21:34:26 -05:00
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Media.MD5Key, medium.MD5);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Media.SHA1Key, medium.SHA1);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Media.SHA256Key, medium.SHA256);
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.Media.SpamSumKey, medium.SpamSum);
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert DeviceRef information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="devicerefs">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertDeviceRefs(Models.Logiqx.DeviceRef[]? devicerefs, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the devicerefs array is missing, we can't do anything
|
|
|
|
|
if (devicerefs == null || !devicerefs.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var deviceref in devicerefs)
|
|
|
|
|
{
|
|
|
|
|
var item = new DeviceReference
|
|
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(deviceref.Name);
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// Convert DeviceRef information
|
2023-07-30 22:06:48 -04:00
|
|
|
/// </summary>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <param name="samples">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertSamples(Models.Logiqx.Sample[]? samples, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the samples array is missing, we can't do anything
|
|
|
|
|
if (samples == null || !samples.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var sample in samples)
|
|
|
|
|
{
|
|
|
|
|
var item = new Sample
|
|
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(sample.Name);
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert Archive information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="archives">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertArchives(Models.Logiqx.Archive[]? archives, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2023-07-30 22:59:04 -04:00
|
|
|
// If the archive array is missing, we can't do anything
|
|
|
|
|
if (archives == null || !archives.Any())
|
2023-07-30 22:06:48 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var archive in archives)
|
|
|
|
|
{
|
|
|
|
|
var item = new Archive
|
|
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(archive.Name);
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert Driver information
|
|
|
|
|
/// </summary>
|
2023-08-10 11:35:32 -04:00
|
|
|
/// <param name="driver">Deserialized model to convert</param>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
2023-08-10 11:35:32 -04:00
|
|
|
private void ConvertDriver(Models.Logiqx.Driver? driver, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
2023-07-30 22:59:04 -04:00
|
|
|
{
|
2023-08-10 11:35:32 -04:00
|
|
|
// If the driver is missing, we can't do anything
|
|
|
|
|
if (driver == null)
|
2023-07-30 22:59:04 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
containsItems = true;
|
2023-08-10 11:35:32 -04:00
|
|
|
var item = new Driver
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-08-10 11:35:32 -04:00
|
|
|
};
|
2024-03-09 21:34:26 -05:00
|
|
|
item.SetFieldValue<SupportStatus>(Models.Metadata.Driver.CocktailKey, driver.Cocktail?.AsEnumValue<SupportStatus>() ?? SupportStatus.NULL);
|
|
|
|
|
item.SetFieldValue<SupportStatus>(Models.Metadata.Driver.EmulationKey, driver.Emulation?.AsEnumValue<SupportStatus>() ?? SupportStatus.NULL);
|
|
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.Driver.IncompleteKey, driver.Incomplete.AsYesNo());
|
|
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.Driver.NoSoundHardwareKey, driver.NoSoundHardware.AsYesNo());
|
|
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.Driver.RequiresArtworkKey, driver.RequiresArtwork.AsYesNo());
|
|
|
|
|
item.SetFieldValue<Supported>(Models.Metadata.Driver.SaveStateKey, driver.SaveState?.AsEnumValue<Supported>() ?? Supported.NULL);
|
|
|
|
|
item.SetFieldValue<SupportStatus>(Models.Metadata.Driver.StatusKey, driver.Status?.AsEnumValue<SupportStatus>() ?? SupportStatus.NULL);
|
|
|
|
|
item.SetFieldValue<bool?>(Models.Metadata.Driver.UnofficialKey, driver.Unofficial.AsYesNo());
|
2023-07-30 22:59:04 -04:00
|
|
|
|
2023-08-10 11:35:32 -04:00
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
2023-07-30 22:59:04 -04:00
|
|
|
}
|
|
|
|
|
|
2023-07-31 12:51:41 -04:00
|
|
|
/// <summary>
|
2023-07-30 22:59:04 -04:00
|
|
|
/// Convert SoftwareList information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="softwarelists">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
|
|
|
|
private void ConvertSoftwareLists(Models.Logiqx.SoftwareList[]? softwarelists, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
|
|
|
|
{
|
|
|
|
|
// If the softwarelists array is missing, we can't do anything
|
|
|
|
|
if (softwarelists == null || !softwarelists.Any())
|
|
|
|
|
return;
|
2023-07-30 22:06:48 -04:00
|
|
|
|
2023-07-30 22:59:04 -04:00
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var softwarelist in softwarelists)
|
|
|
|
|
{
|
|
|
|
|
var item = new DatItems.Formats.SoftwareList
|
2023-07-30 22:06:48 -04:00
|
|
|
{
|
2024-03-08 21:12:13 -05:00
|
|
|
Source = new Source { Index = indexId, Name = filename },
|
2023-07-30 22:59:04 -04:00
|
|
|
};
|
2024-03-08 20:42:24 -05:00
|
|
|
item.SetName(softwarelist.Name);
|
2024-03-09 21:34:26 -05:00
|
|
|
item.SetFieldValue<string?>(Models.Metadata.SoftwareList.FilterKey, softwarelist.Filter);
|
|
|
|
|
item.SetFieldValue<SoftwareListStatus>(Models.Metadata.SoftwareList.StatusKey, softwarelist.Status.AsEnumValue<SoftwareListStatus>());
|
|
|
|
|
item.SetFieldValue<string?>(Models.Metadata.SoftwareList.TagKey, softwarelist.Tag);
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-30 22:59:04 -04:00
|
|
|
|
|
|
|
|
#endregion
|
2023-07-30 22:06:48 -04:00
|
|
|
}
|
|
|
|
|
}
|