mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Machines don't know about field stuff
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatItems;
|
||||
|
||||
namespace SabreTools.Filtering
|
||||
@@ -328,6 +329,474 @@ namespace SabreTools.Filtering
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use these instead of the baked in ones
|
||||
// TODO: Move to new class?
|
||||
#region Field Manipulation
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields with given values
|
||||
/// </summary>
|
||||
/// <param name="datItem">DatItem to remove fields from</param>
|
||||
/// <param name="fields">List of fields to remove</param>
|
||||
public static void RemoveFields(DatItem datItem, List<DatItemField> fields)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields with given values
|
||||
/// </summary>
|
||||
/// <param name="machine">Machine to remove fields from</param>
|
||||
/// <param name="fields">List of fields to remove</param>
|
||||
public static void RemoveFields(Machine machine, List<MachineField> fields)
|
||||
{
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(MachineField.Name))
|
||||
machine.Name = null;
|
||||
|
||||
if (fields.Contains(MachineField.Comment))
|
||||
machine.Comment = null;
|
||||
|
||||
if (fields.Contains(MachineField.Description))
|
||||
machine.Description = null;
|
||||
|
||||
if (fields.Contains(MachineField.Year))
|
||||
machine.Year = null;
|
||||
|
||||
if (fields.Contains(MachineField.Manufacturer))
|
||||
machine.Manufacturer = null;
|
||||
|
||||
if (fields.Contains(MachineField.Publisher))
|
||||
machine.Publisher = null;
|
||||
|
||||
if (fields.Contains(MachineField.Category))
|
||||
machine.Category = null;
|
||||
|
||||
if (fields.Contains(MachineField.RomOf))
|
||||
machine.RomOf = null;
|
||||
|
||||
if (fields.Contains(MachineField.CloneOf))
|
||||
machine.CloneOf = null;
|
||||
|
||||
if (fields.Contains(MachineField.SampleOf))
|
||||
machine.SampleOf = null;
|
||||
|
||||
if (fields.Contains(MachineField.Type))
|
||||
machine.MachineType = 0x0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (fields.Contains(MachineField.Players))
|
||||
machine.Players = null;
|
||||
|
||||
if (fields.Contains(MachineField.Rotation))
|
||||
machine.Rotation = null;
|
||||
|
||||
if (fields.Contains(MachineField.Control))
|
||||
machine.Control = null;
|
||||
|
||||
if (fields.Contains(MachineField.Status))
|
||||
machine.Status = null;
|
||||
|
||||
if (fields.Contains(MachineField.DisplayCount))
|
||||
machine.DisplayCount = null;
|
||||
|
||||
if (fields.Contains(MachineField.DisplayType))
|
||||
machine.DisplayType = null;
|
||||
|
||||
if (fields.Contains(MachineField.Buttons))
|
||||
machine.Buttons = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (fields.Contains(MachineField.SourceFile))
|
||||
machine.SourceFile = null;
|
||||
|
||||
if (fields.Contains(MachineField.Runnable))
|
||||
machine.Runnable = Runnable.NULL;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (fields.Contains(MachineField.Board))
|
||||
machine.Board = null;
|
||||
|
||||
if (fields.Contains(MachineField.RebuildTo))
|
||||
machine.RebuildTo = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx EmuArc
|
||||
|
||||
if (fields.Contains(MachineField.TitleID))
|
||||
machine.TitleID = null;
|
||||
|
||||
if (fields.Contains(MachineField.Developer))
|
||||
machine.Developer = null;
|
||||
|
||||
if (fields.Contains(MachineField.Genre))
|
||||
machine.Genre = null;
|
||||
|
||||
if (fields.Contains(MachineField.Subgenre))
|
||||
machine.Subgenre = null;
|
||||
|
||||
if (fields.Contains(MachineField.Ratings))
|
||||
machine.Ratings = null;
|
||||
|
||||
if (fields.Contains(MachineField.Score))
|
||||
machine.Score = null;
|
||||
|
||||
if (fields.Contains(MachineField.Enabled))
|
||||
machine.Enabled = null;
|
||||
|
||||
if (fields.Contains(MachineField.CRC))
|
||||
machine.Crc = null;
|
||||
|
||||
if (fields.Contains(MachineField.RelatedTo))
|
||||
machine.RelatedTo = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (fields.Contains(MachineField.GenMSXID))
|
||||
machine.GenMSXID = null;
|
||||
|
||||
if (fields.Contains(MachineField.System))
|
||||
machine.System = null;
|
||||
|
||||
if (fields.Contains(MachineField.Country))
|
||||
machine.Country = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (fields.Contains(MachineField.Supported))
|
||||
machine.Supported = Supported.NULL;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields with given values
|
||||
/// </summary>
|
||||
/// <param name="datItem">DatItem to replace fields in</param>
|
||||
/// <param name="repMachine">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of fields representing what should be updated</param>
|
||||
public static void ReplaceFields(DatItem datItem, DatItem repDatItem, List<DatItemField> fields)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields with given values
|
||||
/// </summary>
|
||||
/// <param name="machine">Machine to replace fields in</param>
|
||||
/// <param name="repMachine">Machine to pull new information from</param>
|
||||
/// <param name="fields">List of fields representing what should be updated</param>
|
||||
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
|
||||
public static void ReplaceFields(Machine machine, Machine repMachine, List<MachineField> fields, bool onlySame)
|
||||
{
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(MachineField.Name))
|
||||
machine.Name = repMachine.Name;
|
||||
|
||||
if (fields.Contains(MachineField.Comment))
|
||||
machine.Comment = repMachine.Comment;
|
||||
|
||||
if (fields.Contains(MachineField.Description))
|
||||
{
|
||||
if (!onlySame || (onlySame && machine.Name == machine.Description))
|
||||
machine.Description = repMachine.Description;
|
||||
}
|
||||
|
||||
if (fields.Contains(MachineField.Year))
|
||||
machine.Year = repMachine.Year;
|
||||
|
||||
if (fields.Contains(MachineField.Manufacturer))
|
||||
machine.Manufacturer = repMachine.Manufacturer;
|
||||
|
||||
if (fields.Contains(MachineField.Publisher))
|
||||
machine.Publisher = repMachine.Publisher;
|
||||
|
||||
if (fields.Contains(MachineField.Category))
|
||||
machine.Category = repMachine.Category;
|
||||
|
||||
if (fields.Contains(MachineField.RomOf))
|
||||
machine.RomOf = repMachine.RomOf;
|
||||
|
||||
if (fields.Contains(MachineField.CloneOf))
|
||||
machine.CloneOf = repMachine.CloneOf;
|
||||
|
||||
if (fields.Contains(MachineField.SampleOf))
|
||||
machine.SampleOf = repMachine.SampleOf;
|
||||
|
||||
if (fields.Contains(MachineField.Type))
|
||||
machine.MachineType = repMachine.MachineType;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (fields.Contains(MachineField.Players))
|
||||
machine.Players = repMachine.Players;
|
||||
|
||||
if (fields.Contains(MachineField.Rotation))
|
||||
machine.Rotation = repMachine.Rotation;
|
||||
|
||||
if (fields.Contains(MachineField.Control))
|
||||
machine.Control = repMachine.Control;
|
||||
|
||||
if (fields.Contains(MachineField.Status))
|
||||
machine.Status = repMachine.Status;
|
||||
|
||||
if (fields.Contains(MachineField.DisplayCount))
|
||||
machine.DisplayCount = repMachine.DisplayCount;
|
||||
|
||||
if (fields.Contains(MachineField.DisplayType))
|
||||
machine.DisplayType = repMachine.DisplayType;
|
||||
|
||||
if (fields.Contains(MachineField.Buttons))
|
||||
machine.Buttons = repMachine.Buttons;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (fields.Contains(MachineField.SourceFile))
|
||||
machine.SourceFile = repMachine.SourceFile;
|
||||
|
||||
if (fields.Contains(MachineField.Runnable))
|
||||
machine.Runnable = repMachine.Runnable;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (fields.Contains(MachineField.Board))
|
||||
machine.Board = repMachine.Board;
|
||||
|
||||
if (fields.Contains(MachineField.RebuildTo))
|
||||
machine.RebuildTo = repMachine.RebuildTo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx EmuArc
|
||||
|
||||
if (fields.Contains(MachineField.TitleID))
|
||||
machine.TitleID = repMachine.TitleID;
|
||||
|
||||
if (fields.Contains(MachineField.Developer))
|
||||
machine.Developer = repMachine.Developer;
|
||||
|
||||
if (fields.Contains(MachineField.Genre))
|
||||
machine.Genre = repMachine.Genre;
|
||||
|
||||
if (fields.Contains(MachineField.Subgenre))
|
||||
machine.Subgenre = repMachine.Subgenre;
|
||||
|
||||
if (fields.Contains(MachineField.Ratings))
|
||||
machine.Ratings = repMachine.Ratings;
|
||||
|
||||
if (fields.Contains(MachineField.Score))
|
||||
machine.Score = repMachine.Score;
|
||||
|
||||
if (fields.Contains(MachineField.Enabled))
|
||||
machine.Enabled = repMachine.Enabled;
|
||||
|
||||
if (fields.Contains(MachineField.CRC))
|
||||
machine.Crc = repMachine.Crc;
|
||||
|
||||
if (fields.Contains(MachineField.RelatedTo))
|
||||
machine.RelatedTo = repMachine.RelatedTo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (fields.Contains(MachineField.GenMSXID))
|
||||
machine.GenMSXID = repMachine.GenMSXID;
|
||||
|
||||
if (fields.Contains(MachineField.System))
|
||||
machine.System = repMachine.System;
|
||||
|
||||
if (fields.Contains(MachineField.Country))
|
||||
machine.Country = repMachine.Country;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (fields.Contains(MachineField.Supported))
|
||||
machine.Supported = repMachine.Supported;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="datItem">DatItem to set fields on</param>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public static void SetFields(DatItem datItem, Dictionary<DatItemField, string> mappings)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="machine">Machine to set fields on</param>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public static void SetFields(Machine machine, Dictionary<MachineField, string> mappings)
|
||||
{
|
||||
if (machine == null || mappings == null)
|
||||
return;
|
||||
|
||||
#region Common
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Name))
|
||||
machine.Name = mappings[MachineField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Comment))
|
||||
machine.Comment = mappings[MachineField.Comment];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Description))
|
||||
machine.Description = mappings[MachineField.Description];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Year))
|
||||
machine.Year = mappings[MachineField.Year];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Manufacturer))
|
||||
machine.Manufacturer = mappings[MachineField.Manufacturer];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Publisher))
|
||||
machine.Publisher = mappings[MachineField.Publisher];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Category))
|
||||
machine.Category = mappings[MachineField.Category];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.RomOf))
|
||||
machine.RomOf = mappings[MachineField.RomOf];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.CloneOf))
|
||||
machine.CloneOf = mappings[MachineField.CloneOf];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.SampleOf))
|
||||
machine.SampleOf = mappings[MachineField.SampleOf];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Type))
|
||||
machine.MachineType = mappings[MachineField.Type].AsMachineType();
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Players))
|
||||
machine.Players = mappings[MachineField.Players];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Rotation))
|
||||
machine.Rotation = mappings[MachineField.Rotation];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Control))
|
||||
machine.Control = mappings[MachineField.Control];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Status))
|
||||
machine.Status = mappings[MachineField.Status];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.DisplayCount))
|
||||
machine.DisplayCount = mappings[MachineField.DisplayCount];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.DisplayType))
|
||||
machine.DisplayType = mappings[MachineField.DisplayType];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Buttons))
|
||||
machine.Buttons = mappings[MachineField.Buttons];
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.SourceFile))
|
||||
machine.SourceFile = mappings[MachineField.SourceFile];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Runnable))
|
||||
machine.Runnable = mappings[MachineField.Runnable].AsRunnable();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Board))
|
||||
machine.Board = mappings[MachineField.Board];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.RebuildTo))
|
||||
machine.RebuildTo = mappings[MachineField.RebuildTo];
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx EmuArc
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.TitleID))
|
||||
machine.TitleID = mappings[MachineField.TitleID];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Developer))
|
||||
machine.Developer = mappings[MachineField.Developer];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Genre))
|
||||
machine.Genre = mappings[MachineField.Genre];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Subgenre))
|
||||
machine.Subgenre = mappings[MachineField.Subgenre];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Ratings))
|
||||
machine.Ratings = mappings[MachineField.Ratings];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Score))
|
||||
machine.Score = mappings[MachineField.Score];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Enabled))
|
||||
machine.Enabled = mappings[MachineField.Enabled];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.CRC))
|
||||
machine.Crc = mappings[MachineField.CRC].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.RelatedTo))
|
||||
machine.RelatedTo = mappings[MachineField.RelatedTo];
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.GenMSXID))
|
||||
machine.GenMSXID = mappings[MachineField.GenMSXID];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.System))
|
||||
machine.System = mappings[MachineField.System];
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Country))
|
||||
machine.Country = mappings[MachineField.Country];
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (mappings.Keys.Contains(MachineField.Supported))
|
||||
machine.Supported = mappings[MachineField.Supported].AsSupported();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user