2023-07-31 14:47:25 -04:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-07-31 16:11:27 -04:00
|
|
|
using System.Linq;
|
2023-07-31 14:47:25 -04:00
|
|
|
using SabreTools.Core;
|
|
|
|
|
using SabreTools.Core.Tools;
|
|
|
|
|
using SabreTools.DatItems;
|
|
|
|
|
using SabreTools.DatItems.Formats;
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.DatFiles.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents parsing an OfflineList XML DAT
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal partial class OfflineList : DatFile
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// Deserialize the input file
|
2023-09-11 01:20:21 -04:00
|
|
|
var dat = new Serialization.Files.OfflineList().Deserialize(filename);
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
// Convert the header to the internal format
|
|
|
|
|
ConvertHeader(dat);
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
// Convert the configuration to the internal format
|
2023-08-10 23:22:14 -04:00
|
|
|
ConvertConfiguration(dat?.Configuration, keep);
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
// Convert the games to the internal format
|
|
|
|
|
ConvertGames(dat?.Games, filename, indexId, statsOnly);
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
// Convert the GUI to the internal format
|
|
|
|
|
ConvertGUI(dat?.GUI);
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
catch (Exception ex) when (!throwOnError)
|
|
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
string message = $"'{filename}' - An error occurred during parsing";
|
|
|
|
|
logger.Error(ex, message);
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
#region Converters
|
|
|
|
|
|
2023-07-31 14:47:25 -04:00
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert header information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="dat">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertHeader(Models.OfflineList.Dat? dat)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the datafile is missing, we can't do anything
|
|
|
|
|
if (dat == null)
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
//Header.NoNamespaceSchemaLocation = dat.NoNamespaceSchemaLocation; // TODO: Add to internal model
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert configuration information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="config">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertConfiguration(Models.OfflineList.Configuration? config, bool keep)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the config is missing, we can't do anything
|
|
|
|
|
if (config == null)
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
Header.Name ??= config.DatName;
|
|
|
|
|
//Header.ImFolder ??= config.ImFolder; // TODO: Add to internal model
|
|
|
|
|
Header.Version = config.DatVersion;
|
|
|
|
|
Header.System = config.System;
|
|
|
|
|
Header.ScreenshotsWidth = config.ScreenshotsWidth;
|
|
|
|
|
Header.ScreenshotsHeight = config.ScreenshotsHeight;
|
|
|
|
|
ConvertInfos(config.Infos);
|
|
|
|
|
ConvertCanOpen(config.CanOpen);
|
|
|
|
|
ConvertNewDat(config.NewDat);
|
|
|
|
|
ConvertSearch(config.Search);
|
|
|
|
|
Header.RomTitle = config.RomTitle;
|
|
|
|
|
|
|
|
|
|
// Handle implied SuperDAT
|
2023-08-10 23:22:14 -04:00
|
|
|
if (config.DatName?.Contains(" - SuperDAT") == true && keep)
|
2023-07-31 16:11:27 -04:00
|
|
|
Header.Type ??= "SuperDAT";
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert infos information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="infos">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertInfos(Models.OfflineList.Infos? infos)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the infos is missing, we can't do anything
|
|
|
|
|
if (infos == null)
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
var offlineListInfos = new List<OfflineListInfo>();
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
if (infos.Title != null)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
Name = "title",
|
|
|
|
|
Visible = infos.Title.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.Title.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.Title.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.Location != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "location",
|
|
|
|
|
Visible = infos.Location.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.Location.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.Location.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.Publisher != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "publisher",
|
|
|
|
|
Visible = infos.Publisher.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.Publisher.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.Publisher.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.SourceRom != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "sourceRom",
|
|
|
|
|
Visible = infos.SourceRom.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.SourceRom.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.SourceRom.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.SaveType != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "saveType",
|
|
|
|
|
Visible = infos.SaveType.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.SaveType.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.SaveType.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.RomSize != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "romSize",
|
|
|
|
|
Visible = infos.RomSize.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.RomSize.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.RomSize.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.ReleaseNumber != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "releaseNumber",
|
|
|
|
|
Visible = infos.ReleaseNumber.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.ReleaseNumber.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.ReleaseNumber.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.LanguageNumber != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
Name = "languageNumber",
|
|
|
|
|
Visible = infos.LanguageNumber.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.LanguageNumber.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.LanguageNumber.Default.AsYesNo(),
|
|
|
|
|
});
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
2023-07-31 16:11:27 -04:00
|
|
|
if (infos.Comment != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "comment",
|
|
|
|
|
Visible = infos.Comment.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.Comment.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.Comment.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.RomCRC != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "romCRC",
|
|
|
|
|
Visible = infos.RomCRC.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.RomCRC.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.RomCRC.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.Im1CRC != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "im1CRC",
|
|
|
|
|
Visible = infos.Im1CRC.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.Im1CRC.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.Im1CRC.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.Im2CRC != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "im2CRC",
|
|
|
|
|
Visible = infos.Im2CRC.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.Im2CRC.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.Im2CRC.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (infos.Languages != null)
|
|
|
|
|
{
|
|
|
|
|
offlineListInfos.Add(new OfflineListInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "languages",
|
|
|
|
|
Visible = infos.Languages.Visible.AsYesNo(),
|
|
|
|
|
InNamingOption = infos.Languages.InNamingOption.AsYesNo(),
|
|
|
|
|
Default = infos.Languages.Default.AsYesNo(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Header.Infos = offlineListInfos;
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert canopen information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="canOpen">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertCanOpen(Models.OfflineList.CanOpen? canOpen)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the canOpen is missing, we can't do anything
|
2023-08-10 23:22:14 -04:00
|
|
|
if (canOpen?.Extension == null)
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
Header.CanOpen = new List<string>(canOpen.Extension);
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert newdat information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="newDat">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertNewDat(Models.OfflineList.NewDat? newDat)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the canOpen is missing, we can't do anything
|
|
|
|
|
if (newDat == null)
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
Header.Url = newDat.DatVersionUrl;
|
|
|
|
|
//Header.DatUrl = newDat.DatUrl; // TODO: Add to internal model
|
|
|
|
|
//Header.ImUrl = newDat.ImUrl; // TODO: Add to internal model
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert search information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="search">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertSearch(Models.OfflineList.Search? search)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the search or to array is missing, we can't do anything
|
|
|
|
|
if (search?.To == null)
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
// TODO: Add to internal model
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert games information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="search">Deserialized model to convert</param>
|
2023-07-31 14:47:25 -04:00
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
private void ConvertGames(Models.OfflineList.Games? games, string filename, int indexId, bool statsOnly)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the games array is missing, we can't do anything
|
|
|
|
|
if (games?.Game == null || !games.Game.Any())
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
foreach (var game in games.Game)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
ConvertGame(game, filename, indexId, statsOnly);
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert game information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="search">Deserialized model to convert</param>
|
2023-07-31 14:47:25 -04:00
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
|
|
|
|
private void ConvertGame(Models.OfflineList.Game? game, string filename, int indexId, bool statsOnly)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the game is missing, we can't do anything
|
|
|
|
|
if (game == null)
|
2023-07-31 14:47:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
var machine = new Machine
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
//ImageNumber = game.ImageNumber, // TODO: Add to internal model
|
|
|
|
|
//ReleaseNumber = game.ReleaseNumber, // TODO: Add to internal model
|
|
|
|
|
Name = game.Title,
|
|
|
|
|
//SaveType = game.SaveType, // TODO: Add to internal model
|
|
|
|
|
Publisher = game.Publisher,
|
|
|
|
|
//Location = game.Location, // TODO: Add to internal model
|
|
|
|
|
//SourceRom = game.SourceRom, // TODO: Add to internal model
|
|
|
|
|
//Language = game.Language, // TODO: Add to internal model
|
|
|
|
|
//Im1CRC = game.Im1CRC, // TODO: Add to internal model
|
|
|
|
|
//Im2CRC = game.Im2CRC, // TODO: Add to internal model
|
|
|
|
|
Comment = game.Comment,
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-11 14:30:31 -04:00
|
|
|
long? size = NumberHelper.ConvertToInt64(game.RomSize);
|
2023-07-31 16:11:27 -04:00
|
|
|
if (game.DuplicateID != "0")
|
|
|
|
|
machine.CloneOf = game.DuplicateID;
|
|
|
|
|
|
|
|
|
|
// Check if there are any items
|
|
|
|
|
bool containsItems = false;
|
|
|
|
|
|
|
|
|
|
// Loop through each file
|
|
|
|
|
ConvertFiles(game.Files, machine, size, game.ReleaseNumber, filename, indexId, statsOnly, ref containsItems);
|
|
|
|
|
|
|
|
|
|
// If we had no items, create a Blank placeholder
|
|
|
|
|
if (!containsItems)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
var blank = new Blank
|
|
|
|
|
{
|
|
|
|
|
Source = new Source
|
|
|
|
|
{
|
|
|
|
|
Index = indexId,
|
|
|
|
|
Name = filename,
|
|
|
|
|
},
|
|
|
|
|
};
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
blank.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(blank, statsOnly);
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// Convert Files information
|
2023-07-31 14:47:25 -04:00
|
|
|
/// </summary>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <param name="files">Array of deserialized models to convert</param>
|
|
|
|
|
/// <param name="machine">Prefilled machine to use</param>
|
|
|
|
|
/// <param name="size">Item size to use</param>
|
|
|
|
|
/// <param name="releaseNumber">Release number to use</param>
|
2023-07-31 14:47:25 -04:00
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
2023-07-31 16:11:27 -04:00
|
|
|
/// <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 23:22:14 -04:00
|
|
|
private void ConvertFiles(Models.OfflineList.Files? files, Machine machine, long? size, string? releaseNumber, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
// If the files array is missing, we can't do anything
|
|
|
|
|
if (files?.RomCRC == null || !files.RomCRC.Any())
|
|
|
|
|
return;
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
containsItems = true;
|
|
|
|
|
foreach (var crc in files.RomCRC)
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
string name = string.Empty;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(releaseNumber) && releaseNumber != "0")
|
|
|
|
|
name += $"{releaseNumber} - ";
|
|
|
|
|
name += $"{machine.Name}{crc.Extension}";
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
var item = new Rom
|
2023-07-31 14:47:25 -04:00
|
|
|
{
|
2023-07-31 16:11:27 -04:00
|
|
|
Name = name,
|
2023-08-10 23:22:14 -04:00
|
|
|
Size = size,
|
2023-07-31 16:11:27 -04:00
|
|
|
CRC = crc.Content,
|
2023-07-31 14:47:25 -04:00
|
|
|
ItemStatus = ItemStatus.None,
|
|
|
|
|
|
|
|
|
|
Source = new Source
|
|
|
|
|
{
|
|
|
|
|
Index = indexId,
|
|
|
|
|
Name = filename,
|
|
|
|
|
},
|
2023-07-31 16:11:27 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
item.CopyMachineInformation(machine);
|
|
|
|
|
ParseAddHelper(item, statsOnly);
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
2023-07-31 16:11:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert GUI information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="gui">Deserialized model to convert</param>
|
|
|
|
|
private void ConvertGUI(Models.OfflineList.GUI? gui)
|
|
|
|
|
{
|
|
|
|
|
// If the gui or Images are missing, we can't do anything
|
|
|
|
|
if (gui?.Images?.Image == null || !gui.Images.Image.Any())
|
|
|
|
|
return;
|
2023-07-31 14:47:25 -04:00
|
|
|
|
2023-07-31 16:11:27 -04:00
|
|
|
// TODO: Add to internal model
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
2023-07-31 16:11:27 -04:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-07-31 14:47:25 -04:00
|
|
|
}
|
|
|
|
|
}
|