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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user