Skip to content

Commit

Permalink
Added: Ability to toggle mode for combined tag/trait filtering betwee…
Browse files Browse the repository at this point in the history
…n AND and OR.
  • Loading branch information
Zoltanar committed Nov 8, 2016
1 parent a76ece1 commit acf4a53
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 8 deletions.
25 changes: 22 additions & 3 deletions Visual Novel Database/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 56 additions & 1 deletion Visual Novel Database/FormMainListFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,67 @@ private void ApplyListFilters()
{
tagSignaler.BackColor = _activeTagFilter.Any() ? SignalerActive : SignalerDefault;
traitSignaler.BackColor = _activeTraitFilter.Any() ? SignalerActive : SignalerDefault;
Func<ListedVN, bool>[] funcArray = { GetFunc(ToggleFilter.URT), GetFunc(ToggleFilter.Unreleased), GetFunc(ToggleFilter.Blacklisted), VNMatchesTagFilter, _traitFunction };
Func<ListedVN, bool>[] funcArray;
//do OR for tag/trait filters
if (ToggleFiltersModeButton.Checked)
{
//if both are active
if (_activeTagFilter.Any() && _activeTraitFilter.Any())
{
funcArray = new[] { GetFunc(ToggleFilter.URT), GetFunc(ToggleFilter.Unreleased), GetFunc(ToggleFilter.Blacklisted),
vn => VNMatchesTagFilter(vn) || _traitFunction(vn) };

}
//if only tagfilter is active
else if (_activeTagFilter.Any() && !_activeTraitFilter.Any())
{
funcArray = new[] { GetFunc(ToggleFilter.URT), GetFunc(ToggleFilter.Unreleased), GetFunc(ToggleFilter.Blacklisted),
VNMatchesTagFilter };
}
//if only traitfilter is active
else if (!_activeTagFilter.Any() && _activeTraitFilter.Any())
{
funcArray = new[]
{
GetFunc(ToggleFilter.URT), GetFunc(ToggleFilter.Unreleased), GetFunc(ToggleFilter.Blacklisted),
_traitFunction
};
}
//if none are active
else
{
funcArray = new[]{GetFunc(ToggleFilter.URT), GetFunc(ToggleFilter.Unreleased), GetFunc(ToggleFilter.Blacklisted)};
}
}
else
{
funcArray = new[] { GetFunc(ToggleFilter.URT), GetFunc(ToggleFilter.Unreleased), GetFunc(ToggleFilter.Blacklisted), VNMatchesTagFilter, _traitFunction };
}
tileOLV.ModelFilter = new ModelFilter(vn => funcArray.Select(filter => filter((ListedVN)vn)).All(valid => valid));
objectList_ItemsChanged(null, null);
SaveMainXML();
}

private void ToggleFiltersMode(object sender, EventArgs e)
{
if (ToggleFiltersModeButton.Checked)
{
ToggleFiltersModeButton.BackColor = Color.LightGreen;
ToggleFiltersModeButton.ForeColor = Color.Black;
ToggleFiltersModeButton.Text = @"Or";
}
else
{
ToggleFiltersModeButton.BackColor = Color.Black;
ToggleFiltersModeButton.ForeColor = Color.White;
ToggleFiltersModeButton.Text = @"And";
}
//only reapply filters if both are active (if only one is active, the result would be the same)
if (_activeTagFilter.Any() && _activeTraitFilter.Any())
{
ApplyListFilters();
}
}
#endregion

#region List Results
Expand Down
4 changes: 2 additions & 2 deletions Visual Novel Database/Program Data/Changelog and more.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ Next Milestone == ??

Changelog
---------
Added: Option to toggle mode of combined tag/trait filtering between AND and OR. (Allows for things such as tag=chuunibyou heroine OR trait=personality>chuunibyou)
Added: Logging of features on begin and end. Only with -debug.
Added: Indicators of when tag/trait filters are active.
Added: Command line parameters, described below.
Added: Tooltips to VNs.
Added: Tooltips for VNs.
Fixed: All batch SQLite inserts/updates made into transactions.
Changed: Removed "Loaded" field of Favorite producer.
Changed: Direct command requires to click on send button (instead of enter key)
Expand Down Expand Up @@ -78,7 +79,6 @@ merge feature to merge 2 databases, keeping most-recently-updated in case of sam
better vn character display?
--
let user know of any updates to happy search
add option to make tag/trait filters as OR (e.g. tag=chuunibyou heroine OR trait=personality>chuunibyou)
--


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ <h3>Update</h3>
<p>Gets new titles by producer from VNDB that aren't already in local database.</p>
<h2>Filtering</h2>
<h3>Tag/Trait Filter Indicators</h3>
<p>The small squares indicate whether the tag and/or trait filters, respectively, are active.<br />
Red means they are active and gray means they are not. Click to clear it.</p>
<p>
The small squares indicate whether the tag and/or trait filters, respectively, are active.<br />
Red means they are active and gray means they are not. Click an indicator to clear the respective filter.
</p>
<p>
The button in between indicates whether the filters are used in &#39;AND&#39; mode or &#39;OR&#39; mode.<br />
&#39;AND&#39; mode will list titles that BOTH have all tags in the active tag filter AND characters with all traits in the active trait filter.<br />
&#39;OR&#39; mode will list titles that EITHER have all tags in the active tag filter OR characters with all traits in the active trait filter.
</p>
<h3>URT</h3>
<p>Select whether to show user-related titles, hide them, show ONLY User-related titles, or only show titles that user hasn't finished or dropped.</p>
<h3>Unreleased</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>Trait Filtering</h1>
<li>Choose the type of trait to be added to the list with the dropdown list and type in the name of the trait in the textbox beside it, is case-insensitive and if you wish to use the auto-suggestions you must type in order.</li>
<li>Current trait filters will be displayed below the search box, you can uncheck the checkboxes to remove the trait filter.</li>
<li>You can save a selection of filters as a custom filter in order to quickly filter by the saved traits instead of having to add them one by one each time.</li>
<li>Note that the filtering doesn&#39;t require that a single character has all the traits, just that the combination of all the title&#39;s characters has all the traits.</li>
</ul>
<h2>Buttons and Boxes</h2>
<h3>Trait Type Dropdown List</h3>
Expand Down

0 comments on commit acf4a53

Please sign in to comment.