feat: add tag exclusions

This commit is contained in:
Anna 2021-12-13 05:27:00 -05:00
parent ca8beb53cc
commit 4077719af2
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
1 changed files with 32 additions and 1 deletions

View File

@ -907,6 +907,7 @@ namespace Glamaholic.Ui {
private string Query { get; }
private HashSet<ClassJob> WantedJobs { get; } = new();
private HashSet<string> Tags { get; } = new();
private HashSet<string> ExcludeTags { get; } = new();
private HashSet<uint> ItemIds { get; } = new();
private HashSet<string> ItemNames { get; } = new();
@ -934,6 +935,9 @@ namespace Glamaholic.Ui {
case 2:
this.ItemNames.Add(quoted);
break;
case 3:
this.ExcludeTags.Add(quoted);
break;
}
quoted = null;
@ -984,6 +988,21 @@ namespace Glamaholic.Ui {
continue;
}
if (word.StartsWith("!t:")) {
if (word.StartsWith("!t:\"")) {
if (word.EndsWith('"') && word.Length >= 6) {
this.ExcludeTags.Add(word[4..^1]);
} else {
quoteType = 3;
quoted = word[4..];
}
} else {
this.ExcludeTags.Add(word[3..]);
}
continue;
}
if (word.StartsWith("id:")) {
if (uint.TryParse(word[3..], out var id)) {
this.ItemIds.Add(id);
@ -1020,7 +1039,13 @@ namespace Glamaholic.Ui {
}
// if there's nothing custom about this filter, this is a match
if (this.MaxLevel == 0 && this.WantedJobs.Count == 0 && this.Tags.Count == 0 && this.ItemIds.Count == 0 && this.ItemNames.Count == 0) {
var notCustom = this.MaxLevel == 0
&& this.WantedJobs.Count == 0
&& this.Tags.Count == 0
&& this.ExcludeTags.Count == 0
&& this.ItemIds.Count == 0
&& this.ItemNames.Count == 0;
if (notCustom) {
return true;
}
@ -1030,6 +1055,12 @@ namespace Glamaholic.Ui {
}
}
foreach (var tag in this.ExcludeTags) {
if (plate.Tags.Contains(tag)) {
return false;
}
}
if (this.ItemIds.Count > 0) {
var matching = plate.Items.Values
.Select(mirage => mirage.ItemId)