Support more AttractMode fields

This commit is contained in:
Matt Nadareski
2020-08-20 14:36:36 -07:00
parent a33d88aab3
commit 4a6a3699e7
7 changed files with 770 additions and 251 deletions

View File

@@ -88,7 +88,15 @@ namespace SabreTools.Library.DatFiles
CloneOf = gameinfo[3],
Year = gameinfo[4],
Manufacturer = gameinfo[5],
Category = gameinfo[6],
Players = gameinfo[7],
Rotation = gameinfo[8],
Control = gameinfo[9],
Status = gameinfo[10],
DisplayCount = gameinfo[11],
DisplayType = gameinfo[12],
Comment = gameinfo[15],
Buttons = gameinfo[16],
},
Source = new Source
@@ -262,17 +270,17 @@ namespace SabreTools.Library.DatFiles
datItem.GetField(Field.CloneOf, Header.ExcludeFields),
datItem.GetField(Field.Year, Header.ExcludeFields),
datItem.GetField(Field.Manufacturer, Header.ExcludeFields),
string.Empty, // datItem.GetField(Field.Category, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.Players, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.Rotation, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.Control, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.Status, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.DisplayCount, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.DisplayType, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.AltRomname, DatHeader.ExcludeFields)
string.Empty, // datItem.GetField(Field.AltTitle, DatHeader.ExcludeFields)
datItem.GetField(Field.Category, Header.ExcludeFields),
datItem.GetField(Field.Players, Header.ExcludeFields),
datItem.GetField(Field.Rotation, Header.ExcludeFields),
datItem.GetField(Field.Control, Header.ExcludeFields),
datItem.GetField(Field.Status, Header.ExcludeFields),
datItem.GetField(Field.DisplayCount, Header.ExcludeFields),
datItem.GetField(Field.DisplayType, Header.ExcludeFields),
string.Empty, // datItem.GetField(Field.AltRomname, Header.ExcludeFields),
string.Empty, // datItem.GetField(Field.AltTitle, Header.ExcludeFields),
datItem.GetField(Field.Comment, Header.ExcludeFields),
string.Empty, // datItem.GetField(Field.Buttons, DatHeader.ExcludeFields)
datItem.GetField(Field.Buttons, Header.ExcludeFields),
};
svw.WriteValues(fields);

View File

