mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
MachineType is common, add Logiqx header values
This commit is contained in:
@@ -183,6 +183,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <summary>
|
||||
/// Debug build flag
|
||||
/// </summary>
|
||||
/// <remarks>Also in Logiqx</remarks>
|
||||
[JsonProperty("debug")]
|
||||
public bool? Debug { get; set; } = false;
|
||||
|
||||
@@ -194,6 +195,16 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
/// <summary>
|
||||
/// Build version
|
||||
/// </summary>
|
||||
[JsonProperty("build")]
|
||||
public string Build { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Missfile Fields
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -227,6 +227,15 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
case "build":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Build = (Header.Build == null ? content : Header.Build);
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -341,6 +350,24 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
case "sampleof":
|
||||
machine.SampleOf = jtr.ReadAsString();
|
||||
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))
|
||||
machine.MachineType &= MachineType.Mechanical;
|
||||
|
||||
break;
|
||||
case "items":
|
||||
ReadItems(sr, jtr, filename, indexId, machine);
|
||||
@@ -412,24 +439,6 @@ 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))
|
||||
machine.MachineType &= MachineType.Mechanical;
|
||||
|
||||
break;
|
||||
|
||||
// Logiqx
|
||||
case "board":
|
||||
@@ -1023,6 +1032,16 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Header.Build))
|
||||
{
|
||||
jtw.WritePropertyName("build");
|
||||
jtw.WriteValue(Header.Build);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// End header
|
||||
jtw.WriteEndObject();
|
||||
|
||||
@@ -1105,6 +1124,24 @@ namespace SabreTools.Library.DatFiles
|
||||
jtw.WritePropertyName("sampleof");
|
||||
jtw.WriteValue(datItem.Machine.SampleOf);
|
||||
}
|
||||
if (!Header.ExcludeFields.Contains(Field.MachineType))
|
||||
{
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
|
||||
{
|
||||
jtw.WritePropertyName("isbios");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Device))
|
||||
{
|
||||
jtw.WritePropertyName("isdevice");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
{
|
||||
jtw.WritePropertyName("ismechanical");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
}
|
||||
|
||||
// AttractMode
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Players, Header.ExcludeFields)))
|
||||
@@ -1198,24 +1235,6 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
jtw.WriteEndArray();
|
||||
}
|
||||
if (!Header.ExcludeFields.Contains(Field.MachineType))
|
||||
{
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
|
||||
{
|
||||
jtw.WritePropertyName("isbios");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Device))
|
||||
{
|
||||
jtw.WritePropertyName("isdevice");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
{
|
||||
jtw.WritePropertyName("ismechanical");
|
||||
jtw.WriteValue("yes");
|
||||
}
|
||||
}
|
||||
|
||||
// Logiqx
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Board, Header.ExcludeFields)))
|
||||
|
||||
@@ -76,8 +76,8 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
// The datafile tag can have some attributes
|
||||
case "datafile":
|
||||
// string build = xtr.GetAttribute("build");
|
||||
// string debug = xtr.GetAttribute("debug"); // (yes|no) "no"
|
||||
Header.Build = (Header.Build == null ? xtr.GetAttribute("build") : Header.Build);
|
||||
Header.Debug = (Header.Debug == null ? xtr.GetAttribute("debug").AsYesNo() : Header.Debug);
|
||||
xtr.Read();
|
||||
break;
|
||||
|
||||
@@ -776,6 +776,21 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
xtw.WriteStartElement("datafile");
|
||||
|
||||
if (Header.Build != null)
|
||||
xtw.WriteAttributeString("build", Header.Build);
|
||||
if (Header.Debug != null)
|
||||
{
|
||||
switch (Header.Debug)
|
||||
{
|
||||
case true:
|
||||
xtw.WriteAttributeString("debug", "yes");
|
||||
break;
|
||||
case false:
|
||||
xtw.WriteAttributeString("debug", "no");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
xtw.WriteStartElement("header");
|
||||
xtw.WriteElementString("name", Header.Name);
|
||||
xtw.WriteElementString("description", Header.Description);
|
||||
|
||||
@@ -200,6 +200,14 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
case "DatFile.Build":
|
||||
Header.Build = (Header.Build == null ? value : Header.Build);
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // DatFile
|
||||
|
||||
#region Machine
|
||||
@@ -246,6 +254,10 @@ namespace SabreTools.Library.DatFiles
|
||||
machine.SampleOf = value;
|
||||
break;
|
||||
|
||||
case "Machine.MachineType":
|
||||
machine.MachineType = value.AsMachineType();
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
@@ -321,10 +333,6 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
break;
|
||||
|
||||
case "Machine.MachineType":
|
||||
machine.MachineType = value.AsMachineType();
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
@@ -751,6 +759,13 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
case "build":
|
||||
return "DatFile.Build";
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // DatFile
|
||||
|
||||
#region Machine
|
||||
@@ -803,6 +818,14 @@ namespace SabreTools.Library.DatFiles
|
||||
case "sampleof":
|
||||
return "Machine.SampleOf";
|
||||
|
||||
case "gametype":
|
||||
case "game type":
|
||||
case "game-type":
|
||||
case "machinetype":
|
||||
case "machine type":
|
||||
case "machine-type":
|
||||
return "Machine.MachineType";
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
@@ -861,14 +884,6 @@ namespace SabreTools.Library.DatFiles
|
||||
case "infos":
|
||||
return "Machine.Infos";
|
||||
|
||||
case "gametype":
|
||||
case "game type":
|
||||
case "game-type":
|
||||
case "machinetype":
|
||||
case "machine type":
|
||||
case "machine-type":
|
||||
return "Machine.MachineType";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
@@ -157,6 +157,7 @@ namespace SabreTools.Library.DatItems
|
||||
Field.RomOf,
|
||||
Field.CloneOf,
|
||||
Field.SampleOf,
|
||||
Field.MachineType,
|
||||
|
||||
// AttractMode
|
||||
Field.Players,
|
||||
@@ -173,7 +174,6 @@ namespace SabreTools.Library.DatItems
|
||||
Field.Devices,
|
||||
Field.SlotOptions,
|
||||
Field.Infos,
|
||||
Field.MachineType,
|
||||
|
||||
// Logiqx
|
||||
Field.Board,
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace SabreTools.Library.DatItems
|
||||
RomOf,
|
||||
CloneOf,
|
||||
SampleOf,
|
||||
MachineType,
|
||||
|
||||
// AttractMode Machine
|
||||
Players,
|
||||
@@ -53,7 +54,6 @@ namespace SabreTools.Library.DatItems
|
||||
Devices,
|
||||
SlotOptions,
|
||||
Infos,
|
||||
MachineType,
|
||||
|
||||
// Logiqx Machine
|
||||
Board,
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// <summary>
|
||||
/// Additional notes
|
||||
/// </summary>
|
||||
/// <remarks>Known as "Extra" in AttractMode</remarks>
|
||||
[JsonProperty("comment")]
|
||||
public string Comment { get; set; } = null;
|
||||
|
||||
@@ -76,6 +77,12 @@ namespace SabreTools.Library.DatItems
|
||||
[JsonProperty("sampleof")]
|
||||
public string SampleOf { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Type of the machine
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public MachineType MachineType { get; set; } = MachineType.NULL;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode Fields
|
||||
@@ -129,6 +136,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// <summary>
|
||||
/// Emulator source file related to the machine
|
||||
/// </summary>
|
||||
/// <remarks>Also in Logiqx</remarks>
|
||||
[JsonProperty("sourcefile")]
|
||||
public string SourceFile { get; set; } = null;
|
||||
|
||||
@@ -136,6 +144,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// Machine runnable status
|
||||
/// </summary>
|
||||
/// <remarks>yes = true, partial = null, no = false</remarks>
|
||||
/// <remarks>Also in Logiqx</remarks>
|
||||
[JsonProperty("runnable")]
|
||||
public bool? Runnable { get; set; } = null;
|
||||
|
||||
@@ -157,12 +166,6 @@ namespace SabreTools.Library.DatItems
|
||||
[JsonProperty("infos")]
|
||||
public List<KeyValuePair<string, string>> Infos { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Type of the machine
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public MachineType MachineType { get; set; } = MachineType.NULL;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx Fields
|
||||
@@ -239,6 +242,9 @@ namespace SabreTools.Library.DatItems
|
||||
case Field.SampleOf:
|
||||
fieldValue = SampleOf;
|
||||
break;
|
||||
case Field.MachineType:
|
||||
fieldValue = MachineType.ToString();
|
||||
break;
|
||||
|
||||
// AttractMode
|
||||
case Field.Players:
|
||||
@@ -279,9 +285,6 @@ namespace SabreTools.Library.DatItems
|
||||
case Field.Infos:
|
||||
fieldValue = string.Join(";", (Infos ?? new List<KeyValuePair<string, string>>()).Select(i => $"{i.Key}={i.Value}"));
|
||||
break;
|
||||
case Field.MachineType:
|
||||
fieldValue = MachineType.ToString();
|
||||
break;
|
||||
|
||||
// Logiqx
|
||||
case Field.Board:
|
||||
@@ -645,6 +648,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.SampleOf))
|
||||
SampleOf = null;
|
||||
|
||||
if (fields.Contains(Field.MachineType))
|
||||
MachineType = MachineType.NULL;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
@@ -689,9 +695,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.Infos))
|
||||
Infos = null;
|
||||
|
||||
if (fields.Contains(Field.MachineType))
|
||||
MachineType = MachineType.NULL;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
@@ -759,6 +762,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.SampleOf))
|
||||
SampleOf = machine.SampleOf;
|
||||
|
||||
if (fields.Contains(Field.MachineType))
|
||||
MachineType = machine.MachineType;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
@@ -803,9 +809,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.Infos))
|
||||
Infos = machine.Infos;
|
||||
|
||||
if (fields.Contains(Field.MachineType))
|
||||
MachineType = machine.MachineType;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
@@ -490,6 +490,13 @@ namespace SabreTools.Library.Filtering
|
||||
SampleOf.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.MachineType:
|
||||
if (negate)
|
||||
MachineTypes.Negative |= value.AsMachineType();
|
||||
else
|
||||
MachineTypes.Positive |= value.AsMachineType();
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
@@ -575,13 +582,6 @@ namespace SabreTools.Library.Filtering
|
||||
SlotOptions.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.MachineType:
|
||||
if (negate)
|
||||
MachineTypes.Negative |= value.AsMachineType();
|
||||
else
|
||||
MachineTypes.Positive |= value.AsMachineType();
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
@@ -176,6 +176,14 @@ namespace SabreTools.Library.Tools
|
||||
case "sampleof":
|
||||
return Field.SampleOf;
|
||||
|
||||
case "gametype":
|
||||
case "game type":
|
||||
case "game-type":
|
||||
case "machinetype":
|
||||
case "machine type":
|
||||
case "machine-type":
|
||||
return Field.MachineType;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
@@ -234,14 +242,6 @@ namespace SabreTools.Library.Tools
|
||||
case "infos":
|
||||
return Field.Infos;
|
||||
|
||||
case "gametype":
|
||||
case "game type":
|
||||
case "game-type":
|
||||
case "machinetype":
|
||||
case "machine type":
|
||||
case "machine-type":
|
||||
return Field.MachineType;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
Reference in New Issue
Block a user