From 4077719af28136e102423c47099974caf9adb0fb Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Mon, 13 Dec 2021 05:27:00 -0500 Subject: [PATCH] feat: add tag exclusions --- Glamaholic/Ui/MainInterface.cs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Glamaholic/Ui/MainInterface.cs b/Glamaholic/Ui/MainInterface.cs index 2d52cdd..b52ba7b 100755 --- a/Glamaholic/Ui/MainInterface.cs +++ b/Glamaholic/Ui/MainInterface.cs @@ -907,6 +907,7 @@ namespace Glamaholic.Ui { private string Query { get; } private HashSet WantedJobs { get; } = new(); private HashSet Tags { get; } = new(); + private HashSet ExcludeTags { get; } = new(); private HashSet ItemIds { get; } = new(); private HashSet 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)