@@ -293,66 +293,71 @@ namespace SabreTools.Library.DatFiles
switch (jtr.Value)
{
// Common
case "name":
machine.Name = jtr.ReadAsString();
break;
case "comment":
machine.Comment = jtr.ReadAsString();
break;
case "description":
machine.Description = jtr.ReadAsString();
break;
case "year":
machine.Year = jtr.ReadAsString();
break;
case "manufacturer":
machine.Manufacturer = jtr.ReadAsString();
break;
case "publisher":
machine.Publisher = jtr.ReadAsString();
break;
case "category":
machine.Category = jtr.ReadAsString();
break;
case "romof":
machine.RomOf = jtr.ReadAsString();
break;
case "cloneof":
machine.CloneOf = jtr.ReadAsString();
break;
case "sampleof":
machine.SampleOf = jtr.ReadAsString();
break;
case "supported":
machine.Supported = jtr.ReadAsString().AsYesNo();
case "items":
ReadItems(sr, jtr, filename, indexId, machine);
break;
// AttractMode
case "players":
machine.Players = jtr.ReadAsString();
break;
case "rotation":
machine.Rotation = jtr.ReadAsString();
break;
case "control":
machine.Control = jtr.ReadAsString();
break;
case "status":
machine.Status = jtr.ReadAsString();
break;
case "displaycount":
machine.DisplayCount = jtr.ReadAsString();
break;
case "displaytype":
machine.DisplayType = jtr.ReadAsString();
break;
case "buttons":
machine.Buttons = jtr.ReadAsString();
break;
// ListXML
case "sourcefile":
machine.SourceFile = jtr.ReadAsString();
break;
case "runnable":
machine.Runnable = jtr.ReadAsString().AsYesNo();
break;
case "board":
machine.Board = jtr.ReadAsString();
break;
case "rebuildto":
machine.RebuildTo = jtr.ReadAsString();
break;
case "devices":
machine.Devices = new List<string>();
jtr.Read(); // Start Array
@@ -362,7 +367,6 @@ namespace SabreTools.Library.DatFiles
}
break;
case "slotoptions":
machine.SlotOptions = new List<string>();
jtr.Read(); // Start Array
@@ -372,7 +376,6 @@ namespace SabreTools.Library.DatFiles
}
break;
case "infos":
machine.Infos = new List<KeyValuePair<string, string>>();
jtr.Read(); // Start Array
@@ -391,21 +394,18 @@ namespace SabreTools.Library.DatFiles
}
break;
case "isbios":
string isbios = jtr.ReadAsString();
if (string.Equals(isbios, "yes", StringComparison.OrdinalIgnoreCase))
machine.MachineType &= MachineType.Bios;
break;
case "isdevice":
string isdevice = jtr.ReadAsString();
if (string.Equals(isdevice, "yes", StringComparison.OrdinalIgnoreCase))
machine.MachineType &= MachineType.Device;
break;
case "ismechanical":
string ismechanical = jtr.ReadAsString();
if (string.Equals(ismechanical, "yes", StringComparison.OrdinalIgnoreCase))
@@ -413,8 +413,17 @@ namespace SabreTools.Library.DatFiles
break;
case "items":
ReadItems(sr, jtr, filename, indexId, machine);
// Logiqx
case "board":
machine.Board = jtr.ReadAsString();
break;
case "rebuildto":
machine.RebuildTo = jtr.ReadAsString();
break;
// SoftwareList
case "supported":
machine.Supported = jtr.ReadAsString().AsYesNo();
break;
default:
@@ -1001,6 +1010,7 @@ namespace SabreTools.Library.DatFiles
// Build the state based on excluded fields
jtw.WriteStartObject();
// Common
jtw.WritePropertyName("name");
jtw.WriteValue(datItem.GetField(Field.MachineName, Header.ExcludeFields));
@@ -1049,19 +1059,45 @@ namespace SabreTools.Library.DatFiles
jtw.WritePropertyName("sampleof");
jtw.WriteValue(datItem.Machine.SampleOf);
}
if (!Header.ExcludeFields.Contains(Field.Supported) && datItem.Machine.Supported != null)
// AttractMode
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Players, Header.ExcludeFields)))
{
if (datItem.Machine.Supported == true)
jtw.WritePropertyName("players");
jtw.WriteValue(datItem.Machine.Players);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Rotation, Header.ExcludeFields)))
{
jtw.WritePropertyName("supported");
jtw.WriteValue("yes");
jtw.WritePropertyName("rotation");
jtw.WriteValue(datItem.Machine.Rotation);
}
else if (datItem.Machine.Supported == false)
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Control, Header.ExcludeFields)))
{
jtw.WritePropertyName("supported");
jtw.WriteValue("no");
jtw.WritePropertyName("control");
jtw.WriteValue(datItem.Machine.Control);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SupportStatus, Header.ExcludeFields)))
{
jtw.WritePropertyName("status");
jtw.WriteValue(datItem.Machine.Status);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.DisplayCount, Header.ExcludeFields)))
{
jtw.WritePropertyName("displaycount");
jtw.WriteValue(datItem.Machine.DisplayCount);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.DisplayType, Header.ExcludeFields)))
{
jtw.WritePropertyName("displaytype");
jtw.WriteValue(datItem.Machine.DisplayType);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Buttons, Header.ExcludeFields)))
{
jtw.WritePropertyName("buttons");
jtw.WriteValue(datItem.Machine.Buttons);
}
// ListXML
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, Header.ExcludeFields)))
{
jtw.WritePropertyName("sourcefile");
@@ -1080,16 +1116,6 @@ namespace SabreTools.Library.DatFiles
jtw.WriteValue("no");
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Board, Header.ExcludeFields)))
{
jtw.WritePropertyName("board");
jtw.WriteValue(datItem.Machine.Board);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RebuildTo, Header.ExcludeFields)))
{
jtw.WritePropertyName("rebuildto");
jtw.WriteValue(datItem.Machine.RebuildTo);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Devices, Header.ExcludeFields)))
{
jtw.WritePropertyName("devices");
@@ -1145,6 +1171,33 @@ namespace SabreTools.Library.DatFiles
}
}
// Logiqx
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Board, Header.ExcludeFields)))
{
jtw.WritePropertyName("board");
jtw.WriteValue(datItem.Machine.Board);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RebuildTo, Header.ExcludeFields)))
{
jtw.WritePropertyName("rebuildto");
jtw.WriteValue(datItem.Machine.RebuildTo);
}
// SoftwareList
if (!Header.ExcludeFields.Contains(Field.Supported) && datItem.Machine.Supported != null)
{
if (datItem.Machine.Supported == true)
{
jtw.WritePropertyName("supported");
jtw.WriteValue("yes");
}
else if (datItem.Machine.Supported == false)
{
jtw.WritePropertyName("supported");
jtw.WriteValue("no");
}
}
jtw.WritePropertyName("items");
jtw.WriteStartArray();

