Machine stands alone

This commit is contained in:
Matt Nadareski
2020-08-20 13:17:14 -07:00
parent 80a28539bc
commit 2da51628a4
33 changed files with 1117 additions and 1488 deletions

View File

@@ -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);