mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, Filter] Add filter by game description (fixes #5)
This commit is contained in:
@@ -23,6 +23,7 @@ namespace SabreTools.Library.DatFiles
|
||||
#region Positive
|
||||
|
||||
private List<string> _gameNames;
|
||||
private List<string> _gameDescriptions;
|
||||
private List<string> _romNames;
|
||||
private List<string> _romTypes;
|
||||
private List<string> _crcs;
|
||||
@@ -39,6 +40,7 @@ namespace SabreTools.Library.DatFiles
|
||||
#region Negative
|
||||
|
||||
private List<string> _notGameNames;
|
||||
private List<string> _notGameDescriptions;
|
||||
private List<string> _notRomNames;
|
||||
private List<string> _notRomTypes;
|
||||
private List<string> _notCrcs;
|
||||
@@ -76,6 +78,11 @@ namespace SabreTools.Library.DatFiles
|
||||
get { return _gameNames; }
|
||||
set { _gameNames = value; }
|
||||
}
|
||||
public List<string> MachineDescriptions
|
||||
{
|
||||
get { return _gameDescriptions; }
|
||||
set { _gameDescriptions = value; }
|
||||
}
|
||||
public List<string> ItemNames
|
||||
{
|
||||
get { return _romNames; }
|
||||
@@ -136,6 +143,11 @@ namespace SabreTools.Library.DatFiles
|
||||
get { return _notGameNames; }
|
||||
set { _notGameNames = value; }
|
||||
}
|
||||
public List<string> NotMachineDescriptions
|
||||
{
|
||||
get { return _notGameDescriptions; }
|
||||
set { _notGameDescriptions = value; }
|
||||
}
|
||||
public List<string> NotItemNames
|
||||
{
|
||||
get { return _notRomNames; }
|
||||
@@ -655,6 +667,28 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on game description
|
||||
if (_gameDescriptions.Count > 0)
|
||||
{
|
||||
bool found = FindValueInList(_gameDescriptions, item.MachineDescription);
|
||||
|
||||
// If the game description was not found in the list, return false
|
||||
if (!found)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notGameDescriptions.Count > 0)
|
||||
{
|
||||
bool found = FindValueInList(_notGameDescriptions, item.MachineDescription);
|
||||
|
||||
// If the game description was found in the list, return false
|
||||
if (found)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on rom name
|
||||
if (_romNames.Count > 0)
|
||||
{
|
||||
|
||||
@@ -1406,6 +1406,17 @@ namespace SabreTools
|
||||
null);
|
||||
}
|
||||
}
|
||||
private static Feature gameDescriptionListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
new List<string>() { "-gd", "--game-description" },
|
||||
"Filter by game description",
|
||||
FeatureType.List,
|
||||
null);
|
||||
}
|
||||
}
|
||||
private static Feature gameNameListInput
|
||||
{
|
||||
get
|
||||
@@ -1476,6 +1487,17 @@ namespace SabreTools
|
||||
null);
|
||||
}
|
||||
}
|
||||
private static Feature notGameDescriptionListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
new List<string>() { "-ngd", "--not-game-description" },
|
||||
"Filter by not game description",
|
||||
FeatureType.List,
|
||||
null);
|
||||
}
|
||||
}
|
||||
private static Feature notGameNameListInput
|
||||
{
|
||||
get
|
||||
@@ -2330,6 +2352,8 @@ namespace SabreTools
|
||||
update["reverse-base-replace"].AddFeature("update-manufacturer", updateManufacturerFlag);
|
||||
update.AddFeature("game-name", gameNameListInput);
|
||||
update.AddFeature("not-game-name", notGameNameListInput);
|
||||
update.AddFeature("game-description", gameDescriptionListInput);
|
||||
update.AddFeature("not-game-description", notGameDescriptionListInput);
|
||||
update.AddFeature("match-of-tags", matchOfTagsFlag);
|
||||
update.AddFeature("item-name", itemNameListInput);
|
||||
update.AddFeature("not-item-name", notItemNameListInput);
|
||||
|
||||
@@ -589,6 +589,9 @@ namespace SabreTools
|
||||
case "extb":
|
||||
extb.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
case "game-description":
|
||||
filter.MachineDescriptions.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
case "game-name":
|
||||
filter.MachineNames.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
@@ -610,6 +613,9 @@ namespace SabreTools
|
||||
case "not-crc":
|
||||
filter.NotCRCs.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
case "not-game-description":
|
||||
filter.NotMachineDescriptions.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
case "not-game-name":
|
||||
filter.NotMachineNames.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user