View File

@@ -147,6 +147,7 @@ namespace SabreTools.Library.DatItems
/// </summary>
public static readonly List<Field> MachineFields = new List<Field>()
{
// Common
Field.MachineName,
Field.Comment,
Field.Description,
@@ -156,15 +157,30 @@ namespace SabreTools.Library.DatItems
Field.RomOf,
Field.CloneOf,
Field.SampleOf,
Field.Supported,
// AttractMode
Field.Players,
Field.Rotation,
Field.Control,
Field.SupportStatus,
Field.DisplayCount,
Field.DisplayType,
Field.Buttons,
// ListXML
Field.SourceFile,
Field.Runnable,
Field.Board,
Field.RebuildTo,
Field.Devices,
Field.SlotOptions,
Field.Infos,
Field.MachineType,
// Logiqx
Field.Board,
Field.RebuildTo,
// SoftwareList
Field.Supported,
};
#endregion

View File

@@ -24,16 +24,9 @@ namespace SabreTools.Library.DatItems
{
NULL = 0,
// Generic DatItem
ItemType,
Name,
PartName,
PartInterface,
Features,
AreaName,
AreaSize,
#region Machine
// Machine
// Common Machine
MachineName,
Comment,
Description,
@@ -44,16 +37,44 @@ namespace SabreTools.Library.DatItems
RomOf,
CloneOf,
SampleOf,
Supported,
// AttractMode Machine
Players,
Rotation,
Control,
SupportStatus,
DisplayCount,
DisplayType,
Buttons,
// ListXML Machine
SourceFile,
Runnable,
Board,
RebuildTo,
Devices,
SlotOptions,
Infos,
MachineType,
// Logiqx Machine
Board,
RebuildTo,
// SoftwareList Machine
Supported,
#endregion
#region DatItem
// Common DatItem
ItemType,
Name,
PartName,
PartInterface,
Features,
AreaName,
AreaSize,
// BiosSet
Default,
BiosDescription,
@@ -84,6 +105,8 @@ namespace SabreTools.Library.DatItems
CRC,
Offset,
Inverted,
#endregion
}
/// <summary>

View File

