mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Machine stands alone
This commit is contained in:
@@ -607,7 +607,7 @@ namespace RombaSharp.Features
|
||||
internal static void AddDatToDatabase(Rom dat, SqliteConnection dbc)
|
||||
{
|
||||
// Get the dat full path
|
||||
string fullpath = Path.Combine(_dats, (dat.MachineName == "dats" ? string.Empty : dat.MachineName), dat.Name);
|
||||
string fullpath = Path.Combine(_dats, (dat.Machine.Name == "dats" ? string.Empty : dat.Machine.Name), dat.Name);
|
||||
|
||||
// Parse the Dat if possible
|
||||
Globals.Logger.User($"Adding from '{dat.Name}'");
|
||||
|
||||
@@ -81,15 +81,21 @@ namespace SabreTools.Library.DatFiles
|
||||
SHA1 = Constants.SHA1Zero,
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
MachineName = gameinfo[0],
|
||||
MachineDescription = gameinfo[1],
|
||||
CloneOf = gameinfo[3],
|
||||
Year = gameinfo[4],
|
||||
Manufacturer = gameinfo[5],
|
||||
Comment = gameinfo[15],
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = gameinfo[0],
|
||||
Description = gameinfo[1],
|
||||
CloneOf = gameinfo[3],
|
||||
Year = gameinfo[4],
|
||||
Manufacturer = gameinfo[5],
|
||||
Comment = gameinfo[15],
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -145,14 +151,14 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem item = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (item.Name == null || item.MachineName == null)
|
||||
if (item.Name == null || item.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != item.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != item.Machine.Name.ToLowerInvariant())
|
||||
WriteDatItem(svw, item, ignoreblanks);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -160,14 +166,14 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)item).Size == -1
|
||||
&& ((Rom)item).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {item.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {item.Machine.Name}");
|
||||
|
||||
item.Name = (item.Name == "null" ? "-" : item.Name);
|
||||
((Rom)item).Size = Constants.SizeZero;
|
||||
}
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = item.MachineName;
|
||||
lastgame = item.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +249,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Pre-process the item name
|
||||
ProcessItemName(datItem, true);
|
||||
|
||||
@@ -291,8 +291,8 @@ namespace SabreTools.Library.DatFiles
|
||||
// Then populate it with information
|
||||
item.CopyMachineInformation(machine);
|
||||
|
||||
item.IndexId = indexId;
|
||||
item.IndexSource = filename;
|
||||
item.Source.Index = indexId;
|
||||
item.Source.Name = filename;
|
||||
|
||||
// Loop through all of the attributes
|
||||
foreach (var kvp in cmpr.Internal)
|
||||
@@ -420,8 +420,11 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
{
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -475,18 +478,18 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(cmpw, rom);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(cmpw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -494,7 +497,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
@@ -514,7 +517,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(cmpw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,27 +616,27 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
cmpw.WriteStartElement(datItem.MachineType == MachineType.Bios ? "resource" : "game");
|
||||
cmpw.WriteStartElement(datItem.Machine.MachineType == MachineType.Bios ? "resource" : "game");
|
||||
cmpw.WriteStandalone("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("romof", datItem.RomOf);
|
||||
cmpw.WriteStandalone("romof", datItem.Machine.RomOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("cloneof", datItem.CloneOf);
|
||||
cmpw.WriteStandalone("cloneof", datItem.Machine.CloneOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("sampleof", datItem.SampleOf);
|
||||
cmpw.WriteStandalone("sampleof", datItem.Machine.SampleOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("description", datItem.MachineDescription);
|
||||
cmpw.WriteStandalone("description", datItem.Machine.Description);
|
||||
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("description", datItem.MachineName);
|
||||
cmpw.WriteStandalone("description", datItem.Machine.Name);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("year", datItem.Year);
|
||||
cmpw.WriteStandalone("year", datItem.Machine.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("manufacturer", datItem.Manufacturer);
|
||||
cmpw.WriteStandalone("manufacturer", datItem.Machine.Manufacturer);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("category", datItem.Category);
|
||||
cmpw.WriteStandalone("category", datItem.Machine.Category);
|
||||
|
||||
cmpw.Flush();
|
||||
}
|
||||
@@ -658,7 +661,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
// Build the state based on excluded fields
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)))
|
||||
cmpw.WriteStandalone("sampleof", datItem.SampleOf);
|
||||
cmpw.WriteStandalone("sampleof", datItem.Machine.SampleOf);
|
||||
|
||||
// End game
|
||||
cmpw.WriteEndElement();
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
DatItem newDatItem = datItem.Clone() as DatItem;
|
||||
if (Items.ContainsKey(key) && Items[key].Count() > 0)
|
||||
newDatItem.ReplaceMachineFields(Items[key][0], updateFields, onlySame);
|
||||
newDatItem.Machine.ReplaceFields(Items[key][0].Machine, updateFields, onlySame);
|
||||
|
||||
newDatItems.Add(newDatItem);
|
||||
}
|
||||
@@ -499,13 +499,13 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
// There's odd cases where there are items with System ID < 0. Skip them for now
|
||||
if (item.IndexId < 0)
|
||||
if (item.Source.Index < 0)
|
||||
{
|
||||
Globals.Logger.Warning($"Item found with a <0 SystemID: {item.Name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
outDats[item.IndexId].Items.Add(key, item);
|
||||
outDats[item.Source.Index].Items.Add(key, item);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -581,7 +581,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (item.DupeType.HasFlag(DupeType.External))
|
||||
{
|
||||
DatItem newrom = item.Clone() as DatItem;
|
||||
newrom.MachineName += $" ({Path.GetFileNameWithoutExtension(inputs[item.IndexId].CurrentPath)})";
|
||||
newrom.Machine.Name += $" ({Path.GetFileNameWithoutExtension(inputs[item.Source.Index].CurrentPath)})";
|
||||
|
||||
dupeData.Items.Add(key, newrom);
|
||||
}
|
||||
@@ -660,7 +660,7 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
if (item.DupeType.HasFlag(DupeType.Internal) || item.DupeType == 0x00)
|
||||
outDats[item.IndexId].Items.Add(key, item);
|
||||
outDats[item.Source.Index].Items.Add(key, item);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -736,7 +736,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (item.DupeType.HasFlag(DupeType.Internal) || item.DupeType == 0x00)
|
||||
{
|
||||
DatItem newrom = item.Clone() as DatItem;
|
||||
newrom.MachineName += $" ({Path.GetFileNameWithoutExtension(inputs[item.IndexId].CurrentPath)})";
|
||||
newrom.Machine.Name += $" ({Path.GetFileNameWithoutExtension(inputs[item.Source.Index].CurrentPath)})";
|
||||
outerDiffData.Items.Add(key, newrom);
|
||||
}
|
||||
}
|
||||
@@ -778,14 +778,14 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
DatItem newItem = item;
|
||||
string filename = inputs[newItem.IndexId].CurrentPath;
|
||||
string rootpath = inputs[newItem.IndexId].ParentPath;
|
||||
string filename = inputs[newItem.Source.Index].CurrentPath;
|
||||
string rootpath = inputs[newItem.Source.Index].ParentPath;
|
||||
|
||||
rootpath += (string.IsNullOrWhiteSpace(rootpath) ? string.Empty : Path.DirectorySeparatorChar.ToString());
|
||||
filename = filename.Remove(0, rootpath.Length);
|
||||
newItem.MachineName = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||
newItem.Machine.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
||||
+ newItem.MachineName;
|
||||
+ newItem.Machine.Name;
|
||||
|
||||
newItems.Add(newItem);
|
||||
}
|
||||
@@ -933,26 +933,26 @@ namespace SabreTools.Library.DatFiles
|
||||
if (filter.RemoveUnicode)
|
||||
{
|
||||
item.Name = Sanitizer.RemoveUnicodeCharacters(item.Name);
|
||||
item.MachineName = Sanitizer.RemoveUnicodeCharacters(item.MachineName);
|
||||
item.MachineDescription = Sanitizer.RemoveUnicodeCharacters(item.MachineDescription);
|
||||
item.Machine.Name = Sanitizer.RemoveUnicodeCharacters(item.Machine.Name);
|
||||
item.Machine.Description = Sanitizer.RemoveUnicodeCharacters(item.Machine.Description);
|
||||
}
|
||||
|
||||
// If we're in cleaning mode, do so from all relevant things
|
||||
if (filter.Clean)
|
||||
{
|
||||
item.MachineName = Sanitizer.CleanGameName(item.MachineName);
|
||||
item.MachineDescription = Sanitizer.CleanGameName(item.MachineDescription);
|
||||
item.Machine.Name = Sanitizer.CleanGameName(item.Machine.Name);
|
||||
item.Machine.Description = Sanitizer.CleanGameName(item.Machine.Description);
|
||||
}
|
||||
|
||||
// If we are in single game mode, rename all games
|
||||
if (filter.Single)
|
||||
item.MachineName = "!";
|
||||
item.Machine.Name = "!";
|
||||
|
||||
// If we are in NTFS trim mode, trim the game name
|
||||
if (filter.Trim)
|
||||
{
|
||||
// Windows max name length is 260
|
||||
int usableLength = 260 - item.MachineName.Length - filter.Root.Length;
|
||||
int usableLength = 260 - item.Machine.Name.Length - filter.Root.Length;
|
||||
if (item.Name.Length > usableLength)
|
||||
{
|
||||
string ext = Path.GetExtension(item.Name);
|
||||
@@ -1030,7 +1030,7 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
// If the key mapping doesn't exist, add it
|
||||
mapping.TryAdd(item.MachineName, item.MachineDescription.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
||||
mapping.TryAdd(item.Machine.Name, item.Machine.Description.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1042,20 +1042,20 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
// Update machine name
|
||||
if (!string.IsNullOrWhiteSpace(item.MachineName) && mapping.ContainsKey(item.MachineName))
|
||||
item.MachineName = mapping[item.MachineName];
|
||||
if (!string.IsNullOrWhiteSpace(item.Machine.Name) && mapping.ContainsKey(item.Machine.Name))
|
||||
item.Machine.Name = mapping[item.Machine.Name];
|
||||
|
||||
// Update cloneof
|
||||
if (!string.IsNullOrWhiteSpace(item.CloneOf) && mapping.ContainsKey(item.CloneOf))
|
||||
item.CloneOf = mapping[item.CloneOf];
|
||||
if (!string.IsNullOrWhiteSpace(item.Machine.CloneOf) && mapping.ContainsKey(item.Machine.CloneOf))
|
||||
item.Machine.CloneOf = mapping[item.Machine.CloneOf];
|
||||
|
||||
// Update romof
|
||||
if (!string.IsNullOrWhiteSpace(item.RomOf) && mapping.ContainsKey(item.RomOf))
|
||||
item.RomOf = mapping[item.RomOf];
|
||||
if (!string.IsNullOrWhiteSpace(item.Machine.RomOf) && mapping.ContainsKey(item.Machine.RomOf))
|
||||
item.Machine.RomOf = mapping[item.Machine.RomOf];
|
||||
|
||||
// Update sampleof
|
||||
if (!string.IsNullOrWhiteSpace(item.SampleOf) && mapping.ContainsKey(item.SampleOf))
|
||||
item.SampleOf = mapping[item.SampleOf];
|
||||
if (!string.IsNullOrWhiteSpace(item.Machine.SampleOf) && mapping.ContainsKey(item.Machine.SampleOf))
|
||||
item.Machine.SampleOf = mapping[item.Machine.SampleOf];
|
||||
|
||||
// Add the new item to the output list
|
||||
newItems.Add(item);
|
||||
@@ -1097,30 +1097,30 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem item = Items[key][0];
|
||||
|
||||
// Match on CloneOf first
|
||||
if (!string.IsNullOrEmpty(item.CloneOf))
|
||||
if (!string.IsNullOrEmpty(item.Machine.CloneOf))
|
||||
{
|
||||
if (!parents.ContainsKey(item.CloneOf.ToLowerInvariant()))
|
||||
parents.Add(item.CloneOf.ToLowerInvariant(), new List<string>());
|
||||
if (!parents.ContainsKey(item.Machine.CloneOf.ToLowerInvariant()))
|
||||
parents.Add(item.Machine.CloneOf.ToLowerInvariant(), new List<string>());
|
||||
|
||||
parents[item.CloneOf.ToLowerInvariant()].Add(item.MachineName.ToLowerInvariant());
|
||||
parents[item.Machine.CloneOf.ToLowerInvariant()].Add(item.Machine.Name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
// Then by RomOf
|
||||
else if (!string.IsNullOrEmpty(item.RomOf))
|
||||
else if (!string.IsNullOrEmpty(item.Machine.RomOf))
|
||||
{
|
||||
if (!parents.ContainsKey(item.RomOf.ToLowerInvariant()))
|
||||
parents.Add(item.RomOf.ToLowerInvariant(), new List<string>());
|
||||
if (!parents.ContainsKey(item.Machine.RomOf.ToLowerInvariant()))
|
||||
parents.Add(item.Machine.RomOf.ToLowerInvariant(), new List<string>());
|
||||
|
||||
parents[item.RomOf.ToLowerInvariant()].Add(item.MachineName.ToLowerInvariant());
|
||||
parents[item.Machine.RomOf.ToLowerInvariant()].Add(item.Machine.Name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a parent
|
||||
else
|
||||
{
|
||||
if (!parents.ContainsKey(item.MachineName.ToLowerInvariant()))
|
||||
parents.Add(item.MachineName.ToLowerInvariant(), new List<string>());
|
||||
if (!parents.ContainsKey(item.Machine.Name.ToLowerInvariant()))
|
||||
parents.Add(item.Machine.Name.ToLowerInvariant(), new List<string>());
|
||||
|
||||
parents[item.MachineName.ToLowerInvariant()].Add(item.MachineName.ToLowerInvariant());
|
||||
parents[item.Machine.Name.ToLowerInvariant()].Add(item.Machine.Name.ToLowerInvariant());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@ namespace SabreTools.Library.DatFiles
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
string[] splitname = items[i].Name.Split('.');
|
||||
items[i].MachineName += $"/{string.Join(".", splitname.Take(splitname.Length > 1 ? splitname.Length - 1 : 1))}";
|
||||
items[i].Machine.Name += $"/{string.Join(".", splitname.Take(splitname.Length > 1 ? splitname.Length - 1 : 1))}";
|
||||
items[i].Name = Path.GetFileName(items[i].Name);
|
||||
}
|
||||
});
|
||||
@@ -1220,11 +1220,11 @@ namespace SabreTools.Library.DatFiles
|
||||
for (int j = 0; j < items.Count; j++)
|
||||
{
|
||||
DatItem item = items[j];
|
||||
if (Regex.IsMatch(item.MachineName, pattern))
|
||||
item.MachineName = Regex.Replace(item.MachineName, pattern, "$2");
|
||||
if (Regex.IsMatch(item.Machine.Name, pattern))
|
||||
item.Machine.Name = Regex.Replace(item.Machine.Name, pattern, "$2");
|
||||
|
||||
if (Regex.IsMatch(item.MachineDescription, pattern))
|
||||
item.MachineDescription = Regex.Replace(item.MachineDescription, pattern, "$2");
|
||||
if (Regex.IsMatch(item.Machine.Description, pattern))
|
||||
item.Machine.Description = Regex.Replace(item.Machine.Description, pattern, "$2");
|
||||
|
||||
items[j] = item;
|
||||
}
|
||||
@@ -1390,8 +1390,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Determine if the game has a parent or not
|
||||
string parent = null;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].RomOf))
|
||||
parent = Items[game][0].RomOf;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].Machine.RomOf))
|
||||
parent = Items[game][0].Machine.RomOf;
|
||||
|
||||
// If the parent doesnt exist, we want to continue
|
||||
if (string.IsNullOrWhiteSpace(parent))
|
||||
@@ -1430,20 +1430,20 @@ namespace SabreTools.Library.DatFiles
|
||||
continue;
|
||||
|
||||
// If the game (is/is not) a bios, we want to continue
|
||||
if (dev ^ (Items[game][0].MachineType.HasFlag(MachineType.Device)))
|
||||
if (dev ^ (Items[game][0].Machine.MachineType.HasFlag(MachineType.Device)))
|
||||
continue;
|
||||
|
||||
// If the game has no devices, we continue
|
||||
if (Items[game][0].Devices == null
|
||||
|| Items[game][0].Devices.Count == 0
|
||||
|| (slotoptions && Items[game][0].SlotOptions == null)
|
||||
|| (slotoptions && Items[game][0].SlotOptions.Count == 0))
|
||||
if (Items[game][0].Machine.Devices == null
|
||||
|| Items[game][0].Machine.Devices.Count == 0
|
||||
|| (slotoptions && Items[game][0].Machine.SlotOptions == null)
|
||||
|| (slotoptions && Items[game][0].Machine.SlotOptions.Count == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine if the game has any devices or not
|
||||
List<string> devices = Items[game][0].Devices;
|
||||
List<string> devices = Items[game][0].Machine.Devices;
|
||||
List<string> newdevs = new List<string>();
|
||||
foreach (string device in devices)
|
||||
{
|
||||
@@ -1457,7 +1457,7 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in devItems)
|
||||
{
|
||||
DatItem datItem = (DatItem)item.Clone();
|
||||
newdevs.AddRange(datItem.Devices ?? new List<string>());
|
||||
newdevs.AddRange(datItem.Machine.Devices ?? new List<string>());
|
||||
datItem.CopyMachineInformation(copyFrom);
|
||||
if (Items[game].Where(i => i.Name.ToLowerInvariant() == datItem.Name.ToLowerInvariant()).Count() == 0)
|
||||
{
|
||||
@@ -1470,15 +1470,15 @@ namespace SabreTools.Library.DatFiles
|
||||
// Now that every device is accounted for, add the new list of devices, if they don't already exist
|
||||
foreach (string device in newdevs)
|
||||
{
|
||||
if (!Items[game][0].Devices.Contains(device))
|
||||
Items[game][0].Devices.Add(device);
|
||||
if (!Items[game][0].Machine.Devices.Contains(device))
|
||||
Items[game][0].Machine.Devices.Add(device);
|
||||
}
|
||||
|
||||
// If we're checking slotoptions too
|
||||
if (slotoptions)
|
||||
{
|
||||
// Determine if the game has any slotoptions or not
|
||||
List<string> slotopts = Items[game][0].SlotOptions;
|
||||
List<string> slotopts = Items[game][0].Machine.SlotOptions;
|
||||
List<string> newslotopts = new List<string>();
|
||||
foreach (string slotopt in slotopts)
|
||||
{
|
||||
@@ -1492,7 +1492,7 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in slotItems)
|
||||
{
|
||||
DatItem datItem = (DatItem)item.Clone();
|
||||
newslotopts.AddRange(datItem.SlotOptions ?? new List<string>());
|
||||
newslotopts.AddRange(datItem.Machine.SlotOptions ?? new List<string>());
|
||||
datItem.CopyMachineInformation(copyFrom);
|
||||
if (Items[game].Where(i => i.Name.ToLowerInvariant() == datItem.Name.ToLowerInvariant()).Count() == 0)
|
||||
{
|
||||
@@ -1505,8 +1505,8 @@ namespace SabreTools.Library.DatFiles
|
||||
// Now that every slotoption is accounted for, add the new list of slotoptions, if they don't already exist
|
||||
foreach (string slotopt in newslotopts)
|
||||
{
|
||||
if (!Items[game][0].SlotOptions.Contains(slotopt))
|
||||
Items[game][0].SlotOptions.Add(slotopt);
|
||||
if (!Items[game][0].Machine.SlotOptions.Contains(slotopt))
|
||||
Items[game][0].Machine.SlotOptions.Add(slotopt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1528,8 +1528,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Determine if the game has a parent or not
|
||||
string parent = null;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].CloneOf))
|
||||
parent = Items[game][0].CloneOf;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].Machine.CloneOf))
|
||||
parent = Items[game][0].Machine.CloneOf;
|
||||
|
||||
// If the parent doesnt exist, we want to continue
|
||||
if (string.IsNullOrWhiteSpace(parent))
|
||||
@@ -1555,10 +1555,10 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Now we want to get the parent romof tag and put it in each of the items
|
||||
List<DatItem> items = Items[game];
|
||||
string romof = Items[parent][0].RomOf;
|
||||
string romof = Items[parent][0].Machine.RomOf;
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
item.RomOf = romof;
|
||||
item.Machine.RomOf = romof;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1578,15 +1578,26 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Determine if the game has a parent or not
|
||||
string parent = null;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].CloneOf))
|
||||
parent = Items[game][0].CloneOf;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].Machine.CloneOf))
|
||||
parent = Items[game][0].Machine.CloneOf;
|
||||
|
||||
// If there is no parent, then we continue
|
||||
if (string.IsNullOrWhiteSpace(parent))
|
||||
continue;
|
||||
|
||||
// Otherwise, move the items from the current game to a subfolder of the parent game
|
||||
DatItem copyFrom = Items[parent].Count == 0 ? new Rom { MachineName = parent, MachineDescription = parent } : Items[parent][0];
|
||||
DatItem copyFrom;
|
||||
if (Items[parent].Count == 0)
|
||||
{
|
||||
copyFrom = new Rom();
|
||||
copyFrom.Machine.Name = parent;
|
||||
copyFrom.Machine.Description = parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
copyFrom = Items[parent][0];
|
||||
}
|
||||
|
||||
List<DatItem> items = Items[game];
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
@@ -1631,7 +1642,7 @@ namespace SabreTools.Library.DatFiles
|
||||
else if (rom.MergeTag != null && !Items[parent].Select(i => i.Name).Contains(rom.MergeTag))
|
||||
{
|
||||
if (subfolder)
|
||||
item.Name = $"{item.MachineName}\\{item.Name}";
|
||||
item.Name = $"{item.Machine.Name}\\{item.Name}";
|
||||
|
||||
item.CopyMachineInformation(copyFrom);
|
||||
Items.Add(parent, item);
|
||||
@@ -1641,7 +1652,7 @@ namespace SabreTools.Library.DatFiles
|
||||
else if (!Items[parent].Contains(item))
|
||||
{
|
||||
if (subfolder)
|
||||
item.Name = $"{item.MachineName}\\{item.Name}";
|
||||
item.Name = $"{item.Machine.Name}\\{item.Name}";
|
||||
|
||||
item.CopyMachineInformation(copyFrom);
|
||||
Items.Add(parent, item);
|
||||
@@ -1652,7 +1663,7 @@ namespace SabreTools.Library.DatFiles
|
||||
else if (!Items[parent].Contains(item))
|
||||
{
|
||||
if (subfolder)
|
||||
item.Name = $"{item.MachineName}\\{item.Name}";
|
||||
item.Name = $"{item.Machine.Name}\\{item.Name}";
|
||||
|
||||
item.CopyMachineInformation(copyFrom);
|
||||
Items.Add(parent, item);
|
||||
@@ -1673,8 +1684,8 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (string game in games)
|
||||
{
|
||||
if (Items[game].Count > 0
|
||||
&& (Items[game][0].MachineType.HasFlag(MachineType.Bios)
|
||||
|| Items[game][0].MachineType.HasFlag(MachineType.Device)))
|
||||
&& (Items[game][0].Machine.MachineType.HasFlag(MachineType.Bios)
|
||||
|| Items[game][0].Machine.MachineType.HasFlag(MachineType.Device)))
|
||||
{
|
||||
Items.Remove(game);
|
||||
}
|
||||
@@ -1696,13 +1707,13 @@ namespace SabreTools.Library.DatFiles
|
||||
continue;
|
||||
|
||||
// If the game (is/is not) a bios, we want to continue
|
||||
if (bios ^ Items[game][0].MachineType.HasFlag(MachineType.Bios))
|
||||
if (bios ^ Items[game][0].Machine.MachineType.HasFlag(MachineType.Bios))
|
||||
continue;
|
||||
|
||||
// Determine if the game has a parent or not
|
||||
string parent = null;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].RomOf))
|
||||
parent = Items[game][0].RomOf;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].Machine.RomOf))
|
||||
parent = Items[game][0].Machine.RomOf;
|
||||
|
||||
// If the parent doesnt exist, we want to continue
|
||||
if (string.IsNullOrWhiteSpace(parent))
|
||||
@@ -1739,8 +1750,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Determine if the game has a parent or not
|
||||
string parent = null;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].CloneOf))
|
||||
parent = Items[game][0].CloneOf;
|
||||
if (!string.IsNullOrWhiteSpace(Items[game][0].Machine.CloneOf))
|
||||
parent = Items[game][0].Machine.CloneOf;
|
||||
|
||||
// If the parent doesnt exist, we want to continue
|
||||
if (string.IsNullOrWhiteSpace(parent))
|
||||
@@ -1763,10 +1774,10 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Now we want to get the parent romof tag and put it in each of the remaining items
|
||||
List<DatItem> items = Items[game];
|
||||
string romof = Items[parent][0].RomOf;
|
||||
string romof = Items[parent][0].Machine.RomOf;
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
item.RomOf = romof;
|
||||
item.Machine.RomOf = romof;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1782,9 +1793,9 @@ namespace SabreTools.Library.DatFiles
|
||||
List<DatItem> items = Items[game];
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
item.CloneOf = null;
|
||||
item.RomOf = null;
|
||||
item.SampleOf = null;
|
||||
item.Machine.CloneOf = null;
|
||||
item.Machine.RomOf = null;
|
||||
item.Machine.SampleOf = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2326,8 +2337,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Update rom information
|
||||
datItem.Name = romname;
|
||||
datItem.MachineName = gamename;
|
||||
datItem.MachineDescription = gamename;
|
||||
datItem.Machine.Name = gamename;
|
||||
datItem.Machine.Description = gamename;
|
||||
|
||||
// If we have a Disk, then the ".chd" extension needs to be removed
|
||||
if (datItem.ItemType == ItemType.Disk)
|
||||
@@ -2879,14 +2890,14 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Get the item from the current file
|
||||
Rom item = new Rom(fileStream.GetInfo(keepReadOpen: true));
|
||||
item.MachineName = Path.GetFileNameWithoutExtension(item.Name);
|
||||
item.MachineDescription = Path.GetFileNameWithoutExtension(item.Name);
|
||||
item.Machine.Name = Path.GetFileNameWithoutExtension(item.Name);
|
||||
item.Machine.Description = Path.GetFileNameWithoutExtension(item.Name);
|
||||
|
||||
// If we are coming from an archive, set the correct machine name
|
||||
if (machinename != null)
|
||||
{
|
||||
item.MachineName = machinename;
|
||||
item.MachineDescription = machinename;
|
||||
item.Machine.Name = machinename;
|
||||
item.Machine.Description = machinename;
|
||||
}
|
||||
|
||||
dupes.Add(item);
|
||||
@@ -3128,7 +3139,7 @@ namespace SabreTools.Library.DatFiles
|
||||
List<DatItem> roms = Items[key];
|
||||
foreach (DatItem rom in roms)
|
||||
{
|
||||
if (rom.IndexId == 99)
|
||||
if (rom.Source.Index == 99)
|
||||
{
|
||||
if (rom.ItemType == ItemType.Disk || rom.ItemType == ItemType.Rom)
|
||||
matched.Items.Add(((Disk)rom).SHA1, rom);
|
||||
@@ -3145,7 +3156,7 @@ namespace SabreTools.Library.DatFiles
|
||||
List<DatItem> newroms = DatItem.Merge(roms);
|
||||
foreach (Rom rom in newroms)
|
||||
{
|
||||
if (rom.IndexId == 99)
|
||||
if (rom.Source.Index == 99)
|
||||
matched.Items.Add($"{rom.Size}-{rom.CRC}", rom);
|
||||
}
|
||||
}
|
||||
@@ -3396,8 +3407,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Clean the input list and set all games to be pathless
|
||||
List<DatItem> items = Items[key];
|
||||
items.ForEach(item => item.MachineName = Path.GetFileName(item.MachineName));
|
||||
items.ForEach(item => item.MachineDescription = Path.GetFileName(item.MachineDescription));
|
||||
items.ForEach(item => item.Machine.Name = Path.GetFileName(item.Machine.Name));
|
||||
items.ForEach(item => item.Machine.Description = Path.GetFileName(item.Machine.Description));
|
||||
|
||||
// Now add the game to the output DAT
|
||||
tempDat.Items.AddRange(key, items);
|
||||
@@ -3755,7 +3766,7 @@ namespace SabreTools.Library.DatFiles
|
||||
name += Header.AddExtension;
|
||||
|
||||
if (Header.UseRomName && Header.GameName)
|
||||
name = Path.Combine(item.MachineName, name);
|
||||
name = Path.Combine(item.Machine.Name, name);
|
||||
|
||||
// Now assign back the item name
|
||||
item.Name = pre + name + post;
|
||||
@@ -3778,11 +3789,8 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
// Initialize strings
|
||||
string fix = string.Empty,
|
||||
game = item.MachineName,
|
||||
game = item.Machine.Name,
|
||||
name = item.Name,
|
||||
manufacturer = item.Manufacturer,
|
||||
publisher = item.Publisher,
|
||||
category = item.Category,
|
||||
crc = string.Empty,
|
||||
md5 = string.Empty,
|
||||
ripemd160 = string.Empty,
|
||||
@@ -3831,9 +3839,9 @@ namespace SabreTools.Library.DatFiles
|
||||
.Replace("%game%", game)
|
||||
.Replace("%machine%", game)
|
||||
.Replace("%name%", name)
|
||||
.Replace("%manufacturer%", manufacturer)
|
||||
.Replace("%publisher%", publisher)
|
||||
.Replace("%category%", category)
|
||||
.Replace("%manufacturer%", item.Machine.Manufacturer)
|
||||
.Replace("%publisher%", item.Machine.Publisher)
|
||||
.Replace("%category%", item.Machine.Category)
|
||||
.Replace("%crc%", crc)
|
||||
.Replace("%md5%", md5)
|
||||
.Replace("%ripemd160%", ripemd160)
|
||||
|
||||
@@ -4,6 +4,9 @@ using SabreTools.Library.Data;
|
||||
|
||||
namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// Depot information wrapper
|
||||
/// </summary>
|
||||
public class DepotInformation : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -197,9 +197,11 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Then populate it with information
|
||||
item.CopyMachineInformation(machine);
|
||||
|
||||
item.IndexId = indexId;
|
||||
item.IndexSource = filename;
|
||||
item.Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
};
|
||||
|
||||
// Loop through all of the attributes
|
||||
foreach (var kvp in cmpr.Internal)
|
||||
@@ -245,8 +247,11 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
{
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -301,20 +306,20 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
List<string> newsplit = rom.MachineName.Split('\\').ToList();
|
||||
List<string> newsplit = rom.Machine.Name.Split('\\').ToList();
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(cmpw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(cmpw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -322,7 +327,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
@@ -341,7 +346,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(cmpw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +407,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
cmpw.WriteStartElement("game");
|
||||
|
||||
@@ -68,11 +68,17 @@ namespace SabreTools.Library.DatFiles
|
||||
SHA256 = gameinfo[0],
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
MachineName = fullname[0],
|
||||
MachineDescription = fullname[0],
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = fullname[0],
|
||||
Description = fullname[0],
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -122,7 +128,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem item = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (item.Name == null || item.MachineName == null)
|
||||
if (item.Name == null || item.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
@@ -133,7 +139,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)item).Size == -1
|
||||
&& ((Rom)item).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {item.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {item.Machine.Name}");
|
||||
|
||||
item.Name = (item.Name == "null" ? "-" : item.Name);
|
||||
((Rom)item).Size = Constants.SizeZero;
|
||||
@@ -171,7 +177,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Pre-process the item name
|
||||
ProcessItemName(datItem, true);
|
||||
|
||||
@@ -84,10 +84,16 @@ namespace SabreTools.Library.DatFiles
|
||||
SHA512 = (_hash.HasFlag(Hash.SHA512) ? hash : null),
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
MachineName = Path.GetFileNameWithoutExtension(filename),
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = Path.GetFileNameWithoutExtension(filename),
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -137,7 +143,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
@@ -148,7 +154,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
|
||||
@@ -532,8 +532,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
DatItem datItem = DatItem.Create(itemType.Value);
|
||||
datItem.CopyMachineInformation(machine);
|
||||
datItem.IndexId = indexId;
|
||||
datItem.IndexSource = filename;
|
||||
datItem.Source = new Source { Index = indexId, Name = filename };
|
||||
|
||||
datItem.Name = name;
|
||||
datItem.PartName = partName;
|
||||
@@ -795,18 +794,18 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(jtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(jtw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -814,7 +813,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
@@ -833,7 +832,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(jtw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,7 +996,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
jtw.WriteStartObject();
|
||||
@@ -1008,56 +1007,56 @@ namespace SabreTools.Library.DatFiles
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Comment, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("comment");
|
||||
jtw.WriteValue(datItem.Comment);
|
||||
jtw.WriteValue(datItem.Machine.Comment);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("description");
|
||||
jtw.WriteValue(datItem.MachineDescription);
|
||||
jtw.WriteValue(datItem.Machine.Description);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("year");
|
||||
jtw.WriteValue(datItem.Year);
|
||||
jtw.WriteValue(datItem.Machine.Year);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("manufacturer");
|
||||
jtw.WriteValue(datItem.Manufacturer);
|
||||
jtw.WriteValue(datItem.Machine.Manufacturer);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("publisher");
|
||||
jtw.WriteValue(datItem.Publisher);
|
||||
jtw.WriteValue(datItem.Machine.Publisher);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("category");
|
||||
jtw.WriteValue(datItem.Category);
|
||||
jtw.WriteValue(datItem.Machine.Category);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
jtw.WritePropertyName("romof");
|
||||
jtw.WriteValue(datItem.RomOf);
|
||||
jtw.WriteValue(datItem.Machine.RomOf);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
jtw.WritePropertyName("cloneof");
|
||||
jtw.WriteValue(datItem.CloneOf);
|
||||
jtw.WriteValue(datItem.Machine.CloneOf);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.SampleOf, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
jtw.WritePropertyName("sampleof");
|
||||
jtw.WriteValue(datItem.SampleOf);
|
||||
jtw.WriteValue(datItem.Machine.SampleOf);
|
||||
}
|
||||
if (!Header.ExcludeFields.Contains(Field.Supported) && datItem.Supported != null)
|
||||
if (!Header.ExcludeFields.Contains(Field.Supported) && datItem.Machine.Supported != null)
|
||||
{
|
||||
if (datItem.Supported == true)
|
||||
if (datItem.Machine.Supported == true)
|
||||
{
|
||||
jtw.WritePropertyName("supported");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
else if (datItem.Supported == false)
|
||||
else if (datItem.Machine.Supported == false)
|
||||
{
|
||||
jtw.WritePropertyName("supported");
|
||||
jtw.WriteValue("no");
|
||||
@@ -1066,16 +1065,16 @@ namespace SabreTools.Library.DatFiles
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("sourcefile");
|
||||
jtw.WriteValue(datItem.SourceFile);
|
||||
jtw.WriteValue(datItem.Machine.SourceFile);
|
||||
}
|
||||
if (!Header.ExcludeFields.Contains(Field.Runnable) && datItem.Runnable != null)
|
||||
if (!Header.ExcludeFields.Contains(Field.Runnable) && datItem.Machine.Runnable != null)
|
||||
{
|
||||
if (datItem.Runnable == true)
|
||||
if (datItem.Machine.Runnable == true)
|
||||
{
|
||||
jtw.WritePropertyName("runnable");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
else if (datItem.Runnable == false)
|
||||
else if (datItem.Machine.Runnable == false)
|
||||
{
|
||||
jtw.WritePropertyName("runnable");
|
||||
jtw.WriteValue("no");
|
||||
@@ -1084,18 +1083,18 @@ namespace SabreTools.Library.DatFiles
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Board, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("board");
|
||||
jtw.WriteValue(datItem.Board);
|
||||
jtw.WriteValue(datItem.Machine.Board);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RebuildTo, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("rebuildto");
|
||||
jtw.WriteValue(datItem.RebuildTo);
|
||||
jtw.WriteValue(datItem.Machine.RebuildTo);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Devices, Header.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("devices");
|
||||
jtw.WriteStartArray();
|
||||
foreach (string device in datItem.Devices)
|
||||
foreach (string device in datItem.Machine.Devices)
|
||||
{
|
||||
jtw.WriteValue(device);
|
||||
}
|
||||
@@ -1106,7 +1105,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
jtw.WritePropertyName("slotoptions");
|
||||
jtw.WriteStartArray();
|
||||
foreach (string slotoption in datItem.SlotOptions)
|
||||
foreach (string slotoption in datItem.Machine.SlotOptions)
|
||||
{
|
||||
jtw.WriteValue(slotoption);
|
||||
}
|
||||
@@ -1117,7 +1116,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
jtw.WritePropertyName("infos");
|
||||
jtw.WriteStartArray();
|
||||
foreach (var info in datItem.Infos)
|
||||
foreach (var info in datItem.Machine.Infos)
|
||||
{
|
||||
jtw.WriteStartObject();
|
||||
jtw.WritePropertyName(info.Key);
|
||||
@@ -1129,17 +1128,17 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
if (!Header.ExcludeFields.Contains(Field.MachineType))
|
||||
{
|
||||
if (datItem.MachineType.HasFlag(MachineType.Bios))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
|
||||
{
|
||||
jtw.WritePropertyName("isbios");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
if (datItem.MachineType.HasFlag(MachineType.Device))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Device))
|
||||
{
|
||||
jtw.WritePropertyName("isdevice");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
if (datItem.MachineType.HasFlag(MachineType.Mechanical))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
{
|
||||
jtw.WritePropertyName("ismechanical");
|
||||
jtw.WriteValue("yes");
|
||||
|
||||
@@ -109,10 +109,16 @@ namespace SabreTools.Library.DatFiles
|
||||
Name = romname,
|
||||
SHA1 = Sanitizer.CleanListromHashData(split[0]),
|
||||
|
||||
MachineName = gamename,
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
ParseAddHelper(disk);
|
||||
@@ -127,10 +133,16 @@ namespace SabreTools.Library.DatFiles
|
||||
SHA1 = Sanitizer.CleanListromHashData(split[1]),
|
||||
ItemStatus = ItemStatus.BadDump,
|
||||
|
||||
MachineName = gamename,
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
ParseAddHelper(disk);
|
||||
@@ -149,10 +161,16 @@ namespace SabreTools.Library.DatFiles
|
||||
CRC = Sanitizer.CleanListromHashData(split[1]),
|
||||
SHA1 = Sanitizer.CleanListromHashData(split[2]),
|
||||
|
||||
MachineName = gamename,
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
ParseAddHelper(rom);
|
||||
@@ -166,10 +184,16 @@ namespace SabreTools.Library.DatFiles
|
||||
Name = romname,
|
||||
ItemStatus = ItemStatus.Nodump,
|
||||
|
||||
MachineName = gamename,
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
ParseAddHelper(disk);
|
||||
@@ -189,10 +213,16 @@ namespace SabreTools.Library.DatFiles
|
||||
SHA1 = Sanitizer.CleanListromHashData(split[3]),
|
||||
ItemStatus = ItemStatus.BadDump,
|
||||
|
||||
MachineName = gamename,
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
ParseAddHelper(rom);
|
||||
@@ -210,10 +240,16 @@ namespace SabreTools.Library.DatFiles
|
||||
Size = size,
|
||||
ItemStatus = ItemStatus.Nodump,
|
||||
|
||||
MachineName = gamename,
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
ParseAddHelper(rom);
|
||||
@@ -266,18 +302,18 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(sw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(sw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -285,7 +321,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
@@ -301,7 +337,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +365,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
rom.MachineName = rom.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
rom.Machine.Name = rom.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
sw.Write($"ROMs required for driver \"{rom.GetField(Field.MachineName, Header.ExcludeFields)}\".\n");
|
||||
|
||||
@@ -191,8 +191,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Description = reader.GetAttribute("description"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
biosset.CopyMachineInformation(machine);
|
||||
@@ -226,8 +229,11 @@ namespace SabreTools.Library.DatFiles
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
Optional = reader.GetAttribute("optional").AsYesNo(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
@@ -259,8 +265,11 @@ namespace SabreTools.Library.DatFiles
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
Optional = reader.GetAttribute("optional").AsYesNo(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
disk.CopyMachineInformation(machine);
|
||||
@@ -286,8 +295,11 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
samplerom.CopyMachineInformation(machine);
|
||||
@@ -487,9 +499,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
{
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -587,18 +603,18 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(xtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(xtw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -606,9 +622,9 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -616,7 +632,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(xtw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,51 +690,51 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
xtw.WriteStartElement("machine");
|
||||
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, Header.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sourcefile", datItem.SourceFile);
|
||||
xtw.WriteAttributeString("sourcefile", datItem.Machine.SourceFile);
|
||||
|
||||
if (!Header.ExcludeFields.Contains(Field.MachineType))
|
||||
{
|
||||
if (datItem.MachineType.HasFlag(MachineType.Bios))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
|
||||
xtw.WriteAttributeString("isbios", "yes");
|
||||
if (datItem.MachineType.HasFlag(MachineType.Device))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Device))
|
||||
xtw.WriteAttributeString("isdevice", "yes");
|
||||
if (datItem.MachineType.HasFlag(MachineType.Mechanical))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
xtw.WriteAttributeString("ismechanical", "yes");
|
||||
}
|
||||
|
||||
if (!Header.ExcludeFields.Contains(Field.Runnable))
|
||||
{
|
||||
if (datItem.Runnable == true)
|
||||
if (datItem.Machine.Runnable == true)
|
||||
xtw.WriteAttributeString("runnable", "yes");
|
||||
else if (datItem.Runnable == false)
|
||||
else if (datItem.Machine.Runnable == false)
|
||||
xtw.WriteAttributeString("runnable", "no");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("cloneof", datItem.CloneOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("romof", datItem.RomOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.SampleOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("sampleof", datItem.SampleOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("cloneof", datItem.Machine.CloneOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("romof", datItem.Machine.RomOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("sampleof", datItem.Machine.SampleOf);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("description", datItem.MachineDescription);
|
||||
xtw.WriteElementString("description", datItem.Machine.Description);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("year", datItem.Year);
|
||||
xtw.WriteElementString("year", datItem.Machine.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("publisher", datItem.Publisher);
|
||||
xtw.WriteElementString("publisher", datItem.Machine.Publisher);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("category", datItem.Category);
|
||||
xtw.WriteElementString("category", datItem.Machine.Category);
|
||||
|
||||
if (!Header.ExcludeFields.Contains(Field.Infos) && datItem.Infos != null && datItem.Infos.Count > 0)
|
||||
if (!Header.ExcludeFields.Contains(Field.Infos) && datItem.Machine.Infos != null && datItem.Machine.Infos.Count > 0)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in datItem.Infos)
|
||||
foreach (KeyValuePair<string, string> kvp in datItem.Machine.Infos)
|
||||
{
|
||||
xtw.WriteStartElement("info");
|
||||
xtw.WriteAttributeString("name", kvp.Key);
|
||||
|
||||
@@ -417,8 +417,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Description = reader.GetAttribute("description"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
biosset.CopyMachineInformation(machine);
|
||||
@@ -450,8 +453,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Date = Sanitizer.CleanDate(reader.GetAttribute("date")),
|
||||
Inverted = reader.GetAttribute("inverted").AsYesNo(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
@@ -479,8 +485,11 @@ namespace SabreTools.Library.DatFiles
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
disk.CopyMachineInformation(machine);
|
||||
@@ -498,8 +507,11 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
samplerom.CopyMachineInformation(machine);
|
||||
@@ -517,8 +529,11 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
archiverom.CopyMachineInformation(machine);
|
||||
@@ -540,9 +555,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
{
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -685,18 +704,18 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(xtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(xtw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -704,7 +723,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
@@ -723,7 +742,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(xtw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,48 +875,48 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
xtw.WriteStartElement(_deprecated ? "game" : "machine");
|
||||
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
|
||||
if (!Header.ExcludeFields.Contains(Field.MachineType))
|
||||
{
|
||||
if (datItem.MachineType.HasFlag(MachineType.Bios))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
|
||||
xtw.WriteAttributeString("isbios", "yes");
|
||||
if (datItem.MachineType.HasFlag(MachineType.Device))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Device))
|
||||
xtw.WriteAttributeString("isdevice", "yes");
|
||||
if (datItem.MachineType.HasFlag(MachineType.Mechanical))
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
xtw.WriteAttributeString("ismechanical", "yes");
|
||||
}
|
||||
|
||||
if (!Header.ExcludeFields.Contains(Field.Runnable) && datItem.Runnable != null)
|
||||
if (!Header.ExcludeFields.Contains(Field.Runnable) && datItem.Machine.Runnable != null)
|
||||
{
|
||||
if (datItem.Runnable == true)
|
||||
if (datItem.Machine.Runnable == true)
|
||||
xtw.WriteAttributeString("runnable", "yes");
|
||||
else if (datItem.Runnable == false)
|
||||
else if (datItem.Machine.Runnable == false)
|
||||
xtw.WriteAttributeString("runnable", "no");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("cloneof", datItem.CloneOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("romof", datItem.RomOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.SampleOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("sampleof", datItem.SampleOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("cloneof", datItem.Machine.CloneOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("romof", datItem.Machine.RomOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("sampleof", datItem.Machine.SampleOf);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Comment, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("comment", datItem.Comment);
|
||||
xtw.WriteElementString("comment", datItem.Machine.Comment);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("description", datItem.MachineDescription);
|
||||
xtw.WriteElementString("description", datItem.Machine.Description);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("year", datItem.Year);
|
||||
xtw.WriteElementString("year", datItem.Machine.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("publisher", datItem.Publisher);
|
||||
xtw.WriteElementString("publisher", datItem.Machine.Publisher);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("manufacturer", datItem.Manufacturer);
|
||||
xtw.WriteElementString("manufacturer", datItem.Machine.Manufacturer);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("category", datItem.Category);
|
||||
xtw.WriteElementString("category", datItem.Machine.Category);
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
@@ -90,8 +90,8 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
lastgame = rom.MachineName;
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
lastgame = rom.Machine.Name;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(sw, rom, lastgame, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,10 +140,10 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
sw.Write($"{datItem.GetField(Field.Name, Header.ExcludeFields)}\n");
|
||||
}
|
||||
else if (!Header.UseRomName && datItem.MachineName != lastgame)
|
||||
else if (!Header.UseRomName && datItem.Machine.Name != lastgame)
|
||||
{
|
||||
sw.Write($"{datItem.GetField(Field.MachineName, Header.ExcludeFields)}\n");
|
||||
lastgame = datItem.MachineName;
|
||||
lastgame = datItem.Machine.Name;
|
||||
}
|
||||
|
||||
sw.Flush();
|
||||
|
||||
@@ -643,8 +643,8 @@ namespace SabreTools.Library.DatFiles
|
||||
for (int i = 0; i < roms.Count; i++)
|
||||
{
|
||||
roms[i].Size = size;
|
||||
roms[i].Publisher = publisher;
|
||||
roms[i].CopyMachineInformation(machine);
|
||||
roms[i].Machine.Publisher = publisher;
|
||||
|
||||
// Now process and add the rom
|
||||
ParseAddHelper(roms[i]);
|
||||
@@ -715,8 +715,11 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -769,7 +772,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
@@ -780,7 +783,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
@@ -799,7 +802,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(xtw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -176,9 +176,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
{
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -316,8 +320,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Size = -1,
|
||||
SHA1 = hash,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
@@ -389,8 +396,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Size = -1,
|
||||
SHA1 = hash,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
@@ -457,8 +467,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Size = -1,
|
||||
SHA1 = hash,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
@@ -513,18 +526,18 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(xtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(xtw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -532,9 +545,9 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -542,7 +555,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(xtw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,7 +626,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
xtw.WriteStartElement("software");
|
||||
|
||||
@@ -344,14 +344,21 @@ namespace SabreTools.Library.DatFiles
|
||||
CRC = rominfo[6],
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
MachineName = rominfo[3],
|
||||
MachineDescription = rominfo[4],
|
||||
CloneOf = rominfo[1],
|
||||
RomOf = rominfo[8],
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = rominfo[3],
|
||||
Description = rominfo[4],
|
||||
CloneOf = rominfo[1],
|
||||
RomOf = rominfo[8],
|
||||
},
|
||||
|
||||
MergeTag = rominfo[9],
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -403,7 +410,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
@@ -414,7 +421,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
@@ -433,7 +440,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(iw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +528,7 @@ namespace SabreTools.Library.DatFiles
|
||||
iw.WriteString($"¬{datItem.GetField(Field.CloneOf, Header.ExcludeFields)}");
|
||||
iw.WriteString($"¬{datItem.GetField(Field.CloneOf, Header.ExcludeFields)}");
|
||||
iw.WriteString($"¬{datItem.GetField(Field.MachineName, Header.ExcludeFields)}");
|
||||
if (string.IsNullOrWhiteSpace(datItem.MachineDescription))
|
||||
if (string.IsNullOrWhiteSpace(datItem.Machine.Description))
|
||||
iw.WriteString($"¬{datItem.GetField(Field.MachineName, Header.ExcludeFields)}");
|
||||
else
|
||||
iw.WriteString($"¬{datItem.GetField(Field.Description, Header.ExcludeFields)}");
|
||||
|
||||
@@ -360,8 +360,11 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -372,8 +375,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Description = reader.GetAttribute("description"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -391,8 +397,11 @@ namespace SabreTools.Library.DatFiles
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
ItemStatus = its,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -405,8 +414,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Date = reader.GetAttribute("date"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -427,8 +439,11 @@ namespace SabreTools.Library.DatFiles
|
||||
ItemStatus = its,
|
||||
Date = date,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -437,8 +452,11 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -576,20 +594,20 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
List<string> newsplit = rom.MachineName.Split('\\').ToList();
|
||||
List<string> newsplit = rom.Machine.Name.Split('\\').ToList();
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
depth = WriteEndGame(xtw, splitpath, newsplit, depth, out last);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
depth = WriteStartGame(xtw, rom, newsplit, depth, last);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -597,10 +615,10 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
splitpath = newsplit;
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -609,7 +627,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Set the new data to compare against
|
||||
splitpath = newsplit;
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,7 +790,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
for (int i = (last == -1 ? 0 : last); i < newsplit.Count; i++)
|
||||
|
||||
@@ -436,8 +436,11 @@ namespace SabreTools.Library.DatFiles
|
||||
AreaName = areaName,
|
||||
AreaSize = areaSize,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
archive.CopyMachineInformation(machine);
|
||||
@@ -457,8 +460,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Description = biosDescription,
|
||||
Default = def,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
biosset.CopyMachineInformation(machine);
|
||||
@@ -490,8 +496,11 @@ namespace SabreTools.Library.DatFiles
|
||||
ItemStatus = status,
|
||||
Optional = optional,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
disk.CopyMachineInformation(machine);
|
||||
@@ -513,8 +522,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Date = date,
|
||||
Default = default,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
release.CopyMachineInformation(machine);
|
||||
@@ -550,8 +562,11 @@ namespace SabreTools.Library.DatFiles
|
||||
Optional = optional,
|
||||
Inverted = inverted,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
@@ -568,8 +583,11 @@ namespace SabreTools.Library.DatFiles
|
||||
AreaName = areaName,
|
||||
AreaSize = areaSize,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
sample.CopyMachineInformation(machine);
|
||||
@@ -902,7 +920,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
@@ -913,7 +931,7 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
|
||||
@@ -207,9 +207,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
{
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
@@ -411,8 +415,11 @@ namespace SabreTools.Library.DatFiles
|
||||
PartName = partname,
|
||||
PartInterface = partinterface,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
@@ -500,8 +507,11 @@ namespace SabreTools.Library.DatFiles
|
||||
PartName = partname,
|
||||
PartInterface = partinterface,
|
||||
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
disk.CopyMachineInformation(machine);
|
||||
@@ -567,18 +577,18 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = roms[index];
|
||||
|
||||
// There are apparently times when a null rom can skip by, skip them
|
||||
if (rom.Name == null || rom.MachineName == null)
|
||||
if (rom.Name == null || rom.Machine.Name == null)
|
||||
{
|
||||
Globals.Logger.Warning("Null rom found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(xtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.MachineName.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteStartGame(xtw, rom);
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -586,9 +596,9 @@ namespace SabreTools.Library.DatFiles
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -596,7 +606,7 @@ namespace SabreTools.Library.DatFiles
|
||||
WriteDatItem(xtw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
lastgame = rom.Machine.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,37 +703,37 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state based on excluded fields
|
||||
xtw.WriteStartElement("software");
|
||||
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("cloneof", datItem.CloneOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("cloneof", datItem.Machine.CloneOf);
|
||||
|
||||
if (!Header.ExcludeFields.Contains(Field.Supported))
|
||||
{
|
||||
if (datItem.Supported == true)
|
||||
if (datItem.Machine.Supported == true)
|
||||
xtw.WriteAttributeString("supported", "yes");
|
||||
else if (datItem.Supported == false)
|
||||
else if (datItem.Machine.Supported == false)
|
||||
xtw.WriteAttributeString("supported", "no");
|
||||
else
|
||||
xtw.WriteAttributeString("supported", "partial");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("description", datItem.MachineDescription);
|
||||
xtw.WriteElementString("description", datItem.Machine.Description);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("year", datItem.Year);
|
||||
xtw.WriteElementString("year", datItem.Machine.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("publisher", datItem.Publisher);
|
||||
xtw.WriteElementString("publisher", datItem.Machine.Publisher);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
|
||||
xtw.WriteElementString("category", datItem.Category);
|
||||
xtw.WriteElementString("category", datItem.Machine.Category);
|
||||
|
||||
if (!Header.ExcludeFields.Contains(Field.Infos) && datItem.Infos != null && datItem.Infos.Count > 0)
|
||||
if (!Header.ExcludeFields.Contains(Field.Infos) && datItem.Machine.Infos != null && datItem.Machine.Infos.Count > 0)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in datItem.Infos)
|
||||
foreach (KeyValuePair<string, string> kvp in datItem.Machine.Infos)
|
||||
{
|
||||
xtw.WriteStartElement("info");
|
||||
xtw.WriteAttributeString("name", kvp.Key);
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
/// </summary>
|
||||
public Archive()
|
||||
{
|
||||
this.Name = string.Empty;
|
||||
this.ItemType = ItemType.Archive;
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Archive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -28,33 +28,15 @@
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,14 +47,14 @@
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have an archive, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as an archive
|
||||
Archive newOther = other as Archive;
|
||||
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name);
|
||||
return (Name == newOther.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using SabreTools.Library.Filtering;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -9,7 +10,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public class BiosSet : DatItem
|
||||
{
|
||||
#region Publicly facing variables
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Description of the BIOS
|
||||
@@ -68,8 +69,8 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public BiosSet()
|
||||
{
|
||||
this.Name = string.Empty;
|
||||
this.ItemType = ItemType.BiosSet;
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.BiosSet;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -84,33 +85,15 @@ namespace SabreTools.Library.DatItems
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
Description = this.Description,
|
||||
Default = this.Default,
|
||||
@@ -124,14 +107,14 @@ namespace SabreTools.Library.DatItems
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a biosset, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a biosset
|
||||
BiosSet newOther = other as BiosSet;
|
||||
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name && this.Description == newOther.Description && this.Default == newOther.Default);
|
||||
return (Name == newOther.Name && Description == newOther.Description && Default == newOther.Default);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using SabreTools.Library.Data;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a blank set from an input DAT
|
||||
@@ -14,8 +12,8 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public Blank()
|
||||
{
|
||||
this.Name = string.Empty;
|
||||
this.ItemType = ItemType.Blank;
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Blank;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -30,33 +28,15 @@ namespace SabreTools.Library.DatItems
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,14 +47,14 @@ namespace SabreTools.Library.DatItems
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a blank, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a Blank
|
||||
Blank newOther = other as Blank;
|
||||
|
||||
// If the archive information matches
|
||||
return (_machine == newOther._machine);
|
||||
return (Machine == newOther.Machine);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using SabreTools.Library.DatFiles;
|
||||
using SabreTools.Library.FileTypes;
|
||||
using SabreTools.Library.Filtering;
|
||||
@@ -25,7 +26,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#endregion
|
||||
|
||||
#region Publicly facing variables
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Data MD5 hash
|
||||
@@ -202,10 +203,10 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public Disk()
|
||||
{
|
||||
this.Name = string.Empty;
|
||||
this.ItemType = ItemType.Disk;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Disk;
|
||||
DupeType = 0x00;
|
||||
ItemStatus = ItemStatus.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -214,7 +215,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// <param name="baseFile"></param>
|
||||
public Disk(BaseFile baseFile)
|
||||
{
|
||||
this.Name = baseFile.Filename;
|
||||
Name = baseFile.Filename;
|
||||
_md5 = baseFile.MD5;
|
||||
#if NET_FRAMEWORK
|
||||
_ripemd160 = baseFile.RIPEMD160;
|
||||
@@ -224,9 +225,9 @@ namespace SabreTools.Library.DatItems
|
||||
_sha384 = baseFile.SHA384;
|
||||
_sha512 = baseFile.SHA512;
|
||||
|
||||
this.ItemType = ItemType.Disk;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
ItemType = ItemType.Disk;
|
||||
DupeType = 0x00;
|
||||
ItemStatus = ItemStatus.None;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -241,33 +242,15 @@ namespace SabreTools.Library.DatItems
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
_md5 = this._md5,
|
||||
#if NET_FRAMEWORK
|
||||
@@ -277,7 +260,12 @@ namespace SabreTools.Library.DatItems
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
_sha512 = this._sha512,
|
||||
MergeTag = this.MergeTag,
|
||||
Region = this.Region,
|
||||
Index = this.Index,
|
||||
Writable = this.Writable,
|
||||
ItemStatus = this.ItemStatus,
|
||||
Optional = this.Optional,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -293,6 +281,21 @@ namespace SabreTools.Library.DatItems
|
||||
ItemType = ItemType.Rom,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
MergeTag = this.MergeTag,
|
||||
Region = this.Region,
|
||||
ItemStatus = this.ItemStatus,
|
||||
Optional = this.Optional,
|
||||
|
||||
CRC = null,
|
||||
MD5 = this.MD5,
|
||||
#if NET_FRAMEWORK
|
||||
@@ -302,41 +305,6 @@ namespace SabreTools.Library.DatItems
|
||||
SHA256 = this.SHA256,
|
||||
SHA384 = this.SHA384,
|
||||
SHA512 = this.SHA512,
|
||||
|
||||
MergeTag = this.MergeTag,
|
||||
Region = this.Region,
|
||||
ItemStatus = this.ItemStatus,
|
||||
Optional = this.Optional,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
Supported = this.Supported,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
SlotOptions = this.SlotOptions,
|
||||
Infos = this.Infos,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Remove = this.Remove,
|
||||
};
|
||||
|
||||
return rom;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.Filtering;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
@@ -11,7 +12,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public class Machine : ICloneable
|
||||
{
|
||||
#region Publicly facing variables
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Name of the machine
|
||||
@@ -131,6 +132,91 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Get the value of that field as a string, if possible
|
||||
/// </summary>
|
||||
public string GetField(Field field, List<Field> excludeFields)
|
||||
{
|
||||
// If the field is to be excluded, return empty string
|
||||
if (excludeFields.Contains(field))
|
||||
return string.Empty;
|
||||
|
||||
string fieldValue = null;
|
||||
switch (field)
|
||||
{
|
||||
case Field.MachineName:
|
||||
fieldValue = Name;
|
||||
break;
|
||||
case Field.Comment:
|
||||
fieldValue = Comment;
|
||||
break;
|
||||
case Field.Description:
|
||||
fieldValue = Description;
|
||||
break;
|
||||
case Field.Year:
|
||||
fieldValue = Year;
|
||||
break;
|
||||
case Field.Manufacturer:
|
||||
fieldValue = Manufacturer;
|
||||
break;
|
||||
case Field.Publisher:
|
||||
fieldValue = Publisher;
|
||||
break;
|
||||
case Field.Category:
|
||||
fieldValue = Category;
|
||||
break;
|
||||
case Field.RomOf:
|
||||
fieldValue = RomOf;
|
||||
break;
|
||||
case Field.CloneOf:
|
||||
fieldValue = CloneOf;
|
||||
break;
|
||||
case Field.SampleOf:
|
||||
fieldValue = SampleOf;
|
||||
break;
|
||||
case Field.Supported:
|
||||
fieldValue = Supported?.ToString();
|
||||
break;
|
||||
case Field.SourceFile:
|
||||
fieldValue = SourceFile;
|
||||
break;
|
||||
case Field.Runnable:
|
||||
fieldValue = Runnable?.ToString();
|
||||
break;
|
||||
case Field.Board:
|
||||
fieldValue = Board;
|
||||
break;
|
||||
case Field.RebuildTo:
|
||||
fieldValue = RebuildTo;
|
||||
break;
|
||||
case Field.Devices:
|
||||
fieldValue = string.Join(";", Devices ?? new List<string>());
|
||||
break;
|
||||
case Field.SlotOptions:
|
||||
fieldValue = string.Join(";", SlotOptions ?? new List<string>());
|
||||
break;
|
||||
case Field.Infos:
|
||||
fieldValue = string.Join(";", (Infos ?? new List<KeyValuePair<string, string>>()).Select(i => $"{i.Key}={i.Value}"));
|
||||
break;
|
||||
case Field.MachineType:
|
||||
fieldValue = MachineType.ToString();
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
// Make sure we don't return null
|
||||
if (string.IsNullOrEmpty(fieldValue))
|
||||
fieldValue = string.Empty;
|
||||
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -222,5 +308,291 @@ namespace SabreTools.Library.DatItems
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a Machine passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public bool PassesFilter(Filter filter)
|
||||
{
|
||||
// Filter on machine name
|
||||
bool? machineNameFound = filter.MachineName.MatchesPositiveSet(Name);
|
||||
if (filter.IncludeOfInGame)
|
||||
{
|
||||
machineNameFound |= (filter.MachineName.MatchesPositiveSet(CloneOf) == true);
|
||||
machineNameFound |= (filter.MachineName.MatchesPositiveSet(RomOf) == true);
|
||||
}
|
||||
if (machineNameFound == false)
|
||||
return false;
|
||||
|
||||
machineNameFound = filter.MachineName.MatchesNegativeSet(Name);
|
||||
if (filter.IncludeOfInGame)
|
||||
{
|
||||
machineNameFound |= (filter.MachineName.MatchesNegativeSet(CloneOf) == true);
|
||||
machineNameFound |= (filter.MachineName.MatchesNegativeSet(RomOf) == true);
|
||||
}
|
||||
if (machineNameFound == false)
|
||||
return false;
|
||||
|
||||
// Filter on comment
|
||||
if (filter.Comment.MatchesPositiveSet(Comment) == false)
|
||||
return false;
|
||||
if (filter.Comment.MatchesNegativeSet(Comment) == true)
|
||||
return false;
|
||||
|
||||
// Filter on machine description
|
||||
if (filter.MachineDescription.MatchesPositiveSet(Description) == false)
|
||||
return false;
|
||||
if (filter.MachineDescription.MatchesNegativeSet(Description) == true)
|
||||
return false;
|
||||
|
||||
// Filter on year
|
||||
if (filter.Year.MatchesPositiveSet(Year) == false)
|
||||
return false;
|
||||
if (filter.Year.MatchesNegativeSet(Year) == true)
|
||||
return false;
|
||||
|
||||
// Filter on manufacturer
|
||||
if (filter.Manufacturer.MatchesPositiveSet(Manufacturer) == false)
|
||||
return false;
|
||||
if (filter.Manufacturer.MatchesNegativeSet(Manufacturer) == true)
|
||||
return false;
|
||||
|
||||
// Filter on publisher
|
||||
if (filter.Publisher.MatchesPositiveSet(Publisher) == false)
|
||||
return false;
|
||||
if (filter.Publisher.MatchesNegativeSet(Publisher) == true)
|
||||
return false;
|
||||
|
||||
// Filter on category
|
||||
if (filter.Category.MatchesPositiveSet(Category) == false)
|
||||
return false;
|
||||
if (filter.Category.MatchesNegativeSet(Category) == true)
|
||||
return false;
|
||||
|
||||
// Filter on romof
|
||||
if (filter.RomOf.MatchesPositiveSet(RomOf) == false)
|
||||
return false;
|
||||
if (filter.RomOf.MatchesNegativeSet(RomOf) == true)
|
||||
return false;
|
||||
|
||||
// Filter on cloneof
|
||||
if (filter.CloneOf.MatchesPositiveSet(CloneOf) == false)
|
||||
return false;
|
||||
if (filter.CloneOf.MatchesNegativeSet(CloneOf) == true)
|
||||
return false;
|
||||
|
||||
// Filter on sampleof
|
||||
if (filter.SampleOf.MatchesPositiveSet(SampleOf) == false)
|
||||
return false;
|
||||
if (filter.SampleOf.MatchesNegativeSet(SampleOf) == true)
|
||||
return false;
|
||||
|
||||
// Filter on supported
|
||||
if (filter.Supported.MatchesNeutral(null, Supported) == false)
|
||||
return false;
|
||||
|
||||
// Filter on source file
|
||||
if (filter.SourceFile.MatchesPositiveSet(SourceFile) == false)
|
||||
return false;
|
||||
if (filter.SourceFile.MatchesNegativeSet(SourceFile) == true)
|
||||
return false;
|
||||
|
||||
// Filter on runnable
|
||||
if (filter.Runnable.MatchesNeutral(null, Runnable) == false)
|
||||
return false;
|
||||
|
||||
// Filter on board
|
||||
if (filter.Board.MatchesPositiveSet(Board) == false)
|
||||
return false;
|
||||
if (filter.Board.MatchesNegativeSet(Board) == true)
|
||||
return false;
|
||||
|
||||
// Filter on rebuildto
|
||||
if (filter.RebuildTo.MatchesPositiveSet(RebuildTo) == false)
|
||||
return false;
|
||||
if (filter.RebuildTo.MatchesNegativeSet(RebuildTo) == true)
|
||||
return false;
|
||||
|
||||
// Filter on devices
|
||||
if (Devices != null && Devices.Any())
|
||||
{
|
||||
bool anyPositiveDevice = false;
|
||||
bool anyNegativeDevice = false;
|
||||
foreach (string device in Devices)
|
||||
{
|
||||
anyPositiveDevice |= filter.Devices.MatchesPositiveSet(device) != false;
|
||||
anyNegativeDevice |= filter.Devices.MatchesNegativeSet(device) == false;
|
||||
}
|
||||
|
||||
if (!anyPositiveDevice || anyNegativeDevice)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter on slot options
|
||||
if (SlotOptions != null && SlotOptions.Any())
|
||||
{
|
||||
bool anyPositiveSlotOption = false;
|
||||
bool anyNegativeSlotOption = false;
|
||||
foreach (string slotOption in SlotOptions)
|
||||
{
|
||||
anyPositiveSlotOption |= filter.SlotOptions.MatchesPositiveSet(slotOption) != false;
|
||||
anyNegativeSlotOption |= filter.SlotOptions.MatchesNegativeSet(slotOption) == false;
|
||||
}
|
||||
|
||||
if (!anyPositiveSlotOption || anyNegativeSlotOption)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter on machine type
|
||||
if (filter.MachineTypes.MatchesPositive(MachineType.NULL, MachineType) == false)
|
||||
return false;
|
||||
if (filter.MachineTypes.MatchesNegative(MachineType.NULL, MachineType) == true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the Machine
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public void RemoveFields(List<Field> fields)
|
||||
{
|
||||
if (fields.Contains(Field.MachineName))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.Comment))
|
||||
Comment = null;
|
||||
|
||||
if (fields.Contains(Field.Description))
|
||||
Description = null;
|
||||
|
||||
if (fields.Contains(Field.Year))
|
||||
Year = null;
|
||||
|
||||
if (fields.Contains(Field.Manufacturer))
|
||||
Manufacturer = null;
|
||||
|
||||
if (fields.Contains(Field.Publisher))
|
||||
Publisher = null;
|
||||
|
||||
if (fields.Contains(Field.Category))
|
||||
Category = null;
|
||||
|
||||
if (fields.Contains(Field.RomOf))
|
||||
RomOf = null;
|
||||
|
||||
if (fields.Contains(Field.CloneOf))
|
||||
CloneOf = null;
|
||||
|
||||
if (fields.Contains(Field.SampleOf))
|
||||
SampleOf = null;
|
||||
|
||||
if (fields.Contains(Field.Supported))
|
||||
Supported = null;
|
||||
|
||||
if (fields.Contains(Field.SourceFile))
|
||||
SourceFile = null;
|
||||
|
||||
if (fields.Contains(Field.Runnable))
|
||||
Runnable = null;
|
||||
|
||||
if (fields.Contains(Field.Board))
|
||||
Board = null;
|
||||
|
||||
if (fields.Contains(Field.RebuildTo))
|
||||
RebuildTo = null;
|
||||
|
||||
if (fields.Contains(Field.Devices))
|
||||
Devices = null;
|
||||
|
||||
if (fields.Contains(Field.SlotOptions))
|
||||
SlotOptions = null;
|
||||
|
||||
if (fields.Contains(Field.Infos))
|
||||
Infos = null;
|
||||
|
||||
if (fields.Contains(Field.MachineType))
|
||||
MachineType = MachineType.NULL;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace machine fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
|
||||
public void ReplaceFields(Machine machine, List<Field> fields, bool onlySame)
|
||||
{
|
||||
if (fields.Contains(Field.MachineName))
|
||||
Name = machine.Name;
|
||||
|
||||
if (fields.Contains(Field.Comment))
|
||||
Comment = machine.Comment;
|
||||
|
||||
if (fields.Contains(Field.Description))
|
||||
{
|
||||
if (!onlySame || (onlySame && Name == Description))
|
||||
Description = machine.Description;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.Year))
|
||||
Year = machine.Year;
|
||||
|
||||
if (fields.Contains(Field.Manufacturer))
|
||||
Manufacturer = machine.Manufacturer;
|
||||
|
||||
if (fields.Contains(Field.Publisher))
|
||||
Publisher = machine.Publisher;
|
||||
|
||||
if (fields.Contains(Field.Category))
|
||||
Category = machine.Category;
|
||||
|
||||
if (fields.Contains(Field.RomOf))
|
||||
RomOf = machine.RomOf;
|
||||
|
||||
if (fields.Contains(Field.CloneOf))
|
||||
CloneOf = machine.CloneOf;
|
||||
|
||||
if (fields.Contains(Field.SampleOf))
|
||||
SampleOf = machine.SampleOf;
|
||||
|
||||
if (fields.Contains(Field.Supported))
|
||||
Supported = machine.Supported;
|
||||
|
||||
if (fields.Contains(Field.SourceFile))
|
||||
SourceFile = machine.SourceFile;
|
||||
|
||||
if (fields.Contains(Field.Runnable))
|
||||
Runnable = machine.Runnable;
|
||||
|
||||
if (fields.Contains(Field.Board))
|
||||
Board = machine.Board;
|
||||
|
||||
if (fields.Contains(Field.RebuildTo))
|
||||
RebuildTo = machine.RebuildTo;
|
||||
|
||||
if (fields.Contains(Field.Devices))
|
||||
Devices = machine.Devices;
|
||||
|
||||
if (fields.Contains(Field.SlotOptions))
|
||||
SlotOptions = machine.SlotOptions;
|
||||
|
||||
if (fields.Contains(Field.Infos))
|
||||
Infos = machine.Infos;
|
||||
|
||||
if (fields.Contains(Field.MachineType))
|
||||
MachineType = machine.MachineType;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using SabreTools.Library.Filtering;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -9,7 +10,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public class Release : DatItem
|
||||
{
|
||||
#region Publicly facing variables
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Release region(s)
|
||||
@@ -86,12 +87,12 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public Release()
|
||||
{
|
||||
this.Name = string.Empty;
|
||||
this.ItemType = ItemType.Release;
|
||||
this.Region = string.Empty;
|
||||
this.Language = string.Empty;
|
||||
this.Date = string.Empty;
|
||||
this.Default = null;
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Release;
|
||||
Region = string.Empty;
|
||||
Language = string.Empty;
|
||||
Date = string.Empty;
|
||||
Default = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -106,33 +107,15 @@ namespace SabreTools.Library.DatItems
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
Region = this.Region,
|
||||
Language = this.Language,
|
||||
@@ -148,18 +131,18 @@ namespace SabreTools.Library.DatItems
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a release return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a Release
|
||||
Release newOther = other as Release;
|
||||
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name
|
||||
&& this.Region == newOther.Region
|
||||
&& this.Language == newOther.Language
|
||||
&& this.Date == newOther.Date
|
||||
&& this.Default == newOther.Default);
|
||||
return (Name == newOther.Name
|
||||
&& Region == newOther.Region
|
||||
&& Language == newOther.Language
|
||||
&& Date == newOther.Date
|
||||
&& Default == newOther.Default);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatFiles;
|
||||
using SabreTools.Library.FileTypes;
|
||||
@@ -27,7 +28,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#endregion
|
||||
|
||||
#region Publicly facing variables
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// What BIOS is required for this rom
|
||||
@@ -244,11 +245,11 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
public Rom()
|
||||
{
|
||||
this.Name = string.Empty;
|
||||
this.ItemType = ItemType.Rom;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
this.Date = string.Empty;
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Rom;
|
||||
DupeType = 0x00;
|
||||
ItemStatus = ItemStatus.None;
|
||||
Date = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,12 +260,12 @@ namespace SabreTools.Library.DatItems
|
||||
/// <param name="omitFromScan"></param>
|
||||
public Rom(string name, string machineName)
|
||||
{
|
||||
this.Name = name;
|
||||
this.ItemType = ItemType.Rom;
|
||||
this.Size = -1;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
Name = name;
|
||||
ItemType = ItemType.Rom;
|
||||
Size = -1;
|
||||
ItemStatus = ItemStatus.None;
|
||||
|
||||
_machine = new Machine
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = machineName,
|
||||
Description = machineName,
|
||||
@@ -277,8 +278,8 @@ namespace SabreTools.Library.DatItems
|
||||
/// <param name="baseFile"></param>
|
||||
public Rom(BaseFile baseFile)
|
||||
{
|
||||
this.Name = baseFile.Filename;
|
||||
this.Size = baseFile.Size ?? -1;
|
||||
Name = baseFile.Filename;
|
||||
Size = baseFile.Size ?? -1;
|
||||
_crc = baseFile.CRC;
|
||||
_md5 = baseFile.MD5;
|
||||
#if NET_FRAMEWORK
|
||||
@@ -289,10 +290,10 @@ namespace SabreTools.Library.DatItems
|
||||
_sha384 = baseFile.SHA384;
|
||||
_sha512 = baseFile.SHA512;
|
||||
|
||||
this.ItemType = ItemType.Rom;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
this.Date = baseFile.Date;
|
||||
ItemType = ItemType.Rom;
|
||||
DupeType = 0x00;
|
||||
ItemStatus = ItemStatus.None;
|
||||
Date = baseFile.Date;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -307,34 +308,17 @@ namespace SabreTools.Library.DatItems
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
Bios = this.Bios,
|
||||
Size = this.Size,
|
||||
_crc = this._crc,
|
||||
_md5 = this._md5,
|
||||
@@ -345,8 +329,13 @@ namespace SabreTools.Library.DatItems
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
_sha512 = this._sha512,
|
||||
ItemStatus = this.ItemStatus,
|
||||
MergeTag = this.MergeTag,
|
||||
Region = this.Region,
|
||||
Offset = this.Offset,
|
||||
Date = this.Date,
|
||||
ItemStatus = this.ItemStatus,
|
||||
Optional = this.Optional,
|
||||
Inverted = this.Inverted,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
/// </summary>
|
||||
public Sample()
|
||||
{
|
||||
this.Name = string.Empty;
|
||||
this.ItemType = ItemType.Sample;
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Sample;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -28,33 +28,15 @@
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
IndexId = this.IndexId,
|
||||
IndexSource = this.IndexSource,
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,14 +47,14 @@
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a sample, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a Sample
|
||||
Sample newOther = other as Sample;
|
||||
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name);
|
||||
return (Name == newOther.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
43
SabreTools.Library/DatItems/Source.cs
Normal file
43
SabreTools.Library/DatItems/Source.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Source information wrapper
|
||||
/// </summary>
|
||||
public class Source : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Source index
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Source name
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="id">Source ID, default 0</param>
|
||||
/// <param name="source">Source name, default null</param>
|
||||
public Source(int id = 0, string source = null)
|
||||
{
|
||||
Index = id;
|
||||
Name = source;
|
||||
}
|
||||
|
||||
#region Cloning
|
||||
|
||||
/// <summary>
|
||||
/// Clone the current object
|
||||
/// </summary>
|
||||
public object Clone()
|
||||
{
|
||||
return new Source(Index, Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ namespace SabreTools.Library.FileTypes
|
||||
FileStream outputStream = null;
|
||||
|
||||
// Get the output folder name from the first rebuild rom
|
||||
string fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.MachineName), Sanitizer.RemovePathUnsafeCharacters(rom.Name));
|
||||
string fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name), Sanitizer.RemovePathUnsafeCharacters(rom.Name));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -452,7 +452,7 @@ namespace SabreTools.Library.FileTypes
|
||||
inputStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.MachineName) + (rom.MachineName.EndsWith(".zip") ? string.Empty : ".zip"));
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".7z") ? string.Empty : ".7z"));
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
@@ -660,7 +660,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].MachineName) + (roms[0].MachineName.EndsWith(".zip") ? string.Empty : ".zip"));
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".7z") ? string.Empty : ".7z"));
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
|
||||
@@ -324,7 +324,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.MachineName) + (rom.MachineName.EndsWith(".tar") ? string.Empty : ".tar"));
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".tar") ? string.Empty : ".tar"));
|
||||
|
||||
// Set internal variables
|
||||
TarArchive oldTarFile = TarArchive.Create();
|
||||
@@ -486,7 +486,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].MachineName) + (roms[0].MachineName.EndsWith(".tar") ? string.Empty : ".tar"));
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".tar") ? string.Empty : ".tar"));
|
||||
|
||||
// Set internal variables
|
||||
TarArchive oldTarFile = TarArchive.Create();
|
||||
|
||||
@@ -457,7 +457,7 @@ namespace SabreTools.Library.FileTypes
|
||||
inputStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.MachineName) + (rom.MachineName.EndsWith(".zip") ? string.Empty : ".zip"));
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".zip") ? string.Empty : ".zip"));
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
@@ -666,7 +666,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].MachineName) + (roms[0].MachineName.EndsWith(".zip") ? string.Empty : ".zip"));
|
||||
string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".zip") ? string.Empty : ".zip"));
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
|
||||
Reference in New Issue
Block a user