mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-25 02:42:18 -05:00
filter randomizer checks in tracker (#4021)
* filter randomizer checks in tracker Co-authored-by: Michael Stergianis <michael.stergianis@gmail.com> * Adds an option to hide empty areas Co-authored-by: Jamie Klassen <jamie@tenkeylabs.com> Signed-off-by: Michael Stergianis <michael.stergianis@gmail.com> * Removes extra whitespace Co-authored-by: Jamie Klassen <jamie@tenkeylabs.com> Signed-off-by: Michael Stergianis <michael.stergianis@gmail.com> * Changes gCheckTrackerHideFilteredAreas to default to true Refactors the for loop in shouldHideArea Signed-off-by: Michael Stergianis <michael.stergianis@gmail.com> * Addresses PR feedback * https://github.com/HarbourMasters/Shipwright/pull/4021#discussion_r1538377614 * https://github.com/HarbourMasters/Shipwright/pull/4021#discussion_r1538381310 Co-authored-by: Jamie Klassen <jamie@tenkeylabs.com> Signed-off-by: Michael Stergianis <michael.stergianis@gmail.com> * Updates config variable to gTrackers.CheckTracker.HideFilteredAreas Signed-off-by: Michael Stergianis <michael.stergianis@gmail.com> * Adds check visibility guard to shouldHideArea Refactors rcObject to check in passesTextFilter Signed-off-by: Michael Stergianis <michael.stergianis@gmail.com> --------- Signed-off-by: Michael Stergianis <michael.stergianis@gmail.com> Co-authored-by: Michael Stergianis <michael.stergianis@gmail.com>
This commit is contained in:
parent
3e32d05173
commit
2aa2092c27
@ -133,6 +133,8 @@ RandomizerCheckArea previousArea = RCAREA_INVALID;
|
||||
RandomizerCheckArea currentArea = RCAREA_INVALID;
|
||||
OSContPad* trackerButtonsPressed;
|
||||
|
||||
bool passesTextFilter(ImGuiTextFilter& checkSearch, const RandomizerCheckObject rcObject);
|
||||
bool shouldHideArea(ImGuiTextFilter& checkSearch, std::map<RandomizerCheckArea, std::vector<RandomizerCheckObject>> checksByArea, const RandomizerCheckArea rcArea);
|
||||
void BeginFloatWindows(std::string UniqueName, bool& open, ImGuiWindowFlags flags = 0);
|
||||
bool CompareChecks(RandomizerCheckObject, RandomizerCheckObject);
|
||||
bool CheckByArea(RandomizerCheckArea);
|
||||
@ -927,6 +929,14 @@ void CheckTrackerWindow::DrawElement() {
|
||||
optExpandAll = false;
|
||||
optCollapseAll = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
static ImGuiTextFilter checkSearch;
|
||||
if (ImGui::Button("Clear")) {
|
||||
checkSearch.Clear();
|
||||
}
|
||||
UIWidgets::Tooltip("Clear the search field");
|
||||
checkSearch.Draw();
|
||||
|
||||
UIWidgets::PaddedSeparator();
|
||||
|
||||
//Checks Section Lead-in
|
||||
@ -973,10 +983,9 @@ void CheckTrackerWindow::DrawElement() {
|
||||
previousShowHidden = showHidden;
|
||||
doAreaScroll = true;
|
||||
}
|
||||
if (!showHidden && (
|
||||
hideComplete && thisAreaFullyChecked ||
|
||||
hideIncomplete && !thisAreaFullyChecked
|
||||
)) {
|
||||
if (shouldHideArea(checkSearch, checksByArea, rcArea) ||
|
||||
(!showHidden && ((hideComplete && thisAreaFullyChecked) || (hideIncomplete && !thisAreaFullyChecked)))
|
||||
) {
|
||||
doDraw = false;
|
||||
} else {
|
||||
//Get the colour for the area
|
||||
@ -1035,11 +1044,14 @@ void CheckTrackerWindow::DrawElement() {
|
||||
ImGui::SetScrollHereY(0.0f);
|
||||
doAreaScroll = false;
|
||||
}
|
||||
for (auto rco : objs) {
|
||||
if (IsVisibleInCheckTracker(rco) && doDraw && isThisAreaSpoiled) {
|
||||
DrawLocation(rco);
|
||||
|
||||
for (auto rcObject : objs) {
|
||||
if (IsVisibleInCheckTracker(rcObject) && passesTextFilter(checkSearch, rcObject) && doDraw &&
|
||||
isThisAreaSpoiled) {
|
||||
DrawLocation(rcObject);
|
||||
}
|
||||
}
|
||||
|
||||
if (doDraw) {
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@ -1055,6 +1067,28 @@ void CheckTrackerWindow::DrawElement() {
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldHideArea(ImGuiTextFilter& checkSearch, std::map<RandomizerCheckArea, std::vector<RandomizerCheckObject>> checksByArea, RandomizerCheckArea rcArea) {
|
||||
bool shouldHideFilteredAreas = CVarGetInteger("gTrackers.CheckTracker.HideFilteredAreas", 1);
|
||||
if (!shouldHideFilteredAreas) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto check : checksByArea[rcArea]) {
|
||||
if (IsVisibleInCheckTracker(check) && passesTextFilter(checkSearch, check)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool passesTextFilter(ImGuiTextFilter& checkSearch, RandomizerCheckObject check) {
|
||||
return (
|
||||
checkSearch.PassFilter(RandomizerCheckObjects::GetRCAreaName(check.rcArea).c_str()) ||
|
||||
checkSearch.PassFilter(check.rcShortName.c_str())
|
||||
);
|
||||
}
|
||||
|
||||
// Windowing stuff
|
||||
void BeginFloatWindows(std::string UniqueName, bool& open, ImGuiWindowFlags flags) {
|
||||
ImGuiWindowFlags windowFlags = flags;
|
||||
@ -1604,6 +1638,11 @@ void CheckTrackerSettingsWindow::DrawElement() {
|
||||
}
|
||||
UIWidgets::Tooltip("If enabled, will show GS locations in the tracker regardless of tokensanity settings.");
|
||||
|
||||
// Filtering settings
|
||||
UIWidgets::PaddedSeparator();
|
||||
UIWidgets::EnhancementCheckbox("Filter Empty Areas", "gTrackers.CheckTracker.HideFilteredAreas", false, "", UIWidgets::CheckboxGraphics::Checkmark, true);
|
||||
UIWidgets::Tooltip("If enabled, will hide area headers that have no locations matching filter");
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
CheckTracker::ImGuiDrawTwoColorPickerSection("Area Incomplete", "gCheckTrackerAreaMainIncompleteColor", "gCheckTrackerAreaExtraIncompleteColor", Color_Area_Incomplete_Main, Color_Area_Incomplete_Extra, Color_Main_Default, Color_Area_Incomplete_Extra_Default, "gCheckTrackerAreaIncompleteHide", "");
|
||||
|
Loading…
Reference in New Issue
Block a user