@@ -14,121 +14,183 @@ namespace SabreTools.Library.DatItems
{
#region Fields
#region Common Fields
/// <summary>
/// Name of the machine
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }
public string Name { get; set; } = null;
/// <summary>
/// Additional notes
/// </summary>
[JsonProperty("comment")]
public string Comment { get; set; }
public string Comment { get; set; } = null;
/// <summary>
/// Extended description
/// </summary>
[JsonProperty("description")]
public string Description { get; set; }
public string Description { get; set; } = null;
/// <summary>
/// Year(s) of release/manufacture
/// </summary>
[JsonProperty("year")]
public string Year { get; set; }
public string Year { get; set; } = null;
/// <summary>
/// Manufacturer, if available
/// </summary>
[JsonProperty("manufacturer")]
public string Manufacturer { get; set; }
public string Manufacturer { get; set; } = null;
/// <summary>
/// Publisher, if available
/// </summary>
[JsonProperty("publisher")]
public string Publisher { get; set; }
public string Publisher { get; set; } = null;
/// <summary>
/// Category, if available
/// </summary>
[JsonProperty("category")]
public string Category { get; set; }
public string Category { get; set; } = null;
/// <summary>
/// fomof parent
/// </summary>
[JsonProperty("romof")]
public string RomOf { get; set; }
public string RomOf { get; set; } = null;
/// <summary>
/// cloneof parent
/// </summary>
[JsonProperty("cloneof")]
public string CloneOf { get; set; }
public string CloneOf { get; set; } = null;
/// <summary>
/// sampleof parent
/// </summary>
[JsonProperty("sampleof")]
public string SampleOf { get; set; }
public string SampleOf { get; set; } = null;
#endregion
#region AttractMode Fields
/// <summary>
/// Player count
/// </summary>
[JsonProperty("players")]
public string Players { get; set; } = null;
/// <summary>
/// Screen rotation
/// </summary>
[JsonProperty("rotation")]
public string Rotation { get; set; } = null;
/// <summary>
/// Control method
/// </summary>
[JsonProperty("control")]
public string Control { get; set; } = null;
/// <summary>
/// Support status
/// </summary>
/// <remarks>yes = true, partial = null, no = false</remarks>
[JsonProperty("supported")]
public bool? Supported { get; set; }
[JsonProperty("status")]
public string Status { get; set; } = null;
/// <summary>
/// Display count
/// </summary>
[JsonProperty("displaycount")]
public string DisplayCount { get; set; } = null;
/// <summary>
/// Display type
/// </summary>
[JsonProperty("displaytype")]
public string DisplayType { get; set; } = null;
/// <summary>
/// Number of input buttons
/// </summary>
[JsonProperty("buttons")]
public string Buttons { get; set; } = null;
#endregion
#region ListXML Fields
/// <summary>
/// Emulator source file related to the machine
/// </summary>
[JsonProperty("sourcefile")]
public string SourceFile { get; set; }
public string SourceFile { get; set; } = null;
/// <summary>
/// Machine runnable status
/// </summary>
/// <remarks>yes = true, partial = null, no = false</remarks>
[JsonProperty("runnable")]
public bool? Runnable { get; set; }
/// <summary>
/// Machine board name
/// </summary>
[JsonProperty("board")]
public string Board { get; set; }
/// <summary>
/// Rebuild location if different than machine name
/// </summary>
[JsonProperty("rebuildto")]
public string RebuildTo { get; set; }
public bool? Runnable { get; set; } = null;
/// <summary>
/// List of associated device names
/// </summary>
[JsonProperty("devices")]
public List<string> Devices { get; set; }
public List<string> Devices { get; set; } = null;
/// <summary>
/// List of slot options
/// </summary>
[JsonProperty("slotoptions")]
public List<string> SlotOptions { get; set; }
public List<string> SlotOptions { get; set; } = null;
/// <summary>
/// List of info items
/// </summary>
[JsonProperty("infos")]
public List<KeyValuePair<string, string>> Infos { get; set; }
public List<KeyValuePair<string, string>> Infos { get; set; } = null;
/// <summary>
/// Type of the machine
/// </summary>
[JsonProperty("type")]
public MachineType MachineType { get; set; }
public MachineType MachineType { get; set; } = MachineType.NULL;
#endregion
#region Logiqx Fields
/// <summary>
/// Machine board name
/// </summary>
[JsonProperty("board")]
public string Board { get; set; } = null;
/// <summary>
/// Rebuild location if different than machine name
/// </summary>
[JsonProperty("rebuildto")]
public string RebuildTo { get; set; } = null;
#endregion
#region SoftwareList Fields
/// <summary>
/// Support status
/// </summary>
/// <remarks>yes = true, partial = null, no = false</remarks>
[JsonProperty("supported")]
public bool? Supported { get; set; } = true;
#endregion
#endregion
@@ -146,6 +208,7 @@ namespace SabreTools.Library.DatItems
string fieldValue = null;
switch (field)
{
// Common
case Field.MachineName:
fieldValue = Name;
break;
@@ -176,21 +239,37 @@ namespace SabreTools.Library.DatItems
case Field.SampleOf:
fieldValue = SampleOf;
break;
case Field.Supported:
fieldValue = Supported?.ToString();
// AttractMode
case Field.Players:
fieldValue = Players;
break;
case Field.Rotation:
fieldValue = Rotation;
break;
case Field.Control:
fieldValue = Control;
break;
case Field.SupportStatus:
fieldValue = Status;
break;
case Field.DisplayCount:
fieldValue = DisplayCount;
break;
case Field.DisplayType:
fieldValue = DisplayType;
break;
case Field.Buttons:
fieldValue = Buttons;
break;
// ListXML
case Field.SourceFile:
fieldValue = SourceFile;
break;
case Field.Runnable:
fieldValue = Runnable?.ToString();
break;
case Field.Board:
fieldValue = Board;
break;
case Field.RebuildTo:
fieldValue = RebuildTo;
break;
case Field.Devices:
fieldValue = string.Join(";", Devices ?? new List<string>());
break;
@@ -204,6 +283,19 @@ namespace SabreTools.Library.DatItems
fieldValue = MachineType.ToString();
break;
// Logiqx
case Field.Board:
fieldValue = Board;
break;
case Field.RebuildTo:
fieldValue = RebuildTo;
break;
// SoftwareList
case Field.Supported:
fieldValue = Supported?.ToString();
break;
default:
return null;
}
@@ -224,25 +316,6 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Machine()
{
Name = null;
Comment = null;
Description = null;
Year = null;
Manufacturer = null;
Publisher = null;
Category = null;
RomOf = null;
CloneOf = null;
SampleOf = null;
Supported = true;
SourceFile = null;
Runnable = null;
Board = null;
RebuildTo = null;
Devices = null;
SlotOptions = null;
Infos = null;
MachineType = MachineType.NULL;
}
/// <summary>
@@ -285,6 +358,7 @@ namespace SabreTools.Library.DatItems
{
return new Machine()
{
// Common
Name = this.Name,
Comment = this.Comment,
Description = this.Description,
@@ -295,15 +369,30 @@ namespace SabreTools.Library.DatItems
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
Supported = this.Supported,
// AttractMode
Players = this.Players,
Rotation = this.Rotation,
Control = this.Control,
Status = this.Status,
DisplayCount = this.DisplayCount,
DisplayType = this.DisplayType,
Buttons = this.Buttons,
// ListXML
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
SlotOptions = this.SlotOptions,
Infos = this.Infos,
MachineType = this.MachineType,
// Logiqx
Board = this.Board,
RebuildTo = this.RebuildTo,
// SoftwareList
Supported = this.Supported,
};
}
@@ -318,6 +407,8 @@ namespace SabreTools.Library.DatItems
/// <returns>True if the item passed the filter, false otherwise</returns>
public bool PassesFilter(Filter filter)
{
#region Common
// Filter on machine name
bool? machineNameFound = filter.MachineName.MatchesPositiveSet(Name);
if (filter.IncludeOfInGame)
@@ -391,9 +482,55 @@ namespace SabreTools.Library.DatItems
if (filter.SampleOf.MatchesNegativeSet(SampleOf) == true)
return false;
// Filter on supported
if (filter.Supported.MatchesNeutral(null, Supported) == false)
#endregion
#region AttractMode
// Filter on players
if (filter.Players.MatchesPositiveSet(Players) == false)
return false;
if (filter.Players.MatchesNegativeSet(Players) == true)
return false;
// Filter on rotation
if (filter.Rotation.MatchesPositiveSet(Rotation) == false)
return false;
if (filter.Rotation.MatchesNegativeSet(Rotation) == true)
return false;
// Filter on control
if (filter.Control.MatchesPositiveSet(Control) == false)
return false;
if (filter.Control.MatchesNegativeSet(Control) == true)
return false;
// Filter on support status
if (filter.SupportStatus.MatchesPositiveSet(Status) == false)
return false;
if (filter.SupportStatus.MatchesNegativeSet(Status) == true)
return false;
// Filter on display count
if (filter.DisplayCount.MatchesPositiveSet(DisplayCount) == false)
return false;
if (filter.DisplayCount.MatchesNegativeSet(DisplayCount) == true)
return false;
// Filter on display type
if (filter.DisplayType.MatchesPositiveSet(DisplayType) == false)
return false;
if (filter.DisplayType.MatchesNegativeSet(DisplayType) == true)
return false;
// Filter on buttons
if (filter.Buttons.MatchesPositiveSet(Buttons) == false)
return false;
if (filter.Buttons.MatchesNegativeSet(Buttons) == true)
return false;
#endregion
#region ListXML
// Filter on source file
if (filter.SourceFile.MatchesPositiveSet(SourceFile) == false)
@@ -405,18 +542,6 @@ namespace SabreTools.Library.DatItems
if (filter.Runnable.MatchesNeutral(null, Runnable) == false)
return false;
// Filter on board
if (filter.Board.MatchesPositiveSet(Board) == false)
return false;
if (filter.Board.MatchesNegativeSet(Board) == true)
return false;
// Filter on rebuildto
if (filter.RebuildTo.MatchesPositiveSet(RebuildTo) == false)
return false;
if (filter.RebuildTo.MatchesNegativeSet(RebuildTo) == true)
return false;
// Filter on devices
if (Devices != null && Devices.Any())
{
@@ -453,6 +578,32 @@ namespace SabreTools.Library.DatItems
if (filter.MachineTypes.MatchesNegative(MachineType.NULL, MachineType) == true)
return false;
#endregion
#region Logiqx
// Filter on board
if (filter.Board.MatchesPositiveSet(Board) == false)
return false;
if (filter.Board.MatchesNegativeSet(Board) == true)
return false;
// Filter on rebuildto
if (filter.RebuildTo.MatchesPositiveSet(RebuildTo) == false)
return false;
if (filter.RebuildTo.MatchesNegativeSet(RebuildTo) == true)
return false;
#endregion
#region SoftwareList
// Filter on supported
if (filter.Supported.MatchesNeutral(null, Supported) == false)
return false;
#endregion
return true;
}
@@ -462,6 +613,8 @@ namespace SabreTools.Library.DatItems
/// <param name="fields">List of Fields to remove</param>
public void RemoveFields(List<Field> fields)
{
#region Common
if (fields.Contains(Field.MachineName))
Name = null;
@@ -492,8 +645,34 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.SampleOf))
SampleOf = null;
if (fields.Contains(Field.Supported))
Supported = null;
#endregion
#region AttractMode
if (fields.Contains(Field.Players))
Players = null;
if (fields.Contains(Field.Rotation))
Rotation = null;
if (fields.Contains(Field.Control))
Control = null;
if (fields.Contains(Field.SupportStatus))
Status = null;
if (fields.Contains(Field.DisplayCount))
DisplayCount = null;
if (fields.Contains(Field.DisplayType))
DisplayType = null;
if (fields.Contains(Field.Buttons))
Buttons = null;
#endregion
#region ListXML
if (fields.Contains(Field.SourceFile))
SourceFile = null;
@@ -501,12 +680,6 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.Runnable))
Runnable = null;
if (fields.Contains(Field.Board))
Board = null;
if (fields.Contains(Field.RebuildTo))
RebuildTo = null;
if (fields.Contains(Field.Devices))
Devices = null;
@@ -518,6 +691,25 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.MachineType))
MachineType = MachineType.NULL;
#endregion
#region Logiqx
if (fields.Contains(Field.Board))
Board = null;
if (fields.Contains(Field.RebuildTo))
RebuildTo = null;
#endregion
#region SoftwareList
if (fields.Contains(Field.Supported))
Supported = null;
#endregion
}
#endregion
@@ -532,6 +724,8 @@ namespace SabreTools.Library.DatItems
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
public void ReplaceFields(Machine machine, List<Field> fields, bool onlySame)
{
#region Common
if (fields.Contains(Field.MachineName))
Name = machine.Name;
@@ -565,8 +759,34 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.SampleOf))
SampleOf = machine.SampleOf;
if (fields.Contains(Field.Supported))
Supported = machine.Supported;
#endregion
#region AttractMode
if (fields.Contains(Field.Players))
Players = machine.Players;
if (fields.Contains(Field.Rotation))
Rotation = machine.Rotation;
if (fields.Contains(Field.Control))
Control = machine.Control;
if (fields.Contains(Field.SupportStatus))
Status = machine.Status;
if (fields.Contains(Field.DisplayCount))
DisplayCount = machine.DisplayCount;
if (fields.Contains(Field.DisplayType))
DisplayType = machine.DisplayType;
if (fields.Contains(Field.Buttons))
Buttons = machine.Buttons;
#endregion
#region ListXML
if (fields.Contains(Field.SourceFile))
SourceFile = machine.SourceFile;
@@ -574,12 +794,6 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.Runnable))
Runnable = machine.Runnable;
if (fields.Contains(Field.Board))
Board = machine.Board;
if (fields.Contains(Field.RebuildTo))
RebuildTo = machine.RebuildTo;
if (fields.Contains(Field.Devices))
Devices = machine.Devices;
@@ -591,6 +805,25 @@ namespace SabreTools.Library.DatItems
if (fields.Contains(Field.MachineType))
MachineType = machine.MachineType;
#endregion
#region Logiqx
if (fields.Contains(Field.Board))
Board = machine.Board;
if (fields.Contains(Field.RebuildTo))
RebuildTo = machine.RebuildTo;
#endregion
#region SoftwareList
if (fields.Contains(Field.Supported))
Supported = machine.Supported;
#endregion
}
#endregion

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using SabreTools.Library.Data;
using SabreTools.Library.DatFiles;
using SabreTools.Library.DatItems;
@@ -13,10 +14,12 @@ namespace SabreTools.Library.Filtering
/// TODO: Can clever use of Filtering allow for easier external splitting methods?
public class Filter
{
#region Pubically facing variables
#region Fields
#region Machine Filters
#region Common
/// <summary>
/// Include or exclude machine names
/// </summary>
@@ -67,10 +70,48 @@ namespace SabreTools.Library.Filtering
/// </summary>
public FilterItem<string> SampleOf { get; private set; } = new FilterItem<string>();
#endregion
#region AttractMode
/// <summary>
/// Include or exclude items with the "Supported" tag
/// Include or exclude machine players
/// </summary>
public FilterItem<bool?> Supported { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Players { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine rotation
/// </summary>
public FilterItem<string> Rotation { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine control
/// </summary>
public FilterItem<string> Control { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine support status
/// </summary>
public FilterItem<string> SupportStatus { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine display count
/// </summary>
public FilterItem<string> DisplayCount { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine display type
/// </summary>
public FilterItem<string> DisplayType { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine buttons
/// </summary>
public FilterItem<string> Buttons { get; private set; } = new FilterItem<string>();
#endregion
#region ListXML
/// <summary>
/// Include or exclude machine source file
@@ -82,16 +123,6 @@ namespace SabreTools.Library.Filtering
/// </summary>
public FilterItem<bool?> Runnable { get; private set; } = new FilterItem<bool?>() { Neutral = null };
/// <summary>
/// Include or exclude machine board
/// </summary>
public FilterItem<string> Board { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine rebuildto
/// </summary>
public FilterItem<string> RebuildTo { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine devices
/// </summary>
@@ -111,6 +142,31 @@ namespace SabreTools.Library.Filtering
#endregion
#region Logiqx
/// <summary>
/// Include or exclude machine board
/// </summary>
public FilterItem<string> Board { get; private set; } = new FilterItem<string>();
/// <summary>
/// Include or exclude machine rebuildto
/// </summary>
public FilterItem<string> RebuildTo { get; private set; } = new FilterItem<string>();
#endregion
#region SoftwareList
/// <summary>
/// Include or exclude items with the "Supported" tag
/// </summary>
public FilterItem<bool?> Supported { get; private set; } = new FilterItem<bool?>() { Neutral = null };
#endregion
#endregion // Machine Filters
#region DatItem Filters
/// <summary>
@@ -300,7 +356,7 @@ namespace SabreTools.Library.Filtering
#endregion
#endregion // Pubically facing variables
#endregion // Fields
#region Instance methods
@@ -362,6 +418,8 @@ namespace SabreTools.Library.Filtering
{
#region Machine Filters
#region Common
case Field.MachineName:
if (negate)
MachineName.NegativeSet.Add(value);
@@ -432,13 +490,63 @@ namespace SabreTools.Library.Filtering
SampleOf.PositiveSet.Add(value);
break;
case Field.Supported:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
Supported.Neutral = false;
#endregion
#region AttractMode
case Field.Players:
if (negate)
Players.NegativeSet.Add(value);
else
Supported.Neutral = true;
Players.PositiveSet.Add(value);
break;
case Field.Rotation:
if (negate)
Rotation.NegativeSet.Add(value);
else
Rotation.PositiveSet.Add(value);
break;
case Field.Control:
if (negate)
Control.NegativeSet.Add(value);
else
Control.PositiveSet.Add(value);
break;
case Field.SupportStatus:
if (negate)
SupportStatus.NegativeSet.Add(value);
else
SupportStatus.PositiveSet.Add(value);
break;
case Field.DisplayCount:
if (negate)
DisplayCount.NegativeSet.Add(value);
else
DisplayCount.PositiveSet.Add(value);
break;
case Field.DisplayType:
if (negate)
DisplayType.NegativeSet.Add(value);
else
DisplayType.PositiveSet.Add(value);
break;
case Field.Buttons:
if (negate)
Buttons.NegativeSet.Add(value);
else
Buttons.PositiveSet.Add(value);
break;
#endregion
#region ListXML
case Field.SourceFile:
if (negate)
SourceFile.NegativeSet.Add(value);
@@ -453,20 +561,6 @@ namespace SabreTools.Library.Filtering
Runnable.Neutral = true;
break;
case Field.Board:
if (negate)
Board.NegativeSet.Add(value);
else
Board.PositiveSet.Add(value);
break;
case Field.RebuildTo:
if (negate)
RebuildTo.NegativeSet.Add(value);
else
RebuildTo.PositiveSet.Add(value);
break;
case Field.Devices:
if (negate)
Devices.NegativeSet.Add(value);
@@ -490,6 +584,37 @@ namespace SabreTools.Library.Filtering
#endregion
#region Logiqx
case Field.Board:
if (negate)
Board.NegativeSet.Add(value);
else
Board.PositiveSet.Add(value);
break;
case Field.RebuildTo:
if (negate)
RebuildTo.NegativeSet.Add(value);
else
RebuildTo.PositiveSet.Add(value);
break;
#endregion
#region SoftwareList
case Field.Supported:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
Supported.Neutral = false;
else
Supported.Neutral = true;
break;
#endregion
#endregion // Machine Filters
#region DatItem Filters
case Field.ItemType:

View File

@@ -123,6 +123,117 @@ namespace SabreTools.Library.Tools
{
switch (input?.ToLowerInvariant())
{
#region Machine
#region Common
case "gamename":
case "game-name":
case "machinename":
case "machine-name":
return Field.MachineName;
case "comment":
case "extra":
return Field.Comment;
case "desc":
case "description":
case "gamedesc":
case "gamedescription":
case "game-description":
case "machinedesc":
case "machinedescription":
case "machine-description":
return Field.Description;
case "year":
return Field.Year;
case "manufacturer":
return Field.Manufacturer;
case "publisher":
return Field.Publisher;
case "category":
case "machinecategory":
case "machine-category":
return Field.Category;
case "romof":
return Field.RomOf;
case "cloneof":
return Field.CloneOf;
case "sampleof":
return Field.SampleOf;
#endregion
#region AttractMode
case "players":
return Field.Players;
case "rotation":
return Field.Rotation;
case "control":
return Field.Control;
case "amstatus":
case "am-status":
case "gamestatus":
case "game-status":
case "machinestatus":
case "machine-status":
case "supportstatus":
case "support-status":
return Field.SupportStatus;
case "displaycount":
case "display-count":
case "displays":
return Field.DisplayCount;
case "displaytype":
case "display-type":
return Field.DisplayType;
case "buttons":
return Field.Buttons;
#endregion
#region ListXML
case "sourcefile":
case "source-file":
return Field.SourceFile;
case "runnable":
return Field.Runnable;
case "devices":
return Field.Devices;
case "slotoptions":
case "slot-options":
return Field.SlotOptions;
case "infos":
return Field.Infos;
case "gametype":
case "game-type":
case "machinetype":
case "machine-type":
return Field.MachineType;
#endregion
#region Logiqx
case "board":
return Field.Board;
case "rebuildto":
return Field.RebuildTo;
#endregion
#region SoftwareList
case "supported":
return Field.Supported;
#endregion
#endregion // Machine
#region DatItem
case "areaname":
case "area-name":
return Field.AreaName;
@@ -137,16 +248,6 @@ namespace SabreTools.Library.Tools
case "biosset-description":
case "bios-set-description":
return Field.BiosDescription;
case "board":
return Field.Board;
case "category":
case "machinecategory":
case "machine-category":
return Field.Category;
case "cloneof":
return Field.CloneOf;
case "comment":
return Field.Comment;
case "crc":
case "crc32":
return Field.CRC;
@@ -154,17 +255,6 @@ namespace SabreTools.Library.Tools
return Field.Default;
case "date":
return Field.Date;
case "desc":
case "description":
case "gamedesc":
case "gamedescription":
case "game-description":
case "machinedesc":
case "machinedescription":
case "machine-description":
return Field.Description;
case "devices":
return Field.Devices;
case "equal":
case "greater":
case "less":
@@ -172,18 +262,8 @@ namespace SabreTools.Library.Tools
return Field.Size;
case "features":
return Field.Features;
case "gamename":
case "machinename":
return Field.MachineName;
case "gametype":
case "game-type":
case "machinetype":
case "machine-type":
return Field.MachineType;
case "index":
return Field.Index;
case "infos":
return Field.Infos;
case "inverted":
return Field.Inverted;
case "itemname":
@@ -200,8 +280,6 @@ namespace SabreTools.Library.Tools
return Field.ItemType;
case "language":
return Field.Language;
case "manufacturer":
return Field.Manufacturer;
case "md5":
return Field.MD5;
case "merge":
@@ -218,22 +296,12 @@ namespace SabreTools.Library.Tools
case "partname":
case "part-name":
return Field.PartName;
case "publisher":
return Field.Publisher;
case "rebuildto":
return Field.RebuildTo;
case "region":
return Field.Region;
#if NET_FRAMEWORK
case "ripemd160":
return Field.RIPEMD160;
#endif
case "romof":
return Field.RomOf;
case "runnable":
return Field.Runnable;
case "sampleof":
return Field.SampleOf;
case "sha1":
case "sha-1":
return Field.SHA1;
@@ -246,18 +314,11 @@ namespace SabreTools.Library.Tools
case "sha512":
case "sha-512":
return Field.SHA512;
case "slotoptions":
case "slot-options":
return Field.SlotOptions;
case "sourcefile":
case "source-file":
return Field.SourceFile;
case "supported":
return Field.Supported;
case "writable":
return Field.Writable;
case "year":
return Field.Year;
#endregion
default:
return Field.NULL;
}