mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move machine to same name model as DatItem
This commit is contained in:
@@ -82,7 +82,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItem(sw, datItem, lastgame);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
lastgame = datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItemDB(sw, datItem, lastgame);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
lastgame = machine.Value!.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,8 +199,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Romba mode automatically uses item name
|
||||
if (Modifiers.OutputDepot?.IsActive == true || Modifiers.UseRomName)
|
||||
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
|
||||
else if (!Modifiers.UseRomName && machine!.GetStringFieldValue(Models.Metadata.Machine.NameKey) != lastgame)
|
||||
sw.Write($"{machine!.GetStringFieldValue(Models.Metadata.Machine.NameKey) ?? string.Empty}\n");
|
||||
else if (!Modifiers.UseRomName && machine!.GetName() != lastgame)
|
||||
sw.Write($"{machine!.GetName() ?? string.Empty}\n");
|
||||
|
||||
sw.Flush();
|
||||
}
|
||||
|
||||
@@ -412,11 +412,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
DatItem datItem = datItems[index];
|
||||
|
||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||
if (lastgame != null && !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame != null && !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteEndGame(jtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame == null || !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteStartGame(jtw, datItem);
|
||||
|
||||
// Check for a "null" item
|
||||
@@ -427,7 +427,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItem(jtw, datItem);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
lastgame = datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,11 +493,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
var machine = GetMachineForItemDB(kvp.Key);
|
||||
|
||||
// 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 && !string.Equals(lastgame, machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame != null && !string.Equals(lastgame, machine.Value!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteEndGame(jtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || !string.Equals(lastgame, machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame == null || !string.Equals(lastgame, machine.Value!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteStartGame(jtw, kvp.Value);
|
||||
|
||||
// Check for a "null" item
|
||||
@@ -508,7 +508,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItemDB(jtw, datItem);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
lastgame = machine.Value!.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,8 +555,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
|
||||
{
|
||||
// No game should start with a path separator
|
||||
if (!string.IsNullOrEmpty(datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)))
|
||||
datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!.TrimStart(Path.DirectorySeparatorChar));
|
||||
if (!string.IsNullOrEmpty(datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName()))
|
||||
datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.SetName(datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName()!.TrimStart(Path.DirectorySeparatorChar));
|
||||
|
||||
// Build the state
|
||||
jtw.WriteStartObject();
|
||||
|
||||
@@ -240,11 +240,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
DatItem datItem = datItems[index];
|
||||
|
||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||
if (lastgame != null && !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame != null && !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteEndGame(xtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame == null || !string.Equals(lastgame, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteStartGame(xtw, datItem);
|
||||
|
||||
// Check for a "null" item
|
||||
@@ -255,7 +255,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItem(xtw, datItem);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
lastgame = datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,11 +322,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
var machine = GetMachineForItemDB(kvp.Key);
|
||||
|
||||
// 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 && !string.Equals(lastgame, machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame != null && !string.Equals(lastgame, machine.Value!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteEndGame(xtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || !string.Equals(lastgame, machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase))
|
||||
if (lastgame == null || !string.Equals(lastgame, machine.Value!.GetName(), StringComparison.OrdinalIgnoreCase))
|
||||
WriteStartGame(xtw, kvp.Value);
|
||||
|
||||
// Check for a "null" item
|
||||
@@ -337,7 +337,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItemDB(xtw, datItem);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
lastgame = machine.Value!.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static void WriteStartGame(XmlTextWriter xtw, DatItem datItem)
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)?.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty);
|
||||
datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.SetName(datItem.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName()?.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty);
|
||||
|
||||
// Write the machine
|
||||
xtw.WriteStartElement("directory");
|
||||
|
||||
Reference in New Issue
Block a user