mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add setters and getters for Machine
This commit is contained in:
@@ -785,7 +785,7 @@ CREATE TABLE IF NOT EXISTS dat (
|
|||||||
internal void AddDatToDatabase(Rom dat, SqliteConnection dbc)
|
internal void AddDatToDatabase(Rom dat, SqliteConnection dbc)
|
||||||
{
|
{
|
||||||
// Get the dat full path
|
// Get the dat full path
|
||||||
string fullpath = Path.Combine(_dats!, (dat.Machine.Name == "dats" ? string.Empty : dat.Machine.Name)!, dat.GetName()!);
|
string fullpath = Path.Combine(_dats!, (dat.Machine.GetFieldValue<string?>(SabreTools.Models.Metadata.Machine.NameKey) == "dats" ? string.Empty : dat.Machine.GetFieldValue<string?>(SabreTools.Models.Metadata.Machine.NameKey))!, dat.GetName()!);
|
||||||
|
|
||||||
// Parse the Dat if possible
|
// Parse the Dat if possible
|
||||||
logger.User($"Adding from '{dat.GetName()}'");
|
logger.User($"Adding from '{dat.GetName()}'");
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
// Initialize strings
|
// Initialize strings
|
||||||
string fix,
|
string fix,
|
||||||
game = item.Machine.Name ?? string.Empty,
|
game = item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) ?? string.Empty,
|
||||||
name = item.GetName() ?? item.ItemType.ToString(),
|
name = item.GetName() ?? item.ItemType.ToString(),
|
||||||
crc = string.Empty,
|
crc = string.Empty,
|
||||||
md5 = string.Empty,
|
md5 = string.Empty,
|
||||||
@@ -415,9 +415,9 @@ namespace SabreTools.DatFiles
|
|||||||
.Replace("%game%", game)
|
.Replace("%game%", game)
|
||||||
.Replace("%machine%", game)
|
.Replace("%machine%", game)
|
||||||
.Replace("%name%", name)
|
.Replace("%name%", name)
|
||||||
.Replace("%manufacturer%", item.Machine.Manufacturer ?? string.Empty)
|
.Replace("%manufacturer%", item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey) ?? string.Empty)
|
||||||
.Replace("%publisher%", item.Machine.Publisher ?? string.Empty)
|
.Replace("%publisher%", item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.PublisherKey) ?? string.Empty)
|
||||||
.Replace("%category%", item.Machine.Category ?? string.Empty)
|
.Replace("%category%", item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CategoryKey) ?? string.Empty)
|
||||||
.Replace("%crc%", crc)
|
.Replace("%crc%", crc)
|
||||||
.Replace("%md5%", md5)
|
.Replace("%md5%", md5)
|
||||||
.Replace("%sha1%", sha1)
|
.Replace("%sha1%", sha1)
|
||||||
@@ -447,7 +447,7 @@ namespace SabreTools.DatFiles
|
|||||||
Header.UseRomName = true;
|
Header.UseRomName = true;
|
||||||
|
|
||||||
// Get the name to update
|
// Get the name to update
|
||||||
string? name = (Header.UseRomName ? item.GetName() : item.Machine.Name) ?? string.Empty;
|
string? name = (Header.UseRomName ? item.GetName() : item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)) ?? string.Empty;
|
||||||
|
|
||||||
// Create the proper Prefix and Postfix
|
// Create the proper Prefix and Postfix
|
||||||
string pre = CreatePrefixPostfix(item, true);
|
string pre = CreatePrefixPostfix(item, true);
|
||||||
@@ -504,14 +504,14 @@ namespace SabreTools.DatFiles
|
|||||||
name += Header.AddExtension;
|
name += Header.AddExtension;
|
||||||
|
|
||||||
if (Header.UseRomName && Header.GameName)
|
if (Header.UseRomName && Header.GameName)
|
||||||
name = Path.Combine(item.Machine.Name ?? string.Empty, name);
|
name = Path.Combine(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) ?? string.Empty, name);
|
||||||
|
|
||||||
// Now assign back the formatted name
|
// Now assign back the formatted name
|
||||||
name = $"{pre}{name}{post}";
|
name = $"{pre}{name}{post}";
|
||||||
if (Header.UseRomName)
|
if (Header.UseRomName)
|
||||||
item.SetName(name);
|
item.SetName(name);
|
||||||
else if (item.Machine != null)
|
else if (item.Machine != null)
|
||||||
item.Machine.Name = name;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, name);
|
||||||
|
|
||||||
// Restore all relevant values
|
// Restore all relevant values
|
||||||
if (forceRemoveQuotes)
|
if (forceRemoveQuotes)
|
||||||
@@ -539,7 +539,7 @@ namespace SabreTools.DatFiles
|
|||||||
// If the Rom has "null" characteristics, ensure all fields
|
// If the Rom has "null" characteristics, ensure all fields
|
||||||
if (rom.GetFieldValue<long?>(Models.Metadata.Rom.SizeKey) == null && rom.GetFieldValue<string?>(Models.Metadata.Rom.CRCKey) == "null")
|
if (rom.GetFieldValue<long?>(Models.Metadata.Rom.SizeKey) == null && rom.GetFieldValue<string?>(Models.Metadata.Rom.CRCKey) == "null")
|
||||||
{
|
{
|
||||||
logger.Verbose($"Empty folder found: {datItem.Machine.Name}");
|
logger.Verbose($"Empty folder found: {datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}");
|
||||||
|
|
||||||
rom.SetName(rom.GetName() == "null" ? "-" : rom.GetName());
|
rom.SetName(rom.GetName() == "null" ? "-" : rom.GetName());
|
||||||
rom.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, Constants.SizeZero);
|
rom.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, Constants.SizeZero);
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
filename = filename.Substring(machineName.Length + 1);
|
filename = filename.Substring(machineName.Length + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var machine = new Machine { Name = machineName };
|
var machine = new Machine();
|
||||||
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineName);
|
||||||
|
|
||||||
return (machine, filename);
|
return (machine, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,10 +99,14 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
(var machine, string? name) = DeriveMachine(file.Name);
|
(var machine, string? name) = DeriveMachine(file.Name);
|
||||||
machine ??= new Machine { Name = Path.GetFileNameWithoutExtension(file.Name) };
|
if (machine == null)
|
||||||
|
{
|
||||||
|
machine = new Machine();
|
||||||
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Path.GetFileNameWithoutExtension(file.Name));
|
||||||
|
}
|
||||||
|
|
||||||
machine.Publisher = file.Publisher;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, file.Comment);
|
||||||
machine.Comment = file.Comment;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, file.Publisher);
|
||||||
|
|
||||||
var rom = new Rom()
|
var rom = new Rom()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,23 +65,21 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
if (row == null)
|
if (row == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ButtonsKey, row.Buttons);
|
||||||
Name = row.Name,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, row.Category);
|
||||||
Description = row.Title,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, row.CloneOf);
|
||||||
CloneOf = row.CloneOf,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, row.Extra);
|
||||||
Year = row.Year,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ControlKey, row.Control);
|
||||||
Manufacturer = row.Manufacturer,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, row.Title);
|
||||||
Category = row.Category,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DisplayCountKey, row.DisplayCount);
|
||||||
Players = row.Players,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DisplayTypeKey, row.DisplayType);
|
||||||
Rotation = row.Rotation,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey, row.Manufacturer);
|
||||||
Control = row.Control,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, row.Name);
|
||||||
Status = row.Status,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PlayersKey, row.Players);
|
||||||
DisplayCount = row.DisplayCount,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RotationKey, row.Rotation);
|
||||||
DisplayType = row.DisplayType,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.StatusKey, row.Status);
|
||||||
Comment = row.Extra,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, row.Year);
|
||||||
Buttons = row.Buttons
|
|
||||||
};
|
|
||||||
|
|
||||||
var rom = new Rom()
|
var rom = new Rom()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -124,23 +124,23 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
var row = new Models.AttractMode.Row
|
var row = new Models.AttractMode.Row
|
||||||
{
|
{
|
||||||
Name = rom.Machine.Name,
|
Name = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
Title = rom.Machine.Description,
|
Title = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
Emulator = Header.FileName,
|
Emulator = Header.FileName,
|
||||||
CloneOf = rom.Machine.CloneOf,
|
CloneOf = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey),
|
||||||
Year = rom.Machine.Year,
|
Year = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.YearKey),
|
||||||
Manufacturer = rom.Machine.Manufacturer,
|
Manufacturer = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey),
|
||||||
Category = rom.Machine.Category,
|
Category = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CategoryKey),
|
||||||
Players = rom.Machine.Players,
|
Players = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.PlayersKey),
|
||||||
Rotation = rom.Machine.Rotation,
|
Rotation = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RotationKey),
|
||||||
Control = rom.Machine.Control,
|
Control = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.ControlKey),
|
||||||
Status = rom.Machine.Status,
|
Status = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.StatusKey),
|
||||||
DisplayCount = rom.Machine.DisplayCount,
|
DisplayCount = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DisplayCountKey),
|
||||||
DisplayType = rom.Machine.DisplayType,
|
DisplayType = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DisplayTypeKey),
|
||||||
AltRomname = rom.GetFieldValue<string?>(Models.Metadata.Rom.AltRomnameKey),
|
AltRomname = rom.GetFieldValue<string?>(Models.Metadata.Rom.AltRomnameKey),
|
||||||
AltTitle = rom.GetFieldValue<string?>(Models.Metadata.Rom.AltTitleKey),
|
AltTitle = rom.GetFieldValue<string?>(Models.Metadata.Rom.AltTitleKey),
|
||||||
Extra = rom.Machine.Comment,
|
Extra = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CommentKey),
|
||||||
Buttons = rom.Machine.Buttons,
|
Buttons = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.ButtonsKey),
|
||||||
// TODO: Add extended fields
|
// TODO: Add extended fields
|
||||||
};
|
};
|
||||||
return row;
|
return row;
|
||||||
|
|||||||
@@ -105,18 +105,17 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create the machine for copying information
|
// Create the machine for copying information
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, game.Category);
|
||||||
Name = game.Name,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, game.CloneOf);
|
||||||
Description = game.Description,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, game.Description);
|
||||||
Year = game.Year,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey, game.Manufacturer);
|
||||||
Manufacturer = game.Manufacturer,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, game.Name);
|
||||||
Category = game.Category,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, game.RomOf);
|
||||||
CloneOf = game.CloneOf,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, game.SampleOf);
|
||||||
RomOf = game.RomOf,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, game.Year);
|
||||||
SampleOf = game.SampleOf,
|
if (game is Models.ClrMamePro.Resource)
|
||||||
MachineType = (game is Models.ClrMamePro.Resource ? MachineType.Bios : MachineType.None),
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey, true);
|
||||||
};
|
|
||||||
|
|
||||||
// Check if there are any items
|
// Check if there are any items
|
||||||
bool containsItems = false;
|
bool containsItems = false;
|
||||||
|
|||||||
@@ -232,14 +232,14 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// We normalize to all "game"
|
// We normalize to all "game"
|
||||||
var game = new Models.ClrMamePro.Game
|
var game = new Models.ClrMamePro.Game
|
||||||
{
|
{
|
||||||
Name = machine?.Name,
|
Name = machine?.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
Description = machine?.Description,
|
Description = machine?.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
Year = machine?.Year,
|
Year = machine?.GetFieldValue<string?>(Models.Metadata.Machine.YearKey),
|
||||||
Manufacturer = machine?.Manufacturer,
|
Manufacturer = machine?.GetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey),
|
||||||
Category = machine?.Category,
|
Category = machine?.GetFieldValue<string?>(Models.Metadata.Machine.CategoryKey),
|
||||||
CloneOf = machine?.CloneOf,
|
CloneOf = machine?.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey),
|
||||||
RomOf = machine?.RomOf,
|
RomOf = machine?.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey),
|
||||||
SampleOf = machine?.SampleOf,
|
SampleOf = machine?.GetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create holders for all item types
|
// Create holders for all item types
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
if (machineName?.EndsWith(".zip") == true)
|
if (machineName?.EndsWith(".zip") == true)
|
||||||
machineName = System.IO.Path.GetFileNameWithoutExtension(machineName);
|
machineName = System.IO.Path.GetFileNameWithoutExtension(machineName);
|
||||||
|
|
||||||
var machine = new Machine { Name = machineName };
|
var machine = new Machine();
|
||||||
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineName);
|
||||||
|
|
||||||
// Check if there are any items
|
// Check if there are any items
|
||||||
bool containsItems = false;
|
bool containsItems = false;
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// We re-add the missing parts of the game name
|
// We re-add the missing parts of the game name
|
||||||
var game = new Models.DosCenter.Game
|
var game = new Models.DosCenter.Game
|
||||||
{
|
{
|
||||||
Name = $"\"{machine?.Name ?? string.Empty}.zip\""
|
Name = $"\"{machine?.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) ?? string.Empty}.zip\""
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create holders for all item types
|
// Create holders for all item types
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
filename = filename.Substring(machineName.Length + 1);
|
filename = filename.Substring(machineName.Length + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var machine = new Machine { Name = machineName };
|
var machine = new Machine();
|
||||||
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineName);
|
||||||
|
|
||||||
return (machine, filename);
|
return (machine, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +98,11 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
(var machine, string? name) = DeriveMachine(row.Name);
|
(var machine, string? name) = DeriveMachine(row.Name);
|
||||||
machine ??= new Machine { Name = Path.GetFileNameWithoutExtension(row.Name) };
|
if (machine == null)
|
||||||
|
{
|
||||||
|
machine = new Machine();
|
||||||
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Path.GetFileNameWithoutExtension(row.Name));
|
||||||
|
}
|
||||||
|
|
||||||
var rom = new Rom()
|
var rom = new Rom()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var row = new Models.EverdriveSMDB.Row
|
var row = new Models.EverdriveSMDB.Row
|
||||||
{
|
{
|
||||||
SHA256 = rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA256Key),
|
SHA256 = rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA256Key),
|
||||||
Name = $"{rom.Machine.Name ?? string.Empty}/{rom.GetName()}",
|
Name = $"{rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) ?? string.Empty}/{rom.GetName()}",
|
||||||
SHA1 = rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key),
|
SHA1 = rom.GetFieldValue<string?>(Models.Metadata.Rom.SHA1Key),
|
||||||
MD5 = rom.GetFieldValue<string?>(Models.Metadata.Rom.MD5Key),
|
MD5 = rom.GetFieldValue<string?>(Models.Metadata.Rom.MD5Key),
|
||||||
CRC32 = rom.GetFieldValue<string?>(Models.Metadata.Rom.CRCKey),
|
CRC32 = rom.GetFieldValue<string?>(Models.Metadata.Rom.CRCKey),
|
||||||
|
|||||||
@@ -80,7 +80,9 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
filename = filename.Substring(machineName.Length + 1);
|
filename = filename.Substring(machineName.Length + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var machine = new Machine { Name = machineName };
|
var machine = new Machine();
|
||||||
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineName);
|
||||||
|
|
||||||
return (machine, filename);
|
return (machine, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (Header.GameName && item.Machine != null)
|
if (Header.GameName && item.Machine != null)
|
||||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
name = $"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -295,7 +295,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (Header.GameName && item.Machine != null)
|
if (Header.GameName && item.Machine != null)
|
||||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
name = $"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -362,7 +362,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (Header.GameName && item.Machine != null)
|
if (Header.GameName && item.Machine != null)
|
||||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
name = $"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -429,7 +429,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (Header.GameName && item.Machine != null)
|
if (Header.GameName && item.Machine != null)
|
||||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
name = $"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -488,7 +488,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (Header.GameName && item.Machine != null)
|
if (Header.GameName && item.Machine != null)
|
||||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
name = $"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -539,7 +539,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (Header.GameName && item.Machine != null)
|
if (Header.GameName && item.Machine != null)
|
||||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
name = $"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -590,7 +590,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (Header.GameName && item.Machine != null)
|
if (Header.GameName && item.Machine != null)
|
||||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
name = $"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,19 +69,14 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
Machine machine;
|
Machine machine;
|
||||||
if (!string.IsNullOrEmpty(set.Device))
|
if (!string.IsNullOrEmpty(set.Device))
|
||||||
{
|
{
|
||||||
machine = new Machine
|
machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, set.Device);
|
||||||
Name = set.Device,
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey, true);
|
||||||
MachineType = MachineType.Device,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(set.Driver))
|
else if (!string.IsNullOrEmpty(set.Driver))
|
||||||
{
|
{
|
||||||
machine = new Machine
|
machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, set.Driver);
|
||||||
Name = set.Driver,
|
|
||||||
MachineType = MachineType.None,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -116,13 +116,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
var set = new Models.Listrom.Set
|
var set = new Models.Listrom.Set
|
||||||
{
|
{
|
||||||
#if NETFRAMEWORK
|
Driver = items[0]!.Machine!.GetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey) == true ? items[0]!.Machine!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) : null,
|
||||||
Driver = (items[0]!.Machine!.MachineType & MachineType.Device) != 0 ? items[0]!.Machine!.Name : null,
|
Device = items[0]!.Machine!.GetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey) == true ? items[0]!.Machine!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) : null,
|
||||||
Device = (items[0]!.Machine!.MachineType & MachineType.Device) != 0 ? items[0]!.Machine!.Name : null,
|
|
||||||
#else
|
|
||||||
Driver = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null,
|
|
||||||
Device = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null,
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Loop through and convert the items to respective lists
|
// Loop through and convert the items to respective lists
|
||||||
|
|||||||
@@ -93,26 +93,20 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create the machine for copying information
|
// Create the machine for copying information
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, game.CloneOf);
|
||||||
Name = game.Name,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, game.Description);
|
||||||
SourceFile = game.SourceFile,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.HistoryKey, game.History);
|
||||||
Runnable = game.Runnable.AsEnumValue<Runnable>(),
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey, game.IsBios.AsYesNo());
|
||||||
CloneOf = game.CloneOf,
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey, game.IsDevice.AsYesNo());
|
||||||
RomOf = game.RomOf,
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsMechanicalKey, game.IsMechanical.AsYesNo());
|
||||||
SampleOf = game.SampleOf,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey, game.Manufacturer);
|
||||||
Description = game.Description,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, game.Name);
|
||||||
Year = game.Year,
|
machine.SetFieldValue<Runnable>(Models.Metadata.Machine.RunnableKey, game.Runnable.AsEnumValue<Runnable>());
|
||||||
Manufacturer = game.Manufacturer,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, game.RomOf);
|
||||||
History = game.History,
|
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 (game.IsBios.AsYesNo() == true)
|
|
||||||
machine.MachineType |= MachineType.Bios;
|
|
||||||
if (game.IsDevice.AsYesNo() == true)
|
|
||||||
machine.MachineType |= MachineType.Device;
|
|
||||||
if (game.IsMechanical.AsYesNo() == true)
|
|
||||||
machine.MachineType |= MachineType.Mechanical;
|
|
||||||
|
|
||||||
// Check if there are any items
|
// Check if there are any items
|
||||||
bool containsItems = false;
|
bool containsItems = false;
|
||||||
|
|||||||
@@ -372,33 +372,24 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
var game = new Models.Listxml.Machine
|
var game = new Models.Listxml.Machine
|
||||||
{
|
{
|
||||||
Name = machine.Name,
|
Name = machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
SourceFile = machine.SourceFile,
|
SourceFile = machine.GetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey),
|
||||||
Runnable = machine.Runnable.AsStringValue<Runnable>(),
|
Runnable = machine.GetFieldValue<Runnable>(Models.Metadata.Machine.RunnableKey).AsStringValue<Runnable>(),
|
||||||
CloneOf = machine.CloneOf,
|
CloneOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey),
|
||||||
RomOf = machine.RomOf,
|
RomOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey),
|
||||||
SampleOf = machine.SampleOf,
|
SampleOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey),
|
||||||
Description = machine.Description,
|
Description = machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
Year = machine.Year,
|
Year = machine.GetFieldValue<string?>(Models.Metadata.Machine.YearKey),
|
||||||
Manufacturer = machine.Manufacturer,
|
Manufacturer = machine.GetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey),
|
||||||
History = machine.History,
|
History = machine.GetFieldValue<string?>(Models.Metadata.Machine.HistoryKey),
|
||||||
};
|
};
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
if (machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey) == true)
|
||||||
if ((machine.MachineType & MachineType.Bios) != 0)
|
|
||||||
game.IsBios = "yes";
|
game.IsBios = "yes";
|
||||||
if ((machine.MachineType & MachineType.Device) != 0)
|
if (machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey) == true)
|
||||||
game.IsDevice = "yes";
|
game.IsDevice = "yes";
|
||||||
if ((machine.MachineType & MachineType.Mechanical) != 0)
|
if (machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsMechanicalKey) == true)
|
||||||
game.IsMechanical = "yes";
|
game.IsMechanical = "yes";
|
||||||
#else
|
|
||||||
if (machine.MachineType.HasFlag(MachineType.Bios))
|
|
||||||
game.IsBios = "yes";
|
|
||||||
if (machine.MachineType.HasFlag(MachineType.Device))
|
|
||||||
game.IsDevice = "yes";
|
|
||||||
if (machine.MachineType.HasFlag(MachineType.Mechanical))
|
|
||||||
game.IsMechanical = "yes";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,45 +207,38 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create the machine for copying information
|
// Create the machine for copying information
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.BoardKey, game.Board);
|
||||||
Name = game.Name,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, game.CloneOf);
|
||||||
SourceFile = game.SourceFile,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfIdKey, game.CloneOfId);
|
||||||
CloneOf = game.CloneOf,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, game.Description);
|
||||||
RomOf = game.RomOf,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.IdKey, game.Id);
|
||||||
SampleOf = game.SampleOf,
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey, game.IsBios.AsYesNo());
|
||||||
Board = game.Board,
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey, game.IsDevice.AsYesNo());
|
||||||
RebuildTo = game.RebuildTo,
|
machine.SetFieldValue<bool?>(Models.Metadata.Machine.IsMechanicalKey, game.IsMechanical.AsYesNo());
|
||||||
NoIntroId = game.Id,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey, game.Manufacturer);
|
||||||
NoIntroCloneOfId = game.CloneOfId,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, game.Name);
|
||||||
Runnable = game.Runnable.AsEnumValue<Runnable>(),
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, game.Publisher);
|
||||||
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RebuildToKey, game.RebuildTo);
|
||||||
Description = game.Description,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RomKey, game.RomOf);
|
||||||
Year = game.Year,
|
machine.SetFieldValue<Runnable>(Models.Metadata.Machine.RunnableKey, game.Runnable.AsEnumValue<Runnable>());
|
||||||
Manufacturer = game.Manufacturer,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, game.SampleOf);
|
||||||
Publisher = game.Publisher,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey, game.SourceFile);
|
||||||
};
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, game.Year);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(dirname))
|
if (!string.IsNullOrEmpty(dirname))
|
||||||
machine.Name = $"{dirname}/{machine.Name}";
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, $"{dirname}/{machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}");
|
||||||
|
|
||||||
if (game.IsBios.AsYesNo() == true)
|
|
||||||
machine.MachineType |= MachineType.Bios;
|
|
||||||
if (game.IsDevice.AsYesNo() == true)
|
|
||||||
machine.MachineType |= MachineType.Device;
|
|
||||||
if (game.IsMechanical.AsYesNo() == true)
|
|
||||||
machine.MachineType |= MachineType.Mechanical;
|
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
if (game.Comment != null && game.Comment.Any())
|
if (game.Comment != null && game.Comment.Any())
|
||||||
machine.Comment = string.Join(";", game.Comment);
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, string.Join(";", game.Comment));
|
||||||
if (game.Category != null && game.Category.Any())
|
if (game.Category != null && game.Category.Any())
|
||||||
machine.Category = string.Join(";", game.Category);
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, string.Join(";", game.Category));
|
||||||
#else
|
#else
|
||||||
if (game.Comment != null && game.Comment.Any())
|
if (game.Comment != null && game.Comment.Any())
|
||||||
machine.Comment = string.Join(';', game.Comment);
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, string.Join(';', game.Comment));
|
||||||
if (game.Category != null && game.Category.Any())
|
if (game.Category != null && game.Category.Any())
|
||||||
machine.Category = string.Join(';', game.Category);
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CategoryKey, string.Join(';', game.Category));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (game.Trurip != null)
|
if (game.Trurip != null)
|
||||||
@@ -253,18 +246,18 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var trurip = game.Trurip;
|
var trurip = game.Trurip;
|
||||||
|
|
||||||
machine.TitleID = trurip.TitleID;
|
machine.TitleID = trurip.TitleID;
|
||||||
machine.Publisher = trurip.Publisher;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, trurip.Publisher);
|
||||||
machine.Developer = trurip.Developer;
|
machine.Developer = trurip.Developer;
|
||||||
machine.Year = trurip.Year;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, value: trurip.Year);
|
||||||
machine.Genre = trurip.Genre;
|
machine.Genre = trurip.Genre;
|
||||||
machine.Subgenre = trurip.Subgenre;
|
machine.Subgenre = trurip.Subgenre;
|
||||||
machine.Ratings = trurip.Ratings;
|
machine.Ratings = trurip.Ratings;
|
||||||
machine.Score = trurip.Score;
|
machine.Score = trurip.Score;
|
||||||
machine.Players = trurip.Players;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PlayersKey, trurip.Players);
|
||||||
machine.Enabled = trurip.Enabled;
|
machine.Enabled = trurip.Enabled;
|
||||||
machine.Crc = trurip.CRC.AsYesNo();
|
machine.Crc = trurip.CRC.AsYesNo();
|
||||||
machine.SourceFile = trurip.Source;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey, trurip.Source);
|
||||||
machine.CloneOf = trurip.CloneOf;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, trurip.CloneOf);
|
||||||
machine.RelatedTo = trurip.RelatedTo;
|
machine.RelatedTo = trurip.RelatedTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -389,48 +389,39 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
Models.Logiqx.GameBase game = _deprecated ? new Models.Logiqx.Game() : new Models.Logiqx.Machine();
|
Models.Logiqx.GameBase game = _deprecated ? new Models.Logiqx.Game() : new Models.Logiqx.Machine();
|
||||||
|
|
||||||
game.Name = machine.Name;
|
game.Name = machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey);
|
||||||
game.SourceFile = machine.SourceFile;
|
game.SourceFile = machine.GetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey);
|
||||||
#if NETFRAMEWORK
|
if (machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey) == true)
|
||||||
if ((machine.MachineType & MachineType.Bios) != 0)
|
|
||||||
game.IsBios = "yes";
|
game.IsBios = "yes";
|
||||||
if ((machine.MachineType & MachineType.Device) != 0)
|
if (machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey) == true)
|
||||||
game.IsDevice = "yes";
|
game.IsDevice = "yes";
|
||||||
if ((machine.MachineType & MachineType.Mechanical) != 0)
|
if (machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsMechanicalKey) == true)
|
||||||
game.IsMechanical = "yes";
|
game.IsMechanical = "yes";
|
||||||
#else
|
game.CloneOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey);
|
||||||
if (machine.MachineType.HasFlag(MachineType.Bios))
|
game.RomOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey);
|
||||||
game.IsBios = "yes";
|
game.SampleOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey);
|
||||||
if (machine.MachineType.HasFlag(MachineType.Device))
|
game.Board = machine.GetFieldValue<string?>(Models.Metadata.Machine.BoardKey);
|
||||||
game.IsDevice = "yes";
|
game.RebuildTo = machine.GetFieldValue<string?>(Models.Metadata.Machine.RebuildToKey);
|
||||||
if (machine.MachineType.HasFlag(MachineType.Mechanical))
|
game.Id = machine.GetFieldValue<string?>(Models.Metadata.Machine.IdKey);
|
||||||
game.IsMechanical = "yes";
|
game.CloneOfId = machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfIdKey);
|
||||||
#endif
|
game.Runnable = machine.GetFieldValue<Runnable>(Models.Metadata.Machine.RunnableKey).AsStringValue<Runnable>();
|
||||||
game.CloneOf = machine.CloneOf;
|
if (machine.GetFieldValue<string?>(Models.Metadata.Machine.CommentKey) != null)
|
||||||
game.RomOf = machine.RomOf;
|
|
||||||
game.SampleOf = machine.SampleOf;
|
|
||||||
game.Board = machine.Board;
|
|
||||||
game.RebuildTo = machine.RebuildTo;
|
|
||||||
game.Id = machine.NoIntroId;
|
|
||||||
game.CloneOfId = machine.NoIntroCloneOfId;
|
|
||||||
game.Runnable = machine.Runnable.AsStringValue<Runnable>();
|
|
||||||
if (machine.Comment != null)
|
|
||||||
{
|
{
|
||||||
if (machine.Comment.Contains(';'))
|
if (machine.GetFieldValue<string?>(Models.Metadata.Machine.CommentKey)!.Contains(';'))
|
||||||
game.Comment = machine.Comment.Split(';');
|
game.Comment = machine.GetFieldValue<string?>(Models.Metadata.Machine.CommentKey)!.Split(';');
|
||||||
else
|
else
|
||||||
game.Comment = [machine.Comment];
|
game.Comment = [machine.GetFieldValue<string?>(Models.Metadata.Machine.CommentKey)!];
|
||||||
}
|
}
|
||||||
game.Description = machine.Description;
|
game.Description = machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey);
|
||||||
game.Year = machine.Year;
|
game.Year = machine.GetFieldValue<string?>(Models.Metadata.Machine.YearKey);
|
||||||
game.Manufacturer = machine.Manufacturer;
|
game.Manufacturer = machine.GetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey);
|
||||||
game.Publisher = machine.Publisher;
|
game.Publisher = machine.GetFieldValue<string?>(Models.Metadata.Machine.PublisherKey);
|
||||||
if (machine.Category != null)
|
if (machine.GetFieldValue<string?>(Models.Metadata.Machine.CategoryKey) != null)
|
||||||
{
|
{
|
||||||
if (machine.Category.Contains(';'))
|
if (machine.GetFieldValue<string?>(Models.Metadata.Machine.CategoryKey)!.Contains(';'))
|
||||||
game.Category = machine.Category.Split(';');
|
game.Category = machine.GetFieldValue<string?>(Models.Metadata.Machine.CategoryKey)!.Split(';');
|
||||||
else
|
else
|
||||||
game.Category = [machine.Category];
|
game.Category = [machine.GetFieldValue<string?>(Models.Metadata.Machine.CategoryKey)!];
|
||||||
}
|
}
|
||||||
game.Trurip = CreateTrurip(machine);
|
game.Trurip = CreateTrurip(machine);
|
||||||
|
|
||||||
@@ -459,18 +450,18 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var trurip = new Models.Logiqx.Trurip
|
var trurip = new Models.Logiqx.Trurip
|
||||||
{
|
{
|
||||||
TitleID = machine.TitleID,
|
TitleID = machine.TitleID,
|
||||||
Publisher = machine.Publisher,
|
Publisher = machine.GetFieldValue<string?>(Models.Metadata.Machine.PublisherKey),
|
||||||
Developer = machine.Developer,
|
Developer = machine.Developer,
|
||||||
Year = machine.Year,
|
Year = machine.GetFieldValue<string?>(Models.Metadata.Machine.YearKey),
|
||||||
Genre = machine.Genre,
|
Genre = machine.Genre,
|
||||||
Subgenre = machine.Subgenre,
|
Subgenre = machine.Subgenre,
|
||||||
Ratings = machine.Ratings,
|
Ratings = machine.Ratings,
|
||||||
Score = machine.Score,
|
Score = machine.Score,
|
||||||
Players = machine.Players,
|
Players = machine.GetFieldValue<string?>(Models.Metadata.Machine.PlayersKey),
|
||||||
Enabled = machine.Enabled,
|
Enabled = machine.Enabled,
|
||||||
CRC = machine.Crc.FromYesNo(),
|
CRC = machine.Crc.FromYesNo(),
|
||||||
Source = machine.SourceFile,
|
Source = machine.GetFieldValue<string?>(Models.Metadata.Machine.SourceFileKey),
|
||||||
CloneOf = machine.CloneOf,
|
CloneOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey),
|
||||||
RelatedTo = machine.RelatedTo,
|
RelatedTo = machine.RelatedTo,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
WriteDatItem(sw, datItem, lastgame);
|
WriteDatItem(sw, datItem, lastgame);
|
||||||
|
|
||||||
// Set the new data to compare against
|
// Set the new data to compare against
|
||||||
lastgame = datItem.Machine.Name;
|
lastgame = datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +94,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// Romba mode automatically uses item name
|
// Romba mode automatically uses item name
|
||||||
if (Header.OutputDepot?.IsActive == true || Header.UseRomName)
|
if (Header.OutputDepot?.IsActive == true || Header.UseRomName)
|
||||||
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
|
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
|
||||||
else if (!Header.UseRomName && datItem.Machine.Name != lastgame)
|
else if (!Header.UseRomName && datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) != lastgame)
|
||||||
sw.Write($"{datItem.Machine.Name ?? string.Empty}\n");
|
sw.Write($"{datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) ?? string.Empty}\n");
|
||||||
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,24 +301,22 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
if (game == null)
|
if (game == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, game.Comment);
|
||||||
//ImageNumber = game.ImageNumber, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.Im1CRCKey, game.Im1CRC);
|
||||||
//ReleaseNumber = game.ReleaseNumber, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.Im2CRCKey, game.Im2CRC);
|
||||||
Name = game.Title,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ImageNumberKey, game.ImageNumber);
|
||||||
//SaveType = game.SaveType, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.LanguageKey, game.Language);
|
||||||
Publisher = game.Publisher,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.LocationKey, game.Location);
|
||||||
//Location = game.Location, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, game.Title);
|
||||||
//SourceRom = game.SourceRom, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, game.Publisher);
|
||||||
//Language = game.Language, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ReleaseNumberKey, game.ReleaseNumber);
|
||||||
//Im1CRC = game.Im1CRC, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SaveTypeKey, game.SaveType);
|
||||||
//Im2CRC = game.Im2CRC, // TODO: Add to internal model
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SourceRomKey, game.SourceRom);
|
||||||
Comment = game.Comment,
|
|
||||||
};
|
|
||||||
|
|
||||||
long? size = NumberHelper.ConvertToInt64(game.RomSize);
|
long? size = NumberHelper.ConvertToInt64(game.RomSize);
|
||||||
if (game.DuplicateID != "0")
|
if (game.DuplicateID != "0")
|
||||||
machine.CloneOf = game.DuplicateID;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, game.DuplicateID);
|
||||||
|
|
||||||
// Check if there are any items
|
// Check if there are any items
|
||||||
bool containsItems = false;
|
bool containsItems = false;
|
||||||
@@ -362,7 +360,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
string name = string.Empty;
|
string name = string.Empty;
|
||||||
if (!string.IsNullOrEmpty(releaseNumber) && releaseNumber != "0")
|
if (!string.IsNullOrEmpty(releaseNumber) && releaseNumber != "0")
|
||||||
name += $"{releaseNumber} - ";
|
name += $"{releaseNumber} - ";
|
||||||
name += $"{machine.Name}{crc.Extension}";
|
name += $"{machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}{crc.Extension}";
|
||||||
|
|
||||||
var item = new Rom
|
var item = new Rom
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -361,21 +361,20 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
private static Models.OfflineList.Game CreateGame(Machine machine)
|
private static Models.OfflineList.Game CreateGame(Machine machine)
|
||||||
{
|
{
|
||||||
|
|
||||||
var game = new Models.OfflineList.Game
|
var game = new Models.OfflineList.Game
|
||||||
{
|
{
|
||||||
//ImageNumber = machine.ImageNumber, // TODO: Add to internal model
|
ImageNumber = machine.GetFieldValue<string?>(Models.Metadata.Machine.ImageNumberKey),
|
||||||
//ReleaseNumber = machine.ReleaseNumber, // TODO: Add to internal model
|
ReleaseNumber = machine.GetFieldValue<string?>(Models.Metadata.Machine.ReleaseNumberKey),
|
||||||
Title = machine.Name,
|
Title = machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
//SaveType = machine.SaveType, // TODO: Add to internal model
|
SaveType = machine.GetFieldValue<string?>(Models.Metadata.Machine.SaveTypeKey),
|
||||||
Publisher = machine.Publisher,
|
Publisher = machine.GetFieldValue<string?>(Models.Metadata.Machine.PublisherKey),
|
||||||
//Location = machine.Location, // TODO: Add to internal model
|
Location = machine.GetFieldValue<string?>(Models.Metadata.Machine.LocationKey),
|
||||||
//SourceRom = machine.SourceRom, // TODO: Add to internal model
|
SourceRom = machine.GetFieldValue<string?>(Models.Metadata.Machine.SourceRomKey),
|
||||||
//Language = machine.Language, // TODO: Add to internal model
|
Language = machine.GetFieldValue<string?>(Models.Metadata.Machine.LanguageKey),
|
||||||
//Im1CRC = machine.Im1CRC, // TODO: Add to internal model
|
Im1CRC = machine.GetFieldValue<string?>(Models.Metadata.Machine.Im1CRCKey),
|
||||||
//Im2CRC = machine.Im2CRC, // TODO: Add to internal model
|
Im2CRC = machine.GetFieldValue<string?>(Models.Metadata.Machine.Im2CRCKey),
|
||||||
Comment = machine.Comment,
|
Comment = machine.GetFieldValue<string?>(Models.Metadata.Machine.CommentKey),
|
||||||
DuplicateID = machine.CloneOf,
|
DuplicateID = machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey),
|
||||||
};
|
};
|
||||||
|
|
||||||
return game;
|
return game;
|
||||||
|
|||||||
@@ -84,15 +84,13 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create the machine for copying information
|
// Create the machine for copying information
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CountryKey, software.Country);
|
||||||
Name = software.Title,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.GenMSXIDKey, software.GenMSXID);
|
||||||
GenMSXID = software.GenMSXID,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey, software.Company);
|
||||||
System = software.System,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.SystemKey, software.System);
|
||||||
Manufacturer = software.Company,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, software.Title);
|
||||||
Year = software.Year,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, software.Year);
|
||||||
Country = software.Country,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if there are any items
|
// Check if there are any items
|
||||||
bool containsItems = false;
|
bool containsItems = false;
|
||||||
@@ -136,7 +134,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
var rom = dump.Rom;
|
var rom = dump.Rom;
|
||||||
|
|
||||||
string name = $"{machine.Name}_{index++}{(!string.IsNullOrEmpty(rom.Remark) ? $" {rom.Remark}" : string.Empty)}";
|
string name = $"{machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}_{index++}{(!string.IsNullOrEmpty(rom.Remark) ? $" {rom.Remark}" : string.Empty)}";
|
||||||
var item = new Rom
|
var item = new Rom
|
||||||
{
|
{
|
||||||
Source = new Source { Index = indexId, Name = filename },
|
Source = new Source { Index = indexId, Name = filename },
|
||||||
|
|||||||
@@ -106,12 +106,12 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var machine = items[0].Machine;
|
var machine = items[0].Machine;
|
||||||
var software = new Models.OpenMSX.Software
|
var software = new Models.OpenMSX.Software
|
||||||
{
|
{
|
||||||
Title = machine?.Name,
|
Title = machine?.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
GenMSXID = machine?.GenMSXID,
|
GenMSXID = machine?.GetFieldValue<string?>(Models.Metadata.Machine.GenMSXIDKey),
|
||||||
System = machine?.System,
|
System = machine?.GetFieldValue<string?>(Models.Metadata.Machine.SystemKey),
|
||||||
Company = machine?.Manufacturer,
|
Company = machine?.GetFieldValue<string?>(Models.Metadata.Machine.ManufacturerKey),
|
||||||
Year = machine?.Year,
|
Year = machine?.GetFieldValue<string?>(Models.Metadata.Machine.YearKey),
|
||||||
Country = machine?.Country,
|
Country = machine?.GetFieldValue<string?>(Models.Metadata.Machine.CountryKey),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create holder for dumps
|
// Create holder for dumps
|
||||||
|
|||||||
@@ -107,14 +107,12 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
foreach (var rom in games.Rom)
|
foreach (var rom in games.Rom)
|
||||||
{
|
{
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, rom.ParentName);
|
||||||
Name = rom.GameName,
|
//machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfDescriptionKey, rom.ParentDescription); // TODO: Add to internal model or find mapping
|
||||||
Description = rom.GameDescription,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, rom.GameDescription);
|
||||||
CloneOf = rom.ParentName,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, rom.GameName);
|
||||||
//CloneOfDescription = rom.ParentDescription, // TODO: Add to internal model or find mapping
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, rom.RomOf);
|
||||||
RomOf = rom.RomOf,
|
|
||||||
};
|
|
||||||
|
|
||||||
var item = new Rom
|
var item = new Rom
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -183,14 +183,14 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
var rom = new Models.RomCenter.Rom
|
var rom = new Models.RomCenter.Rom
|
||||||
{
|
{
|
||||||
ParentName = item.Machine.CloneOf,
|
ParentName = item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey),
|
||||||
//ParentDescription = item.Machine.CloneOfDescription, // TODO: Add to internal model or find mapping
|
//ParentDescription = item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfDescription), // TODO: Add to internal model or find mapping
|
||||||
GameName = item.Machine.Name,
|
GameName = item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
GameDescription = item.Machine.Description,
|
GameDescription = item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
RomName = item.GetName(),
|
RomName = item.GetName(),
|
||||||
RomCRC = item.GetFieldValue<string?>(Models.Metadata.Rom.CRCKey),
|
RomCRC = item.GetFieldValue<string?>(Models.Metadata.Rom.CRCKey),
|
||||||
RomSize = item.GetFieldValue<long?>(Models.Metadata.Rom.SizeKey)?.ToString(),
|
RomSize = item.GetFieldValue<long?>(Models.Metadata.Rom.SizeKey)?.ToString(),
|
||||||
RomOf = item.Machine.RomOf,
|
RomOf = item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey),
|
||||||
MergeName = item.GetFieldValue<string?>(Models.Metadata.Rom.MergeKey),
|
MergeName = item.GetFieldValue<string?>(Models.Metadata.Rom.MergeKey),
|
||||||
};
|
};
|
||||||
return rom;
|
return rom;
|
||||||
|
|||||||
@@ -395,11 +395,11 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
DatItem datItem = datItems[index];
|
DatItem datItem = datItems[index];
|
||||||
|
|
||||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||||
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
|
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)?.ToLowerInvariant())
|
||||||
SabreJSON.WriteEndGame(jtw);
|
SabreJSON.WriteEndGame(jtw);
|
||||||
|
|
||||||
// If we have a new game, output the beginning of the new item
|
// If we have a new game, output the beginning of the new item
|
||||||
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
|
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)?.ToLowerInvariant())
|
||||||
SabreJSON.WriteStartGame(jtw, datItem);
|
SabreJSON.WriteStartGame(jtw, datItem);
|
||||||
|
|
||||||
// Check for a "null" item
|
// Check for a "null" item
|
||||||
@@ -410,7 +410,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
WriteDatItem(jtw, datItem);
|
WriteDatItem(jtw, datItem);
|
||||||
|
|
||||||
// Set the new data to compare against
|
// Set the new data to compare against
|
||||||
lastgame = datItem.Machine.Name;
|
lastgame = datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,8 +457,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
private static void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
|
private static void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
|
||||||
{
|
{
|
||||||
// No game should start with a path separator
|
// No game should start with a path separator
|
||||||
if (!string.IsNullOrEmpty(datItem.Machine.Name))
|
if (!string.IsNullOrEmpty(datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)))
|
||||||
datItem.Machine.Name = datItem.Machine.Name!.TrimStart(Path.DirectorySeparatorChar);
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.TrimStart(Path.DirectorySeparatorChar));
|
||||||
|
|
||||||
// Build the state
|
// Build the state
|
||||||
jtw.WriteStartObject();
|
jtw.WriteStartObject();
|
||||||
|
|||||||
@@ -227,11 +227,11 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
DatItem datItem = datItems[index];
|
DatItem datItem = datItems[index];
|
||||||
|
|
||||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||||
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
|
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)?.ToLowerInvariant())
|
||||||
WriteEndGame(xtw);
|
WriteEndGame(xtw);
|
||||||
|
|
||||||
// If we have a new game, output the beginning of the new item
|
// If we have a new game, output the beginning of the new item
|
||||||
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
|
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)?.ToLowerInvariant())
|
||||||
WriteStartGame(xtw, datItem);
|
WriteStartGame(xtw, datItem);
|
||||||
|
|
||||||
// Check for a "null" item
|
// Check for a "null" item
|
||||||
@@ -242,7 +242,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
WriteDatItem(xtw, datItem);
|
WriteDatItem(xtw, datItem);
|
||||||
|
|
||||||
// Set the new data to compare against
|
// Set the new data to compare against
|
||||||
lastgame = datItem.Machine.Name;
|
lastgame = datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
private static void WriteStartGame(XmlTextWriter xtw, DatItem datItem)
|
private static void WriteStartGame(XmlTextWriter xtw, DatItem datItem)
|
||||||
{
|
{
|
||||||
// No game should start with a path separator
|
// No game should start with a path separator
|
||||||
datItem.Machine!.Name = datItem.Machine.Name?.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
|
datItem.Machine!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)?.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty);
|
||||||
|
|
||||||
// Write the machine
|
// Write the machine
|
||||||
xtw.WriteStartElement("directory");
|
xtw.WriteStartElement("directory");
|
||||||
|
|||||||
@@ -71,11 +71,9 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
Header.Description ??= row.Description;
|
Header.Description ??= row.Description;
|
||||||
|
|
||||||
// Read Machine values
|
// Read Machine values
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, row.GameDescription);
|
||||||
Name = row.GameName,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, row.GameName);
|
||||||
Description = row.GameDescription,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Read item values
|
// Read item values
|
||||||
DatItem? item = null;
|
DatItem? item = null;
|
||||||
|
|||||||
@@ -162,8 +162,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
FileName = Header.FileName,
|
FileName = Header.FileName,
|
||||||
InternalName = Header.Name,
|
InternalName = Header.Name,
|
||||||
Description = Header.Description,
|
Description = Header.Description,
|
||||||
GameName = disk.Machine.Name,
|
GameName = disk.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
GameDescription = disk.Machine.Description,
|
GameDescription = disk.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
Type = disk.GetFieldValue<ItemType>(Models.Metadata.Disk.TypeKey).AsStringValue<ItemType>(),
|
Type = disk.GetFieldValue<ItemType>(Models.Metadata.Disk.TypeKey).AsStringValue<ItemType>(),
|
||||||
RomName = string.Empty,
|
RomName = string.Empty,
|
||||||
DiskName = disk.GetName(),
|
DiskName = disk.GetName(),
|
||||||
@@ -190,8 +190,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
FileName = Header.FileName,
|
FileName = Header.FileName,
|
||||||
InternalName = Header.Name,
|
InternalName = Header.Name,
|
||||||
Description = Header.Description,
|
Description = Header.Description,
|
||||||
GameName = media.Machine.Name,
|
GameName = media.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
GameDescription = media.Machine.Description,
|
GameDescription = media.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
Type = media.ItemType.AsStringValue<ItemType>(),
|
Type = media.ItemType.AsStringValue<ItemType>(),
|
||||||
RomName = string.Empty,
|
RomName = string.Empty,
|
||||||
DiskName = media.GetName(),
|
DiskName = media.GetName(),
|
||||||
@@ -218,8 +218,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
FileName = Header.FileName,
|
FileName = Header.FileName,
|
||||||
InternalName = Header.Name,
|
InternalName = Header.Name,
|
||||||
Description = Header.Description,
|
Description = Header.Description,
|
||||||
GameName = rom.Machine.Name,
|
GameName = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
GameDescription = rom.Machine.Description,
|
GameDescription = rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
Type = rom.ItemType.AsStringValue<ItemType>(),
|
Type = rom.ItemType.AsStringValue<ItemType>(),
|
||||||
RomName = rom.GetName(),
|
RomName = rom.GetName(),
|
||||||
DiskName = string.Empty,
|
DiskName = string.Empty,
|
||||||
|
|||||||
@@ -90,16 +90,14 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create the machine for copying information
|
// Create the machine for copying information
|
||||||
var machine = new Machine
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, software.CloneOf);
|
||||||
Name = software.Name,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.CommentKey, software.Notes);
|
||||||
CloneOf = software.CloneOf,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, software.Description);
|
||||||
Supported = software.Supported.AsEnumValue<Supported>(),
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, software.Name);
|
||||||
Description = software.Description,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.PublisherKey, software.Publisher);
|
||||||
Year = software.Year,
|
machine.SetFieldValue<Supported>(Models.Metadata.Machine.SupportedKey, software.Supported.AsEnumValue<Supported>());
|
||||||
Publisher = software.Publisher,
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.YearKey, software.Year);
|
||||||
Comment = software.Notes,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add all Info objects
|
// Add all Info objects
|
||||||
foreach (var info in software.Info ?? [])
|
foreach (var info in software.Info ?? [])
|
||||||
|
|||||||
@@ -259,13 +259,13 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
var software = new Models.SoftwareList.Software
|
var software = new Models.SoftwareList.Software
|
||||||
{
|
{
|
||||||
Name = machine.Name,
|
Name = machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
CloneOf = machine.CloneOf,
|
CloneOf = machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey),
|
||||||
Supported = machine.Supported.AsStringValue<Supported>(useSecond: true),
|
Supported = machine.GetFieldValue<Supported>(Models.Metadata.Machine.SupportedKey).AsStringValue<Supported>(useSecond: true),
|
||||||
Description = machine.Description,
|
Description = machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey),
|
||||||
Year = machine.Year,
|
Year = machine.GetFieldValue<string?>(Models.Metadata.Machine.YearKey),
|
||||||
Publisher = machine.Publisher,
|
Publisher = machine.GetFieldValue<string?>(Models.Metadata.Machine.PublisherKey),
|
||||||
Notes = machine.Comment,
|
Notes = machine.GetFieldValue<string?>(Models.Metadata.Machine.CommentKey),
|
||||||
};
|
};
|
||||||
|
|
||||||
return software;
|
return software;
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ namespace SabreTools.DatFiles
|
|||||||
// Filter the list
|
// Filter the list
|
||||||
return fi.Where(i => i != null)
|
return fi.Where(i => i != null)
|
||||||
.Where(i => !i.Remove)
|
.Where(i => !i.Remove)
|
||||||
.Where(i => i.Machine.Name != null)
|
.Where(i => i.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) != null)
|
||||||
.ToConcurrentList();
|
.ToConcurrentList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ namespace SabreTools.DatFiles
|
|||||||
// Filter the list
|
// Filter the list
|
||||||
return fi.Where(i => i != null)
|
return fi.Where(i => i != null)
|
||||||
.Where(i => !i.Remove)
|
.Where(i => !i.Remove)
|
||||||
.Where(i => i.Machine.Name != null)
|
.Where(i => i.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) != null)
|
||||||
.ToConcurrentList();
|
.ToConcurrentList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ namespace SabreTools.DatItems
|
|||||||
if (lastItem.DupeType.HasFlag(DupeType.External) || lastItem?.Source?.Index != Source?.Index)
|
if (lastItem.DupeType.HasFlag(DupeType.External) || lastItem?.Source?.Index != Source?.Index)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (lastItem?.Machine.Name == Machine?.Name && lastItem?.GetName() == GetName())
|
if (lastItem?.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) == Machine?.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) && lastItem?.GetName() == GetName())
|
||||||
output = DupeType.External | DupeType.All;
|
output = DupeType.External | DupeType.All;
|
||||||
else
|
else
|
||||||
output = DupeType.External | DupeType.Hash;
|
output = DupeType.External | DupeType.Hash;
|
||||||
@@ -396,7 +396,7 @@ namespace SabreTools.DatItems
|
|||||||
// Otherwise, it's considered an internal dupe
|
// Otherwise, it's considered an internal dupe
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lastItem?.Machine.Name == Machine?.Name && lastItem?.GetName() == GetName())
|
if (lastItem?.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) == Machine?.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) && lastItem?.GetName() == GetName())
|
||||||
output = DupeType.Internal | DupeType.All;
|
output = DupeType.Internal | DupeType.All;
|
||||||
else
|
else
|
||||||
output = DupeType.Internal | DupeType.Hash;
|
output = DupeType.Internal | DupeType.Hash;
|
||||||
@@ -476,9 +476,9 @@ namespace SabreTools.DatItems
|
|||||||
key = (norename ? string.Empty
|
key = (norename ? string.Empty
|
||||||
: Source?.Index.ToString().PadLeft(10, '0')
|
: Source?.Index.ToString().PadLeft(10, '0')
|
||||||
+ "-")
|
+ "-")
|
||||||
+ (string.IsNullOrEmpty(Machine?.Name)
|
+ (string.IsNullOrEmpty(Machine?.GetFieldValue<string?>(Models.Metadata.Machine.NameKey))
|
||||||
? "Default"
|
? "Default"
|
||||||
: Machine!.Name!);
|
: Machine!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!);
|
||||||
if (lower)
|
if (lower)
|
||||||
key = key.ToLowerInvariant();
|
key = key.ToLowerInvariant();
|
||||||
|
|
||||||
@@ -614,7 +614,8 @@ namespace SabreTools.DatItems
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the current machine is a child of the new machine, use the new machine instead
|
// If the current machine is a child of the new machine, use the new machine instead
|
||||||
if (saveditem.Machine.CloneOf == file.Machine.Name || saveditem.Machine.RomOf == file.Machine.Name)
|
if (saveditem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey) == file.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)
|
||||||
|
|| saveditem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey) == file.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey))
|
||||||
{
|
{
|
||||||
saveditem.CopyMachineInformation(file);
|
saveditem.CopyMachineInformation(file);
|
||||||
saveditem.SetName(file.GetName());
|
saveditem.SetName(file.GetName());
|
||||||
@@ -765,7 +766,7 @@ namespace SabreTools.DatItems
|
|||||||
NaturalComparer nc = new();
|
NaturalComparer nc = new();
|
||||||
|
|
||||||
// If machine names match, more refinement is needed
|
// If machine names match, more refinement is needed
|
||||||
if (x.Machine.Name == y.Machine.Name)
|
if (x.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) == y.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey))
|
||||||
{
|
{
|
||||||
// If item types match, more refinement is needed
|
// If item types match, more refinement is needed
|
||||||
if (x.ItemType == y.ItemType)
|
if (x.ItemType == y.ItemType)
|
||||||
@@ -781,7 +782,7 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
// If item names match, then compare on machine or source, depending on the flag
|
// If item names match, then compare on machine or source, depending on the flag
|
||||||
if (xName == yName)
|
if (xName == yName)
|
||||||
return (norename ? nc.Compare(x.Machine.Name, y.Machine.Name) : (x.Source?.Index - y.Source?.Index) ?? 0);
|
return (norename ? nc.Compare(x.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey), y.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)) : (x.Source?.Index - y.Source?.Index) ?? 0);
|
||||||
|
|
||||||
// Otherwise, just sort based on item names
|
// Otherwise, just sort based on item names
|
||||||
return nc.Compare(xName, yName);
|
return nc.Compare(xName, yName);
|
||||||
@@ -796,7 +797,7 @@ namespace SabreTools.DatItems
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, just sort based on machine name
|
// Otherwise, just sort based on machine name
|
||||||
return nc.Compare(x.Machine.Name, y.Machine.Name);
|
return nc.Compare(x.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey), y.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,6 +103,17 @@ namespace SabreTools.DatItems.Formats
|
|||||||
ItemType = ItemType.Archive;
|
ItemType = ItemType.Archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create an Archive object from the internal model
|
||||||
|
/// </summary>
|
||||||
|
public Archive(Models.Metadata.Archive? item)
|
||||||
|
{
|
||||||
|
_internal = item ?? [];
|
||||||
|
Machine = new Machine();
|
||||||
|
|
||||||
|
ItemType = ItemType.Archive;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Cloning Methods
|
#region Cloning Methods
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ namespace SabreTools.DatItems.Formats
|
|||||||
return new BaseFile()
|
return new BaseFile()
|
||||||
{
|
{
|
||||||
Filename = this.GetName(),
|
Filename = this.GetName(),
|
||||||
Parent = this.Machine.Name,
|
Parent = this.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
MD5 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Disk.MD5Key)),
|
MD5 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Disk.MD5Key)),
|
||||||
SHA1 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Disk.SHA1Key)),
|
SHA1 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Disk.SHA1Key)),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace SabreTools.DatItems.Formats
|
|||||||
[JsonProperty("format", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("format")]
|
[JsonProperty("format", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("format")]
|
||||||
public string? Format { get; set; }
|
public string? Format { get; set; }
|
||||||
|
|
||||||
#endregion // Fields
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ namespace SabreTools.DatItems.Formats
|
|||||||
{
|
{
|
||||||
return new BaseFile()
|
return new BaseFile()
|
||||||
{
|
{
|
||||||
Parent = this.Machine.Name,
|
Parent = this.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
CRC = this._crc,
|
CRC = this._crc,
|
||||||
MD5 = this._md5,
|
MD5 = this._md5,
|
||||||
SHA1 = this._sha1,
|
SHA1 = this._sha1,
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace SabreTools.DatItems.Formats
|
|||||||
return new BaseFile()
|
return new BaseFile()
|
||||||
{
|
{
|
||||||
Filename = this.GetName(),
|
Filename = this.GetName(),
|
||||||
Parent = this.Machine.Name,
|
Parent = this.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
MD5 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Media.MD5Key)),
|
MD5 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Media.MD5Key)),
|
||||||
SHA1 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Media.SHA1Key)),
|
SHA1 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Media.SHA1Key)),
|
||||||
SHA256 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Media.SHA256Key)),
|
SHA256 = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Media.SHA256Key)),
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace SabreTools.DatItems.Formats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion // Fields
|
#endregion
|
||||||
|
|
||||||
#region Accessors
|
#region Accessors
|
||||||
|
|
||||||
@@ -102,11 +102,9 @@ namespace SabreTools.DatItems.Formats
|
|||||||
SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, null);
|
SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, null);
|
||||||
SetFieldValue<ItemStatus>(Models.Metadata.Rom.StatusKey, ItemStatus.None);
|
SetFieldValue<ItemStatus>(Models.Metadata.Rom.StatusKey, ItemStatus.None);
|
||||||
|
|
||||||
Machine = new Machine
|
Machine = new Machine();
|
||||||
{
|
Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, machineName);
|
||||||
Name = machineName,
|
Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineName);
|
||||||
Description = machineName,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -174,7 +172,7 @@ namespace SabreTools.DatItems.Formats
|
|||||||
return new BaseFile()
|
return new BaseFile()
|
||||||
{
|
{
|
||||||
Filename = GetName(),
|
Filename = GetName(),
|
||||||
Parent = this.Machine.Name,
|
Parent = this.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey),
|
||||||
Date = GetFieldValue<string?>(Models.Metadata.Rom.DateKey),
|
Date = GetFieldValue<string?>(Models.Metadata.Rom.DateKey),
|
||||||
Size = GetFieldValue<long?>(Models.Metadata.Rom.SizeKey),
|
Size = GetFieldValue<long?>(Models.Metadata.Rom.SizeKey),
|
||||||
CRC = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Rom.CRCKey)),
|
CRC = TextHelper.StringToByteArray(GetFieldValue<string?>(Models.Metadata.Rom.CRCKey)),
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
using SabreTools.Core.Tools;
|
|
||||||
using SabreTools.Filter;
|
using SabreTools.Filter;
|
||||||
|
|
||||||
namespace SabreTools.DatItems
|
namespace SabreTools.DatItems
|
||||||
@@ -17,340 +14,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
#region Common
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Name of the machine
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Include)]
|
|
||||||
[XmlElement("name")]
|
|
||||||
public string? Name
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.NameKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.NameKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Additional notes
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Known as "Extra" in AttractMode</remarks>
|
|
||||||
[JsonProperty("comment", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("comment")]
|
|
||||||
public string? Comment
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.CommentKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.CommentKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Extended description
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("description", DefaultValueHandling = DefaultValueHandling.Include)]
|
|
||||||
[XmlElement("description")]
|
|
||||||
public string? Description
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.DescriptionKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.DescriptionKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Year(s) of release/manufacture
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("year", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("year")]
|
|
||||||
public string? Year
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.YearKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.YearKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Manufacturer, if available
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("manufacturer", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("manufacturer")]
|
|
||||||
public string? Manufacturer
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.ManufacturerKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.ManufacturerKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Publisher, if available
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("publisher", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("publisher")]
|
|
||||||
public string? Publisher
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.PublisherKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.PublisherKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Category, if available
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("category", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("category")]
|
|
||||||
public string? Category
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.CategoryKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.CategoryKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// fomof parent
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("romof", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("romof")]
|
|
||||||
public string? RomOf
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.RomOfKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.RomOfKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// cloneof parent
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("cloneof", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("cloneof")]
|
|
||||||
public string? CloneOf
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.CloneOfKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.CloneOfKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// sampleof parent
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("sampleof", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("sampleof")]
|
|
||||||
public string? SampleOf
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.SampleOfKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.SampleOfKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Type of the machine
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
|
||||||
[XmlElement("type")]
|
|
||||||
public MachineType MachineType
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
bool? isBios = _machine.ReadBool(Models.Metadata.Machine.IsBiosKey);
|
|
||||||
bool? isDevice = _machine.ReadBool(Models.Metadata.Machine.IsDeviceKey);
|
|
||||||
bool? isMechanical = _machine.ReadBool(Models.Metadata.Machine.IsMechanicalKey);
|
|
||||||
|
|
||||||
MachineType machineType = MachineType.None;
|
|
||||||
if (isBios == true)
|
|
||||||
machineType |= MachineType.Bios;
|
|
||||||
if (isDevice == true)
|
|
||||||
machineType |= MachineType.Device;
|
|
||||||
if (isMechanical == true)
|
|
||||||
machineType |= MachineType.Mechanical;
|
|
||||||
|
|
||||||
return machineType;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
#if NETFRAMEWORK
|
|
||||||
if ((value & MachineType.Bios) != 0)
|
|
||||||
_machine[Models.Metadata.Machine.IsBiosKey] = "yes";
|
|
||||||
if ((value & MachineType.Device) != 0)
|
|
||||||
_machine[Models.Metadata.Machine.IsDeviceKey] = "yes";
|
|
||||||
if ((value & MachineType.Mechanical) != 0)
|
|
||||||
_machine[Models.Metadata.Machine.IsMechanicalKey] = "yes";
|
|
||||||
#else
|
|
||||||
if (value.HasFlag(MachineType.Bios))
|
|
||||||
_machine[Models.Metadata.Machine.IsBiosKey] = "yes";
|
|
||||||
if (value.HasFlag(MachineType.Device))
|
|
||||||
_machine[Models.Metadata.Machine.IsDeviceKey] = "yes";
|
|
||||||
if (value.HasFlag(MachineType.Mechanical))
|
|
||||||
_machine[Models.Metadata.Machine.IsMechanicalKey] = "yes";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public bool MachineTypeSpecified { get { return MachineType != 0x0 && MachineType != MachineType.None; } }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region AttractMode
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Player count
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Also in Logiqx EmuArc</remarks>
|
|
||||||
[JsonProperty("players", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("players")]
|
|
||||||
public string? Players
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.PlayersKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.PlayersKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Screen rotation
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("rotation", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("rotation")]
|
|
||||||
public string? Rotation
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.RotationKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.RotationKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Control method
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("control", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("control")]
|
|
||||||
public string? Control
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.ControlKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.ControlKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Support status
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("status")]
|
|
||||||
public string? Status
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.StatusKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.StatusKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Display count
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("displaycount", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("displaycount")]
|
|
||||||
public string? DisplayCount
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.DisplayCountKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.DisplayCountKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Display type
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("displaytype", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("displaytype")]
|
|
||||||
public string? DisplayType
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.DisplayTypeKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.DisplayTypeKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of input buttons
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("buttons")]
|
|
||||||
public string? Buttons
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.ButtonsKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.ButtonsKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ListXML
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// History.dat entry for the machine
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("history", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("history")]
|
|
||||||
public string? History
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.HistoryKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.HistoryKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Emulator source file related to the machine
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Also in Logiqx</remarks>
|
|
||||||
[JsonProperty("sourcefile", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("sourcefile")]
|
|
||||||
public string? SourceFile
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.SourceFileKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.SourceFileKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Machine runnable status
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Also in Logiqx</remarks>
|
|
||||||
[JsonProperty("runnable", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("runnable")]
|
|
||||||
public Runnable Runnable
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.RunnableKey).AsEnumValue<Runnable>();
|
|
||||||
set => _machine[Models.Metadata.Machine.RunnableKey] = value.AsStringValue<Runnable>();
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public bool RunnableSpecified { get { return Runnable != Runnable.NULL; } }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Logiqx
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Machine board name
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("board", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("board")]
|
|
||||||
public string? Board
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.BoardKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.BoardKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Rebuild location if different than machine name
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("rebuildto", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("rebuildto")]
|
|
||||||
public string? RebuildTo
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.RebuildToKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.RebuildToKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// No-Intro ID for the game
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("nointroid", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("nointroid")]
|
|
||||||
public string? NoIntroId
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.IdKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.IdKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// No-Intro ID for the game
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("nointrocloneofid", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("nointrocloneofid")]
|
|
||||||
public string? NoIntroCloneOfId
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.CloneOfIdKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.CloneOfIdKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// TODO: Should this be a separate object for TruRip?
|
// TODO: Should this be a separate object for TruRip?
|
||||||
#region Logiqx EmuArc
|
#region Logiqx EmuArc
|
||||||
|
|
||||||
@@ -422,68 +85,51 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region OpenMSX
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generation MSX ID
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("genmsxid", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("genmsxid")]
|
|
||||||
public string? GenMSXID
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.GenMSXIDKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.GenMSXIDKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// MSX System
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("system", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("system")]
|
|
||||||
public string? System
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.SystemKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.SystemKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Machine country of origin
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("country", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("country")]
|
|
||||||
public string? Country
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.CountryKey);
|
|
||||||
set => _machine[Models.Metadata.Machine.CountryKey] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region SoftwareList
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Support status
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("supported", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
[XmlElement("supported")]
|
|
||||||
public Supported Supported
|
|
||||||
{
|
|
||||||
get => _machine.ReadString(Models.Metadata.Machine.SupportedKey).AsEnumValue<Supported>();
|
|
||||||
set => _machine[Models.Metadata.Machine.SupportedKey] = value.AsStringValue<Supported>(useSecond: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public bool SupportedSpecified { get { return Supported != Supported.NULL; } }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal Machine model
|
/// Internal Machine model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
private Models.Metadata.Machine _machine = [];
|
private Models.Metadata.Machine _machine = [];
|
||||||
|
|
||||||
#endregion // Fields
|
#endregion
|
||||||
|
|
||||||
|
#region Accessors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the value from a field based on the type provided
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type of the value to get from the internal model</typeparam>
|
||||||
|
/// <param name="fieldName">Field to retrieve</param>
|
||||||
|
/// <returns>Value from the field, if possible</returns>
|
||||||
|
public T? GetFieldValue<T>(string? fieldName)
|
||||||
|
{
|
||||||
|
// Invalid field cannot be processed
|
||||||
|
if (string.IsNullOrEmpty(fieldName))
|
||||||
|
return default;
|
||||||
|
|
||||||
|
// Get the value based on the type
|
||||||
|
return _machine.Read<T>(fieldName!);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the value from a field based on the type provided
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type of the value to set in the internal model</typeparam>
|
||||||
|
/// <param name="fieldName">Field to set</param>
|
||||||
|
/// <param name="value">Value to set</param>
|
||||||
|
/// <returns>True if the value was set, false otherwise</returns>
|
||||||
|
public bool SetFieldValue<T>(string? fieldName, T? value)
|
||||||
|
{
|
||||||
|
// Invalid field cannot be processed
|
||||||
|
if (string.IsNullOrEmpty(fieldName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Set the value based on the type
|
||||||
|
_machine[fieldName!] = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
@@ -521,8 +167,8 @@ namespace SabreTools.DatItems
|
|||||||
/// <param name="description">Description of the machine</param>
|
/// <param name="description">Description of the machine</param>
|
||||||
public Machine(string name, string description)
|
public Machine(string name, string description)
|
||||||
{
|
{
|
||||||
Name = name;
|
SetFieldValue<string?>(Models.Metadata.Machine.NameKey, name);
|
||||||
Description = description;
|
SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ namespace SabreTools.DatTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename = filename.Remove(0, rootpath?.Length ?? 0);
|
filename = filename.Remove(0, rootpath?.Length ?? 0);
|
||||||
newItem.Machine.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
newItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||||
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
||||||
+ newItem.Machine.Name;
|
+ newItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
|
|
||||||
newItems.Add(newItem);
|
newItems.Add(newItem);
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ namespace SabreTools.DatTools
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (item.Source != null)
|
if (item.Source != null)
|
||||||
newrom.Machine.Name += $" ({Path.GetFileNameWithoutExtension(inputs[item.Source.Index].CurrentPath)})";
|
newrom.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, newrom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) + $" ({Path.GetFileNameWithoutExtension(inputs[item.Source.Index].CurrentPath)})");
|
||||||
|
|
||||||
dupeData.Items.Add(key, newrom);
|
dupeData.Items.Add(key, newrom);
|
||||||
}
|
}
|
||||||
@@ -622,7 +622,7 @@ namespace SabreTools.DatTools
|
|||||||
if (item.Clone() is not DatItem newrom || newrom.Source == null)
|
if (item.Clone() is not DatItem newrom || newrom.Source == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
newrom.Machine.Name += $" ({Path.GetFileNameWithoutExtension(inputs[newrom.Source.Index].CurrentPath)})";
|
newrom.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, newrom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) + $" ({Path.GetFileNameWithoutExtension(inputs[newrom.Source.Index].CurrentPath)})");
|
||||||
outerDiffData.Items.Add(key, newrom);
|
outerDiffData.Items.Add(key, newrom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -493,8 +493,8 @@ namespace SabreTools.DatTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update machine information
|
// Update machine information
|
||||||
datItem.Machine.Name = machineName;
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, machineName);
|
||||||
datItem.Machine.Description = machineName;
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineName);
|
||||||
|
|
||||||
// If we have a Disk, then the ".chd" extension needs to be removed
|
// If we have a Disk, then the ".chd" extension needs to be removed
|
||||||
if (datItem.ItemType == ItemType.Disk && itemName!.EndsWith(".chd"))
|
if (datItem.ItemType == ItemType.Disk && itemName!.EndsWith(".chd"))
|
||||||
|
|||||||
@@ -437,11 +437,11 @@ namespace SabreTools.DatTools
|
|||||||
foreach (DatItem item in dupes)
|
foreach (DatItem item in dupes)
|
||||||
{
|
{
|
||||||
// If we don't have a proper machine
|
// If we don't have a proper machine
|
||||||
if (item.Machine?.Name == null || !datFile.Items.ContainsKey(item.Machine.Name))
|
if (item.Machine?.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) == null || !datFile.Items.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If we should check for the items in the machine
|
// If we should check for the items in the machine
|
||||||
var items = datFile.Items[item.Machine.Name];
|
var items = datFile.Items[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!];
|
||||||
if (shouldCheck && items!.Count > 1)
|
if (shouldCheck && items!.Count > 1)
|
||||||
outputFormat = OutputFormat.Folder;
|
outputFormat = OutputFormat.Folder;
|
||||||
else if (shouldCheck && items!.Count == 1)
|
else if (shouldCheck && items!.Count == 1)
|
||||||
@@ -547,14 +547,14 @@ namespace SabreTools.DatTools
|
|||||||
|
|
||||||
// Get the item from the current file
|
// Get the item from the current file
|
||||||
Rom item = new(BaseFile.GetInfo(stream, keepReadOpen: true));
|
Rom item = new(BaseFile.GetInfo(stream, keepReadOpen: true));
|
||||||
item.Machine.Name = Path.GetFileNameWithoutExtension(item.GetName());
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, Path.GetFileNameWithoutExtension(item.GetName()));
|
||||||
item.Machine.Description = Path.GetFileNameWithoutExtension(item.GetName());
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Path.GetFileNameWithoutExtension(item.GetName()));
|
||||||
|
|
||||||
// If we are coming from an archive, set the correct machine name
|
// If we are coming from an archive, set the correct machine name
|
||||||
if (machinename != null)
|
if (machinename != null)
|
||||||
{
|
{
|
||||||
item.Machine.Name = machinename;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, machinename);
|
||||||
item.Machine.Description = machinename;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machinename);
|
||||||
}
|
}
|
||||||
|
|
||||||
dupes.Add(item);
|
dupes.Add(item);
|
||||||
|
|||||||
@@ -295,8 +295,8 @@ namespace SabreTools.DatTools
|
|||||||
#else
|
#else
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
items.ForEach(item => item.Machine.Name = Path.GetFileName(item.Machine.Name));
|
items.ForEach(item => item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Path.GetFileName(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey))));
|
||||||
items.ForEach(item => item.Machine.Description = Path.GetFileName(item.Machine.Description));
|
items.ForEach(item => item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, Path.GetFileName(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey))));
|
||||||
|
|
||||||
// Now add the game to the output DAT
|
// Now add the game to the output DAT
|
||||||
tempDat.Items.AddRange(key, items);
|
tempDat.Items.AddRange(key, items);
|
||||||
|
|||||||
@@ -195,27 +195,27 @@ namespace SabreTools.Filtering
|
|||||||
// If we're stripping unicode characters, strip machine name and description
|
// If we're stripping unicode characters, strip machine name and description
|
||||||
if (RemoveUnicode)
|
if (RemoveUnicode)
|
||||||
{
|
{
|
||||||
datItem.Machine.Name = TextHelper.RemoveUnicodeCharacters(datItem.Machine.Name);
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, TextHelper.RemoveUnicodeCharacters(datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)));
|
||||||
datItem.Machine.Description = TextHelper.RemoveUnicodeCharacters(datItem.Machine.Description);
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, TextHelper.RemoveUnicodeCharacters(datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey)));
|
||||||
datItem.SetName(TextHelper.RemoveUnicodeCharacters(datItem.GetName()));
|
datItem.SetName(TextHelper.RemoveUnicodeCharacters(datItem.GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're in cleaning mode, sanitize machine name and description
|
// If we're in cleaning mode, sanitize machine name and description
|
||||||
if (Clean)
|
if (Clean)
|
||||||
{
|
{
|
||||||
datItem.Machine.Name = TextHelper.NormalizeCharacters(datItem.Machine.Name);
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, TextHelper.NormalizeCharacters(datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)));
|
||||||
datItem.Machine.Description = TextHelper.NormalizeCharacters(datItem.Machine.Description);
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, TextHelper.NormalizeCharacters(datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are in single game mode, rename the machine
|
// If we are in single game mode, rename the machine
|
||||||
if (Single)
|
if (Single)
|
||||||
datItem.Machine.Name = "!";
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "!");
|
||||||
|
|
||||||
// If we are in NTFS trim mode, trim the item name
|
// If we are in NTFS trim mode, trim the item name
|
||||||
if (Trim && datItem.GetName() != null)
|
if (Trim && datItem.GetName() != null)
|
||||||
{
|
{
|
||||||
// Windows max name length is 260
|
// Windows max name length is 260
|
||||||
int usableLength = 260 - datItem.Machine.Name!.Length - (Root?.Length ?? 0);
|
int usableLength = 260 - datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.Length - (Root?.Length ?? 0);
|
||||||
if (datItem.GetName()!.Length > usableLength)
|
if (datItem.GetName()!.Length > usableLength)
|
||||||
{
|
{
|
||||||
string ext = Path.GetExtension(datItem.GetName()!);
|
string ext = Path.GetExtension(datItem.GetName()!);
|
||||||
@@ -261,9 +261,9 @@ namespace SabreTools.Filtering
|
|||||||
{
|
{
|
||||||
// If the key mapping doesn't exist, add it
|
// If the key mapping doesn't exist, add it
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
mapping.TryAdd(item.Machine.Name!, item.Machine.Description!.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
mapping.TryAdd(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!, item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
||||||
#else
|
#else
|
||||||
mapping[item.Machine.Name!] = item.Machine.Description!.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
mapping[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!] = item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
@@ -293,20 +293,20 @@ namespace SabreTools.Filtering
|
|||||||
foreach (DatItem item in items)
|
foreach (DatItem item in items)
|
||||||
{
|
{
|
||||||
// Update machine name
|
// Update machine name
|
||||||
if (!string.IsNullOrEmpty(item.Machine.Name) && mapping.ContainsKey(item.Machine.Name!))
|
if (!string.IsNullOrEmpty(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)) && mapping.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!))
|
||||||
item.Machine.Name = mapping[item.Machine.Name!];
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, mapping[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!]);
|
||||||
|
|
||||||
// Update cloneof
|
// Update cloneof
|
||||||
if (!string.IsNullOrEmpty(item.Machine.CloneOf) && mapping.ContainsKey(item.Machine.CloneOf!))
|
if (!string.IsNullOrEmpty(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)) && mapping.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)!))
|
||||||
item.Machine.CloneOf = mapping[item.Machine.CloneOf!];
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, mapping[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)!]);
|
||||||
|
|
||||||
// Update romof
|
// Update romof
|
||||||
if (!string.IsNullOrEmpty(item.Machine.RomOf) && mapping.ContainsKey(item.Machine.RomOf!))
|
if (!string.IsNullOrEmpty(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)) && mapping.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)!))
|
||||||
item.Machine.RomOf = mapping[item.Machine.RomOf!];
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, mapping[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)!]);
|
||||||
|
|
||||||
// Update sampleof
|
// Update sampleof
|
||||||
if (!string.IsNullOrEmpty(item.Machine.SampleOf) && mapping.ContainsKey(item.Machine.SampleOf!))
|
if (!string.IsNullOrEmpty(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey)) && mapping.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey)!))
|
||||||
item.Machine.SampleOf = mapping[item.Machine.SampleOf!];
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, mapping[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey)!]);
|
||||||
|
|
||||||
// Add the new item to the output list
|
// Add the new item to the output list
|
||||||
newItems.Add(item);
|
newItems.Add(item);
|
||||||
@@ -356,30 +356,30 @@ namespace SabreTools.Filtering
|
|||||||
DatItem item = datFile.Items[key]![0];
|
DatItem item = datFile.Items[key]![0];
|
||||||
|
|
||||||
// Match on CloneOf first
|
// Match on CloneOf first
|
||||||
if (!string.IsNullOrEmpty(item.Machine.CloneOf))
|
if (!string.IsNullOrEmpty(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)))
|
||||||
{
|
{
|
||||||
if (!parents.ContainsKey(item.Machine.CloneOf!.ToLowerInvariant()))
|
if (!parents.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)!.ToLowerInvariant()))
|
||||||
parents.Add(item.Machine.CloneOf.ToLowerInvariant(), new List<string>());
|
parents.Add(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)!.ToLowerInvariant(), []);
|
||||||
|
|
||||||
parents[item.Machine.CloneOf.ToLowerInvariant()].Add(item.Machine.Name!.ToLowerInvariant());
|
parents[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)!.ToLowerInvariant()].Add(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.ToLowerInvariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then by RomOf
|
// Then by RomOf
|
||||||
else if (!string.IsNullOrEmpty(item.Machine.RomOf))
|
else if (!string.IsNullOrEmpty(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)))
|
||||||
{
|
{
|
||||||
if (!parents.ContainsKey(item.Machine.RomOf!.ToLowerInvariant()))
|
if (!parents.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)!.ToLowerInvariant()))
|
||||||
parents.Add(item.Machine.RomOf.ToLowerInvariant(), new List<string>());
|
parents.Add(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)!.ToLowerInvariant(), []);
|
||||||
|
|
||||||
parents[item.Machine.RomOf.ToLowerInvariant()].Add(item.Machine.Name!.ToLowerInvariant());
|
parents[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)!.ToLowerInvariant()].Add(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.ToLowerInvariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, treat it as a parent
|
// Otherwise, treat it as a parent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!parents.ContainsKey(item.Machine.Name!.ToLowerInvariant()))
|
if (!parents.ContainsKey(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.ToLowerInvariant()))
|
||||||
parents.Add(item.Machine.Name!.ToLowerInvariant(), new List<string>());
|
parents.Add(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.ToLowerInvariant(), []);
|
||||||
|
|
||||||
parents[item.Machine.Name.ToLowerInvariant()].Add(item.Machine.Name.ToLowerInvariant());
|
parents[item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.ToLowerInvariant()].Add(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!.ToLowerInvariant());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,9 +458,9 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
string[] splitname = datItem.GetName()!.Split('.');
|
string[] splitname = datItem.GetName()!.Split('.');
|
||||||
#if NET20 || NET35
|
#if NET20 || NET35
|
||||||
datItem.Machine.Name += $"/{string.Join(".", splitname.Take(splitname.Length > 1 ? splitname.Length - 1 : 1).ToArray())}";
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) + $"/{string.Join(".", splitname.Take(splitname.Length > 1 ? splitname.Length - 1 : 1).ToArray())}");
|
||||||
#else
|
#else
|
||||||
datItem.Machine.Name += $"/{string.Join(".", splitname.Take(splitname.Length > 1 ? splitname.Length - 1 : 1))}";
|
datItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) + $"/{string.Join(".", splitname.Take(splitname.Length > 1 ? splitname.Length - 1 : 1))}");
|
||||||
#endif
|
#endif
|
||||||
datItem.SetName(Path.GetFileName(datItem.GetName()));
|
datItem.SetName(Path.GetFileName(datItem.GetName()));
|
||||||
}
|
}
|
||||||
@@ -497,11 +497,11 @@ namespace SabreTools.Filtering
|
|||||||
for (int j = 0; j < items.Count; j++)
|
for (int j = 0; j < items.Count; j++)
|
||||||
{
|
{
|
||||||
DatItem item = items[j];
|
DatItem item = items[j];
|
||||||
if (Regex.IsMatch(item.Machine.Name!, pattern))
|
if (Regex.IsMatch(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!, pattern))
|
||||||
item.Machine.Name = Regex.Replace(item.Machine.Name!, pattern, "$2");
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Regex.Replace(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)!, pattern, "$2"));
|
||||||
|
|
||||||
if (Regex.IsMatch(item.Machine.Description!, pattern))
|
if (Regex.IsMatch(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey)!, pattern))
|
||||||
item.Machine.Description = Regex.Replace(item.Machine.Description!, pattern, "$2");
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, Regex.Replace(item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey)!, pattern, "$2"));
|
||||||
|
|
||||||
items[j] = item;
|
items[j] = item;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ namespace SabreTools.Filtering
|
|||||||
// Special case for description
|
// Special case for description
|
||||||
if (machineFieldNames.Contains(Models.Metadata.Machine.DescriptionKey))
|
if (machineFieldNames.Contains(Models.Metadata.Machine.DescriptionKey))
|
||||||
{
|
{
|
||||||
if (!onlySame || (onlySame && machine.Name == machine.Description))
|
if (!onlySame || (onlySame && machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) == machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey)))
|
||||||
machine.Description = repMachine.Description;
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, repMachine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,8 +246,8 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
// Determine if the game has a parent or not
|
// Determine if the game has a parent or not
|
||||||
string? parent = null;
|
string? parent = null;
|
||||||
if (!string.IsNullOrEmpty(items[0].Machine.RomOf))
|
if (!string.IsNullOrEmpty(items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)))
|
||||||
parent = items[0].Machine.RomOf;
|
parent = items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey);
|
||||||
|
|
||||||
// If the parent doesnt exist, we want to continue
|
// If the parent doesnt exist, we want to continue
|
||||||
if (string.IsNullOrEmpty(parent))
|
if (string.IsNullOrEmpty(parent))
|
||||||
@@ -290,11 +290,7 @@ namespace SabreTools.Filtering
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If the machine (is/is not) a device, we want to continue
|
// If the machine (is/is not) a device, we want to continue
|
||||||
#if NETFRAMEWORK
|
if (dev ^ (datFile.Items[machine]![0].Machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey) == true))
|
||||||
if (dev ^ ((datFile.Items[machine]![0].Machine.MachineType & MachineType.Device) != 0))
|
|
||||||
#else
|
|
||||||
if (dev ^ (datFile.Items[machine]![0].Machine.MachineType.HasFlag(MachineType.Device)))
|
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Get all device reference names from the current machine
|
// Get all device reference names from the current machine
|
||||||
@@ -441,8 +437,8 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
// Determine if the game has a parent or not
|
// Determine if the game has a parent or not
|
||||||
string? parent = null;
|
string? parent = null;
|
||||||
if (!string.IsNullOrEmpty(items[0].Machine.CloneOf))
|
if (!string.IsNullOrEmpty(items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)))
|
||||||
parent = items[0].Machine.CloneOf;
|
parent = items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey);
|
||||||
|
|
||||||
// If the parent doesnt exist, we want to continue
|
// If the parent doesnt exist, we want to continue
|
||||||
if (string.IsNullOrEmpty(parent))
|
if (string.IsNullOrEmpty(parent))
|
||||||
@@ -468,10 +464,10 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
// Now we want to get the parent romof tag and put it in each of the items
|
// Now we want to get the parent romof tag and put it in each of the items
|
||||||
items = datFile.Items[game];
|
items = datFile.Items[game];
|
||||||
string? romof = datFile.Items[parent!]![0].Machine.RomOf;
|
string? romof = datFile.Items[parent!]![0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey);
|
||||||
foreach (DatItem item in items!)
|
foreach (DatItem item in items!)
|
||||||
{
|
{
|
||||||
item.Machine.RomOf = romof;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, romof);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,8 +490,8 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
// Determine if the game has a parent or not
|
// Determine if the game has a parent or not
|
||||||
string? parent = null;
|
string? parent = null;
|
||||||
if (!string.IsNullOrEmpty(items[0].Machine.CloneOf))
|
if (!string.IsNullOrEmpty(items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)))
|
||||||
parent = items[0].Machine.CloneOf;
|
parent = items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey);
|
||||||
|
|
||||||
// If there is no parent, then we continue
|
// If there is no parent, then we continue
|
||||||
if (string.IsNullOrEmpty(parent))
|
if (string.IsNullOrEmpty(parent))
|
||||||
@@ -506,8 +502,8 @@ namespace SabreTools.Filtering
|
|||||||
if (datFile.Items[parent!]!.Count == 0)
|
if (datFile.Items[parent!]!.Count == 0)
|
||||||
{
|
{
|
||||||
copyFrom = new Rom();
|
copyFrom = new Rom();
|
||||||
copyFrom.Machine.Name = parent;
|
copyFrom.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, parent);
|
||||||
copyFrom.Machine.Description = parent;
|
copyFrom.Machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, parent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -559,7 +555,7 @@ namespace SabreTools.Filtering
|
|||||||
else if (rom.GetFieldValue<string?>(Models.Metadata.Rom.MergeKey) != null && !datFile.Items[parent!]!.Where(i => i.ItemType == ItemType.Rom).Select(i => (i as Rom)!.GetName()).Contains(rom.GetFieldValue<string?>(Models.Metadata.Rom.MergeKey)))
|
else if (rom.GetFieldValue<string?>(Models.Metadata.Rom.MergeKey) != null && !datFile.Items[parent!]!.Where(i => i.ItemType == ItemType.Rom).Select(i => (i as Rom)!.GetName()).Contains(rom.GetFieldValue<string?>(Models.Metadata.Rom.MergeKey)))
|
||||||
{
|
{
|
||||||
if (subfolder)
|
if (subfolder)
|
||||||
rom.SetName($"{rom.Machine.Name}\\{rom.GetName()}");
|
rom.SetName($"{rom.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}\\{rom.GetName()}");
|
||||||
|
|
||||||
rom.CopyMachineInformation(copyFrom);
|
rom.CopyMachineInformation(copyFrom);
|
||||||
datFile.Items.Add(parent!, rom);
|
datFile.Items.Add(parent!, rom);
|
||||||
@@ -569,7 +565,7 @@ namespace SabreTools.Filtering
|
|||||||
else if (!datFile.Items[parent!]!.Contains(item) || skipDedup)
|
else if (!datFile.Items[parent!]!.Contains(item) || skipDedup)
|
||||||
{
|
{
|
||||||
if (subfolder)
|
if (subfolder)
|
||||||
rom.SetName($"{item.Machine.Name}\\{rom.GetName()}");
|
rom.SetName($"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}\\{rom.GetName()}");
|
||||||
|
|
||||||
rom.CopyMachineInformation(copyFrom);
|
rom.CopyMachineInformation(copyFrom);
|
||||||
datFile.Items.Add(parent!, rom);
|
datFile.Items.Add(parent!, rom);
|
||||||
@@ -580,7 +576,7 @@ namespace SabreTools.Filtering
|
|||||||
else if (!datFile.Items[parent!]!.Contains(item))
|
else if (!datFile.Items[parent!]!.Contains(item))
|
||||||
{
|
{
|
||||||
if (subfolder)
|
if (subfolder)
|
||||||
item.SetName($"{item.Machine.Name}\\{item.GetName()}");
|
item.SetName($"{item.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey)}\\{item.GetName()}");
|
||||||
|
|
||||||
item.CopyMachineInformation(copyFrom);
|
item.CopyMachineInformation(copyFrom);
|
||||||
datFile.Items.Add(parent!, item);
|
datFile.Items.Add(parent!, item);
|
||||||
@@ -606,13 +602,8 @@ namespace SabreTools.Filtering
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (items.Count > 0
|
if (items.Count > 0
|
||||||
#if NETFRAMEWORK
|
&& ((items[0].Machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey) == true)
|
||||||
&& ((items[0].Machine.MachineType & MachineType.Bios) != 0
|
|| (items[0].Machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsDeviceKey) == true)))
|
||||||
|| (items[0].Machine.MachineType & MachineType.Device) != 0))
|
|
||||||
#else
|
|
||||||
&& (items[0].Machine.MachineType.HasFlag(MachineType.Bios)
|
|
||||||
|| items[0].Machine.MachineType.HasFlag(MachineType.Device)))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
datFile.Items.Remove(game);
|
datFile.Items.Remove(game);
|
||||||
}
|
}
|
||||||
@@ -636,17 +627,13 @@ namespace SabreTools.Filtering
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If the game (is/is not) a bios, we want to continue
|
// If the game (is/is not) a bios, we want to continue
|
||||||
#if NETFRAMEWORK
|
if (bios ^ (items[0].Machine.GetFieldValue<bool?>(Models.Metadata.Machine.IsBiosKey) == true))
|
||||||
if (bios ^ (items[0].Machine.MachineType & MachineType.Bios) != 0)
|
|
||||||
#else
|
|
||||||
if (bios ^ items[0].Machine.MachineType.HasFlag(MachineType.Bios))
|
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Determine if the game has a parent or not
|
// Determine if the game has a parent or not
|
||||||
string? parent = null;
|
string? parent = null;
|
||||||
if (!string.IsNullOrEmpty(items[0].Machine.RomOf))
|
if (!string.IsNullOrEmpty(items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey)))
|
||||||
parent = items[0].Machine.RomOf;
|
parent = items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey);
|
||||||
|
|
||||||
// If the parent doesnt exist, we want to continue
|
// If the parent doesnt exist, we want to continue
|
||||||
if (string.IsNullOrEmpty(parent))
|
if (string.IsNullOrEmpty(parent))
|
||||||
@@ -691,8 +678,8 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
// Determine if the game has a parent or not
|
// Determine if the game has a parent or not
|
||||||
string? parent = null;
|
string? parent = null;
|
||||||
if (!string.IsNullOrEmpty(items[0].Machine.CloneOf))
|
if (!string.IsNullOrEmpty(items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey)))
|
||||||
parent = items[0].Machine.CloneOf;
|
parent = items[0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey);
|
||||||
|
|
||||||
// If the parent doesnt exist, we want to continue
|
// If the parent doesnt exist, we want to continue
|
||||||
if (string.IsNullOrEmpty(parent))
|
if (string.IsNullOrEmpty(parent))
|
||||||
@@ -715,10 +702,10 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
// Now we want to get the parent romof tag and put it in each of the remaining items
|
// Now we want to get the parent romof tag and put it in each of the remaining items
|
||||||
items = datFile.Items[game];
|
items = datFile.Items[game];
|
||||||
string? romof = datFile.Items[parent!]![0].Machine.RomOf;
|
string? romof = datFile.Items[parent!]![0].Machine.GetFieldValue<string?>(Models.Metadata.Machine.RomOfKey);
|
||||||
foreach (DatItem item in items!)
|
foreach (DatItem item in items!)
|
||||||
{
|
{
|
||||||
item.Machine.RomOf = romof;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, romof);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -738,9 +725,9 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
foreach (DatItem item in items)
|
foreach (DatItem item in items)
|
||||||
{
|
{
|
||||||
item.Machine.CloneOf = null;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, null);
|
||||||
item.Machine.RomOf = null;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, null);
|
||||||
item.Machine.SampleOf = null;
|
item.Machine.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,29 +15,39 @@ namespace SabreTools.Test.DatFiles
|
|||||||
public void BucketByTest(ItemKey itemKey, int expected)
|
public void BucketByTest(ItemKey itemKey, int expected)
|
||||||
{
|
{
|
||||||
// Setup the items
|
// Setup the items
|
||||||
var rom1 = new Rom { Machine = new Machine { Name = "game-1" } };
|
var machine1 = new Machine();
|
||||||
|
machine1.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "game-1");
|
||||||
|
|
||||||
|
var machine2 = new Machine();
|
||||||
|
machine2.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "game-2");
|
||||||
|
|
||||||
|
var rom1 = new Rom();
|
||||||
rom1.SetName("rom-1");
|
rom1.SetName("rom-1");
|
||||||
rom1.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
rom1.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
||||||
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
var rom2 = new Rom { Machine = new Machine { Name = "game-1" } };
|
var rom2 = new Rom();
|
||||||
rom2.SetName("rom-2");
|
rom2.SetName("rom-2");
|
||||||
rom2.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
rom2.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
||||||
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
var rom3 = new Rom { Machine = new Machine { Name = "game-2" } };
|
var rom3 = new Rom();
|
||||||
rom3.SetName("rom-3");
|
rom3.SetName("rom-3");
|
||||||
rom3.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
rom3.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
rom3.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "00000ea4014ce66679e7e17d56ac510f67e39e26");
|
rom3.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "00000ea4014ce66679e7e17d56ac510f67e39e26");
|
||||||
rom3.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom3.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine2);
|
||||||
|
|
||||||
var rom4 = new Rom { Machine = new Machine { Name = "game-2" } };
|
var rom4 = new Rom();
|
||||||
rom4.SetName("rom-4");
|
rom4.SetName("rom-4");
|
||||||
rom4.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
rom4.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
rom4.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "00000151d437442e74e5134023fab8bf694a2487");
|
rom4.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "00000151d437442e74e5134023fab8bf694a2487");
|
||||||
rom4.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom4.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine2);
|
||||||
|
|
||||||
// Setup the dictionary
|
// Setup the dictionary
|
||||||
var dict = new ItemDictionary
|
var dict = new ItemDictionary
|
||||||
@@ -69,17 +79,22 @@ namespace SabreTools.Test.DatFiles
|
|||||||
public void ClearMarkedTest()
|
public void ClearMarkedTest()
|
||||||
{
|
{
|
||||||
// Setup the items
|
// Setup the items
|
||||||
var rom1 = new Rom { Machine = new Machine { Name = "game-1" } };
|
var machine1 = new Machine();
|
||||||
|
machine1.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "game-1");
|
||||||
|
|
||||||
|
var rom1 = new Rom();
|
||||||
rom1.SetName("rom-1");
|
rom1.SetName("rom-1");
|
||||||
rom1.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
rom1.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
||||||
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
var rom2 = new Rom { Machine = new Machine { Name = "game-1" }, Remove = true };
|
var rom2 = new Rom { Remove = true };
|
||||||
rom2.SetName("rom-2");
|
rom2.SetName("rom-2");
|
||||||
rom2.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
rom2.SetFieldValue<string?>(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
||||||
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
// Setup the dictionary
|
// Setup the dictionary
|
||||||
var dict = new ItemDictionary
|
var dict = new ItemDictionary
|
||||||
@@ -100,15 +115,20 @@ namespace SabreTools.Test.DatFiles
|
|||||||
public void GetDuplicatesTest(bool hasDuplicate, int expected)
|
public void GetDuplicatesTest(bool hasDuplicate, int expected)
|
||||||
{
|
{
|
||||||
// Setup the items
|
// Setup the items
|
||||||
var rom1 = new Rom { Machine = new Machine { Name = "game-1" } };
|
var machine1 = new Machine();
|
||||||
|
machine1.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "game-1");
|
||||||
|
|
||||||
|
var rom1 = new Rom();
|
||||||
rom1.SetName("rom-1");
|
rom1.SetName("rom-1");
|
||||||
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
||||||
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
var rom2 = new Rom { Machine = new Machine { Name = "game-1" } };
|
var rom2 = new Rom();
|
||||||
rom2.SetName("rom-2");
|
rom2.SetName("rom-2");
|
||||||
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
||||||
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
// Setup the dictionary
|
// Setup the dictionary
|
||||||
var dict = new ItemDictionary
|
var dict = new ItemDictionary
|
||||||
@@ -117,10 +137,11 @@ namespace SabreTools.Test.DatFiles
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Setup the test item
|
// Setup the test item
|
||||||
var rom = new Rom { Machine = new Machine { Name = "game-1" } };
|
var rom = new Rom();
|
||||||
rom.SetName("rom-1");
|
rom.SetName("rom-1");
|
||||||
rom.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
rom.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
||||||
rom.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, hasDuplicate ? 1024 : 2048);
|
rom.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, hasDuplicate ? 1024 : 2048);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
var actual = dict.GetDuplicates(rom);
|
var actual = dict.GetDuplicates(rom);
|
||||||
Assert.Equal(expected, actual.Count);
|
Assert.Equal(expected, actual.Count);
|
||||||
@@ -132,15 +153,20 @@ namespace SabreTools.Test.DatFiles
|
|||||||
public void HasDuplicatesTest(bool expected)
|
public void HasDuplicatesTest(bool expected)
|
||||||
{
|
{
|
||||||
// Setup the items
|
// Setup the items
|
||||||
var rom1 = new Rom { Machine = new Machine { Name = "game-1" } };
|
var machine1 = new Machine();
|
||||||
|
machine1.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "game-1");
|
||||||
|
|
||||||
|
var rom1 = new Rom();
|
||||||
rom1.SetName("rom-1");
|
rom1.SetName("rom-1");
|
||||||
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
rom1.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
||||||
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom1.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
var rom2 = new Rom { Machine = new Machine { Name = "game-1" } };
|
var rom2 = new Rom();
|
||||||
rom2.SetName("rom-2");
|
rom2.SetName("rom-2");
|
||||||
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
rom2.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "000000e948edcb4f7704b8af85a77a3339ecce44");
|
||||||
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
rom2.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, 1024);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
// Setup the dictionary
|
// Setup the dictionary
|
||||||
var dict = new ItemDictionary
|
var dict = new ItemDictionary
|
||||||
@@ -149,10 +175,11 @@ namespace SabreTools.Test.DatFiles
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Setup the test item
|
// Setup the test item
|
||||||
var rom = new Rom { Machine = new Machine { Name = "game-1" } };
|
var rom = new Rom();
|
||||||
rom.SetName("rom-1");
|
rom.SetName("rom-1");
|
||||||
rom.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
rom.SetFieldValue<string?>(Models.Metadata.Rom.SHA1Key, "0000000fbbb37f8488100b1b4697012de631a5e6");
|
||||||
rom.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, expected ? 1024 : 2048);
|
rom.SetFieldValue<long?>(Models.Metadata.Rom.SizeKey, expected ? 1024 : 2048);
|
||||||
|
rom1.CopyMachineInformation(machine1);
|
||||||
|
|
||||||
bool actual = dict.HasDuplicates(rom);
|
bool actual = dict.HasDuplicates(rom);
|
||||||
Assert.Equal(expected, actual);
|
Assert.Equal(expected, actual);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace SabreTools.Test.DatFiles
|
|||||||
var setter = new Setter();
|
var setter = new Setter();
|
||||||
setter.PopulateSetters("machine.name", "foo");
|
setter.PopulateSetters("machine.name", "foo");
|
||||||
setter.SetFields(datItem.Machine);
|
setter.SetFields(datItem.Machine);
|
||||||
Assert.Equal("foo", datItem.Machine.Name);
|
Assert.Equal("foo", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -32,15 +32,13 @@ namespace SabreTools.Test.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static DatItem CreateDatItem()
|
private static DatItem CreateDatItem()
|
||||||
{
|
{
|
||||||
var rom = new Rom
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "bar");
|
||||||
Machine = new Machine
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, "bar");
|
||||||
{
|
|
||||||
Name = "bar",
|
var rom = new Rom { Machine = machine };
|
||||||
Description = "bar",
|
|
||||||
}
|
|
||||||
};
|
|
||||||
rom.SetName("foo");
|
rom.SetName("foo");
|
||||||
|
|
||||||
return rom;
|
return rom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,21 +47,27 @@ namespace SabreTools.Test.DatItems
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void DuplicateStatusExternalAllTest()
|
public void DuplicateStatusExternalAllTest()
|
||||||
{
|
{
|
||||||
|
var machineA = new Machine();
|
||||||
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
||||||
|
|
||||||
|
var machineB = new Machine();
|
||||||
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
||||||
|
|
||||||
var romA = new Rom
|
var romA = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "name-same" },
|
|
||||||
Source = new Source { Index = 0 },
|
Source = new Source { Index = 0 },
|
||||||
};
|
};
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom
|
var romB = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "name-same" },
|
|
||||||
Source = new Source { Index = 1 },
|
Source = new Source { Index = 1 },
|
||||||
};
|
};
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
Assert.Equal(DupeType.External | DupeType.All, actual);
|
Assert.Equal(DupeType.External | DupeType.All, actual);
|
||||||
@@ -70,21 +76,27 @@ namespace SabreTools.Test.DatItems
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void DuplicateStatusExternalHashTest()
|
public void DuplicateStatusExternalHashTest()
|
||||||
{
|
{
|
||||||
|
var machineA = new Machine();
|
||||||
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
||||||
|
|
||||||
|
var machineB = new Machine();
|
||||||
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "not-name-same");
|
||||||
|
|
||||||
var romA = new Rom
|
var romA = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "name-same" },
|
|
||||||
Source = new Source { Index = 0 },
|
Source = new Source { Index = 0 },
|
||||||
};
|
};
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom
|
var romB = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "not-name-same" },
|
|
||||||
Source = new Source { Index = 1 },
|
Source = new Source { Index = 1 },
|
||||||
};
|
};
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
Assert.Equal(DupeType.External | DupeType.Hash, actual);
|
Assert.Equal(DupeType.External | DupeType.Hash, actual);
|
||||||
@@ -93,21 +105,27 @@ namespace SabreTools.Test.DatItems
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void DuplicateStatusInternalAllTest()
|
public void DuplicateStatusInternalAllTest()
|
||||||
{
|
{
|
||||||
|
var machineA = new Machine();
|
||||||
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
||||||
|
|
||||||
|
var machineB = new Machine();
|
||||||
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
||||||
|
|
||||||
var romA = new Rom
|
var romA = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "name-same" },
|
|
||||||
Source = new Source { Index = 0 },
|
Source = new Source { Index = 0 },
|
||||||
};
|
};
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom
|
var romB = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "name-same" },
|
|
||||||
Source = new Source { Index = 0 },
|
Source = new Source { Index = 0 },
|
||||||
};
|
};
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
Assert.Equal(DupeType.Internal | DupeType.All, actual);
|
Assert.Equal(DupeType.Internal | DupeType.All, actual);
|
||||||
@@ -116,21 +134,27 @@ namespace SabreTools.Test.DatItems
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void DuplicateStatusInternalHashTest()
|
public void DuplicateStatusInternalHashTest()
|
||||||
{
|
{
|
||||||
|
var machineA = new Machine();
|
||||||
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
||||||
|
|
||||||
|
var machineB = new Machine();
|
||||||
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "not-name-same");
|
||||||
|
|
||||||
var romA = new Rom
|
var romA = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "name-same" },
|
|
||||||
Source = new Source { Index = 0 },
|
Source = new Source { Index = 0 },
|
||||||
};
|
};
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom
|
var romB = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine { Name = "not-name-same" },
|
|
||||||
Source = new Source { Index = 0 },
|
Source = new Source { Index = 0 },
|
||||||
};
|
};
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
Assert.Equal(DupeType.Internal | DupeType.Hash, actual);
|
Assert.Equal(DupeType.Internal | DupeType.Hash, actual);
|
||||||
|
|||||||
@@ -68,15 +68,13 @@ namespace SabreTools.Test.Filter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static DatItem CreateDatItem()
|
private static DatItem CreateDatItem()
|
||||||
{
|
{
|
||||||
var rom = new Rom
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "bar");
|
||||||
Machine = new Machine
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, "bar");
|
||||||
{
|
|
||||||
Name = "bar",
|
var rom = new Rom { Machine = machine };
|
||||||
Description = "bar",
|
|
||||||
}
|
|
||||||
};
|
|
||||||
rom.SetName("foo");
|
rom.SetName("foo");
|
||||||
|
|
||||||
return rom;
|
return rom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ namespace SabreTools.Test.Filtering
|
|||||||
|
|
||||||
// Check the fields
|
// Check the fields
|
||||||
Assert.Equal("nam", datItem.GetName());
|
Assert.Equal("nam", datItem.GetName());
|
||||||
Assert.Equal("nam-2", datItem.Machine.Name);
|
Assert.Equal("nam-2", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
Assert.Equal("nam-3", datItem.Machine.Description);
|
Assert.Equal("nam-3", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -45,8 +45,8 @@ namespace SabreTools.Test.Filtering
|
|||||||
|
|
||||||
// Check the fields
|
// Check the fields
|
||||||
Assert.Equal("name", datItem.GetName());
|
Assert.Equal("name", datItem.GetName());
|
||||||
Assert.Equal("'AB'", datItem.Machine.Name);
|
Assert.Equal("'AB'", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
Assert.Equal("ae-Zh", datItem.Machine.Description);
|
Assert.Equal("ae-Zh", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -66,8 +66,8 @@ namespace SabreTools.Test.Filtering
|
|||||||
|
|
||||||
// Check the fields
|
// Check the fields
|
||||||
Assert.Equal("name", datItem.GetName());
|
Assert.Equal("name", datItem.GetName());
|
||||||
Assert.Equal("!", datItem.Machine.Name);
|
Assert.Equal("!", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
Assert.Equal("name-3", datItem.Machine.Description);
|
Assert.Equal("name-3", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@@ -92,8 +92,8 @@ namespace SabreTools.Test.Filtering
|
|||||||
|
|
||||||
// Check the fields
|
// Check the fields
|
||||||
Assert.Equal(expected, datItem.GetName());
|
Assert.Equal(expected, datItem.GetName());
|
||||||
Assert.Equal("name-2", datItem.Machine.Name);
|
Assert.Equal("name-2", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
Assert.Equal("name-3", datItem.Machine.Description);
|
Assert.Equal("name-3", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -107,23 +107,21 @@ namespace SabreTools.Test.Filtering
|
|||||||
|
|
||||||
// Check the fields
|
// Check the fields
|
||||||
Assert.Equal("name", datItem.GetName());
|
Assert.Equal("name", datItem.GetName());
|
||||||
Assert.Equal("name-2/name", datItem.Machine.Name);
|
Assert.Equal("name-2/name", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a consistent DatItem for testing
|
/// Generate a consistent DatItem for testing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static DatItem CreateDatItem(string name, string machine, string desc)
|
private static DatItem CreateDatItem(string name, string machName, string desc)
|
||||||
{
|
{
|
||||||
var rom = new Rom
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machName);
|
||||||
Machine = new Machine
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, desc);
|
||||||
{
|
|
||||||
Name = machine,
|
var rom = new Rom { Machine = machine };
|
||||||
Description = desc,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
rom.SetName(name);
|
rom.SetName(name);
|
||||||
|
|
||||||
return rom;
|
return rom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace SabreTools.Test.Filtering
|
|||||||
var remover = new Remover();
|
var remover = new Remover();
|
||||||
remover.PopulateExclusions("Machine.Name");
|
remover.PopulateExclusions("Machine.Name");
|
||||||
remover.RemoveFields(datItem);
|
remover.RemoveFields(datItem);
|
||||||
Assert.Null(datItem.Machine.Name);
|
Assert.Null(datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -32,15 +32,13 @@ namespace SabreTools.Test.Filtering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static DatItem CreateDatItem()
|
private static DatItem CreateDatItem()
|
||||||
{
|
{
|
||||||
var rom = new Rom
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "bar");
|
||||||
Machine = new Machine
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, "bar");
|
||||||
{
|
|
||||||
Name = "bar",
|
var rom = new Rom { Machine = machine };
|
||||||
Description = "bar",
|
|
||||||
}
|
|
||||||
};
|
|
||||||
rom.SetName("foo");
|
rom.SetName("foo");
|
||||||
|
|
||||||
return rom;
|
return rom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ namespace SabreTools.Test.Filtering
|
|||||||
{
|
{
|
||||||
var datItem = CreateDatItem();
|
var datItem = CreateDatItem();
|
||||||
var repDatItem = CreateDatItem();
|
var repDatItem = CreateDatItem();
|
||||||
repDatItem.Machine.Name = "foo";
|
repDatItem.Machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "foo");
|
||||||
List<string> fields = [Models.Metadata.Machine.NameKey];
|
List<string> fields = [Models.Metadata.Machine.NameKey];
|
||||||
Replacer.ReplaceFields(datItem.Machine, repDatItem.Machine, fields, false);
|
Replacer.ReplaceFields(datItem.Machine, repDatItem.Machine, fields, false);
|
||||||
Assert.Equal("foo", datItem.Machine.Name);
|
Assert.Equal("foo", datItem.Machine.GetFieldValue<string?>(Models.Metadata.Machine.NameKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -40,15 +40,13 @@ namespace SabreTools.Test.Filtering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static DatItem CreateDatItem()
|
private static DatItem CreateDatItem()
|
||||||
{
|
{
|
||||||
var rom = new Rom
|
var machine = new Machine();
|
||||||
{
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "bar");
|
||||||
Machine = new Machine
|
machine.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, "bar");
|
||||||
{
|
|
||||||
Name = "bar",
|
var rom = new Rom { Machine = machine };
|
||||||
Description = "bar",
|
|
||||||
}
|
|
||||||
};
|
|
||||||
rom.SetName("foo");
|
rom.SetName("foo");
|
||||||
|
|
||||||
return rom;
|
return rom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user