mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Convert Logiqx
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
|
||||
namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
@@ -19,15 +16,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Deserialize the input file
|
||||
var metadataFile = new Serialization.Files.Logiqx().Deserialize(filename);
|
||||
var metadata = new Serialization.CrossModel.Logiqx().Serialize(metadataFile);
|
||||
|
||||
// Convert the header to the internal format
|
||||
ConvertHeader(metadataFile, keep);
|
||||
|
||||
// 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);
|
||||
// Convert to the internal format
|
||||
ConvertMetadata(metadata, filename, indexId, statsOnly);
|
||||
}
|
||||
catch (Exception ex) when (!throwOnError)
|
||||
{
|
||||
@@ -133,491 +128,6 @@ namespace SabreTools.DatFiles.Formats
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert dir information
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
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>
|
||||
/// <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 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;
|
||||
|
||||
// Loop through the games and add
|
||||
foreach (var game in games)
|
||||
{
|
||||
ConvertGame(game, filename, indexId, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
private void ConvertGame(Models.Logiqx.GameBase game, string filename, int indexId, bool statsOnly, string? dirname = null)
|
||||
{
|
||||
// If the game is missing, we can't do anything
|
||||
if (game == null)
|
||||
return;
|
||||
|
||||
// Create the machine for copying information
|
||||
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);
|
||||
|
||||
if (!string.IsNullOrEmpty(dirname))
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, $"{dirname}/{machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}");
|
||||
|
||||
#if NETFRAMEWORK
|
||||
if (game.Comment != null && game.Comment.Any())
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, string.Join(";", game.Comment));
|
||||
if (game.Category != null && game.Category.Any())
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, string.Join(";", game.Category));
|
||||
#else
|
||||
if (game.Comment != null && game.Comment.Any())
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, string.Join(';', game.Comment));
|
||||
if (game.Category != null && game.Category.Any())
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, string.Join(';', game.Category));
|
||||
#endif
|
||||
|
||||
if (game.Trurip != null)
|
||||
{
|
||||
var trurip = game.Trurip;
|
||||
|
||||
machine.TitleID = trurip.TitleID;
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, trurip.Publisher);
|
||||
machine.Developer = trurip.Developer;
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, value: trurip.Year);
|
||||
machine.Genre = trurip.Genre;
|
||||
machine.Subgenre = trurip.Subgenre;
|
||||
machine.Ratings = trurip.Ratings;
|
||||
machine.Score = trurip.Score;
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.PlayersKey, trurip.Players);
|
||||
machine.Enabled = trurip.Enabled;
|
||||
machine.Crc = trurip.CRC.AsYesNo();
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey, trurip.Source);
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, trurip.CloneOf);
|
||||
machine.RelatedTo = trurip.RelatedTo;
|
||||
}
|
||||
|
||||
// Check if there are any items
|
||||
bool containsItems = false;
|
||||
|
||||
// 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);
|
||||
ConvertSamples(game.Sample, machine, filename, indexId, statsOnly, ref containsItems);
|
||||
ConvertArchives(game.Archive, machine, filename, indexId, statsOnly, ref containsItems);
|
||||
ConvertDriver(game.Driver, machine, filename, indexId, statsOnly, ref containsItems);
|
||||
ConvertSoftwareLists(game.SoftwareList, machine, filename, indexId, statsOnly, ref containsItems);
|
||||
|
||||
// If we had no items, create a Blank placeholder
|
||||
if (!containsItems)
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
ParseAddHelper(blank, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
|
||||
containsItems = true;
|
||||
foreach (var release in releases)
|
||||
{
|
||||
var item = new Release
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(release.Name);
|
||||
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);
|
||||
|
||||
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
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(biosset.Name);
|
||||
item.SetFieldValue<bool?>(Models.Metadata.BiosSet.DefaultKey, biosset.Default?.AsYesNo());
|
||||
item.SetFieldValue<string?>(Models.Metadata.BiosSet.DescriptionKey, biosset.Description);
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
|
||||
containsItems = true;
|
||||
foreach (var rom in roms)
|
||||
{
|
||||
var item = new Rom
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(rom.Name);
|
||||
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);
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
|
||||
containsItems = true;
|
||||
foreach (var disk in disks)
|
||||
{
|
||||
var item = new Disk
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(disk.Name);
|
||||
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);
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
var item = new Media
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(medium.Name);
|
||||
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);
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(deviceref.Name);
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert DeviceRef information
|
||||
/// </summary>
|
||||
/// <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
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(sample.Name);
|
||||
|
||||
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)
|
||||
{
|
||||
// If the archive array is missing, we can't do anything
|
||||
if (archives == null || !archives.Any())
|
||||
return;
|
||||
|
||||
containsItems = true;
|
||||
foreach (var archive in archives)
|
||||
{
|
||||
var item = new Archive
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(archive.Name);
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert Driver information
|
||||
/// </summary>
|
||||
/// <param name="driver">Deserialized model 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 ConvertDriver(Models.Logiqx.Driver? driver, Machine machine, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
||||
{
|
||||
// If the driver is missing, we can't do anything
|
||||
if (driver == null)
|
||||
return;
|
||||
|
||||
containsItems = true;
|
||||
var item = new Driver
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
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());
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
|
||||
containsItems = true;
|
||||
foreach (var softwarelist in softwarelists)
|
||||
{
|
||||
var item = new DatItems.Formats.SoftwareList
|
||||
{
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(softwarelist.Name);
|
||||
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);
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user