mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add history tag support (fixes #34)
This commit is contained in:
@@ -741,6 +741,7 @@ namespace SabreTools.Core
|
||||
|
||||
#region ListXML
|
||||
|
||||
History,
|
||||
SourceFile,
|
||||
Runnable,
|
||||
|
||||
|
||||
@@ -1051,6 +1051,9 @@ namespace SabreTools.Core.Tools
|
||||
|
||||
#region ListXML
|
||||
|
||||
case "history":
|
||||
return MachineField.History;
|
||||
|
||||
case "sourcefile":
|
||||
case "source_file":
|
||||
return MachineField.SourceFile;
|
||||
|
||||
@@ -337,6 +337,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
machine.Manufacturer = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "history":
|
||||
machine.History = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "adjuster":
|
||||
var adjuster = new Adjuster
|
||||
{
|
||||
@@ -1473,6 +1477,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
xtw.WriteOptionalElementString("description", datItem.Machine.Description);
|
||||
xtw.WriteOptionalElementString("year", datItem.Machine.Year);
|
||||
xtw.WriteOptionalElementString("manufacturer", datItem.Machine.Manufacturer);
|
||||
xtw.WriteOptionalElementString("history", datItem.Machine.History);
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
|
||||
@@ -902,6 +902,9 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (fields.Contains(MachineField.History))
|
||||
machine.History = null;
|
||||
|
||||
if (fields.Contains(MachineField.SourceFile))
|
||||
machine.SourceFile = null;
|
||||
|
||||
@@ -1891,6 +1894,9 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (machineFields.Contains(MachineField.History))
|
||||
machine.History = repMachine.History;
|
||||
|
||||
if (machineFields.Contains(MachineField.SourceFile))
|
||||
machine.SourceFile = repMachine.SourceFile;
|
||||
|
||||
@@ -2839,6 +2845,9 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.History))
|
||||
machine.History = mappings[MachineField.History];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.SourceFile))
|
||||
machine.SourceFile = mappings[MachineField.SourceFile];
|
||||
|
||||
|
||||
@@ -157,6 +157,13 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region ListXML
|
||||
|
||||
/// <summary>
|
||||
/// History.dat entry for the machine
|
||||
/// </summary>
|
||||
[JsonProperty("history", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("history")]
|
||||
public string History { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Emulator source file related to the machine
|
||||
/// </summary>
|
||||
@@ -370,6 +377,7 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region ListXML
|
||||
|
||||
History = this.History,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
|
||||
|
||||
@@ -1699,6 +1699,10 @@ namespace SabreTools.Filtering
|
||||
|
||||
#region ListXML
|
||||
|
||||
// Machine_History
|
||||
if (!Filter.PassStringFilter(MachineFilter.History, machine.History))
|
||||
return false;
|
||||
|
||||
// Machine_SourceFile
|
||||
if (!Filter.PassStringFilter(MachineFilter.SourceFile, machine.SourceFile))
|
||||
return false;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.Logging;
|
||||
|
||||
namespace SabreTools.Filtering
|
||||
@@ -45,6 +46,7 @@ namespace SabreTools.Filtering
|
||||
|
||||
#region ListXML
|
||||
|
||||
public FilterItem<string> History { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> SourceFile { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<Runnable> Runnable { get; private set; } = new FilterItem<Runnable>() { Positive = Core.Runnable.NULL, Negative = Core.Runnable.NULL };
|
||||
|
||||
@@ -221,6 +223,10 @@ namespace SabreTools.Filtering
|
||||
|
||||
#region ListXML
|
||||
|
||||
case MachineField.History:
|
||||
SetStringFilter(History, value, negate);
|
||||
break;
|
||||
|
||||
case MachineField.SourceFile:
|
||||
SetStringFilter(SourceFile, value, negate);
|
||||
break;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<description>Game! (Version 1)</description>
|
||||
<year>1980</year>
|
||||
<manufacturer>Manufacturer</manufacturer>
|
||||
<history>A long and storied history</history>
|
||||
<adjuster name="adjuster" default="yes">
|
||||
<condition tag="tag" mask="mask" relation="eq" value="value" />
|
||||
</adjuster>
|
||||
|
||||
Reference in New Issue
Block a user