From 2165cd2173cc4e243a29fd602598e926062ae3ec Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 9 Mar 2024 23:52:01 -0500 Subject: [PATCH] Add metadata converter skeleton with TODOs --- SabreTools.DatFiles/MetadataConverter.cs | 824 ++++++++++++++++++++++- SabreTools.DatItems/Formats/Display.cs | 12 + 2 files changed, 803 insertions(+), 33 deletions(-) diff --git a/SabreTools.DatFiles/MetadataConverter.cs b/SabreTools.DatFiles/MetadataConverter.cs index f34dd431..cc28bc09 100644 --- a/SabreTools.DatFiles/MetadataConverter.cs +++ b/SabreTools.DatFiles/MetadataConverter.cs @@ -1,9 +1,11 @@ using System.Linq; -using SabreTools.DatItems; -using SabreTools.Filter; namespace SabreTools.DatFiles { + // TODO: Have the converters return a value OR port functionality to DatFile + // TODO: Figure out if there's a way to condense the various processing methods + // TODO: Convert nested items (e.g. Configuration, DipLocation) + // TODO: Determine which items need to have their values flipped (e.g. Part, DiskArea, DataArea) public static class MetadataConverter { #region Converters @@ -47,38 +49,794 @@ namespace SabreTools.DatFiles return; // Create an internal machine - var machine = new Machine(item); + var machine = new DatItems.Machine(item); - // Process all possible items - /* - AdjusterKey - ArchiveKey - BiosSetKey - ChipKey - ConfigurationKey - DeviceKey - DeviceRefKey - DipSwitchKey - DiskKey - DisplayKey - DriverKey - DumpKey - FeatureKey - InfoKey - InputKey - MediaKey - PartKey - PortKey - RamOptionKey - ReleaseKey - RomKey - SampleKey - SharedFeatKey - SoftwareListKey - SoundKey - TruripKey - VideoKey - */ + // Convert items in the machine + if (item.ContainsKey(Models.Metadata.Machine.AdjusterKey)) + { + var items = item.Read(Models.Metadata.Machine.AdjusterKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.ArchiveKey)) + { + var items = item.Read(Models.Metadata.Machine.ArchiveKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.BiosSetKey)) + { + var items = item.Read(Models.Metadata.Machine.BiosSetKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.ChipKey)) + { + var items = item.Read(Models.Metadata.Machine.ChipKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.ConfigurationKey)) + { + var items = item.Read(Models.Metadata.Machine.ConfigurationKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.DeviceKey)) + { + var items = item.Read(Models.Metadata.Machine.DeviceKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.DeviceRefKey)) + { + var items = item.Read(Models.Metadata.Machine.DeviceRefKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.DipSwitchKey)) + { + var items = item.Read(Models.Metadata.Machine.DipSwitchKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.DiskKey)) + { + var items = item.Read(Models.Metadata.Machine.DiskKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.DisplayKey)) + { + var items = item.Read(Models.Metadata.Machine.DisplayKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.DriverKey)) + { + var items = item.Read(Models.Metadata.Machine.DriverKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.DumpKey)) + { + // TODO: Figure out what this maps to + // var items = item.Read(Models.Metadata.Machine.DumpKey); + // ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.FeatureKey)) + { + var items = item.Read(Models.Metadata.Machine.FeatureKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.InfoKey)) + { + var items = item.Read(Models.Metadata.Machine.InfoKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.InputKey)) + { + var items = item.Read(Models.Metadata.Machine.InputKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.MediaKey)) + { + var items = item.Read(Models.Metadata.Machine.MediaKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.PartKey)) + { + var items = item.Read(Models.Metadata.Machine.PartKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.PortKey)) + { + var items = item.Read(Models.Metadata.Machine.PortKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.RamOptionKey)) + { + var items = item.Read(Models.Metadata.Machine.RamOptionKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.ReleaseKey)) + { + var items = item.Read(Models.Metadata.Machine.ReleaseKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.RomKey)) + { + var items = item.Read(Models.Metadata.Machine.RomKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.SampleKey)) + { + var items = item.Read(Models.Metadata.Machine.SampleKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.SharedFeatKey)) + { + var items = item.Read(Models.Metadata.Machine.SharedFeatKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.SoftwareListKey)) + { + var items = item.Read(Models.Metadata.Machine.SoftwareListKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.SoundKey)) + { + var items = item.Read(Models.Metadata.Machine.SoundKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + if (item.ContainsKey(Models.Metadata.Machine.TruripKey)) + { + // TODO: Figure out what this maps to + } + if (item.ContainsKey(Models.Metadata.Machine.VideoKey)) + { + var items = item.Read(Models.Metadata.Machine.VideoKey); + ProcessItems(items, machine, filename, indexId, statsOnly); + } + } + + /// + /// Convert Adjuster information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Adjuster[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Adjuster(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Archive information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Archive[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Archive(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert BiosSet information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.BiosSet[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.BiosSet(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Chip information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Chip[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Chip(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Configuration information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Configuration[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Configuration(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Device information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Device[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Device(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert DeviceRef information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.DeviceRef[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.DeviceReference(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert DipSwitch information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.DipSwitch[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.DipSwitch(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Disk information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Disk[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Disk(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Display information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Display[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Display(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Driver information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Driver[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Driver(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Feature information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Feature[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Feature(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Info information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Info[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Info(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Input information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Input[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Input(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Media information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Media[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Media(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Part information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Part[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Part(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Port information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Port[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Port(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert RamOption information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.RamOption[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.RamOption(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Release information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Release[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Release(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Rom information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Rom[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Rom(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Sample information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Sample[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Sample(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert SharedFeat information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.SharedFeat[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.SharedFeature(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert SoftwareList information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.SoftwareList[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.SoftwareList(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Sound information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Sound[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Sound(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } + } + + /// + /// Convert Video information + /// + /// Array of internal items to convert + /// Machine to use with the converted items + /// Name of the file to be parsed + /// Index ID for the DAT + /// True to only add item statistics while parsing, false otherwise + private static void ProcessItems(Models.Metadata.Video[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly) + { + // If the array is null or empty, return without processing + if (items == null || items.Length == 0) + return; + + // Loop through the items and add + foreach (var item in items) + { + var datItem = new DatItems.Formats.Display(item) + { + Source = new DatItems.Source { Index = indexId, Name = filename } + }; + datItem.CopyMachineInformation(machine); + //ParseAddHelper(datItem, statsOnly); + } } #endregion diff --git a/SabreTools.DatItems/Formats/Display.cs b/SabreTools.DatItems/Formats/Display.cs index d46e300e..14420c56 100644 --- a/SabreTools.DatItems/Formats/Display.cs +++ b/SabreTools.DatItems/Formats/Display.cs @@ -34,6 +34,18 @@ namespace SabreTools.DatItems.Formats ItemType = ItemType.Display; } + /// + /// Create a Display object from the internal model + /// + public Display(Models.Metadata.Video? item) + { + // TODO: Determine what transformation is needed here + _internal = item ?? []; + Machine = new Machine(); + + ItemType = ItemType.Display; + } + #endregion #region Cloning Methods