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:
@@ -125,7 +125,7 @@ namespace SabreTools.DatFiles
|
||||
continue;
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? machineName = machine.GetName();
|
||||
string? machineDesc = machine.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey);
|
||||
if (machineName == null || machineDesc == null)
|
||||
continue;
|
||||
@@ -166,7 +166,7 @@ namespace SabreTools.DatFiles
|
||||
continue;
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? machineName = machine.Value.GetName();
|
||||
string? machineDesc = machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey);
|
||||
if (machineName == null || machineDesc == null)
|
||||
continue;
|
||||
@@ -332,7 +332,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
// Get machine information
|
||||
Machine? machine = item.GetFieldValue<Machine>(DatItem.MachineKey);
|
||||
string? machineName = machine?.GetStringFieldValue(Models.Metadata.Machine.NameKey)?.ToLowerInvariant();
|
||||
string? machineName = machine?.GetName()?.ToLowerInvariant();
|
||||
if (machine == null || machineName == null)
|
||||
continue;
|
||||
|
||||
@@ -411,7 +411,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
// Get machine information
|
||||
Machine? machineObj = machine.Value;
|
||||
string? machineName = machineObj?.GetStringFieldValue(Models.Metadata.Machine.NameKey)?.ToLowerInvariant();
|
||||
string? machineName = machineObj?.GetName()?.ToLowerInvariant();
|
||||
if (machineObj == null || machineName == null)
|
||||
continue;
|
||||
|
||||
@@ -535,19 +535,19 @@ namespace SabreTools.DatFiles
|
||||
if (datItem is DatItems.Formats.File || datItem is Rom)
|
||||
{
|
||||
string[] splitname = itemName.Split('.');
|
||||
itemName = machine.GetStringFieldValue(Models.Metadata.Machine.NameKey)
|
||||
itemName = machine.GetName()
|
||||
+ $"/{string.Join(".", splitname, 0, splitname.Length > 1 ? splitname.Length - 1 : 1)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
itemName = machine.GetStringFieldValue(Models.Metadata.Machine.NameKey) + $"/{itemName}";
|
||||
itemName = machine.GetName() + $"/{itemName}";
|
||||
}
|
||||
|
||||
// Strip off "Default" prefix only for ORPG
|
||||
if (itemName.StartsWith("Default"))
|
||||
itemName = itemName.Substring("Default".Length + 1);
|
||||
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, itemName);
|
||||
machine.SetName(itemName);
|
||||
datItem.SetName(Path.GetFileName(datItem.GetName()));
|
||||
}
|
||||
|
||||
@@ -615,19 +615,19 @@ namespace SabreTools.DatFiles
|
||||
if (datItem.Value is DatItems.Formats.File || datItem.Value is Rom)
|
||||
{
|
||||
string[] splitname = itemName.Split('.');
|
||||
itemName = machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey)
|
||||
itemName = machine.Value.GetName()
|
||||
+ $"/{string.Join(".", splitname, 0, splitname.Length > 1 ? splitname.Length - 1 : 1)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
itemName = machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey) + $"/{itemName}";
|
||||
itemName = machine.Value.GetName() + $"/{itemName}";
|
||||
}
|
||||
|
||||
// Strip off "Default" prefix only for ORPG
|
||||
if (itemName.StartsWith("Default"))
|
||||
itemName = itemName.Substring("Default".Length + 1);
|
||||
|
||||
machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, itemName);
|
||||
machine.Value.SetName(itemName);
|
||||
datItem.Value.SetName(Path.GetFileName(datItem.Value.GetName()));
|
||||
}
|
||||
|
||||
@@ -662,11 +662,11 @@ namespace SabreTools.DatFiles
|
||||
continue;
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? machineName = machine.GetName();
|
||||
string? machineDesc = machine.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey);
|
||||
|
||||
if (machineName != null && Regex.IsMatch(machineName, SceneNamePattern))
|
||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Regex.Replace(machineName, SceneNamePattern, "$2"));
|
||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetName(Regex.Replace(machineName, SceneNamePattern, "$2"));
|
||||
|
||||
if (machineDesc != null && Regex.IsMatch(machineDesc, SceneNamePattern))
|
||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, Regex.Replace(machineDesc, SceneNamePattern, "$2"));
|
||||
@@ -702,11 +702,11 @@ namespace SabreTools.DatFiles
|
||||
#endif
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? machineName = machine.Value.GetName();
|
||||
string? machineDesc = machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey);
|
||||
|
||||
if (machineName != null && Regex.IsMatch(machineName, SceneNamePattern))
|
||||
machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Regex.Replace(machineName, SceneNamePattern, "$2"));
|
||||
machine.Value.SetName(Regex.Replace(machineName, SceneNamePattern, "$2"));
|
||||
|
||||
if (machineDesc != null && Regex.IsMatch(machineDesc, SceneNamePattern))
|
||||
machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, Regex.Replace(machineDesc, SceneNamePattern, "$2"));
|
||||
@@ -747,14 +747,14 @@ namespace SabreTools.DatFiles
|
||||
continue;
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? machineName = machine.GetName();
|
||||
string? cloneOf = machine.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey);
|
||||
string? romOf = machine.GetStringFieldValue(Models.Metadata.Machine.RomOfKey);
|
||||
string? sampleOf = machine.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey);
|
||||
|
||||
// Update machine name
|
||||
if (machineName != null && mapping.ContainsKey(machineName))
|
||||
machine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, mapping[machineName]);
|
||||
machine.SetName(mapping[machineName]);
|
||||
|
||||
// Update cloneof
|
||||
if (cloneOf != null && mapping.ContainsKey(cloneOf))
|
||||
@@ -788,14 +788,14 @@ namespace SabreTools.DatFiles
|
||||
continue;
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? machineName = machine.Value.GetName();
|
||||
string? cloneOf = machine.Value.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey);
|
||||
string? romOf = machine.Value.GetStringFieldValue(Models.Metadata.Machine.RomOfKey);
|
||||
string? sampleOf = machine.Value.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey);
|
||||
|
||||
// Update machine name
|
||||
if (machineName != null && mapping.ContainsKey(machineName))
|
||||
machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, mapping[machineName]);
|
||||
machine.Value.SetName(mapping[machineName]);
|
||||
|
||||
// Update cloneof
|
||||
if (cloneOf != null && mapping.ContainsKey(cloneOf))
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace SabreTools.DatFiles
|
||||
if (item.ContainsKey(Models.Metadata.Machine.DumpKey))
|
||||
{
|
||||
var items = item.ReadItemArray<Models.Metadata.Dump>(Models.Metadata.Machine.DumpKey);
|
||||
string? machineName = machine.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? machineName = machine.GetName();
|
||||
ProcessItems(items, machine, machineIndex: 0, source, sourceIndex, statsOnly, machineName);
|
||||
}
|
||||
if (item.ContainsKey(Models.Metadata.Machine.FeatureKey))
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace SabreTools.DatFiles
|
||||
if (parentItems.Count == 0)
|
||||
{
|
||||
copyFrom = new Rom();
|
||||
copyFrom.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, cloneOf);
|
||||
copyFrom.GetFieldValue<Machine>(DatItem.MachineKey)!.SetName(cloneOf);
|
||||
copyFrom.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, cloneOf);
|
||||
}
|
||||
else
|
||||
@@ -325,7 +325,7 @@ namespace SabreTools.DatFiles
|
||||
.Contains(rom.GetStringFieldValue(Models.Metadata.Rom.MergeKey)))
|
||||
{
|
||||
if (subfolder)
|
||||
rom.SetName($"{rom.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)}\\{rom.GetName()}");
|
||||
rom.SetName($"{rom.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName()}\\{rom.GetName()}");
|
||||
|
||||
rom.CopyMachineInformation(copyFrom);
|
||||
AddItem(rom, statsOnly: false);
|
||||
@@ -335,7 +335,7 @@ namespace SabreTools.DatFiles
|
||||
else if (!GetItemsForBucket(cloneOf).Contains(item) || skipDedup)
|
||||
{
|
||||
if (subfolder)
|
||||
rom.SetName($"{item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)}\\{rom.GetName()}");
|
||||
rom.SetName($"{item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName()}\\{rom.GetName()}");
|
||||
|
||||
rom.CopyMachineInformation(copyFrom);
|
||||
AddItem(rom, statsOnly: false);
|
||||
@@ -346,7 +346,7 @@ namespace SabreTools.DatFiles
|
||||
else if (!GetItemsForBucket(cloneOf).Contains(item))
|
||||
{
|
||||
if (subfolder)
|
||||
item.SetName($"{item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)}\\{item.GetName()}");
|
||||
item.SetName($"{item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetName()}\\{item.GetName()}");
|
||||
|
||||
item.CopyMachineInformation(copyFrom);
|
||||
AddItem(item, statsOnly: false);
|
||||
@@ -404,7 +404,7 @@ namespace SabreTools.DatFiles
|
||||
continue;
|
||||
|
||||
string? machineName = GetMachineForItemDB(item.Key).Value?
|
||||
.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
.GetName();
|
||||
|
||||
// Special disk handling
|
||||
if (item.Value is Disk disk)
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
@@ -487,7 +488,7 @@ namespace SabreTools.DatFiles
|
||||
// Get the name to update
|
||||
string? name = (useRomName
|
||||
? item.GetName()
|
||||
: machine?.GetStringFieldValue(Models.Metadata.Machine.NameKey)) ?? string.Empty;
|
||||
: machine?.GetName()) ?? string.Empty;
|
||||
|
||||
// If we're in Depot mode, take care of that instead
|
||||
if (Modifiers.OutputDepot?.IsActive == true)
|
||||
@@ -553,14 +554,14 @@ namespace SabreTools.DatFiles
|
||||
name += Modifiers.AddExtension;
|
||||
|
||||
if (useRomName && Modifiers.GameName)
|
||||
name = Path.Combine(machine?.GetStringFieldValue(Models.Metadata.Machine.NameKey) ?? string.Empty, name);
|
||||
name = Path.Combine(machine?.GetName() ?? string.Empty, name);
|
||||
|
||||
// Now assign back the formatted name
|
||||
name = $"{pre}{name}{post}";
|
||||
if (useRomName)
|
||||
item.SetName(name);
|
||||
else
|
||||
machine?.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, name);
|
||||
machine?.SetName(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -575,7 +576,7 @@ namespace SabreTools.DatFiles
|
||||
// Initialize strings
|
||||
string? type = item.GetStringFieldValue(Models.Metadata.DatItem.TypeKey);
|
||||
string
|
||||
game = machine?.GetStringFieldValue(Models.Metadata.Machine.NameKey) ?? string.Empty,
|
||||
game = machine?.GetName() ?? string.Empty,
|
||||
manufacturer = machine?.GetStringFieldValue(Models.Metadata.Machine.ManufacturerKey) ?? string.Empty,
|
||||
publisher = machine?.GetStringFieldValue(Models.Metadata.Machine.PublisherKey) ?? string.Empty,
|
||||
category = machine?.GetStringFieldValue(Models.Metadata.Machine.CategoryKey) ?? string.Empty,
|
||||
@@ -1000,8 +1001,8 @@ namespace SabreTools.DatFiles
|
||||
var nc = new NaturalComparer();
|
||||
|
||||
// If machine names don't match
|
||||
string? xMachineName = x.GetFieldValue<Machine>(DatItem.MachineKey)?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? yMachineName = y.GetFieldValue<Machine>(DatItem.MachineKey)?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? xMachineName = x.GetFieldValue<Machine>(DatItem.MachineKey)?.GetName();
|
||||
string? yMachineName = y.GetFieldValue<Machine>(DatItem.MachineKey)?.GetName();
|
||||
if (xMachineName != yMachineName)
|
||||
return nc.Compare(xMachineName, yMachineName);
|
||||
|
||||
@@ -1055,8 +1056,8 @@ namespace SabreTools.DatFiles
|
||||
// TODO: Fix this since DB uses an external map for machines
|
||||
|
||||
// If machine names don't match
|
||||
string? xMachineName = x.Value.GetFieldValue<Machine>(DatItem.MachineKey)?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? yMachineName = y.Value.GetFieldValue<Machine>(DatItem.MachineKey)?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? xMachineName = x.Value.GetFieldValue<Machine>(DatItem.MachineKey)?.GetName();
|
||||
string? yMachineName = y.Value.GetFieldValue<Machine>(DatItem.MachineKey)?.GetName();
|
||||
if (xMachineName != yMachineName)
|
||||
return nc.Compare(xMachineName, yMachineName);
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -533,8 +533,8 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// If the saved machine is a child of the current machine, use the current machine instead
|
||||
if (savedMachine?.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey) == itemMachine?.GetStringFieldValue(Models.Metadata.Machine.NameKey)
|
||||
|| savedMachine?.GetStringFieldValue(Models.Metadata.Machine.RomOfKey) == itemMachine?.GetStringFieldValue(Models.Metadata.Machine.NameKey))
|
||||
if (savedMachine?.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey) == itemMachine?.GetName()
|
||||
|| savedMachine?.GetStringFieldValue(Models.Metadata.Machine.RomOfKey) == itemMachine?.GetName())
|
||||
{
|
||||
savedItem.CopyMachineInformation(datItem);
|
||||
savedItem.SetName(datItem.GetName());
|
||||
@@ -799,8 +799,8 @@ namespace SabreTools.DatFiles
|
||||
Machine? yMachine = y.GetFieldValue<Machine>(DatItem.MachineKey);
|
||||
|
||||
// If machine names don't match
|
||||
string? xMachineName = xMachine?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? yMachineName = yMachine?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? xMachineName = xMachine?.GetName();
|
||||
string? yMachineName = yMachine?.GetName();
|
||||
if (xMachineName != yMachineName)
|
||||
return nc.Compare(xMachineName, yMachineName);
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace SabreTools.DatFiles
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return new KeyValuePair<long, Machine?>(-1, null);
|
||||
|
||||
var machine = _machines.FirstOrDefault(m => m.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey) == name);
|
||||
var machine = _machines.FirstOrDefault(m => m.Value.GetName() == name);
|
||||
return new KeyValuePair<long, Machine?>(machine.Key, machine.Value);
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ namespace SabreTools.DatFiles
|
||||
if (string.IsNullOrEmpty(machineName))
|
||||
return false;
|
||||
|
||||
var machine = _machines.FirstOrDefault(m => m.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey) == machineName);
|
||||
var machine = _machines.FirstOrDefault(m => m.Value.GetName() == machineName);
|
||||
return RemoveMachine(machine.Key);
|
||||
}
|
||||
|
||||
@@ -874,8 +874,8 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// If the saved machine is a child of the current machine, use the current machine instead
|
||||
if (savedMachine.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey) == itemMachine.GetStringFieldValue(Models.Metadata.Machine.NameKey)
|
||||
|| savedMachine.GetStringFieldValue(Models.Metadata.Machine.RomOfKey) == itemMachine.GetStringFieldValue(Models.Metadata.Machine.NameKey))
|
||||
if (savedMachine.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey) == itemMachine.GetName()
|
||||
|| savedMachine.GetStringFieldValue(Models.Metadata.Machine.RomOfKey) == itemMachine.GetName())
|
||||
{
|
||||
_machines[_itemToMachineMapping[savedIndex]] = (itemMachine.Clone() as Machine)!;
|
||||
savedItem.SetName(datItem.GetName());
|
||||
@@ -1101,8 +1101,8 @@ namespace SabreTools.DatFiles
|
||||
Machine? yMachine = _machines[_itemToMachineMapping[y.Key]];
|
||||
|
||||
// If machine names don't match
|
||||
string? xMachineName = xMachine?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? yMachineName = yMachine?.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||
string? xMachineName = xMachine?.GetName();
|
||||
string? yMachineName = yMachine?.GetName();
|
||||
if (xMachineName != yMachineName)
|
||||
return nc.Compare(xMachineName, yMachineName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user