mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add nullable context to SabreTools.DatItems
This change also starts migrating the internals of the DatItem formats to the new internal models. Right now, it's basically just acting like a wrapper around those models.
This commit is contained in:
@@ -316,7 +316,7 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
// Initialize strings
|
||||
string fix,
|
||||
game = item.Machine.Name,
|
||||
game = item.Machine?.Name ?? string.Empty,
|
||||
name = item.GetName() ?? item.ItemType.ToString(),
|
||||
crc = string.Empty,
|
||||
md5 = string.Empty,
|
||||
@@ -365,9 +365,9 @@ namespace SabreTools.DatFiles
|
||||
.Replace("%game%", game)
|
||||
.Replace("%machine%", game)
|
||||
.Replace("%name%", name)
|
||||
.Replace("%manufacturer%", item.Machine.Manufacturer ?? string.Empty)
|
||||
.Replace("%publisher%", item.Machine.Publisher ?? string.Empty)
|
||||
.Replace("%category%", item.Machine.Category ?? string.Empty)
|
||||
.Replace("%manufacturer%", item.Machine?.Manufacturer ?? string.Empty)
|
||||
.Replace("%publisher%", item.Machine?.Publisher ?? string.Empty)
|
||||
.Replace("%category%", item.Machine?.Category ?? string.Empty)
|
||||
.Replace("%crc%", crc)
|
||||
.Replace("%md5%", md5)
|
||||
.Replace("%sha1%", sha1)
|
||||
@@ -397,7 +397,7 @@ namespace SabreTools.DatFiles
|
||||
Header.UseRomName = true;
|
||||
|
||||
// Get the name to update
|
||||
string? name = (Header.UseRomName ? item.GetName() : item.Machine.Name) ?? string.Empty;
|
||||
string? name = (Header.UseRomName ? item.GetName() : item.Machine?.Name) ?? string.Empty;
|
||||
|
||||
// Create the proper Prefix and Postfix
|
||||
string pre = CreatePrefixPostfix(item, true);
|
||||
@@ -454,13 +454,13 @@ namespace SabreTools.DatFiles
|
||||
name += Header.AddExtension;
|
||||
|
||||
if (Header.UseRomName && Header.GameName)
|
||||
name = Path.Combine(item.Machine.Name, name);
|
||||
name = Path.Combine(item.Machine?.Name ?? string.Empty, name);
|
||||
|
||||
// Now assign back the formatted name
|
||||
name = $"{pre}{name}{post}";
|
||||
if (Header.UseRomName)
|
||||
item.SetName(name);
|
||||
else
|
||||
else if (item.Machine != null)
|
||||
item.Machine.Name = name;
|
||||
|
||||
// Restore all relevant values
|
||||
@@ -489,7 +489,7 @@ namespace SabreTools.DatFiles
|
||||
// If the Rom has "null" characteristics, ensure all fields
|
||||
if (rom.Size == null && rom.CRC == "null")
|
||||
{
|
||||
logger.Verbose($"Empty folder found: {datItem.Machine.Name}");
|
||||
logger.Verbose($"Empty folder found: {datItem.Machine?.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
rom.Size = Constants.SizeZero;
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA1 = file.SHA1,
|
||||
//FileCount = file.FileCount, // TODO: Add to internal model
|
||||
ArchiveDotOrgFormat = file.Format,
|
||||
//Original = file.Original, // TODO: Add to internal model
|
||||
OriginalFilename = file.Original,
|
||||
Summation = file.Summation,
|
||||
//MatrixNumber = file.MatrixNumber, // TODO: Add to internal model
|
||||
//CollectionCatalogNumber = file.CollectionCatalogNumber, // TODO: Add to internal model
|
||||
|
||||
@@ -121,23 +121,23 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var row = new Models.AttractMode.Row
|
||||
{
|
||||
Name = rom.Machine.Name,
|
||||
Title = rom.Machine.Description,
|
||||
Name = rom.Machine?.Name,
|
||||
Title = rom.Machine?.Description,
|
||||
Emulator = Header.FileName,
|
||||
CloneOf = rom.Machine.CloneOf,
|
||||
Year = rom.Machine.Year,
|
||||
Manufacturer = rom.Machine.Manufacturer,
|
||||
Category = rom.Machine.Category,
|
||||
Players = rom.Machine.Players,
|
||||
Rotation = rom.Machine.Rotation,
|
||||
Control = rom.Machine.Control,
|
||||
Status = rom.Machine.Status,
|
||||
DisplayCount = rom.Machine.DisplayCount,
|
||||
DisplayType = rom.Machine.DisplayType,
|
||||
CloneOf = rom.Machine?.CloneOf,
|
||||
Year = rom.Machine?.Year,
|
||||
Manufacturer = rom.Machine?.Manufacturer,
|
||||
Category = rom.Machine?.Category,
|
||||
Players = rom.Machine?.Players,
|
||||
Rotation = rom.Machine?.Rotation,
|
||||
Control = rom.Machine?.Control,
|
||||
Status = rom.Machine?.Status,
|
||||
DisplayCount = rom.Machine?.DisplayCount,
|
||||
DisplayType = rom.Machine?.DisplayType,
|
||||
AltRomname = rom.AltName,
|
||||
AltTitle = rom.AltTitle,
|
||||
Extra = rom.Machine.Comment,
|
||||
Buttons = rom.Machine.Buttons,
|
||||
Extra = rom.Machine?.Comment,
|
||||
Buttons = rom.Machine?.Buttons,
|
||||
// TODO: Add extended fields
|
||||
};
|
||||
return row;
|
||||
|
||||
@@ -571,7 +571,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
var item = new DipSwitch
|
||||
{
|
||||
Name = dipswitch.Name,
|
||||
Values = new List<Setting>(),
|
||||
Values = new List<DipValue>(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
@@ -582,13 +582,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
foreach (string entry in dipswitch.Entry ?? Array.Empty<string>())
|
||||
{
|
||||
var setting = new Setting
|
||||
var dipValue = new DipValue
|
||||
{
|
||||
Name = dipswitch.Name,
|
||||
Value = entry,
|
||||
Default = entry == dipswitch.Default,
|
||||
};
|
||||
item.Values.Add(setting);
|
||||
item.Values.Add(dipValue);
|
||||
}
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
|
||||
@@ -232,14 +232,14 @@ namespace SabreTools.DatFiles.Formats
|
||||
// We normalize to all "game"
|
||||
var game = new Models.ClrMamePro.Game
|
||||
{
|
||||
Name = machine.Name,
|
||||
Description = machine.Description,
|
||||
Year = machine.Year,
|
||||
Manufacturer = machine.Manufacturer,
|
||||
Category = machine.Category,
|
||||
CloneOf = machine.CloneOf,
|
||||
RomOf = machine.RomOf,
|
||||
SampleOf = machine.SampleOf,
|
||||
Name = machine?.Name,
|
||||
Description = machine?.Description,
|
||||
Year = machine?.Year,
|
||||
Manufacturer = machine?.Manufacturer,
|
||||
Category = machine?.Category,
|
||||
CloneOf = machine?.CloneOf,
|
||||
RomOf = machine?.RomOf,
|
||||
SampleOf = machine?.SampleOf,
|
||||
};
|
||||
|
||||
// Create holders for all item types
|
||||
@@ -535,7 +535,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
};
|
||||
|
||||
if (item.ControlsSpecified)
|
||||
input.Buttons = item.Controls[0].Buttons?.ToString();
|
||||
input.Buttons = item.Controls![0].Buttons?.ToString();
|
||||
|
||||
return input;
|
||||
}
|
||||
@@ -553,9 +553,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (item.ValuesSpecified)
|
||||
{
|
||||
var entries = new List<string>();
|
||||
foreach (var setting in item.Values)
|
||||
foreach (var setting in item.Values!)
|
||||
{
|
||||
entries.Add(setting.Value);
|
||||
entries.Add(setting.Value!);
|
||||
if (setting.Default == true)
|
||||
dipswitch.Default = setting.Value;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// We re-add the missing parts of the game name
|
||||
var game = new Models.DosCenter.Game
|
||||
{
|
||||
Name = $"\"{machine.Name}.zip\""
|
||||
Name = $"\"{machine?.Name ?? string.Empty}.zip\""
|
||||
};
|
||||
|
||||
// Create holders for all item types
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
var row = new Models.EverdriveSMDB.Row
|
||||
{
|
||||
SHA256 = rom.SHA256,
|
||||
Name = $"{rom.Machine.Name}/{rom.Name}",
|
||||
Name = $"{rom.Machine?.Name ?? string.Empty}/{rom.Name}",
|
||||
SHA1 = rom.SHA1,
|
||||
MD5 = rom.MD5,
|
||||
CRC32 = rom.CRC,
|
||||
|
||||
@@ -116,8 +116,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
var set = new Models.Listrom.Set
|
||||
{
|
||||
Driver = !items[0].Machine.MachineType.HasFlag(MachineType.Device) ? items[0].Machine.Name : null,
|
||||
Device = items[0].Machine.MachineType.HasFlag(MachineType.Device) ? items[0].Machine.Name : null,
|
||||
Driver = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null,
|
||||
Device = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null,
|
||||
};
|
||||
|
||||
// Loop through and convert the items to respective lists
|
||||
|
||||
@@ -615,10 +615,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
item.Conditions = new List<Condition> { condition };
|
||||
}
|
||||
|
||||
var locations = new List<Location>();
|
||||
var locations = new List<DipLocation>();
|
||||
foreach (var diplocation in dipswitch.DipLocation ?? Array.Empty<Models.Listxml.DipLocation>())
|
||||
{
|
||||
var locationItem = new Location
|
||||
var locationItem = new DipLocation
|
||||
{
|
||||
Name = diplocation.Name,
|
||||
Number = NumberHelper.ConvertToInt64(diplocation.Number),
|
||||
@@ -630,10 +630,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (locations.Any())
|
||||
item.Locations = locations;
|
||||
|
||||
var settings = new List<Setting>();
|
||||
var settings = new List<DipValue>();
|
||||
foreach (var dipvalue in dipswitch.DipValue ?? Array.Empty<Models.Listxml.DipValue>())
|
||||
{
|
||||
var settingItem = new Setting
|
||||
var dipValueItem = new DipValue
|
||||
{
|
||||
Name = dipvalue.Name,
|
||||
Value = dipvalue.Value,
|
||||
@@ -649,10 +649,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
Relation = dipvalue.Condition.Relation.AsRelation(),
|
||||
Value = dipvalue.Condition.Value,
|
||||
};
|
||||
settingItem.Conditions = new List<Condition> { condition };
|
||||
dipValueItem.Conditions = new List<Condition> { condition };
|
||||
}
|
||||
|
||||
settings.Add(settingItem);
|
||||
settings.Add(dipValueItem);
|
||||
}
|
||||
|
||||
if (settings.Any())
|
||||
@@ -696,20 +696,20 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
if (configuration.Condition != null)
|
||||
{
|
||||
var condition = new Condition
|
||||
var condition = new DatItems.Formats.Condition
|
||||
{
|
||||
Tag = configuration.Condition.Tag,
|
||||
Mask = configuration.Condition.Mask,
|
||||
Relation = configuration.Condition.Relation.AsRelation(),
|
||||
Value = configuration.Condition.Value,
|
||||
};
|
||||
item.Conditions = new List<Condition> { condition };
|
||||
item.Conditions = new List<DatItems.Formats.Condition> { condition };
|
||||
}
|
||||
|
||||
var locations = new List<Location>();
|
||||
var locations = new List<ConfLocation>();
|
||||
foreach (var confLocation in configuration.ConfLocation ?? Array.Empty<Models.Listxml.ConfLocation>())
|
||||
{
|
||||
var locationItem = new Location
|
||||
var locationItem = new ConfLocation
|
||||
{
|
||||
Name = confLocation.Name,
|
||||
Number = NumberHelper.ConvertToInt64(confLocation.Number),
|
||||
@@ -721,10 +721,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (locations.Any())
|
||||
item.Locations = locations;
|
||||
|
||||
var settings = new List<Setting>();
|
||||
var settings = new List<ConfSetting>();
|
||||
foreach (var dipvalue in configuration.ConfSetting ?? Array.Empty<Models.Listxml.ConfSetting>())
|
||||
{
|
||||
var settingItem = new Setting
|
||||
var settingItem = new ConfSetting
|
||||
{
|
||||
Name = dipvalue.Name,
|
||||
Value = dipvalue.Value,
|
||||
@@ -1094,6 +1094,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Name = ramoption.Name,
|
||||
Default = ramoption.Default.AsYesNo(),
|
||||
Content = ramoption.Content,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Get the first item for game information
|
||||
var machine = items[0].Machine;
|
||||
var game = CreateGame(machine);
|
||||
var game = CreateGame(machine!);
|
||||
|
||||
// Create holders for all item types
|
||||
var biosSets = new List<Models.Listxml.BiosSet>();
|
||||
@@ -604,19 +604,19 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
if (item.ConditionsSpecified)
|
||||
{
|
||||
var conditionItem = item.Conditions[0];
|
||||
var conditionItem = item.Conditions?.FirstOrDefault();
|
||||
var condition = new Models.Listxml.Condition
|
||||
{
|
||||
Tag = conditionItem.Tag,
|
||||
Mask = conditionItem.Mask,
|
||||
Relation = conditionItem.Relation.FromRelation(),
|
||||
Value = conditionItem.Value,
|
||||
Tag = conditionItem?.Tag,
|
||||
Mask = conditionItem?.Mask,
|
||||
Relation = conditionItem?.Relation.FromRelation(),
|
||||
Value = conditionItem?.Value,
|
||||
};
|
||||
dipswitch.Condition = condition;
|
||||
}
|
||||
|
||||
var diplocations = new List<Models.Listxml.DipLocation>();
|
||||
foreach (var locationItem in item.Locations ?? new List<Location>())
|
||||
foreach (var locationItem in item.Locations ?? new List<DipLocation>())
|
||||
{
|
||||
var control = CreateDipLocation(locationItem);
|
||||
diplocations.Add(control);
|
||||
@@ -626,9 +626,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
dipswitch.DipLocation = diplocations.ToArray();
|
||||
|
||||
var dipvalues = new List<Models.Listxml.DipValue>();
|
||||
foreach (var settingItem in item.Values ?? new List<Setting>())
|
||||
foreach (var dipValueItem in item.Values ?? new List<DipValue>())
|
||||
{
|
||||
var dipvalue = CreateDipValue(settingItem);
|
||||
var dipvalue = CreateDipValue(dipValueItem);
|
||||
dipvalues.Add(dipvalue);
|
||||
}
|
||||
|
||||
@@ -639,9 +639,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a DipLocation from the current Location DatItem
|
||||
/// Create a DipLocation from the current DipLocation DatItem
|
||||
/// <summary>
|
||||
private static Models.Listxml.DipLocation CreateDipLocation(Location item)
|
||||
private static Models.Listxml.DipLocation CreateDipLocation(DipLocation item)
|
||||
{
|
||||
var diplocation = new Models.Listxml.DipLocation
|
||||
{
|
||||
@@ -654,9 +654,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a DipValue from the current Setting DatItem
|
||||
/// Create a DipValue from the current DipValue DatItem
|
||||
/// <summary>
|
||||
private static Models.Listxml.DipValue CreateDipValue(Setting item)
|
||||
private static Models.Listxml.DipValue CreateDipValue(DipValue item)
|
||||
{
|
||||
var dipvalue = new Models.Listxml.DipValue
|
||||
{
|
||||
@@ -667,13 +667,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
if (item.ConditionsSpecified)
|
||||
{
|
||||
var conditionItem = item.Conditions[0];
|
||||
var conditionItem = item.Conditions?.FirstOrDefault();
|
||||
var condition = new Models.Listxml.Condition
|
||||
{
|
||||
Tag = conditionItem.Tag,
|
||||
Mask = conditionItem.Mask,
|
||||
Relation = conditionItem.Relation.FromRelation(),
|
||||
Value = conditionItem.Value,
|
||||
Tag = conditionItem?.Tag,
|
||||
Mask = conditionItem?.Mask,
|
||||
Relation = conditionItem?.Relation.FromRelation(),
|
||||
Value = conditionItem?.Value,
|
||||
};
|
||||
dipvalue.Condition = condition;
|
||||
}
|
||||
@@ -695,19 +695,19 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
if (item.ConditionsSpecified)
|
||||
{
|
||||
var conditionItem = item.Conditions[0];
|
||||
var conditionItem = item.Conditions?.FirstOrDefault();
|
||||
var condition = new Models.Listxml.Condition
|
||||
{
|
||||
Tag = conditionItem.Tag,
|
||||
Mask = conditionItem.Mask,
|
||||
Relation = conditionItem.Relation.FromRelation(),
|
||||
Value = conditionItem.Value,
|
||||
Tag = conditionItem?.Tag,
|
||||
Mask = conditionItem?.Mask,
|
||||
Relation = conditionItem?.Relation.FromRelation(),
|
||||
Value = conditionItem?.Value,
|
||||
};
|
||||
configuration.Condition = condition;
|
||||
}
|
||||
|
||||
var confLocations = new List<Models.Listxml.ConfLocation>();
|
||||
foreach (var location in item.Locations ?? new List<Location>())
|
||||
foreach (var location in item.Locations ?? new List<ConfLocation>())
|
||||
{
|
||||
var control = CreateConfLocation(location);
|
||||
confLocations.Add(control);
|
||||
@@ -717,9 +717,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
configuration.ConfLocation = confLocations.ToArray();
|
||||
|
||||
var confsettings = new List<Models.Listxml.ConfSetting>();
|
||||
foreach (var settingItem in item.Settings ?? new List<Setting>())
|
||||
foreach (var confSettingItem in item.Settings ?? new List<ConfSetting>())
|
||||
{
|
||||
var dipvalue = CreateConfSetting(settingItem);
|
||||
var dipvalue = CreateConfSetting(confSettingItem);
|
||||
confsettings.Add(dipvalue);
|
||||
}
|
||||
|
||||
@@ -730,9 +730,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a ConfLocation from the current Location DatItem
|
||||
/// Create a ConfLocation from the current ConfLocation DatItem
|
||||
/// <summary>
|
||||
private static Models.Listxml.ConfLocation CreateConfLocation(Location item)
|
||||
private static Models.Listxml.ConfLocation CreateConfLocation(ConfLocation item)
|
||||
{
|
||||
var conflocation = new Models.Listxml.ConfLocation
|
||||
{
|
||||
@@ -745,9 +745,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a ConfSetting from the current Setting DatItem
|
||||
/// Create a ConfSetting from the current ConfSetting DatItem
|
||||
/// <summary>
|
||||
private static Models.Listxml.ConfSetting CreateConfSetting(Setting item)
|
||||
private static Models.Listxml.ConfSetting CreateConfSetting(ConfSetting item)
|
||||
{
|
||||
var confsetting = new Models.Listxml.ConfSetting
|
||||
{
|
||||
@@ -758,13 +758,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
if (item.ConditionsSpecified)
|
||||
{
|
||||
var conditionItem = item.Conditions[0];
|
||||
var conditionItem = item.Conditions?.FirstOrDefault();
|
||||
var condition = new Models.Listxml.Condition
|
||||
{
|
||||
Tag = conditionItem.Tag,
|
||||
Mask = conditionItem.Mask,
|
||||
Relation = conditionItem.Relation.FromRelation(),
|
||||
Value = conditionItem.Value,
|
||||
Tag = conditionItem?.Tag,
|
||||
Mask = conditionItem?.Mask,
|
||||
Relation = conditionItem?.Relation.FromRelation(),
|
||||
Value = conditionItem?.Value,
|
||||
};
|
||||
confsetting.Condition = condition;
|
||||
}
|
||||
@@ -798,13 +798,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
if (item.ConditionsSpecified)
|
||||
{
|
||||
var conditionItem = item.Conditions[0];
|
||||
var conditionItem = item.Conditions?.FirstOrDefault();
|
||||
var condition = new Models.Listxml.Condition
|
||||
{
|
||||
Tag = conditionItem.Tag,
|
||||
Mask = conditionItem.Mask,
|
||||
Relation = conditionItem.Relation.FromRelation(),
|
||||
Value = conditionItem.Value,
|
||||
Tag = conditionItem?.Tag,
|
||||
Mask = conditionItem?.Mask,
|
||||
Relation = conditionItem?.Relation.FromRelation(),
|
||||
Value = conditionItem?.Value,
|
||||
};
|
||||
adjuster.Condition = condition;
|
||||
}
|
||||
@@ -866,11 +866,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
if (item.InstancesSpecified)
|
||||
{
|
||||
var instanceItem = item.Instances[0];
|
||||
var instanceItem = item.Instances?.FirstOrDefault();
|
||||
var instance = new Models.Listxml.Instance
|
||||
{
|
||||
Name = instanceItem.Name,
|
||||
BriefName = instanceItem.BriefName,
|
||||
Name = instanceItem?.Name,
|
||||
BriefName = instanceItem?.BriefName,
|
||||
};
|
||||
device.Instance = instance;
|
||||
}
|
||||
@@ -944,6 +944,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Name = item.Name,
|
||||
Default = item.Default.FromYesNo(),
|
||||
Content = item.Content,
|
||||
};
|
||||
|
||||
return softwarelist;
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Get the first item for game information
|
||||
var machine = items[0].Machine;
|
||||
var game = CreateGame(machine);
|
||||
var game = CreateGame(machine!);
|
||||
|
||||
// Create holders for all item types
|
||||
var releases = new List<Models.Logiqx.Release>();
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItem(sw, datItem, lastgame);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = datItem.Machine.Name;
|
||||
lastgame = datItem.Machine?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Romba mode automatically uses item name
|
||||
if (Header.OutputDepot?.IsActive == true || Header.UseRomName)
|
||||
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
|
||||
else if (!Header.UseRomName && datItem.Machine.Name != lastgame)
|
||||
sw.Write($"{datItem.Machine.Name}\n");
|
||||
else if (!Header.UseRomName && datItem.Machine?.Name != lastgame)
|
||||
sw.Write($"{datItem.Machine?.Name ?? string.Empty}\n");
|
||||
|
||||
sw.Flush();
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Get the first item for game information
|
||||
var machine = items[0].Machine;
|
||||
var game = CreateGame(machine);
|
||||
var game = CreateGame(machine!);
|
||||
|
||||
// Create holders for all item types
|
||||
var romCRCs = new List<Models.OfflineList.FileRomCRC>();
|
||||
|
||||
@@ -105,12 +105,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
var machine = items[0].Machine;
|
||||
var software = new Models.OpenMSX.Software
|
||||
{
|
||||
Title = machine.Name,
|
||||
GenMSXID = machine.GenMSXID,
|
||||
System = machine.System,
|
||||
Company = machine.Manufacturer,
|
||||
Year = machine.Year,
|
||||
Country = machine.Country,
|
||||
Title = machine?.Name,
|
||||
GenMSXID = machine?.GenMSXID,
|
||||
System = machine?.System,
|
||||
Company = machine?.Manufacturer,
|
||||
Year = machine?.Year,
|
||||
Country = machine?.Country,
|
||||
};
|
||||
|
||||
// Create holder for dumps
|
||||
|
||||
@@ -183,14 +183,14 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var rom = new Models.RomCenter.Rom
|
||||
{
|
||||
ParentName = item.Machine.CloneOf,
|
||||
//ParentDescription = item.Machine.CloneOfDescription, // TODO: Add to internal model or find mapping
|
||||
GameName = item.Machine.Name,
|
||||
GameDescription = item.Machine.Description,
|
||||
ParentName = item.Machine?.CloneOf,
|
||||
//ParentDescription = item.Machine?.CloneOfDescription, // TODO: Add to internal model or find mapping
|
||||
GameName = item.Machine?.Name,
|
||||
GameDescription = item.Machine?.Description,
|
||||
RomName = item.Name,
|
||||
RomCRC = item.CRC,
|
||||
RomSize = item.Size?.ToString(),
|
||||
RomOf = item.Machine.RomOf,
|
||||
RomOf = item.Machine?.RomOf,
|
||||
MergeName = item.MergeTag,
|
||||
};
|
||||
return rom;
|
||||
|
||||
@@ -235,6 +235,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
case ItemType.Configuration:
|
||||
datItem = datItemObj.ToObject<Configuration>();
|
||||
break;
|
||||
case ItemType.ConfLocation:
|
||||
datItem = datItemObj.ToObject<ConfLocation>();
|
||||
break;
|
||||
case ItemType.ConfSetting:
|
||||
datItem = datItemObj.ToObject<ConfSetting>();
|
||||
break;
|
||||
case ItemType.Control:
|
||||
datItem = datItemObj.ToObject<Control>();
|
||||
break;
|
||||
@@ -247,6 +253,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
case ItemType.DeviceReference:
|
||||
datItem = datItemObj.ToObject<DeviceReference>();
|
||||
break;
|
||||
case ItemType.DipLocation:
|
||||
datItem = datItemObj.ToObject<DipLocation>();
|
||||
break;
|
||||
case ItemType.DipValue:
|
||||
datItem = datItemObj.ToObject<DipValue>();
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
datItem = datItemObj.ToObject<DipSwitch>();
|
||||
break;
|
||||
@@ -277,9 +289,6 @@ namespace SabreTools.DatFiles.Formats
|
||||
case ItemType.Instance:
|
||||
datItem = datItemObj.ToObject<Instance>();
|
||||
break;
|
||||
case ItemType.Location:
|
||||
datItem = datItemObj.ToObject<Location>();
|
||||
break;
|
||||
case ItemType.Media:
|
||||
datItem = datItemObj.ToObject<Media>();
|
||||
break;
|
||||
@@ -310,9 +319,6 @@ namespace SabreTools.DatFiles.Formats
|
||||
case ItemType.Serials:
|
||||
datItem = datItemObj.ToObject<Serials>();
|
||||
break;
|
||||
case ItemType.Setting:
|
||||
datItem = datItemObj.ToObject<Setting>();
|
||||
break;
|
||||
case ItemType.SharedFeature:
|
||||
datItem = datItemObj.ToObject<SharedFeature>();
|
||||
break;
|
||||
@@ -389,11 +395,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 && lastgame.ToLowerInvariant() != datItem.Machine.Name.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
|
||||
WriteEndGame(jtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
|
||||
WriteStartGame(jtw, datItem);
|
||||
|
||||
// Check for a "null" item
|
||||
@@ -404,7 +410,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItem(jtw, datItem);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = datItem.Machine.Name;
|
||||
lastgame = datItem.Machine?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,7 +457,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
private void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine?.Name))
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
|
||||
|
||||
// Build the state
|
||||
jtw.WriteStartObject();
|
||||
|
||||
@@ -223,11 +223,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 && lastgame.ToLowerInvariant() != datItem.Machine.Name.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
|
||||
WriteEndGame(xtw);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
|
||||
WriteStartGame(xtw, datItem);
|
||||
|
||||
// Check for a "null" item
|
||||
@@ -238,7 +238,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteDatItem(xtw, datItem);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = datItem.Machine.Name;
|
||||
lastgame = datItem.Machine?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private void WriteStartGame(XmlTextWriter xtw, DatItem datItem)
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.Machine.Name = datItem.Machine.Name?.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
|
||||
datItem.Machine!.Name = datItem.Machine.Name?.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
|
||||
|
||||
// Write the machine
|
||||
xtw.WriteStartElement("directory");
|
||||
|
||||
@@ -162,8 +162,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
FileName = Header.FileName,
|
||||
InternalName = Header.Name,
|
||||
Description = Header.Description,
|
||||
GameName = disk.Machine.Name,
|
||||
GameDescription = disk.Machine.Description,
|
||||
GameName = disk.Machine?.Name,
|
||||
GameDescription = disk.Machine?.Description,
|
||||
Type = disk.ItemType.FromItemType(),
|
||||
RomName = string.Empty,
|
||||
DiskName = disk.Name,
|
||||
@@ -190,8 +190,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
FileName = Header.FileName,
|
||||
InternalName = Header.Name,
|
||||
Description = Header.Description,
|
||||
GameName = media.Machine.Name,
|
||||
GameDescription = media.Machine.Description,
|
||||
GameName = media.Machine?.Name,
|
||||
GameDescription = media.Machine?.Description,
|
||||
Type = media.ItemType.FromItemType(),
|
||||
RomName = string.Empty,
|
||||
DiskName = media.Name,
|
||||
@@ -218,8 +218,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
FileName = Header.FileName,
|
||||
InternalName = Header.Name,
|
||||
Description = Header.Description,
|
||||
GameName = rom.Machine.Name,
|
||||
GameDescription = rom.Machine.Description,
|
||||
GameName = rom.Machine?.Name,
|
||||
GameDescription = rom.Machine?.Description,
|
||||
Type = rom.ItemType.FromItemType(),
|
||||
RomName = rom.Name,
|
||||
DiskName = string.Empty,
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Name = dipswitch.Name,
|
||||
Tag = dipswitch.Tag,
|
||||
Mask = dipswitch.Mask,
|
||||
Values = CreateSettings(dipswitch.DipValue, machine, filename, indexId),
|
||||
Values = CreateDipValues(dipswitch.DipValue, machine, filename, indexId),
|
||||
|
||||
Part = part,
|
||||
|
||||
@@ -441,16 +441,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="machine">Prefilled machine to use</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
private static List<Setting>? CreateSettings(Models.SoftwareList.DipValue[]? dipvalues, Machine machine, string filename, int indexId)
|
||||
private static List<DipValue>? CreateDipValues(Models.SoftwareList.DipValue[]? dipvalues, Machine machine, string filename, int indexId)
|
||||
{
|
||||
// If the feature array is missing, we can't do anything
|
||||
if (dipvalues == null || !dipvalues.Any())
|
||||
return null;
|
||||
|
||||
var settings = new List<Setting>();
|
||||
var settings = new List<DipValue>();
|
||||
foreach (var dipvalue in dipvalues)
|
||||
{
|
||||
var item = new Setting
|
||||
var item = new DipValue
|
||||
{
|
||||
Name = dipvalue.Name,
|
||||
Value = dipvalue.Value,
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Part.Name))
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Part!.Name))
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Part.Interface))
|
||||
missingFields.Add(DatItemField.Part_Interface);
|
||||
@@ -54,9 +54,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
missingFields.Add(DatItemField.Mask);
|
||||
if (dipSwitch.ValuesSpecified)
|
||||
{
|
||||
if (dipSwitch.Values.Any(dv => string.IsNullOrWhiteSpace(dv.Name)))
|
||||
if (dipSwitch.Values!.Any(dv => string.IsNullOrWhiteSpace(dv.Name)))
|
||||
missingFields.Add(DatItemField.Part_Feature_Name);
|
||||
if (dipSwitch.Values.Any(dv => string.IsNullOrWhiteSpace(dv.Value)))
|
||||
if (dipSwitch.Values!.Any(dv => string.IsNullOrWhiteSpace(dv.Value)))
|
||||
missingFields.Add(DatItemField.Part_Feature_Value);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(disk.Part.Name))
|
||||
if (string.IsNullOrWhiteSpace(disk.Part!.Name))
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
if (string.IsNullOrWhiteSpace(disk.Part.Interface))
|
||||
missingFields.Add(DatItemField.Part_Interface);
|
||||
@@ -81,7 +81,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(disk.DiskArea.Name))
|
||||
if (string.IsNullOrWhiteSpace(disk.DiskArea!.Name))
|
||||
missingFields.Add(DatItemField.AreaName);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(disk.Name))
|
||||
@@ -101,7 +101,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(rom.Part.Name))
|
||||
if (string.IsNullOrWhiteSpace(rom.Part!.Name))
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
if (string.IsNullOrWhiteSpace(rom.Part.Interface))
|
||||
missingFields.Add(DatItemField.Part_Interface);
|
||||
@@ -113,7 +113,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(rom.DataArea.Name))
|
||||
if (string.IsNullOrWhiteSpace(rom.DataArea!.Name))
|
||||
missingFields.Add(DatItemField.AreaName);
|
||||
if (!rom.DataArea.SizeSpecified)
|
||||
missingFields.Add(DatItemField.AreaSize);
|
||||
@@ -197,7 +197,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Get the first item for game information
|
||||
var machine = items[0].Machine;
|
||||
var sw = CreateSoftware(machine);
|
||||
var sw = CreateSoftware(machine!);
|
||||
|
||||
// Create holders for all item types
|
||||
var infos = new List<Models.SoftwareList.Info>();
|
||||
@@ -304,9 +304,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var part = new Models.SoftwareList.Part
|
||||
{
|
||||
Name = item.Part.Name,
|
||||
Interface = item.Part.Interface,
|
||||
Feature = CreateFeatures(item.Part.Features),
|
||||
Name = item.Part?.Name,
|
||||
Interface = item.Part?.Interface,
|
||||
Feature = CreateFeatures(item.Part?.Features),
|
||||
DataArea = CreateDataAreas(item),
|
||||
DiskArea = null,
|
||||
DipSwitch = null,
|
||||
@@ -321,9 +321,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var part = new Models.SoftwareList.Part
|
||||
{
|
||||
Name = item.Part.Name,
|
||||
Interface = item.Part.Interface,
|
||||
Feature = CreateFeatures(item.Part.Features),
|
||||
Name = item.Part?.Name,
|
||||
Interface = item.Part?.Interface,
|
||||
Feature = CreateFeatures(item.Part?.Features),
|
||||
DataArea = null,
|
||||
DiskArea = CreateDiskAreas(item),
|
||||
DipSwitch = null,
|
||||
@@ -338,9 +338,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var part = new Models.SoftwareList.Part
|
||||
{
|
||||
Name = item.Part.Name,
|
||||
Interface = item.Part.Interface,
|
||||
Feature = CreateFeatures(item.Part.Features),
|
||||
Name = item.Part?.Name,
|
||||
Interface = item.Part?.Interface,
|
||||
Feature = CreateFeatures(item.Part?.Features),
|
||||
DataArea = null,
|
||||
DiskArea = null,
|
||||
DipSwitch = CreateDipSwitches(item),
|
||||
@@ -351,7 +351,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <summary>
|
||||
/// Create a Feature array from the current list of PartFeature DatItems
|
||||
/// <summary>
|
||||
private static Models.SoftwareList.Feature[]? CreateFeatures(List<PartFeature> items)
|
||||
private static Models.SoftwareList.Feature[]? CreateFeatures(List<PartFeature>? items)
|
||||
{
|
||||
// If we don't have features, we can't do anything
|
||||
if (items == null || !items.Any())
|
||||
@@ -378,10 +378,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var dataArea = new Models.SoftwareList.DataArea
|
||||
{
|
||||
Name = item.DataArea.Name,
|
||||
Size = item.DataArea.Size?.ToString(),
|
||||
Width = item.DataArea.Width?.ToString(),
|
||||
Endianness = item.DataArea.Endianness.FromEndianness(),
|
||||
Name = item.DataArea?.Name,
|
||||
Size = item.DataArea?.Size?.ToString(),
|
||||
Width = item.DataArea?.Width?.ToString(),
|
||||
Endianness = item.DataArea?.Endianness.FromEndianness(),
|
||||
Rom = CreateRom(item),
|
||||
};
|
||||
return new Models.SoftwareList.DataArea[] { dataArea };
|
||||
@@ -441,7 +441,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static Models.SoftwareList.DipSwitch[]? CreateDipSwitches(DipSwitch item)
|
||||
{
|
||||
var dipValues = new List<Models.SoftwareList.DipValue>();
|
||||
foreach (var setting in item.Values ?? new List<Setting>())
|
||||
foreach (var setting in item.Values ?? new List<DipValue>())
|
||||
{
|
||||
var dipValue = new Models.SoftwareList.DipValue
|
||||
{
|
||||
|
||||
@@ -231,10 +231,14 @@ namespace SabreTools.DatFiles
|
||||
case Chip chip: SetFields(chip); break;
|
||||
case Condition condition: SetFields(condition); break;
|
||||
case Configuration condition: SetFields(condition); break;
|
||||
case ConfLocation confLocation: SetFields(confLocation); break;
|
||||
case ConfSetting confSetting: SetFields(confSetting); break;
|
||||
case Control control: SetFields(control); break;
|
||||
case DataArea dataArea: SetFields(dataArea); break;
|
||||
case Device device: SetFields(device); break;
|
||||
case DipLocation dipLocation: SetFields(dipLocation); break;
|
||||
case DipSwitch dipSwitch: SetFields(dipSwitch); break;
|
||||
case DipValue dipValue: SetFields(dipValue); break;
|
||||
case Disk disk: SetFields(disk); break;
|
||||
case DiskArea diskArea: SetFields(diskArea); break;
|
||||
case Display display: SetFields(display); break;
|
||||
@@ -243,7 +247,6 @@ namespace SabreTools.DatFiles
|
||||
case Feature feature: SetFields(feature); break;
|
||||
case Input input: SetFields(input); break;
|
||||
case Instance instance: SetFields(instance); break;
|
||||
case Location location: SetFields(location); break;
|
||||
case Media media: SetFields(media); break;
|
||||
case Part part: SetFields(part); break;
|
||||
case PartFeature partFeature: SetFields(partFeature); break;
|
||||
@@ -251,7 +254,6 @@ namespace SabreTools.DatFiles
|
||||
case RamOption ramOption: SetFields(ramOption); break;
|
||||
case Release release: SetFields(release); break;
|
||||
case Rom rom: SetFields(rom); break;
|
||||
case Setting setting: SetFields(setting); break;
|
||||
case SharedFeature sharedFeat: SetFields(sharedFeat); break;
|
||||
case Slot slot: SetFields(slot); break;
|
||||
case SlotOption slotOption: SetFields(slotOption); break;
|
||||
@@ -398,7 +400,7 @@ namespace SabreTools.DatFiles
|
||||
// Field.DatItem_Conditions does not apply here
|
||||
if (adjuster.ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition subCondition in adjuster.Conditions)
|
||||
foreach (Condition subCondition in adjuster.Conditions!)
|
||||
{
|
||||
SetFields(subCondition, true);
|
||||
}
|
||||
@@ -529,7 +531,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (configuration.ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition subCondition in configuration.Conditions)
|
||||
foreach (Condition subCondition in configuration.Conditions!)
|
||||
{
|
||||
SetFields(subCondition, true);
|
||||
}
|
||||
@@ -537,7 +539,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (configuration.LocationsSpecified)
|
||||
{
|
||||
foreach (Location subLocation in configuration.Locations)
|
||||
foreach (ConfLocation subLocation in configuration.Locations!)
|
||||
{
|
||||
SetFields(subLocation);
|
||||
}
|
||||
@@ -545,13 +547,53 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (configuration.SettingsSpecified)
|
||||
{
|
||||
foreach (Setting subSetting in configuration.Settings)
|
||||
foreach (ConfSetting subSetting in configuration.Settings!)
|
||||
{
|
||||
SetFields(subSetting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="confLocation">ConfLocation to remove replace fields in</param>
|
||||
private void SetFields(ConfLocation confLocation)
|
||||
{
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Inverted))
|
||||
confLocation.Inverted = DatItemMappings[DatItemField.Location_Inverted].AsYesNo();
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Name))
|
||||
confLocation.Name = DatItemMappings[DatItemField.Location_Name];
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Number))
|
||||
confLocation.Number = NumberHelper.ConvertToInt64(DatItemMappings[DatItemField.Location_Number]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="confSetting">ConfSetting to remove replace fields in</param>
|
||||
private void SetFields(ConfSetting confSetting)
|
||||
{
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Default))
|
||||
confSetting.Default = DatItemMappings[DatItemField.Setting_Default].AsYesNo();
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Name))
|
||||
confSetting.Name = DatItemMappings[DatItemField.Setting_Name];
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Value))
|
||||
confSetting.Value = DatItemMappings[DatItemField.Setting_Value];
|
||||
|
||||
if (confSetting.ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition subCondition in confSetting.Conditions!)
|
||||
{
|
||||
SetFields(subCondition, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
@@ -637,7 +679,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (device.ExtensionsSpecified)
|
||||
{
|
||||
foreach (Extension subExtension in device.Extensions)
|
||||
foreach (Extension subExtension in device.Extensions!)
|
||||
{
|
||||
SetFields(subExtension);
|
||||
}
|
||||
@@ -645,13 +687,29 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (device.InstancesSpecified)
|
||||
{
|
||||
foreach (Instance subInstance in device.Instances)
|
||||
foreach (Instance subInstance in device.Instances!)
|
||||
{
|
||||
SetFields(subInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="dipLocation">DipLocation to remove replace fields in</param>
|
||||
private void SetFields(DipLocation dipLocation)
|
||||
{
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Inverted))
|
||||
dipLocation.Inverted = DatItemMappings[DatItemField.Location_Inverted].AsYesNo();
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Name))
|
||||
dipLocation.Name = DatItemMappings[DatItemField.Location_Name];
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Number))
|
||||
dipLocation.Number = NumberHelper.ConvertToInt64(DatItemMappings[DatItemField.Location_Number]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
@@ -666,7 +724,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (dipSwitch.ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition subCondition in dipSwitch.Conditions)
|
||||
foreach (Condition subCondition in dipSwitch.Conditions!)
|
||||
{
|
||||
SetFields(subCondition, true);
|
||||
}
|
||||
@@ -674,7 +732,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (dipSwitch.LocationsSpecified)
|
||||
{
|
||||
foreach (Location subLocation in dipSwitch.Locations)
|
||||
foreach (DipLocation subLocation in dipSwitch.Locations!)
|
||||
{
|
||||
SetFields(subLocation);
|
||||
}
|
||||
@@ -682,7 +740,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (dipSwitch.ValuesSpecified)
|
||||
{
|
||||
foreach (Setting subValue in dipSwitch.Values)
|
||||
foreach (DipValue subValue in dipSwitch.Values!)
|
||||
{
|
||||
SetFields(subValue);
|
||||
}
|
||||
@@ -692,6 +750,30 @@ namespace SabreTools.DatFiles
|
||||
SetFields(dipSwitch.Part);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="dipValue">DipValue to remove replace fields in</param>
|
||||
private void SetFields(DipValue dipValue)
|
||||
{
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Default))
|
||||
dipValue.Default = DatItemMappings[DatItemField.Setting_Default].AsYesNo();
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Name))
|
||||
dipValue.Name = DatItemMappings[DatItemField.Setting_Name];
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Value))
|
||||
dipValue.Value = DatItemMappings[DatItemField.Setting_Value];
|
||||
|
||||
if (dipValue.ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition subCondition in dipValue.Conditions!)
|
||||
{
|
||||
SetFields(subCondition, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
@@ -875,7 +957,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (input.ControlsSpecified)
|
||||
{
|
||||
foreach (Control subControl in input.Controls)
|
||||
foreach (Control subControl in input.Controls!)
|
||||
{
|
||||
SetFields(subControl);
|
||||
}
|
||||
@@ -895,22 +977,6 @@ namespace SabreTools.DatFiles
|
||||
instance.BriefName = DatItemMappings[DatItemField.Instance_Name];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="location">Location to remove replace fields in</param>
|
||||
private void SetFields(Location location)
|
||||
{
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Inverted))
|
||||
location.Inverted = DatItemMappings[DatItemField.Location_Inverted].AsYesNo();
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Name))
|
||||
location.Name = DatItemMappings[DatItemField.Location_Name];
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Number))
|
||||
location.Number = NumberHelper.ConvertToInt64(DatItemMappings[DatItemField.Location_Number]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
@@ -944,7 +1010,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (part.FeaturesSpecified)
|
||||
{
|
||||
foreach (PartFeature subPartFeature in part.Features)
|
||||
foreach (PartFeature subPartFeature in part.Features!)
|
||||
{
|
||||
SetFields(subPartFeature);
|
||||
}
|
||||
@@ -975,7 +1041,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
if (port.AnalogsSpecified)
|
||||
{
|
||||
foreach (Analog subAnalog in port.Analogs)
|
||||
foreach (Analog subAnalog in port.Analogs!)
|
||||
{
|
||||
SetFields(subAnalog);
|
||||
}
|
||||
@@ -1120,30 +1186,6 @@ namespace SabreTools.DatFiles
|
||||
SetFields(rom.Part);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="setting">Setting to remove replace fields in</param>
|
||||
private void SetFields(Setting setting)
|
||||
{
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Default))
|
||||
setting.Default = DatItemMappings[DatItemField.Setting_Default].AsYesNo();
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Name))
|
||||
setting.Name = DatItemMappings[DatItemField.Setting_Name];
|
||||
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Value))
|
||||
setting.Value = DatItemMappings[DatItemField.Setting_Value];
|
||||
|
||||
if (setting.ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition subCondition in setting.Conditions)
|
||||
{
|
||||
SetFields(subCondition, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
@@ -1162,7 +1204,7 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
if (slot.SlotOptionsSpecified)
|
||||
{
|
||||
foreach (SlotOption subSlotOption in slot.SlotOptions)
|
||||
foreach (SlotOption subSlotOption in slot.SlotOptions!)
|
||||
{
|
||||
SetFields(subSlotOption);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user