Promote Slot to DatItem

This commit is contained in:
Matt Nadareski
2020-09-01 16:21:55 -07:00
parent 7d3f3f1803
commit 9604e16287
24 changed files with 860 additions and 743 deletions

View File

@@ -26,7 +26,7 @@ Unpacked files will be stored as individual entries. Prior to unpacking a zip
file, the external SHA1 is checked against the DAT index. file, the external SHA1 is checked against the DAT index.
If -only-needed is set, only those files are put in the ROM archive that If -only-needed is set, only those files are put in the ROM archive that
have a current entry in the DAT index."; have a current entry in the DAT index.";
Features = new Dictionary<string, Feature>(); Features = new Dictionary<string, SabreTools.Library.Help.Feature>();
AddFeature(OnlyNeededFlag); AddFeature(OnlyNeededFlag);
AddFeature(ResumeStringInput); AddFeature(ResumeStringInput);
@@ -39,7 +39,7 @@ have a current entry in the DAT index.";
AddFeature(NoDbFlag); AddFeature(NoDbFlag);
} }
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, SabreTools.Library.Help.Feature> features)
{ {
base.ProcessFeatures(features); base.ProcessFeatures(features);

View File

@@ -19,11 +19,11 @@ namespace RombaSharp.Features
#region Private Flag features #region Private Flag features
internal const string CopyValue = "copy"; internal const string CopyValue = "copy";
internal static Feature CopyFlag internal static SabreTools.Library.Help.Feature CopyFlag
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
CopyValue, CopyValue,
"-copy", "-copy",
"Copy files to output instead of rebuilding", "Copy files to output instead of rebuilding",
@@ -32,11 +32,11 @@ namespace RombaSharp.Features
} // Unique to RombaSharp } // Unique to RombaSharp
internal const string FixdatOnlyValue = "fixdat-only"; internal const string FixdatOnlyValue = "fixdat-only";
internal static Feature FixdatOnlyFlag internal static SabreTools.Library.Help.Feature FixdatOnlyFlag
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
FixdatOnlyValue, FixdatOnlyValue,
"-fixdatOnly", "-fixdatOnly",
"only fix dats and don't generate torrentzips", "only fix dats and don't generate torrentzips",
@@ -45,11 +45,11 @@ namespace RombaSharp.Features
} }
internal const string LogOnlyValue = "log-only"; internal const string LogOnlyValue = "log-only";
internal static Feature LogOnlyFlag internal static SabreTools.Library.Help.Feature LogOnlyFlag
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
LogOnlyValue, LogOnlyValue,
"-log-only", "-log-only",
"Only write out actions to log", "Only write out actions to log",
@@ -58,11 +58,11 @@ namespace RombaSharp.Features
} }
internal const string NoDbValue = "no-db"; internal const string NoDbValue = "no-db";
internal static Feature NoDbFlag internal static SabreTools.Library.Help.Feature NoDbFlag
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
NoDbValue, NoDbValue,
"-no-db", "-no-db",
"archive into depot but do not touch DB index and ignore only-needed flag", "archive into depot but do not touch DB index and ignore only-needed flag",
@@ -71,11 +71,11 @@ namespace RombaSharp.Features
} }
internal const string OnlyNeededValue = "only-needed"; internal const string OnlyNeededValue = "only-needed";
internal static Feature OnlyNeededFlag internal static SabreTools.Library.Help.Feature OnlyNeededFlag
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
OnlyNeededValue, OnlyNeededValue,
"-only-needed", "-only-needed",
"only archive ROM files actually referenced by DAT files from the DAT index", "only archive ROM files actually referenced by DAT files from the DAT index",
@@ -84,11 +84,11 @@ namespace RombaSharp.Features
} }
internal const string SkipInitialScanValue = "skip-initial-scan"; internal const string SkipInitialScanValue = "skip-initial-scan";
internal static Feature SkipInitialScanFlag internal static SabreTools.Library.Help.Feature SkipInitialScanFlag
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
SkipInitialScanValue, SkipInitialScanValue,
"-skip-initial-scan", "-skip-initial-scan",
"skip the initial scan of the files to determine amount of work", "skip the initial scan of the files to determine amount of work",
@@ -97,11 +97,11 @@ namespace RombaSharp.Features
} }
internal const string UseGolangZipValue = "use-golang-zip"; internal const string UseGolangZipValue = "use-golang-zip";
internal static Feature UseGolangZipFlag internal static SabreTools.Library.Help.Feature UseGolangZipFlag
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
UseGolangZipValue, UseGolangZipValue,
"-use-golang-zip", "-use-golang-zip",
"use go zip implementation instead of zlib", "use go zip implementation instead of zlib",
@@ -114,11 +114,11 @@ namespace RombaSharp.Features
#region Private Int32 features #region Private Int32 features
internal const string Include7ZipsInt32Value = "include-7zips"; internal const string Include7ZipsInt32Value = "include-7zips";
internal static Feature Include7ZipsInt32Input internal static SabreTools.Library.Help.Feature Include7ZipsInt32Input
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
Include7ZipsInt32Value, Include7ZipsInt32Value,
"-include-7zips", "-include-7zips",
"flag value == 0 means: add 7zip files themselves into the depot in addition to their contents, flag value == 2 means add 7zip files themselves but don't add content", "flag value == 0 means: add 7zip files themselves into the depot in addition to their contents, flag value == 2 means add 7zip files themselves but don't add content",
@@ -127,11 +127,11 @@ namespace RombaSharp.Features
} }
internal const string IncludeGZipsInt32Value = "include-gzips"; internal const string IncludeGZipsInt32Value = "include-gzips";
internal static Feature IncludeGZipsInt32Input internal static SabreTools.Library.Help.Feature IncludeGZipsInt32Input
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
IncludeGZipsInt32Value, IncludeGZipsInt32Value,
"-include-gzips", "-include-gzips",
"flag value == 0 means: add gzip files themselves into the depot in addition to their contents, flag value == 2 means add gzip files themselves but don't add content", "flag value == 0 means: add gzip files themselves into the depot in addition to their contents, flag value == 2 means add gzip files themselves but don't add content",
@@ -140,11 +140,11 @@ namespace RombaSharp.Features
} }
internal const string IncludeZipsInt32Value = "include-zips"; internal const string IncludeZipsInt32Value = "include-zips";
internal static Feature IncludeZipsInt32Input internal static SabreTools.Library.Help.Feature IncludeZipsInt32Input
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
IncludeZipsInt32Value, IncludeZipsInt32Value,
"-include-zips", "-include-zips",
"flag value == 0 means: add zip files themselves into the depot in addition to their contents, flag value == 2 means add zip files themselves but don't add content", "flag value == 0 means: add zip files themselves into the depot in addition to their contents, flag value == 2 means add zip files themselves but don't add content",
@@ -153,11 +153,11 @@ namespace RombaSharp.Features
} }
internal const string SubworkersInt32Value = "subworkers"; internal const string SubworkersInt32Value = "subworkers";
internal static Feature SubworkersInt32Input internal static SabreTools.Library.Help.Feature SubworkersInt32Input
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
SubworkersInt32Value, SubworkersInt32Value,
"-subworkers", "-subworkers",
"how many subworkers to launch for each worker", "how many subworkers to launch for each worker",
@@ -166,11 +166,11 @@ namespace RombaSharp.Features
} // Defaults to Workers count in config } // Defaults to Workers count in config
internal const string WorkersInt32Value = "workers"; internal const string WorkersInt32Value = "workers";
internal static Feature WorkersInt32Input internal static SabreTools.Library.Help.Feature WorkersInt32Input
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
WorkersInt32Value, WorkersInt32Value,
"-workers", "-workers",
"how many workers to launch for the job", "how many workers to launch for the job",
@@ -183,11 +183,11 @@ namespace RombaSharp.Features
#region Private Int64 features #region Private Int64 features
internal const string SizeInt64Value = "size"; internal const string SizeInt64Value = "size";
internal static Feature SizeInt64Input internal static SabreTools.Library.Help.Feature SizeInt64Input
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
SizeInt64Value, SizeInt64Value,
"-size", "-size",
"size of the rom to lookup", "size of the rom to lookup",
@@ -200,11 +200,11 @@ namespace RombaSharp.Features
#region Private List<String> features #region Private List<String> features
internal const string DatsListStringValue = "dats"; internal const string DatsListStringValue = "dats";
internal static Feature DatsListStringInput internal static SabreTools.Library.Help.Feature DatsListStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
DatsListStringValue, DatsListStringValue,
"-dats", "-dats",
"purge only roms declared in these dats", "purge only roms declared in these dats",
@@ -213,11 +213,11 @@ namespace RombaSharp.Features
} }
internal const string DepotListStringValue = "depot"; internal const string DepotListStringValue = "depot";
internal static Feature DepotListStringInput internal static SabreTools.Library.Help.Feature DepotListStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
DepotListStringValue, DepotListStringValue,
"-depot", "-depot",
"work only on specified depot path", "work only on specified depot path",
@@ -230,11 +230,11 @@ namespace RombaSharp.Features
#region Private String features #region Private String features
internal const string BackupStringValue = "backup"; internal const string BackupStringValue = "backup";
internal static Feature BackupStringInput internal static SabreTools.Library.Help.Feature BackupStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
BackupStringValue, BackupStringValue,
"-backup", "-backup",
"backup directory where backup files are moved to", "backup directory where backup files are moved to",
@@ -243,11 +243,11 @@ namespace RombaSharp.Features
} }
internal const string DescriptionStringValue = "description"; internal const string DescriptionStringValue = "description";
internal static Feature DescriptionStringInput internal static SabreTools.Library.Help.Feature DescriptionStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
DescriptionStringValue, DescriptionStringValue,
"-description", "-description",
"description value in DAT header", "description value in DAT header",
@@ -256,11 +256,11 @@ namespace RombaSharp.Features
} }
internal const string MissingSha1sStringValue = "missing-sha1s"; internal const string MissingSha1sStringValue = "missing-sha1s";
internal static Feature MissingSha1sStringInput internal static SabreTools.Library.Help.Feature MissingSha1sStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
MissingSha1sStringValue, MissingSha1sStringValue,
"-missingSha1s", "-missingSha1s",
"write paths of dats with missing sha1s into this file", "write paths of dats with missing sha1s into this file",
@@ -269,11 +269,11 @@ namespace RombaSharp.Features
} }
internal const string NameStringValue = "name"; internal const string NameStringValue = "name";
internal static Feature NameStringInput internal static SabreTools.Library.Help.Feature NameStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
NameStringValue, NameStringValue,
"-name", "-name",
"name value in DAT header", "name value in DAT header",
@@ -282,11 +282,11 @@ namespace RombaSharp.Features
} }
internal const string NewStringValue = "new"; internal const string NewStringValue = "new";
internal static Feature NewStringInput internal static SabreTools.Library.Help.Feature NewStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
NewStringValue, NewStringValue,
"-new", "-new",
"new DAT file", "new DAT file",
@@ -295,11 +295,11 @@ namespace RombaSharp.Features
} }
internal const string OldStringValue = "old"; internal const string OldStringValue = "old";
internal static Feature OldStringInput internal static SabreTools.Library.Help.Feature OldStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
OldStringValue, OldStringValue,
"-old", "-old",
"old DAT file", "old DAT file",
@@ -308,11 +308,11 @@ namespace RombaSharp.Features
} }
internal const string OutStringValue = "out"; internal const string OutStringValue = "out";
internal static Feature OutStringInput internal static SabreTools.Library.Help.Feature OutStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
OutStringValue, OutStringValue,
"-out", "-out",
"output file", "output file",
@@ -321,11 +321,11 @@ namespace RombaSharp.Features
} }
internal const string ResumeStringValue = "resume"; internal const string ResumeStringValue = "resume";
internal static Feature ResumeStringInput internal static SabreTools.Library.Help.Feature ResumeStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
ResumeStringValue, ResumeStringValue,
"-resume", "-resume",
"resume a previously interrupted operation from the specified path", "resume a previously interrupted operation from the specified path",
@@ -334,11 +334,11 @@ namespace RombaSharp.Features
} }
internal const string SourceStringValue = "source"; internal const string SourceStringValue = "source";
internal static Feature SourceStringInput internal static SabreTools.Library.Help.Feature SourceStringInput
{ {
get get
{ {
return new Feature( return new SabreTools.Library.Help.Feature(
SourceStringValue, SourceStringValue,
"-source", "-source",
"source directory", "source directory",
@@ -370,7 +370,7 @@ namespace RombaSharp.Features
internal const string _dbSchema = "rombasharp"; internal const string _dbSchema = "rombasharp";
internal static string _connectionString; internal static string _connectionString;
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, SabreTools.Library.Help.Feature> features)
{ {
InitializeConfiguration(); InitializeConfiguration();
DatabaseTools.EnsureDatabase(_dbSchema, _db, _connectionString); DatabaseTools.EnsureDatabase(_dbSchema, _db, _connectionString);

View File

@@ -24,13 +24,13 @@ namespace RombaSharp.Features
Detects any changes in the DAT master directory tree and updates the DAT index Detects any changes in the DAT master directory tree and updates the DAT index
accordingly, marking deleted or overwritten dats as orphaned and updating accordingly, marking deleted or overwritten dats as orphaned and updating
contents of any changed dats."; contents of any changed dats.";
Features = new Dictionary<string, Feature>(); Features = new Dictionary<string, SabreTools.Library.Help.Feature>();
AddFeature(WorkersInt32Input); AddFeature(WorkersInt32Input);
AddFeature(MissingSha1sStringInput); AddFeature(MissingSha1sStringInput);
} }
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, SabreTools.Library.Help.Feature> features)
{ {
base.ProcessFeatures(features); base.ProcessFeatures(features);

View File

@@ -21,10 +21,10 @@ namespace RombaSharp.Features
Description = "Rescan a specific depot to get new information"; Description = "Rescan a specific depot to get new information";
_featureType = FeatureType.Flag; _featureType = FeatureType.Flag;
LongDescription = "Rescan a specific depot to get new information"; LongDescription = "Rescan a specific depot to get new information";
Features = new Dictionary<string, Feature>(); Features = new Dictionary<string, SabreTools.Library.Help.Feature>();
} }
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, SabreTools.Library.Help.Feature> features)
{ {
base.ProcessFeatures(features); base.ProcessFeatures(features);
Globals.Logger.Error("This feature is not yet implemented: rescan-depots"); Globals.Logger.Error("This feature is not yet implemented: rescan-depots");

View File

@@ -1441,17 +1441,18 @@ namespace SabreTools.Library.DatFiles
if (slotoptions) if (slotoptions)
{ {
// If the game has no slot options, we continue // If the game has no slot options, we continue
if (Items[game][0].Machine.Slots == null if (Items[game]
|| Items[game][0].Machine.Slots .Where(i => i.ItemType == ItemType.Slot)
.SelectMany(s => s.SlotOptions ?? new List<ListXmlSlotOption>()).Count() == 0) .SelectMany(s => (s as Slot).SlotOptions ?? new List<SlotOption>()).Count() == 0)
{ {
continue; continue;
} }
// Determine if the game has any slot options or not // Determine if the game has any slot options or not
List<string> slotOptions = Items[game][0].Machine.Slots List<string> slotOptions = Items[game]
.Where(s => s.SlotOptions != null && s.SlotOptions.Count != 0) .Where(i => i.ItemType == ItemType.Slot)
.SelectMany(s => s.SlotOptions) .Where(s => (s as Slot).SlotOptions != null && (s as Slot).SlotOptions.Count != 0)
.SelectMany(s => (s as Slot).SlotOptions)
.Select(o => o.DeviceName) .Select(o => o.DeviceName)
.Distinct() .Distinct()
.ToList(); .ToList();
@@ -1465,18 +1466,15 @@ namespace SabreTools.Library.DatFiles
// Otherwise, copy the items from the slot option to the current game // Otherwise, copy the items from the slot option to the current game
DatItem copyFrom = Items[game][0]; DatItem copyFrom = Items[game][0];
List<DatItem> slotOptionItems = Items[slotOption]; List<DatItem> slotOptionItems = Items[slotOption];
newSlotOptions.AddRange((Items[slotOption] ?? new List<DatItem>())
.Where(i => i.ItemType == ItemType.Slot)
.Where(s => (s as Slot).SlotOptions != null && (s as Slot).SlotOptions.Count != 0)
.SelectMany(s => (s as Slot).SlotOptions)
.Select(o => o.DeviceName));
foreach (DatItem item in slotOptionItems) foreach (DatItem item in slotOptionItems)
{ {
DatItem datItem = (DatItem)item.Clone(); DatItem datItem = (DatItem)item.Clone();
List<string> machineSlotOptions =
(datItem.Machine.Slots ?? new List<ListXmlSlot>())
.Where(s => s.SlotOptions != null && s.SlotOptions.Count != 0)
.SelectMany(s => s.SlotOptions)
.Select(o => o.DeviceName)
.Distinct()
.ToList();
newSlotOptions.AddRange(machineSlotOptions);
datItem.CopyMachineInformation(copyFrom); datItem.CopyMachineInformation(copyFrom);
if (Items[game].Where(i => i.ItemType == datItem.ItemType && i.Name == datItem.Name).Count() == 0) if (Items[game].Where(i => i.ItemType == datItem.ItemType && i.Name == datItem.Name).Count() == 0)
{ {
@@ -1493,7 +1491,7 @@ namespace SabreTools.Library.DatFiles
foreach (string slotOption in newSlotOptions) foreach (string slotOption in newSlotOptions)
{ {
if (!slotOptions.Contains(slotOption)) if (!slotOptions.Contains(slotOption))
Items[game][0].Machine.Slots.Add(new ListXmlSlot() { SlotOptions = new List<ListXmlSlotOption> { new ListXmlSlotOption { DeviceName = slotOption } } }); Items[game].Add(new Slot() { SlotOptions = new List<SlotOption> { new SlotOption { DeviceName = slotOption } } });
} }
} }
} }

View File

@@ -155,6 +155,12 @@ namespace SabreTools.Library.DatFiles
[JsonIgnore] [JsonIgnore]
public long SampleCount { get; private set; } = 0; public long SampleCount { get; private set; } = 0;
/// <summary>
/// Number of Slot items
/// </summary>
[JsonIgnore]
public long SlotCount { get; private set; } = 0;
/// <summary> /// <summary>
/// Number of SoftwareList items /// Number of SoftwareList items
/// </summary> /// </summary>
@@ -558,6 +564,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.Sample: case ItemType.Sample:
SampleCount++; SampleCount++;
break; break;
case ItemType.Slot:
SlotCount++;
break;
case ItemType.SoftwareList: case ItemType.SoftwareList:
SoftwareListCount++; SoftwareListCount++;
break; break;
@@ -705,6 +714,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.Sample: case ItemType.Sample:
SampleCount--; SampleCount--;
break; break;
case ItemType.Slot:
SlotCount--;
break;
case ItemType.SoftwareList: case ItemType.SoftwareList:
SoftwareListCount--; SoftwareListCount--;
break; break;

View File

@@ -250,6 +250,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.Sample: case ItemType.Sample:
datItem = datItemObj.ToObject<Sample>(); datItem = datItemObj.ToObject<Sample>();
break; break;
case ItemType.Slot:
datItem = datItemObj.ToObject<Slot>();
break;
case ItemType.SoftwareList: case ItemType.SoftwareList:
datItem = datItemObj.ToObject<DatItems.SoftwareList>(); datItem = datItemObj.ToObject<DatItems.SoftwareList>();
break; break;

View File

@@ -171,7 +171,7 @@ namespace SabreTools.Library.DatFiles
{ {
Name = reader.GetAttribute("name"), Name = reader.GetAttribute("name"),
Default = reader.GetAttribute("default").AsYesNo(), Default = reader.GetAttribute("default").AsYesNo(),
Conditions = new List<ListXmlCondition>(), Conditions = new List<Condition>(),
}; };
// Now read the internal tags // Now read the internal tags
@@ -224,9 +224,9 @@ namespace SabreTools.Library.DatFiles
Name = reader.GetAttribute("name"), Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"), Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"), Mask = reader.GetAttribute("mask"),
Conditions = new List<ListXmlCondition>(), Conditions = new List<Condition>(),
Locations = new List<ListXmlConfLocation>(), Locations = new List<Location>(),
Settings = new List<ListXmlConfSetting>(), Settings = new List<Setting>(),
}; };
// Now read the internal tags // Now read the internal tags
@@ -253,14 +253,16 @@ namespace SabreTools.Library.DatFiles
Name = reader.GetAttribute("name"), Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"), Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"), Mask = reader.GetAttribute("mask"),
Conditions = new List<ListXmlCondition>(), Conditions = new List<Condition>(),
Locations = new List<ListXmlDipLocation>(), Locations = new List<Location>(),
Values = new List<ListXmlDipValue>(), Values = new List<Setting>(),
}; };
// Now read the internal tags // Now read the internal tags
ReadDipSwitch(reader.ReadSubtree(), dipSwitch); ReadDipSwitch(reader.ReadSubtree(), dipSwitch);
datItems.Add(dipSwitch);
// Skip the dipswitch now that we've processed it // Skip the dipswitch now that we've processed it
reader.Skip(); reader.Skip();
break; break;
@@ -336,6 +338,22 @@ namespace SabreTools.Library.DatFiles
reader.Read(); reader.Read();
break; break;
case "slot":
var slot = new Slot
{
Name = reader.GetAttribute("name"),
SlotOptions = new List<SlotOption>(),
};
// Now read the internal tags
ReadSlot(reader.ReadSubtree(), slot);
datItems.Add(slot);
// Skip the slot now that we've processed it
reader.Skip();
break;
case "softwarelist": case "softwarelist":
datItems.Add(new DatItems.SoftwareList datItems.Add(new DatItems.SoftwareList
{ {
@@ -355,7 +373,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "display": case "display":
var display = new ListXmlDisplay(); var display = new Display();
display.Tag = reader.GetAttribute("tag"); display.Tag = reader.GetAttribute("tag");
display.Type = reader.GetAttribute("type"); display.Type = reader.GetAttribute("type");
display.Rotate = reader.GetAttribute("rotate"); display.Rotate = reader.GetAttribute("rotate");
@@ -373,7 +391,7 @@ namespace SabreTools.Library.DatFiles
// Ensure the list exists // Ensure the list exists
if (machine.Displays == null) if (machine.Displays == null)
machine.Displays = new List<ListXmlDisplay>(); machine.Displays = new List<Display>();
machine.Displays.Add(display); machine.Displays.Add(display);
@@ -381,12 +399,12 @@ namespace SabreTools.Library.DatFiles
break; break;
case "sound": case "sound":
var sound = new ListXmlSound(); var sound = new Sound();
sound.Channels = reader.GetAttribute("channels"); sound.Channels = reader.GetAttribute("channels");
// Ensure the list exists // Ensure the list exists
if (machine.Sounds == null) if (machine.Sounds == null)
machine.Sounds = new List<ListXmlSound>(); machine.Sounds = new List<Sound>();
machine.Sounds.Add(sound); machine.Sounds.Add(sound);
@@ -394,7 +412,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -402,7 +420,7 @@ namespace SabreTools.Library.DatFiles
// Ensure the list exists // Ensure the list exists
if (machine.Conditions == null) if (machine.Conditions == null)
machine.Conditions = new List<ListXmlCondition>(); machine.Conditions = new List<Condition>();
machine.Conditions.Add(condition); machine.Conditions.Add(condition);
@@ -410,7 +428,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "input": case "input":
var input = new ListXmlInput(); var input = new Input();
input.Service = reader.GetAttribute("service").AsYesNo(); input.Service = reader.GetAttribute("service").AsYesNo();
input.Tilt = reader.GetAttribute("tilt").AsYesNo(); input.Tilt = reader.GetAttribute("tilt").AsYesNo();
input.Players = reader.GetAttribute("players"); input.Players = reader.GetAttribute("players");
@@ -421,7 +439,7 @@ namespace SabreTools.Library.DatFiles
// Ensure the list exists // Ensure the list exists
if (machine.Inputs == null) if (machine.Inputs == null)
machine.Inputs = new List<ListXmlInput>(); machine.Inputs = new List<Input>();
machine.Inputs.Add(input); machine.Inputs.Add(input);
@@ -430,7 +448,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "port": case "port":
var port = new ListXmlPort(); var port = new Port();
port.Tag = reader.GetAttribute("tag"); port.Tag = reader.GetAttribute("tag");
// Now read the internal tags // Now read the internal tags
@@ -438,7 +456,7 @@ namespace SabreTools.Library.DatFiles
// Ensure the list exists // Ensure the list exists
if (machine.Ports == null) if (machine.Ports == null)
machine.Ports = new List<ListXmlPort>(); machine.Ports = new List<Port>();
machine.Ports.Add(port); machine.Ports.Add(port);
@@ -447,7 +465,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "driver": case "driver":
var driver = new ListXmlDriver(); var driver = new Driver();
driver.Status = reader.GetAttribute("status"); driver.Status = reader.GetAttribute("status");
driver.Emulation = reader.GetAttribute("emulation"); driver.Emulation = reader.GetAttribute("emulation");
driver.Cocktail = reader.GetAttribute("cocktail"); driver.Cocktail = reader.GetAttribute("cocktail");
@@ -455,7 +473,7 @@ namespace SabreTools.Library.DatFiles
// Ensure the list exists // Ensure the list exists
if (machine.Drivers == null) if (machine.Drivers == null)
machine.Drivers = new List<ListXmlDriver>(); machine.Drivers = new List<Driver>();
machine.Drivers.Add(driver); machine.Drivers.Add(driver);
@@ -463,14 +481,14 @@ namespace SabreTools.Library.DatFiles
break; break;
case "feature": case "feature":
var feature = new ListXmlFeature(); var feature = new Feature();
feature.Type = reader.GetAttribute("type"); feature.Type = reader.GetAttribute("type");
feature.Status = reader.GetAttribute("status"); feature.Status = reader.GetAttribute("status");
feature.Overall = reader.GetAttribute("overall"); feature.Overall = reader.GetAttribute("overall");
// Ensure the list exists // Ensure the list exists
if (machine.Features == null) if (machine.Features == null)
machine.Features = new List<ListXmlFeature>(); machine.Features = new List<Feature>();
machine.Features.Add(feature); machine.Features.Add(feature);
@@ -478,7 +496,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "device": case "device":
var device = new ListXmlDevice(); var device = new Device();
device.Type = reader.GetAttribute("type"); device.Type = reader.GetAttribute("type");
device.Tag = reader.GetAttribute("tag"); device.Tag = reader.GetAttribute("tag");
device.FixedImage = reader.GetAttribute("fixed_image"); device.FixedImage = reader.GetAttribute("fixed_image");
@@ -490,7 +508,7 @@ namespace SabreTools.Library.DatFiles
// Ensure the list exists // Ensure the list exists
if (machine.Devices == null) if (machine.Devices == null)
machine.Devices = new List<ListXmlDevice>(); machine.Devices = new List<Device>();
machine.Devices.Add(device); machine.Devices.Add(device);
@@ -498,23 +516,6 @@ namespace SabreTools.Library.DatFiles
reader.Skip(); reader.Skip();
break; break;
case "slot":
var slot = new ListXmlSlot();
slot.Name = reader.GetAttribute("name");
// Now read the internal tags
ReadSlot(reader.ReadSubtree(), slot);
// Ensure the list exists
if (machine.Slots == null)
machine.Slots = new List<ListXmlSlot>();
machine.Slots.Add(slot);
// Skip the slot now that we've processed it
reader.Skip();
break;
default: default:
reader.Read(); reader.Read();
break; break;
@@ -555,14 +556,14 @@ namespace SabreTools.Library.DatFiles
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a machine block</param> /// <param name="reader">XmlReader representing a machine block</param>
/// <param name="slot">ListXmlSlot to populate</param> /// <param name="slot">ListXmlSlot to populate</param>
private void ReadSlot(XmlReader reader, ListXmlSlot slot) private void ReadSlot(XmlReader reader, Slot slot)
{ {
// If we have an empty machine, skip it // If we have an empty machine, skip it
if (reader == null) if (reader == null)
return; return;
// Get list ready // Get list ready
slot.SlotOptions = new List<ListXmlSlotOption>(); slot.SlotOptions = new List<SlotOption>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -580,7 +581,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "slotoption": case "slotoption":
var slotOption = new ListXmlSlotOption(); var slotOption = new SlotOption();
slotOption.Name = reader.GetAttribute("name"); slotOption.Name = reader.GetAttribute("name");
slotOption.DeviceName = reader.GetAttribute("devname"); slotOption.DeviceName = reader.GetAttribute("devname");
slotOption.Default = reader.GetAttribute("default").AsYesNo(); slotOption.Default = reader.GetAttribute("default").AsYesNo();
@@ -602,14 +603,14 @@ namespace SabreTools.Library.DatFiles
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a diskarea block</param> /// <param name="reader">XmlReader representing a diskarea block</param>
/// <param name="input">ListXmlInput to populate</param> /// <param name="input">ListXmlInput to populate</param>
private void ReadInput(XmlReader reader, ListXmlInput input) private void ReadInput(XmlReader reader, Input input)
{ {
// If we have an empty input, skip it // If we have an empty input, skip it
if (reader == null) if (reader == null)
return; return;
// Get list ready // Get list ready
input.Controls = new List<ListXmlControl>(); input.Controls = new List<Control>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -627,7 +628,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "control": case "control":
var control = new ListXmlControl(); var control = new Control();
control.Type = reader.GetAttribute("type"); control.Type = reader.GetAttribute("type");
control.Player = reader.GetAttribute("player"); control.Player = reader.GetAttribute("player");
control.Buttons = reader.GetAttribute("buttons"); control.Buttons = reader.GetAttribute("buttons");
@@ -665,9 +666,9 @@ namespace SabreTools.Library.DatFiles
return; return;
// Get lists ready // Get lists ready
dipSwitch.Conditions = new List<ListXmlCondition>(); dipSwitch.Conditions = new List<Condition>();
dipSwitch.Locations = new List<ListXmlDipLocation>(); dipSwitch.Locations = new List<Location>();
dipSwitch.Values = new List<ListXmlDipValue>(); dipSwitch.Values = new List<Setting>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -685,7 +686,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -697,7 +698,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "diplocation": case "diplocation":
var dipLocation = new ListXmlDipLocation(); var dipLocation = new Location();
dipLocation.Name = reader.GetAttribute("name"); dipLocation.Name = reader.GetAttribute("name");
dipLocation.Number = reader.GetAttribute("number"); dipLocation.Number = reader.GetAttribute("number");
dipLocation.Inverted = reader.GetAttribute("inverted").AsYesNo(); dipLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
@@ -708,7 +709,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "dipvalue": case "dipvalue":
var dipValue = new ListXmlDipValue(); var dipValue = new Setting();
dipValue.Name = reader.GetAttribute("name"); dipValue.Name = reader.GetAttribute("name");
dipValue.Value = reader.GetAttribute("value"); dipValue.Value = reader.GetAttribute("value");
dipValue.Default = reader.GetAttribute("default").AsYesNo(); dipValue.Default = reader.GetAttribute("default").AsYesNo();
@@ -733,15 +734,15 @@ namespace SabreTools.Library.DatFiles
/// Read DipValue information /// Read DipValue information
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a diskarea block</param> /// <param name="reader">XmlReader representing a diskarea block</param>
/// <param name="dipValue">ListXmlDipValue to populate</param> /// <param name="dipValue">Setting to populate</param>
private void ReadDipValue(XmlReader reader, ListXmlDipValue dipValue) private void ReadDipValue(XmlReader reader, Setting dipValue)
{ {
// If we have an empty dipvalue, skip it // If we have an empty dipvalue, skip it
if (reader == null) if (reader == null)
return; return;
// Get list ready // Get list ready
dipValue.Conditions = new List<ListXmlCondition>(); dipValue.Conditions = new List<Condition>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -759,7 +760,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -789,9 +790,9 @@ namespace SabreTools.Library.DatFiles
return; return;
// Get lists ready // Get lists ready
configuration.Conditions = new List<ListXmlCondition>(); configuration.Conditions = new List<Condition>();
configuration.Locations = new List<ListXmlConfLocation>(); configuration.Locations = new List<Location>();
configuration.Settings = new List<ListXmlConfSetting>(); configuration.Settings = new List<Setting>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -809,7 +810,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -821,7 +822,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "conflocation": case "conflocation":
var confLocation = new ListXmlConfLocation(); var confLocation = new Location();
confLocation.Name = reader.GetAttribute("name"); confLocation.Name = reader.GetAttribute("name");
confLocation.Number = reader.GetAttribute("number"); confLocation.Number = reader.GetAttribute("number");
confLocation.Inverted = reader.GetAttribute("inverted").AsYesNo(); confLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
@@ -832,7 +833,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "confsetting": case "confsetting":
var confSetting = new ListXmlConfSetting(); var confSetting = new Setting();
confSetting.Name = reader.GetAttribute("name"); confSetting.Name = reader.GetAttribute("name");
confSetting.Value = reader.GetAttribute("value"); confSetting.Value = reader.GetAttribute("value");
confSetting.Default = reader.GetAttribute("default").AsYesNo(); confSetting.Default = reader.GetAttribute("default").AsYesNo();
@@ -857,15 +858,15 @@ namespace SabreTools.Library.DatFiles
/// Read ConfSetting information /// Read ConfSetting information
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a diskarea block</param> /// <param name="reader">XmlReader representing a diskarea block</param>
/// <param name="confSetting">ListXmlConfSetting to populate</param> /// <param name="confSetting">Setting to populate</param>
private void ReadConfSetting(XmlReader reader, ListXmlConfSetting confSetting) private void ReadConfSetting(XmlReader reader, Setting confSetting)
{ {
// If we have an empty confsetting, skip it // If we have an empty confsetting, skip it
if (reader == null) if (reader == null)
return; return;
// Get list ready // Get list ready
confSetting.Conditions = new List<ListXmlCondition>(); confSetting.Conditions = new List<Condition>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -883,7 +884,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -906,14 +907,14 @@ namespace SabreTools.Library.DatFiles
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a diskarea block</param> /// <param name="reader">XmlReader representing a diskarea block</param>
/// <param name="port">ListXmlPort to populate</param> /// <param name="port">ListXmlPort to populate</param>
private void ReadPort(XmlReader reader, ListXmlPort port) private void ReadPort(XmlReader reader, Port port)
{ {
// If we have an empty port, skip it // If we have an empty port, skip it
if (reader == null) if (reader == null)
return; return;
// Get list ready // Get list ready
port.Analogs = new List<ListXmlAnalog>(); port.Analogs = new List<Analog>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -931,7 +932,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "analog": case "analog":
var analog = new ListXmlAnalog(); var analog = new Analog();
analog.Mask = reader.GetAttribute("mask"); analog.Mask = reader.GetAttribute("mask");
port.Analogs.Add(analog); port.Analogs.Add(analog);
@@ -958,7 +959,7 @@ namespace SabreTools.Library.DatFiles
return; return;
// Get list ready // Get list ready
adjuster.Conditions = new List<ListXmlCondition>(); adjuster.Conditions = new List<Condition>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -976,7 +977,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -999,15 +1000,15 @@ namespace SabreTools.Library.DatFiles
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a diskarea block</param> /// <param name="reader">XmlReader representing a diskarea block</param>
/// <param name="device">ListXmlDevice to populate</param> /// <param name="device">ListXmlDevice to populate</param>
private void ReadDevice(XmlReader reader, ListXmlDevice device) private void ReadDevice(XmlReader reader, Device device)
{ {
// If we have an empty port, skip it // If we have an empty port, skip it
if (reader == null) if (reader == null)
return; return;
// Get lists ready // Get lists ready
device.Instances = new List<ListXmlInstance>(); device.Instances = new List<Instance>();
device.Extensions = new List<ListXmlExtension>(); device.Extensions = new List<Extension>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -1025,7 +1026,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "instance": case "instance":
var instance = new ListXmlInstance(); var instance = new Instance();
instance.Name = reader.GetAttribute("name"); instance.Name = reader.GetAttribute("name");
instance.BriefName = reader.GetAttribute("briefname"); instance.BriefName = reader.GetAttribute("briefname");
@@ -1035,7 +1036,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "extension": case "extension":
var extension = new ListXmlExtension(); var extension = new Extension();
extension.Name = reader.GetAttribute("name"); extension.Name = reader.GetAttribute("name");
device.Extensions.Add(extension); device.Extensions.Add(extension);
@@ -1384,33 +1385,6 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement(); xtw.WriteEndElement();
} }
} }
if (datItem.Machine.Slots != null)
{
foreach (var slot in datItem.Machine.Slots)
{
xtw.WriteStartElement("slot");
xtw.WriteOptionalAttributeString("name", slot.Name);
if (slot.SlotOptions != null)
{
foreach (var slotOption in slot.SlotOptions)
{
xtw.WriteStartElement("slotoption");
xtw.WriteOptionalAttributeString("name", slotOption.Name);
xtw.WriteOptionalAttributeString("devname", slotOption.DeviceName);
xtw.WriteOptionalAttributeString("default", slotOption.Default.FromYesNo());
// End slotoption
xtw.WriteEndElement();
}
}
// End slot
xtw.WriteEndElement();
}
}
xtw.Flush(); xtw.Flush();
} }
@@ -1651,6 +1625,24 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement(); xtw.WriteEndElement();
break; break;
case ItemType.Slot:
var slot = datItem as Slot;
xtw.WriteStartElement("slot");
xtw.WriteOptionalAttributeString("name", slot.Name);
if (slot.SlotOptions != null)
{
foreach (var slotOption in slot.SlotOptions)
{
xtw.WriteStartElement("slotoption");
xtw.WriteOptionalAttributeString("name", slotOption.Name);
xtw.WriteOptionalAttributeString("devname", slotOption.DeviceName);
xtw.WriteOptionalAttributeString("default", slotOption.Default.FromYesNo());
xtw.WriteEndElement();
}
}
xtw.WriteEndElement();
break;
case ItemType.SoftwareList: case ItemType.SoftwareList:
var softwareList = datItem as DatItems.SoftwareList; var softwareList = datItem as DatItems.SoftwareList;
xtw.WriteStartElement("softwarelist"); xtw.WriteStartElement("softwarelist");

View File

@@ -356,7 +356,7 @@ namespace SabreTools.Library.DatFiles
{ {
Name = reader.GetAttribute("name"), Name = reader.GetAttribute("name"),
Default = reader.GetAttribute("default").AsYesNo(), Default = reader.GetAttribute("default").AsYesNo(),
Conditions = new List<ListXmlCondition>(), Conditions = new List<Condition>(),
}; };
// Now read the internal tags // Now read the internal tags
@@ -416,9 +416,9 @@ namespace SabreTools.Library.DatFiles
Name = reader.GetAttribute("name"), Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"), Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"), Mask = reader.GetAttribute("mask"),
Conditions = new List<ListXmlCondition>(), Conditions = new List<Condition>(),
Locations = new List<ListXmlConfLocation>(), Locations = new List<Location>(),
Settings = new List<ListXmlConfSetting>(), Settings = new List<Setting>(),
}; };
// Now read the internal tags // Now read the internal tags
@@ -443,9 +443,9 @@ namespace SabreTools.Library.DatFiles
Name = reader.GetAttribute("name"), Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"), Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"), Mask = reader.GetAttribute("mask"),
Conditions = new List<ListXmlCondition>(), Conditions = new List<Condition>(),
Locations = new List<ListXmlDipLocation>(), Locations = new List<Location>(),
Values = new List<ListXmlDipValue>(), Values = new List<Setting>(),
}; };
// Now read the internal tags // Now read the internal tags
@@ -643,7 +643,7 @@ namespace SabreTools.Library.DatFiles
return; return;
// Get list ready // Get list ready
(adjuster as Adjuster).Conditions = new List<ListXmlCondition>(); (adjuster as Adjuster).Conditions = new List<Condition>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -661,7 +661,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -695,9 +695,9 @@ namespace SabreTools.Library.DatFiles
return; return;
// Get lists ready // Get lists ready
(configuration as Configuration).Conditions = new List<ListXmlCondition>(); (configuration as Configuration).Conditions = new List<Condition>();
(configuration as Configuration).Locations = new List<ListXmlConfLocation>(); (configuration as Configuration).Locations = new List<Location>();
(configuration as Configuration).Settings = new List<ListXmlConfSetting>(); (configuration as Configuration).Settings = new List<Setting>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -715,7 +715,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -727,7 +727,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "conflocation": case "conflocation":
var confLocation = new ListXmlConfLocation(); var confLocation = new Location();
confLocation.Name = reader.GetAttribute("name"); confLocation.Name = reader.GetAttribute("name");
confLocation.Number = reader.GetAttribute("number"); confLocation.Number = reader.GetAttribute("number");
confLocation.Inverted = reader.GetAttribute("inverted").AsYesNo(); confLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
@@ -738,7 +738,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "confsetting": case "confsetting":
var confSetting = new ListXmlConfSetting(); var confSetting = new Setting();
confSetting.Name = reader.GetAttribute("name"); confSetting.Name = reader.GetAttribute("name");
confSetting.Value = reader.GetAttribute("value"); confSetting.Value = reader.GetAttribute("value");
confSetting.Default = reader.GetAttribute("default").AsYesNo(); confSetting.Default = reader.GetAttribute("default").AsYesNo();
@@ -764,14 +764,14 @@ namespace SabreTools.Library.DatFiles
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a diskarea block</param> /// <param name="reader">XmlReader representing a diskarea block</param>
/// <param name="confSetting">ListXmlConfSetting to populate</param> /// <param name="confSetting">ListXmlConfSetting to populate</param>
private void ReadConfSetting(XmlReader reader, ListXmlConfSetting confSetting) private void ReadConfSetting(XmlReader reader, Setting confSetting)
{ {
// If we have an empty confsetting, skip it // If we have an empty confsetting, skip it
if (reader == null) if (reader == null)
return; return;
// Get list ready // Get list ready
confSetting.Conditions = new List<ListXmlCondition>(); confSetting.Conditions = new List<Condition>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -789,7 +789,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -823,9 +823,9 @@ namespace SabreTools.Library.DatFiles
return; return;
// Get lists ready // Get lists ready
(dipSwitch as DipSwitch).Conditions = new List<ListXmlCondition>(); (dipSwitch as DipSwitch).Conditions = new List<Condition>();
(dipSwitch as DipSwitch).Locations = new List<ListXmlDipLocation>(); (dipSwitch as DipSwitch).Locations = new List<Location>();
(dipSwitch as DipSwitch).Values = new List<ListXmlDipValue>(); (dipSwitch as DipSwitch).Values = new List<Setting>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -843,7 +843,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -855,7 +855,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "diplocation": case "diplocation":
var dipLocation = new ListXmlDipLocation(); var dipLocation = new Location();
dipLocation.Name = reader.GetAttribute("name"); dipLocation.Name = reader.GetAttribute("name");
dipLocation.Number = reader.GetAttribute("number"); dipLocation.Number = reader.GetAttribute("number");
dipLocation.Inverted = reader.GetAttribute("inverted").AsYesNo(); dipLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
@@ -866,7 +866,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "dipvalue": case "dipvalue":
var dipValue = new ListXmlDipValue(); var dipValue = new Setting();
dipValue.Name = reader.GetAttribute("name"); dipValue.Name = reader.GetAttribute("name");
dipValue.Value = reader.GetAttribute("value"); dipValue.Value = reader.GetAttribute("value");
dipValue.Default = reader.GetAttribute("default").AsYesNo(); dipValue.Default = reader.GetAttribute("default").AsYesNo();
@@ -891,15 +891,15 @@ namespace SabreTools.Library.DatFiles
/// Read DipValue information /// Read DipValue information
/// </summary> /// </summary>
/// <param name="reader">XmlReader representing a diskarea block</param> /// <param name="reader">XmlReader representing a diskarea block</param>
/// <param name="dipValue">ListXmlDipValue to populate</param> /// <param name="dipValue">Setting to populate</param>
private void ReadDipValue(XmlReader reader, ListXmlDipValue dipValue) private void ReadDipValue(XmlReader reader, Setting dipValue)
{ {
// If we have an empty dipvalue, skip it // If we have an empty dipvalue, skip it
if (reader == null) if (reader == null)
return; return;
// Get list ready // Get list ready
dipValue.Conditions = new List<ListXmlCondition>(); dipValue.Conditions = new List<Condition>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -917,7 +917,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "condition": case "condition":
var condition = new ListXmlCondition(); var condition = new Condition();
condition.Tag = reader.GetAttribute("tag"); condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask"); condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation"); condition.Relation = reader.GetAttribute("relation");
@@ -1458,6 +1458,25 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement(); xtw.WriteEndElement();
break; break;
case ItemType.Slot:
var slot = datItem as Slot;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "slot");
xtw.WriteOptionalAttributeString("name", slot.Name);
if (slot.SlotOptions != null)
{
foreach (var slotOption in slot.SlotOptions)
{
xtw.WriteStartElement("slotoption");
xtw.WriteOptionalAttributeString("name", slotOption.Name);
xtw.WriteOptionalAttributeString("devname", slotOption.DeviceName);
xtw.WriteOptionalAttributeString("default", slotOption.Default.FromYesNo());
xtw.WriteEndElement();
}
}
xtw.WriteEndElement();
break;
case ItemType.SoftwareList: case ItemType.SoftwareList:
var softwareList = datItem as DatItems.SoftwareList; var softwareList = datItem as DatItems.SoftwareList;
xtw.WriteStartElement("file"); xtw.WriteStartElement("file");

View File

@@ -341,9 +341,9 @@ namespace SabreTools.Library.DatFiles
Name = reader.GetAttribute("name"), Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"), Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"), Mask = reader.GetAttribute("mask"),
Conditions = new List<ListXmlCondition>(), Conditions = new List<Condition>(),
Locations = new List<ListXmlDipLocation>(), Locations = new List<Location>(),
Values = new List<ListXmlDipValue>(), Values = new List<Setting>(),
}; };
// Now read the internal tags // Now read the internal tags
@@ -526,7 +526,7 @@ namespace SabreTools.Library.DatFiles
return; return;
// Get list ready // Get list ready
dipSwitch.Values = new List<ListXmlDipValue>(); dipSwitch.Values = new List<Setting>();
// Otherwise, add what is possible // Otherwise, add what is possible
reader.MoveToContent(); reader.MoveToContent();
@@ -544,7 +544,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name) switch (reader.Name)
{ {
case "dipvalue": case "dipvalue":
var dipValue = new ListXmlDipValue(); var dipValue = new Setting();
dipValue.Name = reader.GetAttribute("name"); dipValue.Name = reader.GetAttribute("name");
dipValue.Value = reader.GetAttribute("value"); dipValue.Value = reader.GetAttribute("value");
dipValue.Default = reader.GetAttribute("default").AsYesNo(); dipValue.Default = reader.GetAttribute("default").AsYesNo();
@@ -795,7 +795,7 @@ namespace SabreTools.Library.DatFiles
xtw.WriteRequiredAttributeString("mask", dipSwitch.Mask); xtw.WriteRequiredAttributeString("mask", dipSwitch.Mask);
if (dipSwitch.Values != null) if (dipSwitch.Values != null)
{ {
foreach (ListXmlDipValue dipValue in dipSwitch.Values) foreach (Setting dipValue in dipSwitch.Values)
{ {
xtw.WriteStartElement("dipvalue"); xtw.WriteStartElement("dipvalue");
xtw.WriteRequiredAttributeString("name", dipValue.Name); xtw.WriteRequiredAttributeString("name", dipValue.Name);

View File

@@ -25,7 +25,7 @@ namespace SabreTools.Library.DatItems
/// Conditions associated with the adjustment /// Conditions associated with the adjustment
/// </summary> /// </summary>
[JsonProperty("conditions")] [JsonProperty("conditions")]
public List<ListXmlCondition> Conditions { get; set; } public List<Condition> Conditions { get; set; }
#endregion #endregion

View File

@@ -15,7 +15,7 @@ namespace SabreTools.Library.DatItems
/// Represents one ListXML analog /// Represents one ListXML analog
/// </summary> /// </summary>
[JsonObject("analog")] [JsonObject("analog")]
public class ListXmlAnalog public class Analog
{ {
[JsonProperty("mask")] [JsonProperty("mask")]
public string Mask { get; set; } public string Mask { get; set; }
@@ -26,7 +26,7 @@ namespace SabreTools.Library.DatItems
/// </summary> /// </summary>
/// TODO: Promote to DatItem level? (Both used at ListXML level AND under a lot of stuff) /// TODO: Promote to DatItem level? (Both used at ListXML level AND under a lot of stuff)
[JsonObject("condition")] [JsonObject("condition")]
public class ListXmlCondition public class Condition
{ {
[JsonProperty("tag")] [JsonProperty("tag")]
public string Tag { get; set; } public string Tag { get; set; }
@@ -41,46 +41,11 @@ namespace SabreTools.Library.DatItems
public string Value { get; set; } public string Value { get; set; }
} }
/// <summary>
/// Represents one ListXML conflocation
/// </summary>
[JsonObject("conflocation")]
public class ListXmlConfLocation
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("inverted")]
public bool? Inverted { get; set; }
}
/// <summary>
/// Represents one ListXML confsetting
/// </summary>
[JsonObject("confsetting")]
public class ListXmlConfSetting
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("value")]
public string Value { get; set; }
[JsonProperty("default")]
public bool? Default { get; set; }
[JsonProperty("conditions")]
public List<ListXmlCondition> Conditions { get; set; }
}
/// <summary> /// <summary>
/// Represents one ListXML control /// Represents one ListXML control
/// </summary> /// </summary>
[JsonObject("control")] [JsonObject("control")]
public class ListXmlControl public class Control
{ {
[JsonProperty("type")] [JsonProperty("type")]
public string Type { get; set; } public string Type { get; set; }
@@ -124,7 +89,7 @@ namespace SabreTools.Library.DatItems
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (doesn't have "name" field?) (contains list) /// TODO: Promote to DatItem level (doesn't have "name" field?) (contains list)
[JsonObject("device")] [JsonObject("device")]
public class ListXmlDevice public class Device
{ {
[JsonProperty("type")] [JsonProperty("type")]
public string Type { get; set; } public string Type { get; set; }
@@ -142,10 +107,10 @@ namespace SabreTools.Library.DatItems
public string Interface { get; set; } public string Interface { get; set; }
[JsonProperty("instances")] [JsonProperty("instances")]
public List<ListXmlInstance> Instances { get; set; } public List<Instance> Instances { get; set; }
[JsonProperty("extensions")] [JsonProperty("extensions")]
public List<ListXmlExtension> Extensions { get; set; } public List<Extension> Extensions { get; set; }
} }
/// <summary> /// <summary>
@@ -153,7 +118,7 @@ namespace SabreTools.Library.DatItems
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (doesn't have "name" field?) /// TODO: Promote to DatItem level (doesn't have "name" field?)
[JsonObject("display")] [JsonObject("display")]
public class ListXmlDisplay public class Display
{ {
[JsonProperty("tag")] [JsonProperty("tag")]
public string Tag { get; set; } public string Tag { get; set; }
@@ -198,48 +163,12 @@ namespace SabreTools.Library.DatItems
public string VBStart { get; set; } // TODO: Int32? Float? public string VBStart { get; set; } // TODO: Int32? Float?
} }
/// <summary>
/// Represents one ListXML diplocation
/// </summary>
[JsonObject("diplocation")]
public class ListXmlDipLocation
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("inverted")]
public bool? Inverted { get; set; }
}
/// <summary>
/// Represents one ListXML dipvalue
/// </summary>
/// <remarks>Also used by SoftwareList</remarks>
[JsonObject("dipvalue")]
public class ListXmlDipValue
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("value")]
public string Value { get; set; }
[JsonProperty("default")]
public bool? Default { get; set; }
[JsonProperty("conditions")]
public List<ListXmlCondition> Conditions { get; set; }
}
/// <summary> /// <summary>
/// Represents one ListXML driver /// Represents one ListXML driver
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (doesn't have "name" field?) /// TODO: Promote to DatItem level (doesn't have "name" field?)
[JsonObject("driver")] [JsonObject("driver")]
public class ListXmlDriver public class Driver
{ {
[JsonProperty("status")] [JsonProperty("status")]
public string Status { get; set; } // TODO: (good|imperfect|preliminary) public string Status { get; set; } // TODO: (good|imperfect|preliminary)
@@ -258,7 +187,7 @@ namespace SabreTools.Library.DatItems
/// Represents one ListXML extension /// Represents one ListXML extension
/// </summary> /// </summary>
[JsonObject("extension")] [JsonObject("extension")]
public class ListXmlExtension public class Extension
{ {
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
@@ -269,7 +198,7 @@ namespace SabreTools.Library.DatItems
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (doesn't have "name" field?) /// TODO: Promote to DatItem level (doesn't have "name" field?)
[JsonObject("feature")] [JsonObject("feature")]
public class ListXmlFeature public class Feature
{ {
[JsonProperty("type")] [JsonProperty("type")]
public string Type { get; set; } // TODO: (protection|palette|graphics|sound|controls|keyboard|mouse|microphone|camera|disk|printer|lan|wan|timing) public string Type { get; set; } // TODO: (protection|palette|graphics|sound|controls|keyboard|mouse|microphone|camera|disk|printer|lan|wan|timing)
@@ -286,7 +215,7 @@ namespace SabreTools.Library.DatItems
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (doesn't have "name" field?) (contains list) /// TODO: Promote to DatItem level (doesn't have "name" field?) (contains list)
[JsonObject("input")] [JsonObject("input")]
public class ListXmlInput public class Input
{ {
[JsonProperty("service")] [JsonProperty("service")]
public bool? Service { get; set; } public bool? Service { get; set; }
@@ -301,14 +230,14 @@ namespace SabreTools.Library.DatItems
public string Coins { get; set; } // TODO: Int32? public string Coins { get; set; } // TODO: Int32?
[JsonProperty("controls")] [JsonProperty("controls")]
public List<ListXmlControl> Controls { get; set; } public List<Control> Controls { get; set; }
} }
/// <summary> /// <summary>
/// Represents one ListXML instance /// Represents one ListXML instance
/// </summary> /// </summary>
[JsonObject("instance")] [JsonObject("instance")]
public class ListXmlInstance public class Instance
{ {
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
@@ -317,39 +246,60 @@ namespace SabreTools.Library.DatItems
public string BriefName { get; set; } public string BriefName { get; set; }
} }
/// <summary>
/// Represents one ListXML conflocation or diplocation
/// </summary>
[JsonObject("location")]
public class Location
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("inverted")]
public bool? Inverted { get; set; }
}
/// <summary> /// <summary>
/// Represents one ListXML port /// Represents one ListXML port
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (doesn't have "name" field?) (contains list) /// TODO: Promote to DatItem level (doesn't have "name" field?) (contains list)
[JsonObject("port")] [JsonObject("port")]
public class ListXmlPort public class Port
{ {
[JsonProperty("tag")] [JsonProperty("tag")]
public string Tag { get; set; } public string Tag { get; set; }
[JsonProperty("analogs")] [JsonProperty("analogs")]
public List<ListXmlAnalog> Analogs { get; set; } public List<Analog> Analogs { get; set; }
} }
/// <summary> /// <summary>
/// Represents one ListXML slot /// Represents one ListXML confsetting or dipvalue
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (contains list) [JsonObject("setting")]
[JsonObject("slot")] public class Setting
public class ListXmlSlot
{ {
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty("slotoptions")] [JsonProperty("value")]
public List<ListXmlSlotOption> SlotOptions { get; set; } public string Value { get; set; }
[JsonProperty("default")]
public bool? Default { get; set; }
[JsonProperty("conditions")]
public List<Condition> Conditions { get; set; }
} }
/// <summary> /// <summary>
/// Represents one ListXML slotoption /// Represents one ListXML slotoption
/// </summary> /// </summary>
[JsonObject("slotoption")] [JsonObject("slotoption")]
public class ListXmlSlotOption public class SlotOption
{ {
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
@@ -366,7 +316,7 @@ namespace SabreTools.Library.DatItems
/// </summary> /// </summary>
/// TODO: Promote to DatItem level (doesn't have "name" field?) /// TODO: Promote to DatItem level (doesn't have "name" field?)
[JsonObject("sound")] [JsonObject("sound")]
public class ListXmlSound public class Sound
{ {
[JsonProperty("channels")] [JsonProperty("channels")]
public string Channels { get; set; } // TODO: Int32? public string Channels { get; set; } // TODO: Int32?

View File

@@ -30,19 +30,19 @@ namespace SabreTools.Library.DatItems
/// Conditions associated with the configuration /// Conditions associated with the configuration
/// </summary> /// </summary>
[JsonProperty("conditions")] [JsonProperty("conditions")]
public List<ListXmlCondition> Conditions { get; set; } public List<Condition> Conditions { get; set; }
/// <summary> /// <summary>
/// Locations associated with the configuration /// Locations associated with the configuration
/// </summary> /// </summary>
[JsonProperty("locations")] [JsonProperty("locations")]
public List<ListXmlConfLocation> Locations { get; set; } public List<Location> Locations { get; set; }
/// <summary> /// <summary>
/// Settings associated with the configuration /// Settings associated with the configuration
/// </summary> /// </summary>
[JsonProperty("settings")] [JsonProperty("settings")]
public List<ListXmlConfSetting> Settings { get; set; } public List<Setting> Settings { get; set; }
#endregion #endregion

View File

@@ -289,6 +289,12 @@ namespace SabreTools.Library.DatItems
// Ram Option // Ram Option
Field.DatItem_Content, Field.DatItem_Content,
// Slot.SlotOptions
Field.DatItem_SlotOptions,
Field.DatItem_SlotOption_Name,
Field.DatItem_SlotOption_DeviceName,
Field.DatItem_SlotOption_Default,
// Release // Release
Field.DatItem_Language, Field.DatItem_Language,
@@ -327,7 +333,6 @@ namespace SabreTools.Library.DatItems
// ListXML // ListXML
Field.Machine_SourceFile, Field.Machine_SourceFile,
Field.Machine_Runnable, Field.Machine_Runnable,
Field.Machine_Slots,
Field.Machine_Infos, Field.Machine_Infos,
// Logiqx // Logiqx
@@ -497,6 +502,9 @@ namespace SabreTools.Library.DatItems
case ItemType.Sample: case ItemType.Sample:
return new Sample(); return new Sample();
case ItemType.Slot:
return new Slot();
case ItemType.SoftwareList: case ItemType.SoftwareList:
return new SoftwareList(); return new SoftwareList();

View File

@@ -30,19 +30,19 @@ namespace SabreTools.Library.DatItems
/// Conditions associated with the dipswitch /// Conditions associated with the dipswitch
/// </summary> /// </summary>
[JsonProperty("conditions")] [JsonProperty("conditions")]
public List<ListXmlCondition> Conditions { get; set; } public List<Condition> Conditions { get; set; }
/// <summary> /// <summary>
/// Locations associated with the dipswitch /// Locations associated with the dipswitch
/// </summary> /// </summary>
[JsonProperty("locations")] [JsonProperty("locations")]
public List<ListXmlDipLocation> Locations { get; set; } public List<Location> Locations { get; set; }
/// <summary> /// <summary>
/// Settings associated with the dipswitch /// Settings associated with the dipswitch
/// </summary> /// </summary>
[JsonProperty("values")] [JsonProperty("values")]
public List<ListXmlDipValue> Values { get; set; } public List<Setting> Values { get; set; }
#endregion #endregion

View File

@@ -217,16 +217,6 @@ namespace SabreTools.Library.DatItems
Machine_Device_Extensions, Machine_Device_Extensions,
Machine_Device_Extension_Name, Machine_Device_Extension_Name,
// Slots
Machine_Slots,
Machine_Slot_Name,
// Slots.SlotOptions
Machine_Slot_SlotOptions,
Machine_Slot_SlotOption_Name,
Machine_Slot_SlotOption_DeviceName,
Machine_Slot_SlotOption_Default,
#endregion #endregion
#region Logiqx #region Logiqx
@@ -398,6 +388,12 @@ namespace SabreTools.Library.DatItems
// Release // Release
DatItem_Language, DatItem_Language,
// Slot.SlotOptions
DatItem_SlotOptions,
DatItem_SlotOption_Name,
DatItem_SlotOption_DeviceName,
DatItem_SlotOption_Default,
// Software List // Software List
DatItem_SoftwareListStatus, DatItem_SoftwareListStatus,
DatItem_Filter, DatItem_Filter,
@@ -448,6 +444,7 @@ namespace SabreTools.Library.DatItems
RamOption, RamOption,
Release, Release,
Sample, Sample,
Slot,
SoftwareList, SoftwareList,
Blank = 99, // This is not a real type, only used internally Blank = 99, // This is not a real type, only used internally

View File

@@ -156,55 +156,49 @@ namespace SabreTools.Library.DatItems
/// List of associated displays /// List of associated displays
/// </summary> /// </summary>
[JsonProperty("displays", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("displays", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlDisplay> Displays { get; set; } = null; public List<Display> Displays { get; set; } = null;
/// <summary> /// <summary>
/// List of associated sounds /// List of associated sounds
/// </summary> /// </summary>
[JsonProperty("sounds", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("sounds", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlSound> Sounds { get; set; } = null; public List<Sound> Sounds { get; set; } = null;
/// <summary> /// <summary>
/// List of associated conditions /// List of associated conditions
/// </summary> /// </summary>
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlCondition> Conditions { get; set; } = null; public List<Condition> Conditions { get; set; } = null;
/// <summary> /// <summary>
/// List of associated inputs /// List of associated inputs
/// </summary> /// </summary>
[JsonProperty("inputs", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("inputs", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlInput> Inputs { get; set; } = null; public List<Input> Inputs { get; set; } = null;
/// <summary> /// <summary>
/// List of associated ports /// List of associated ports
/// </summary> /// </summary>
[JsonProperty("ports", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("ports", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlPort> Ports { get; set; } = null; public List<Port> Ports { get; set; } = null;
/// <summary> /// <summary>
/// List of associated drivers /// List of associated drivers
/// </summary> /// </summary>
[JsonProperty("drivers", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("drivers", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlDriver> Drivers { get; set; } = null; public List<Driver> Drivers { get; set; } = null;
/// <summary> /// <summary>
/// List of associated features /// List of associated features
/// </summary> /// </summary>
[JsonProperty("features", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("features", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlFeature> Features { get; set; } = null; public List<Feature> Features { get; set; } = null;
/// <summary> /// <summary>
/// List of associated devices /// List of associated devices
/// </summary> /// </summary>
[JsonProperty("devices", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("devices", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlDevice> Devices { get; set; } = null; public List<Device> Devices { get; set; } = null;
/// <summary>
/// List of slot options
/// </summary>
[JsonProperty("slots", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<ListXmlSlot> Slots { get; set; } = null;
#endregion #endregion
@@ -566,7 +560,6 @@ namespace SabreTools.Library.DatItems
Drivers = this.Drivers, Drivers = this.Drivers,
Features = this.Features, Features = this.Features,
Devices = this.Devices, Devices = this.Devices,
Slots = this.Slots,
#endregion #endregion
@@ -1456,9 +1449,6 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.Machine_Runnable)) if (fields.Contains(Field.Machine_Runnable))
Runnable = Runnable.NULL; Runnable = Runnable.NULL;
if (fields.Contains(Field.Machine_Slots))
Slots = null;
if (fields.Contains(Field.Machine_Infos)) if (fields.Contains(Field.Machine_Infos))
Infos = null; Infos = null;
@@ -1615,9 +1605,6 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.Machine_Runnable)) if (fields.Contains(Field.Machine_Runnable))
Runnable = machine.Runnable; Runnable = machine.Runnable;
if (fields.Contains(Field.Machine_Slots))
Slots = machine.Slots;
if (fields.Contains(Field.Machine_Infos)) if (fields.Contains(Field.Machine_Infos))
Infos = machine.Infos; Infos = machine.Infos;

View File

@@ -0,0 +1,174 @@
using System.Collections.Generic;
using SabreTools.Library.Filtering;
using Newtonsoft.Json;
namespace SabreTools.Library.DatItems
{
/// <summary>
/// Represents which Slot(s) is associated with a set
/// </summary>
[JsonObject("slot")]
public class Slot : DatItem
{
#region Fields
/// <summary>
/// Slot options associated with the slot
/// </summary>
[JsonProperty("slotoptions")]
public List<SlotOption> SlotOptions { get; set; }
#endregion
#region Accessors
/// <summary>
/// Set fields with given values
/// </summary>
/// <param name="mappings">Mappings dictionary</param>
public override void SetFields(Dictionary<Field, string> mappings)
{
// Set base fields
base.SetFields(mappings);
// Handle Slot-specific fields
// TODO: Handle DatItem_SlotOption*
}
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Slot object
/// </summary>
public Slot()
{
Name = string.Empty;
ItemType = ItemType.Slot;
}
#endregion
#region Cloning Methods
public override object Clone()
{
return new Slot()
{
Name = this.Name,
ItemType = this.ItemType,
DupeType = this.DupeType,
AltName = this.AltName,
AltTitle = this.AltTitle,
Original = this.Original,
OpenMSXSubType = this.OpenMSXSubType,
OpenMSXType = this.OpenMSXType,
Remark = this.Remark,
Boot = this.Boot,
Part = this.Part,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
AreaWidth = this.AreaWidth,
AreaEndianness = this.AreaEndianness,
Value = this.Value,
LoadFlag = this.LoadFlag,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
SlotOptions = this.SlotOptions,
};
}
#endregion
#region Comparision Methods
public override bool Equals(DatItem other)
{
// If we don't have a Slot, return false
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Slot
Slot newOther = other as Slot;
// If the Slot information matches
return (Name == newOther.Name); // TODO: Handle DatItem_SlotOption*
}
#endregion
#region Filtering
/// <summary>
/// Check to see if a DatItem passes the filter
/// </summary>
/// <param name="filter">Filter to check against</param>
/// <returns>True if the item passed the filter, false otherwise</returns>
public override bool PassesFilter(Filter filter)
{
// Check common fields first
if (!base.PassesFilter(filter))
return false;
// TODO: Handle DatItem_SlotOption*
return true;
}
/// <summary>
/// Remove fields from the DatItem
/// </summary>
/// <param name="fields">List of Fields to remove</param>
public override void RemoveFields(List<Field> fields)
{
// Remove common fields first
base.RemoveFields(fields);
// Remove the fields
if (fields.Contains(Field.DatItem_SlotOptions))
SlotOptions = null;
// TODO: Handle DatItem_SlotOption*
}
#endregion
#region Sorting and Merging
/// <summary>
/// Replace fields from another item
/// </summary>
/// <param name="item">DatItem to pull new information from</param>
/// <param name="fields">List of Fields representing what should be updated</param>
public override void ReplaceFields(DatItem item, List<Field> fields)
{
// Replace common fields first
base.ReplaceFields(item, fields);
// If we don't have a Slot to replace from, ignore specific fields
if (item.ItemType != ItemType.Slot)
return;
// Cast for easier access
Slot newItem = item as Slot;
// Replace the fields
if (fields.Contains(Field.DatItem_SlotOptions))
SlotOptions = newItem.SlotOptions;
// TODO: Handle DatItem_SlotOption*
}
#endregion
}
}

View File

@@ -139,16 +139,6 @@ namespace SabreTools.Library.Filtering
public FilterItem<bool?> Machine_Device_Extensions { get; private set; } = new FilterItem<bool?>() { Neutral = null }; public FilterItem<bool?> Machine_Device_Extensions { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Machine_Device_Extension_Name { get; private set; } = new FilterItem<string>(); public FilterItem<string> Machine_Device_Extension_Name { get; private set; } = new FilterItem<string>();
// Slots
public FilterItem<bool?> Machine_Slots { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Machine_Slot_Name { get; private set; } = new FilterItem<string>();
// Slots.SlotOptions
public FilterItem<bool?> Machine_Slot_SlotOptions { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Machine_Slot_SlotOption_Name { get; private set; } = new FilterItem<string>();
public FilterItem<string> Machine_Slot_SlotOption_DeviceName { get; private set; } = new FilterItem<string>();
public FilterItem<bool?> Machine_Slot_SlotOption_Default { get; private set; } = new FilterItem<bool?>() { Neutral = null };
#endregion #endregion
#region Logiqx #region Logiqx
@@ -320,6 +310,12 @@ namespace SabreTools.Library.Filtering
// Release // Release
public FilterItem<string> DatItem_Language { get; private set; } = new FilterItem<string>(); public FilterItem<string> DatItem_Language { get; private set; } = new FilterItem<string>();
// Slots.SlotOptions
public FilterItem<bool?> DatItem_SlotOptions { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> DatItem_SlotOption_Name { get; private set; } = new FilterItem<string>();
public FilterItem<string> DatItem_SlotOption_DeviceName { get; private set; } = new FilterItem<string>();
public FilterItem<bool?> DatItem_SlotOption_Default { get; private set; } = new FilterItem<bool?>() { Neutral = null };
// Software List // Software List
public FilterItem<SoftwareListStatus> DatItem_SoftwareListStatus { get; private set; } = new FilterItem<SoftwareListStatus>() { Positive = SoftwareListStatus.NULL, Negative = SoftwareListStatus.NULL }; public FilterItem<SoftwareListStatus> DatItem_SoftwareListStatus { get; private set; } = new FilterItem<SoftwareListStatus>() { Positive = SoftwareListStatus.NULL, Negative = SoftwareListStatus.NULL };
public FilterItem<string> DatItem_Filter { get; private set; } = new FilterItem<string>(); public FilterItem<string> DatItem_Filter { get; private set; } = new FilterItem<string>();
@@ -1011,50 +1007,6 @@ namespace SabreTools.Library.Filtering
Machine_Device_Extension_Name.PositiveSet.Add(value); Machine_Device_Extension_Name.PositiveSet.Add(value);
break; break;
// Slots
case Field.Machine_Slots:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
Machine_Slots.Neutral = false;
else
Machine_Slots.Neutral = true;
break;
case Field.Machine_Slot_Name:
if (negate)
Machine_Slot_Name.NegativeSet.Add(value);
else
Machine_Slot_Name.PositiveSet.Add(value);
break;
// Slots.SlotOptions
case Field.Machine_Slot_SlotOptions:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
Machine_Slot_SlotOptions.Neutral = false;
else
Machine_Slot_SlotOptions.Neutral = true;
break;
case Field.Machine_Slot_SlotOption_Name:
if (negate)
Machine_Slot_SlotOption_Name.NegativeSet.Add(value);
else
Machine_Slot_SlotOption_Name.PositiveSet.Add(value);
break;
case Field.Machine_Slot_SlotOption_DeviceName:
if (negate)
Machine_Slot_SlotOption_DeviceName.NegativeSet.Add(value);
else
Machine_Slot_SlotOption_DeviceName.PositiveSet.Add(value);
break;
case Field.Machine_Slot_SlotOption_Default:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
Machine_Slot_SlotOption_Default.Neutral = false;
else
Machine_Slot_SlotOption_Default.Neutral = true;
break;
#endregion #endregion
#region Logiqx #region Logiqx
@@ -1806,6 +1758,35 @@ namespace SabreTools.Library.Filtering
DatItem_Language.PositiveSet.Add(value); DatItem_Language.PositiveSet.Add(value);
break; break;
// Slots.SlotOptions
case Field.DatItem_SlotOptions:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
DatItem_SlotOptions.Neutral = false;
else
DatItem_SlotOptions.Neutral = true;
break;
case Field.DatItem_SlotOption_Name:
if (negate)
DatItem_SlotOption_Name.NegativeSet.Add(value);
else
DatItem_SlotOption_Name.PositiveSet.Add(value);
break;
case Field.DatItem_SlotOption_DeviceName:
if (negate)
DatItem_SlotOption_DeviceName.NegativeSet.Add(value);
else
DatItem_SlotOption_DeviceName.PositiveSet.Add(value);
break;
case Field.DatItem_SlotOption_Default:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
DatItem_SlotOption_Default.Neutral = false;
else
DatItem_SlotOption_Default.Neutral = true;
break;
// Software List // Software List
case Field.DatItem_SoftwareListStatus: case Field.DatItem_SoftwareListStatus:
if (negate) if (negate)

View File

@@ -647,24 +647,6 @@ namespace SabreTools.Library.Tools
case "device_extension_name": case "device_extension_name":
return Field.Machine_Device_Extension_Name; return Field.Machine_Device_Extension_Name;
case "slots":
return Field.Machine_Slots;
case "slot_name":
return Field.Machine_Slot_Name;
case "slot_slotoptions":
return Field.Machine_Slot_SlotOptions;
case "slot_slotoption_name":
return Field.Machine_Slot_SlotOption_Name;
case "slot_slotoption_devicename":
return Field.Machine_Slot_SlotOption_DeviceName;
case "slot_slotoption_default":
return Field.Machine_Slot_SlotOption_Default;
#endregion #endregion
#region Logiqx #region Logiqx
@@ -1046,6 +1028,19 @@ namespace SabreTools.Library.Tools
case "language": case "language":
return Field.DatItem_Language; return Field.DatItem_Language;
// Slot
case "slotoptions":
return Field.DatItem_SlotOptions;
case "slotoption_name":
return Field.DatItem_SlotOption_Name;
case "slotoption_devicename":
return Field.DatItem_SlotOption_DeviceName;
case "slotoption_default":
return Field.DatItem_SlotOption_Default;
// Software List // Software List
case "softwareliststatus": case "softwareliststatus":
case "softwarelist_status": case "softwarelist_status":
@@ -1172,11 +1167,6 @@ namespace SabreTools.Library.Tools
case "runnable": case "runnable":
return Field.Machine_Runnable; return Field.Machine_Runnable;
case "slotoptions":
case "slot options":
case "slot-options":
return Field.Machine_Slots;
case "infos": case "infos":
return Field.Machine_Infos; return Field.Machine_Infos;
@@ -1589,6 +1579,8 @@ namespace SabreTools.Library.Tools
return ItemType.Rom; return ItemType.Rom;
case "sample": case "sample":
return ItemType.Sample; return ItemType.Sample;
case "slot":
return ItemType.Slot;
case "softwarelist": case "softwarelist":
return ItemType.SoftwareList; return ItemType.SoftwareList;
default: default:
@@ -1611,6 +1603,7 @@ namespace SabreTools.Library.Tools
"release" => ItemType.Release, "release" => ItemType.Release,
"rom" => ItemType.Rom, "rom" => ItemType.Rom,
"sample" => ItemType.Sample, "sample" => ItemType.Sample,
"slot" => ItemType.Slot,
"softwarelist" => ItemType.SoftwareList, "softwarelist" => ItemType.SoftwareList,
_ => null, _ => null,
}; };
@@ -2031,6 +2024,8 @@ namespace SabreTools.Library.Tools
return "rom"; return "rom";
case ItemType.Sample: case ItemType.Sample:
return "sample"; return "sample";
case ItemType.Slot:
return "slot";
case ItemType.SoftwareList: case ItemType.SoftwareList:
return "softwarelist"; return "softwarelist";
default: default:
@@ -2053,6 +2048,7 @@ namespace SabreTools.Library.Tools
ItemType.Release => "release", ItemType.Release => "release",
ItemType.Rom => "rom", ItemType.Rom => "rom",
ItemType.Sample => "sample", ItemType.Sample => "sample",
ItemType.Slot => "slot",
ItemType.SoftwareList => "softwarelist", ItemType.SoftwareList => "softwarelist",
_ => null, _ => null,
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -43,10 +43,10 @@ Add new output format(s): format(datformat, ...);
Set the output directory: output(outdir); Set the output directory: output(outdir);
Write the internal items: write([overwrite = true]); Write the internal items: write([overwrite = true]);
Reset the internal state: reset();"; Reset the internal state: reset();";
Features = new Dictionary<string, Feature>(); Features = new Dictionary<string, Library.Help.Feature>();
} }
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, Library.Help.Feature> features)
{ {
base.ProcessFeatures(features); base.ProcessFeatures(features);

View File

@@ -21,7 +21,7 @@ namespace SabreTools.Features
Description = "Split input DATs by a given criteria"; Description = "Split input DATs by a given criteria";
_featureType = FeatureType.Flag; _featureType = FeatureType.Flag;
LongDescription = "This feature allows the user to split input DATs by a number of different possible criteria. See the individual input information for details. More than one split type is allowed at a time."; LongDescription = "This feature allows the user to split input DATs by a number of different possible criteria. See the individual input information for details. More than one split type is allowed at a time.";
Features = new Dictionary<string, Feature>(); Features = new Dictionary<string, Library.Help.Feature>();
AddFeature(OutputTypeListInput); AddFeature(OutputTypeListInput);
this[OutputTypeListInput].AddFeature(DeprecatedFlag); this[OutputTypeListInput].AddFeature(DeprecatedFlag);
@@ -39,7 +39,7 @@ namespace SabreTools.Features
AddFeature(TypeFlag); AddFeature(TypeFlag);
} }
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, Library.Help.Feature> features)
{ {
base.ProcessFeatures(features); base.ProcessFeatures(features);
SplittingMode splittingMode = GetSplittingMode(features); SplittingMode splittingMode = GetSplittingMode(features);

View File

@@ -23,7 +23,7 @@ namespace SabreTools.Features
Description = "Update and manipulate DAT(s)"; Description = "Update and manipulate DAT(s)";
_featureType = FeatureType.Flag; _featureType = FeatureType.Flag;
LongDescription = "This is the multitool part of the program, allowing for almost every manipulation to a DAT, or set of DATs. This is also a combination of many different programs that performed DAT manipulation that work better together."; LongDescription = "This is the multitool part of the program, allowing for almost every manipulation to a DAT, or set of DATs. This is also a combination of many different programs that performed DAT manipulation that work better together.";
Features = new Dictionary<string, Feature>(); Features = new Dictionary<string, Library.Help.Feature>();
// Output Formats // Output Formats
AddFeature(OutputTypeListInput); AddFeature(OutputTypeListInput);
@@ -98,7 +98,7 @@ namespace SabreTools.Features
AddFeature(ThreadsInt32Input); AddFeature(ThreadsInt32Input);
} }
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, Library.Help.Feature> features)
{ {
base.ProcessFeatures(features); base.ProcessFeatures(features);