Reorganize filters based on other changes

This commit is contained in:
Matt Nadareski
2023-04-20 22:11:45 -04:00
parent 7c6945fe09
commit de59a91bef
2 changed files with 1233 additions and 1487 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using SabreTools.Core; using SabreTools.Core;
using SabreTools.Core.Tools; using SabreTools.Core.Tools;
using SabreTools.DatItems; using SabreTools.DatItems;
@@ -16,78 +15,44 @@ namespace SabreTools.Filtering
#region Filters #region Filters
#region Common public FilterItem<string> Board { get; private set; } = new FilterItem<string>();
public FilterItem<string> Buttons { get; private set; } = new FilterItem<string>();
public FilterItem<string> Name { get; private set; } = new FilterItem<string>();
public FilterItem<string> Comment { get; private set; } = new FilterItem<string>();
public FilterItem<string> Description { get; private set; } = new FilterItem<string>();
public FilterItem<string> Year { get; private set; } = new FilterItem<string>();
public FilterItem<string> Manufacturer { get; private set; } = new FilterItem<string>();
public FilterItem<string> Publisher { get; private set; } = new FilterItem<string>();
public FilterItem<string> Category { get; private set; } = new FilterItem<string>(); public FilterItem<string> Category { get; private set; } = new FilterItem<string>();
public FilterItem<string> RomOf { get; private set; } = new FilterItem<string>();
public FilterItem<string> CloneOf { get; private set; } = new FilterItem<string>(); public FilterItem<string> CloneOf { get; private set; } = new FilterItem<string>();
public FilterItem<string> SampleOf { get; private set; } = new FilterItem<string>(); public FilterItem<string> CloneOfID { get; private set; } = new FilterItem<string>();
public FilterItem<MachineType> Type { get; private set; } = new FilterItem<MachineType>() { Positive = 0x0, Negative = 0x0 }; public FilterItem<string> Comment { get; private set; } = new FilterItem<string>();
#endregion
#region AttractMode
public FilterItem<string> Players { get; private set; } = new FilterItem<string>();
public FilterItem<string> Rotation { get; private set; } = new FilterItem<string>();
public FilterItem<string> Control { get; private set; } = new FilterItem<string>(); public FilterItem<string> Control { get; private set; } = new FilterItem<string>();
public FilterItem<string> Status { get; private set; } = new FilterItem<string>(); public FilterItem<string> Country { get; private set; } = new FilterItem<string>();
public FilterItem<bool?> CRC { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Description { get; private set; } = new FilterItem<string>();
public FilterItem<string> Developer { get; private set; } = new FilterItem<string>();
public FilterItem<string> DisplayCount { get; private set; } = new FilterItem<string>(); public FilterItem<string> DisplayCount { get; private set; } = new FilterItem<string>();
public FilterItem<string> DisplayType { get; private set; } = new FilterItem<string>(); public FilterItem<string> DisplayType { get; private set; } = new FilterItem<string>();
public FilterItem<string> Buttons { get; private set; } = new FilterItem<string>();
#endregion
#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 };
#endregion
#region Logiqx
public FilterItem<string> Board { get; private set; } = new FilterItem<string>();
public FilterItem<string> RebuildTo { get; private set; } = new FilterItem<string>();
public FilterItem<string> NoIntroId { get; private set; } = new FilterItem<string>();
public FilterItem<string> NoIntroCloneOfId { get; private set; } = new FilterItem<string>();
#endregion
#region Logiqx EmuArc
public FilterItem<string> TitleID { get; private set; } = new FilterItem<string>();
public FilterItem<string> Developer { get; private set; } = new FilterItem<string>();
public FilterItem<string> Genre { get; private set; } = new FilterItem<string>();
public FilterItem<string> Subgenre { get; private set; } = new FilterItem<string>();
public FilterItem<string> Ratings { get; private set; } = new FilterItem<string>();
public FilterItem<string> Score { get; private set; } = new FilterItem<string>();
public FilterItem<string> Enabled { get; private set; } = new FilterItem<string>(); public FilterItem<string> Enabled { get; private set; } = new FilterItem<string>();
public FilterItem<bool?> CRC { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> RelatedTo { get; private set; } = new FilterItem<string>();
#endregion
#region OpenMSX
public FilterItem<string> GenMSXID { get; private set; } = new FilterItem<string>(); public FilterItem<string> GenMSXID { get; private set; } = new FilterItem<string>();
public FilterItem<string> System { get; private set; } = new FilterItem<string>(); public FilterItem<string> Genre { get; private set; } = new FilterItem<string>();
public FilterItem<string> Country { get; private set; } = new FilterItem<string>(); public FilterItem<string> History { get; private set; } = new FilterItem<string>();
public FilterItem<string> ID { get; private set; } = new FilterItem<string>();
#endregion public FilterItem<string> Manufacturer { get; private set; } = new FilterItem<string>();
public FilterItem<string> Name { get; private set; } = new FilterItem<string>();
#region SoftwareList public FilterItem<string> Players { get; private set; } = new FilterItem<string>();
public FilterItem<string> Publisher { get; private set; } = new FilterItem<string>();
public FilterItem<string> Ratings { get; private set; } = new FilterItem<string>();
public FilterItem<string> RebuildTo { get; private set; } = new FilterItem<string>();
public FilterItem<string> RelatedTo { get; private set; } = new FilterItem<string>();
public FilterItem<string> RomOf { get; private set; } = new FilterItem<string>();
public FilterItem<string> Rotation { get; private set; } = new FilterItem<string>();
public FilterItem<Runnable> Runnable { get; private set; } = new FilterItem<Runnable>() { Positive = Core.Runnable.NULL, Negative = Core.Runnable.NULL };
public FilterItem<string> SampleOf { get; private set; } = new FilterItem<string>();
public FilterItem<string> Score { get; private set; } = new FilterItem<string>();
public FilterItem<string> SourceFile { get; private set; } = new FilterItem<string>();
public FilterItem<string> Status { get; private set; } = new FilterItem<string>();
public FilterItem<string> Subgenre { get; private set; } = new FilterItem<string>();
public FilterItem<Supported> Supported { get; private set; } = new FilterItem<Supported>() { Positive = Core.Supported.NULL, Negative = Core.Supported.NULL }; public FilterItem<Supported> Supported { get; private set; } = new FilterItem<Supported>() { Positive = Core.Supported.NULL, Negative = Core.Supported.NULL };
public FilterItem<string> System { get; private set; } = new FilterItem<string>();
#endregion public FilterItem<string> TitleID { get; private set; } = new FilterItem<string>();
public FilterItem<MachineType> Type { get; private set; } = new FilterItem<MachineType>() { Positive = 0x0, Negative = 0x0 };
public FilterItem<string> Year { get; private set; } = new FilterItem<string>();
#endregion // Machine Filters #endregion // Machine Filters
@@ -145,73 +110,48 @@ namespace SabreTools.Filtering
{ {
switch (key) switch (key)
{ {
#region Common case MachineField.Board:
SetStringFilter(Board, value, negate);
case MachineField.Name:
SetStringFilter(Name, value, negate);
break; break;
case MachineField.Comment: case MachineField.Buttons:
SetStringFilter(Comment, value, negate); SetStringFilter(Buttons, value, negate);
break;
case MachineField.Description:
SetStringFilter(Description, value, negate);
break;
case MachineField.Year:
SetStringFilter(Year, value, negate);
break;
case MachineField.Manufacturer:
SetStringFilter(Manufacturer, value, negate);
break;
case MachineField.Publisher:
SetStringFilter(Publisher, value, negate);
break; break;
case MachineField.Category: case MachineField.Category:
SetStringFilter(Category, value, negate); SetStringFilter(Category, value, negate);
break; break;
case MachineField.RomOf:
SetStringFilter(RomOf, value, negate);
break;
case MachineField.CloneOf: case MachineField.CloneOf:
SetStringFilter(CloneOf, value, negate); SetStringFilter(CloneOf, value, negate);
break; break;
case MachineField.SampleOf: case MachineField.CloneOfID:
SetStringFilter(SampleOf, value, negate); SetStringFilter(CloneOfID, value, negate);
break; break;
case MachineField.Type: case MachineField.Comment:
if (negate) SetStringFilter(Comment, value, negate);
Type.Negative |= value.AsMachineType();
else
Type.Positive |= value.AsMachineType();
break;
#endregion
#region AttractMode
case MachineField.Players:
SetStringFilter(Players, value, negate);
break;
case MachineField.Rotation:
SetStringFilter(Rotation, value, negate);
break; break;
case MachineField.Control: case MachineField.Control:
SetStringFilter(Control, value, negate); SetStringFilter(Control, value, negate);
break; break;
case MachineField.Status: case MachineField.CRC:
SetStringFilter(Status, value, negate); SetBooleanFilter(CRC, value, negate);
break;
case MachineField.Country:
SetStringFilter(Country, value, negate);
break;
case MachineField.Description:
SetStringFilter(Description, value, negate);
break;
case MachineField.Developer:
SetStringFilter(Developer, value, negate);
break; break;
case MachineField.DisplayCount: case MachineField.DisplayCount:
@@ -222,20 +162,60 @@ namespace SabreTools.Filtering
SetStringFilter(DisplayType, value, negate); SetStringFilter(DisplayType, value, negate);
break; break;
case MachineField.Buttons: case MachineField.Enabled:
SetStringFilter(Buttons, value, negate); SetStringFilter(Enabled, value, negate);
break; break;
#endregion case MachineField.GenMSXID:
SetStringFilter(GenMSXID, value, negate);
break;
#region ListXML case MachineField.Genre:
SetStringFilter(Genre, value, negate);
break;
case MachineField.History: case MachineField.History:
SetStringFilter(History, value, negate); SetStringFilter(History, value, negate);
break; break;
case MachineField.SourceFile: case MachineField.ID:
SetStringFilter(SourceFile, value, negate); SetStringFilter(ID, value, negate);
break;
case MachineField.Manufacturer:
SetStringFilter(Manufacturer, value, negate);
break;
case MachineField.Name:
SetStringFilter(Name, value, negate);
break;
case MachineField.Players:
SetStringFilter(Players, value, negate);
break;
case MachineField.Publisher:
SetStringFilter(Publisher, value, negate);
break;
case MachineField.Ratings:
SetStringFilter(Ratings, value, negate);
break;
case MachineField.RebuildTo:
SetStringFilter(RebuildTo, value, negate);
break;
case MachineField.RelatedTo:
SetStringFilter(RelatedTo, value, negate);
break;
case MachineField.RomOf:
SetStringFilter(RomOf, value, negate);
break;
case MachineField.Rotation:
SetStringFilter(Rotation, value, negate);
break; break;
case MachineField.Runnable: case MachineField.Runnable:
@@ -243,88 +223,28 @@ namespace SabreTools.Filtering
Runnable.Negative |= value.AsRunnable(); Runnable.Negative |= value.AsRunnable();
else else
Runnable.Positive |= value.AsRunnable(); Runnable.Positive |= value.AsRunnable();
break; break;
#endregion case MachineField.SampleOf:
SetStringFilter(SampleOf, value, negate);
#region Logiqx
case MachineField.Board:
SetStringFilter(Board, value, negate);
break;
case MachineField.RebuildTo:
SetStringFilter(RebuildTo, value, negate);
break;
case MachineField.ID:
SetStringFilter(NoIntroId, value, negate);
break;
case MachineField.CloneOfID:
SetStringFilter(NoIntroCloneOfId, value, negate);
break;
#endregion
#region Logiqx EmuArc
case MachineField.TitleID:
SetStringFilter(TitleID, value, negate);
break;
case MachineField.Developer:
SetStringFilter(Developer, value, negate);
break;
case MachineField.Genre:
SetStringFilter(Genre, value, negate);
break;
case MachineField.Subgenre:
SetStringFilter(Subgenre, value, negate);
break;
case MachineField.Ratings:
SetStringFilter(Ratings, value, negate);
break; break;
case MachineField.Score: case MachineField.Score:
SetStringFilter(Score, value, negate); SetStringFilter(Score, value, negate);
break; break;
case MachineField.Enabled: case MachineField.SourceFile:
SetStringFilter(Enabled, value, negate); SetStringFilter(SourceFile, value, negate);
break; break;
case MachineField.CRC: case MachineField.Status:
SetBooleanFilter(CRC, value, negate); SetStringFilter(Status, value, negate);
break; break;
case MachineField.RelatedTo: case MachineField.Subgenre:
SetStringFilter(RelatedTo, value, negate); SetStringFilter(Subgenre, value, negate);
break; break;
#endregion
#region OpenMSX
case MachineField.GenMSXID:
SetStringFilter(GenMSXID, value, negate);
break;
case MachineField.System:
SetStringFilter(System, value, negate);
break;
case MachineField.Country:
SetStringFilter(Country, value, negate);
break;
#endregion
#region SoftwareList
case MachineField.Supported: case MachineField.Supported:
if (negate) if (negate)
Supported.Negative |= value.AsSupported(); Supported.Negative |= value.AsSupported();
@@ -332,7 +252,24 @@ namespace SabreTools.Filtering
Supported.Positive |= value.AsSupported(); Supported.Positive |= value.AsSupported();
break; break;
#endregion case MachineField.System:
SetStringFilter(System, value, negate);
break;
case MachineField.TitleID:
SetStringFilter(TitleID, value, negate);
break;
case MachineField.Type:
if (negate)
Type.Negative |= value.AsMachineType();
else
Type.Positive |= value.AsMachineType();
break;
case MachineField.Year:
SetStringFilter(Year, value, negate);
break;
} }
} }
@@ -350,7 +287,81 @@ namespace SabreTools.Filtering
if (machine == null) if (machine == null)
return false; return false;
#region Common // Machine_Board
if (!PassStringFilter(Board, machine.Board))
return false;
// Machine_Buttons
if (!PassStringFilter(Buttons, machine.Buttons))
return false;
// Machine_Category
if (!PassStringFilter(Category, machine.Category))
return false;
// Machine_CloneOf
if (!PassStringFilter(CloneOf, machine.CloneOf))
return false;
// Machine_CloneOfID
if (!PassStringFilter(CloneOfID, value: machine.NoIntroCloneOfId))
return false;
// Machine_Comment
if (!PassStringFilter(Comment, machine.Comment))
return false;
// Machine_Control
if (!PassStringFilter(Control, machine.Control))
return false;
// Machine_Country
if (!PassStringFilter(Country, machine.Country))
return false;
// Machine_CRC
if (!PassBoolFilter(CRC, machine.Crc))
return false;
// Machine_Description
if (!PassStringFilter(Description, machine.Description))
return false;
// Machine_Developer
if (!PassStringFilter(Developer, machine.Developer))
return false;
// Machine_DisplayCount
if (!PassStringFilter(DisplayCount, machine.DisplayCount))
return false;
// Machine_DisplayType
if (!PassStringFilter(DisplayType, machine.DisplayType))
return false;
// Machine_Enabled
if (!PassStringFilter(Enabled, machine.Enabled))
return false;
// Machine_GenMSXID
if (!PassStringFilter(GenMSXID, machine.GenMSXID))
return false;
// Machine_Genre
if (!PassStringFilter(Genre, machine.Genre))
return false;
// Machine_History
if (!PassStringFilter(History, machine.History))
return false;
// Machine_ID
if (!PassStringFilter(ID, machine.NoIntroId))
return false;
// Machine_Manufacturer
if (!PassStringFilter(Manufacturer, machine.Manufacturer))
return false;
// Machine_Name // Machine_Name
bool passes = PassStringFilter(Name, machine.Name); bool passes = PassStringFilter(Name, machine.Name);
@@ -362,186 +373,83 @@ namespace SabreTools.Filtering
if (!passes) if (!passes)
return false; return false;
// Machine_Comment // Machine_Players
if (!PassStringFilter(Comment, machine.Comment)) if (!PassStringFilter(Players, machine.Players))
return false;
// Machine_Description
if (!PassStringFilter(Description, machine.Description))
return false;
// Machine_Year
if (!PassStringFilter(Year, machine.Year))
return false;
// Machine_Manufacturer
if (!PassStringFilter(Manufacturer, machine.Manufacturer))
return false; return false;
// Machine_Publisher // Machine_Publisher
if (!PassStringFilter(Publisher, machine.Publisher)) if (!PassStringFilter(Publisher, machine.Publisher))
return false; return false;
// Machine_Category // Machine_Ratings
if (!PassStringFilter(Category, machine.Category)) if (!PassStringFilter(Ratings, machine.Ratings))
return false;
// Machine_RebuildTo
if (!PassStringFilter(RebuildTo, machine.RebuildTo))
return false;
// Machine_RelatedTo
if (!PassStringFilter(RelatedTo, machine.RelatedTo))
return false; return false;
// Machine_RomOf // Machine_RomOf
if (!PassStringFilter(RomOf, machine.RomOf)) if (!PassStringFilter(RomOf, machine.RomOf))
return false; return false;
// Machine_CloneOf
if (!PassStringFilter(CloneOf, machine.CloneOf))
return false;
// Machine_SampleOf
if (!PassStringFilter(SampleOf, machine.SampleOf))
return false;
// Machine_Type
if (Type.MatchesPositive(0x0, machine.MachineType) == false)
return false;
if (Type.MatchesNegative(0x0, machine.MachineType) == true)
return false;
#endregion
#region AttractMode
// Machine_Players
if (!PassStringFilter(Players, machine.Players))
return false;
// Machine_Rotation // Machine_Rotation
if (!PassStringFilter(Rotation, machine.Rotation)) if (!PassStringFilter(Rotation, machine.Rotation))
return false; return false;
// Machine_Control
if (!PassStringFilter(Control, machine.Control))
return false;
// Machine_Status
if (!PassStringFilter(Status, machine.Status))
return false;
// Machine_DisplayCount
if (!PassStringFilter(DisplayCount, machine.DisplayCount))
return false;
// Machine_DisplayType
if (!PassStringFilter(DisplayType, machine.DisplayType))
return false;
// Machine_Buttons
if (!PassStringFilter(Buttons, machine.Buttons))
return false;
#endregion
#region ListXML
// Machine_History
if (!PassStringFilter(History, machine.History))
return false;
// Machine_SourceFile
if (!PassStringFilter(SourceFile, machine.SourceFile))
return false;
// Machine_Runnable // Machine_Runnable
if (Runnable.MatchesPositive(Core.Runnable.NULL, machine.Runnable) == false) if (Runnable.MatchesPositive(Core.Runnable.NULL, machine.Runnable) == false)
return false; return false;
if (Runnable.MatchesNegative(Core.Runnable.NULL, machine.Runnable) == true) if (Runnable.MatchesNegative(Core.Runnable.NULL, machine.Runnable) == true)
return false; return false;
#endregion // Machine_SampleOf
if (!PassStringFilter(SampleOf, machine.SampleOf))
#region Logiqx
// Machine_Board
if (!PassStringFilter(Board, machine.Board))
return false;
// Machine_RebuildTo
if (!PassStringFilter(RebuildTo, machine.RebuildTo))
return false;
// Machine_NoIntroId
if (!PassStringFilter(NoIntroId, machine.NoIntroId))
return false;
// Machine_NoIntroCloneOfId
if (!PassStringFilter(NoIntroCloneOfId, value: machine.NoIntroCloneOfId))
return false;
#endregion
#region Logiqx EmuArc
// Machine_TitleID
if (!PassStringFilter(TitleID, machine.TitleID))
return false;
// Machine_Developer
if (!PassStringFilter(Developer, machine.Developer))
return false;
// Machine_Genre
if (!PassStringFilter(Genre, machine.Genre))
return false;
// Machine_Subgenre
if (!PassStringFilter(Subgenre, machine.Subgenre))
return false;
// Machine_Ratings
if (!PassStringFilter(Ratings, machine.Ratings))
return false; return false;
// Machine_Score // Machine_Score
if (!PassStringFilter(Score, machine.Score)) if (!PassStringFilter(Score, machine.Score))
return false; return false;
// Machine_Enabled // Machine_SourceFile
if (!PassStringFilter(Enabled, machine.Enabled)) if (!PassStringFilter(SourceFile, machine.SourceFile))
return false; return false;
// Machine_CRC // Machine_Status
if (!PassBoolFilter(CRC, machine.Crc)) if (!PassStringFilter(Status, machine.Status))
return false; return false;
// Machine_RelatedTo // Machine_Subgenre
if (!PassStringFilter(RelatedTo, machine.RelatedTo)) if (!PassStringFilter(Subgenre, machine.Subgenre))
return false; return false;
#endregion
#region OpenMSX
// Machine_GenMSXID
if (!PassStringFilter(GenMSXID, machine.GenMSXID))
return false;
// Machine_System
if (!PassStringFilter(System, machine.System))
return false;
// Machine_Country
if (!PassStringFilter(Country, machine.Country))
return false;
#endregion
#region SoftwareList
// Machine_Supported // Machine_Supported
if (Supported.MatchesPositive(Core.Supported.NULL, machine.Supported) == false) if (Supported.MatchesPositive(Core.Supported.NULL, machine.Supported) == false)
return false; return false;
if (Supported.MatchesNegative(Core.Supported.NULL, machine.Supported) == true) if (Supported.MatchesNegative(Core.Supported.NULL, machine.Supported) == true)
return false; return false;
#endregion // SoftwareList // Machine_System
if (!PassStringFilter(System, machine.System))
return false;
// Machine_TitleID
if (!PassStringFilter(TitleID, machine.TitleID))
return false;
// Machine_Type
if (Type.MatchesPositive(0x0, machine.MachineType) == false)
return false;
if (Type.MatchesNegative(0x0, machine.MachineType) == true)
return false;
// Machine_Year
if (!PassStringFilter(Year, machine.Year))
return false;
return true; return true;
} }