From c7b3dc5582c3533ff4c325310a05eb0e5ad8c54a Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 25 Aug 2024 00:23:11 -0400 Subject: [PATCH] Press F1 in save search to open help text + document new advanced search I tried to document everything the advanced search does, but it was mostly a guessing game discovering all its features. It appears to be insanely powerful, supporting AND, OR, negation, parenthesis,quote-encapsulated phrases, and limiting search to only certain fields. These can be chained together as well. I tried giving examples that could possibly be useful. Terms like before: and after: are not part of advanced search, and thus are global search options even if they're inside parenthesis --- src/gui/search/SearchView.cpp | 37 ++++++++++++++++++++++++++++++++++- src/gui/search/SearchView.h | 1 + 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/gui/search/SearchView.cpp b/src/gui/search/SearchView.cpp index dd84d631c..80e5d14aa 100644 --- a/src/gui/search/SearchView.cpp +++ b/src/gui/search/SearchView.cpp @@ -3,6 +3,7 @@ #include "SearchModel.h" #include "client/Client.h" #include "client/SaveInfo.h" +#include "gui/dialogues/InformationMessage.h" #include "gui/interface/SaveButton.h" #include "gui/interface/Button.h" #include "gui/interface/Label.h" @@ -45,7 +46,7 @@ SearchView::SearchView(): AddComponent(pageCountLabel); AddComponent(pageTextbox); - searchField = new ui::Textbox(ui::Point(60, 10), ui::Point(WINDOWW-283, 17), "", "[search]"); + searchField = new ui::Textbox(ui::Point(60, 10), ui::Point(WINDOWW-283, 17), "", "[search, F1 for help]"); searchField->Appearance.icon = IconSearch; searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; searchField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; @@ -165,6 +166,38 @@ void SearchView::doSearch() c->DoSearch(searchField->GetText()); } +void SearchView::searchHelp() +{ + String info = + "Type in the search bar to begin automatically searching save titles and tags. Search terms are ORed together.\n" + "\n" + "Sorting: click the \bt\"By Votes\"\bw / \bt\"By Date\"\bw buttons to change the order saves are displayed in\n" + "Categories: If you're logged in, use \bt\"My Own\"\bw to view only your own saves, or click the Star icon to view your favorited saves\n" + "Date Range: Click the dropdown to the right of the search box to select the date range for your search\n" + "\n" + "Special search terms:\n" + "\btid:#######\bw - search by save id\n" + "\bthistory:#######\bw - see previous versions for a save id\n" + "\btuser:XXXXXX\bw - search for saves by a specific user\n" + "\btbefore:YYYY-MM-DD\bw - all saves originally created before a certain date. Month and Day portions are both optional\n" + "\btafter:YYYY-MM-DD\bw - all saves originally created after a certain date. Month and Day portions are both optional\n" + "\n" + "Advanced search:\n" + "Start a search with \bt~\bw to do an advanced search. This search works across save titles, descriptions, usernames, and tags, rather than only save titles and tags." + " It also concatenates search terms with AND instead of OR.\n" + "Use \bt|\bw to OR together search terms, for example \bg~bomb | nuke | explosive\bw\n" + "Use \bt!\bw to negate terms, for example \bg~city !destroyable !desert\bw\n" + "Use \bt\"\bw to create multi-word search terms, for example \bg~\"power plant\" uran | plut | polo\bw\n" + "Use \bt@title\bw to limit search to only save titles, for example \bg~@title subframe\bw\n" + "Use \bt@description\bw to limit search to only save descriptions, for example \bg~@description \"No description provided\"\bw\n" + "Use \bt@user\bw to limit search to only specific users, for example \bg~@user 117n00b | Catelite | Fluttershy @title laser\bw\n" + "Use \bt@tags\bw to limit search to only specific users, for example \bg~@tags resistcup @title printer | @description spider before:2024-06\bw\n" + "Parenthesis can be used to further complicate your searches. For example: \bg~(@user MG99 @description complete) | (@user goglesq @tags tutorial)\bw" + ; + + new InformationMessage("Search Help", info, true); +} + void SearchView::clearSearch() { searchField->SetText(""); @@ -664,6 +697,8 @@ void SearchView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctr c->SelectAllSaves(); else if (key == SDLK_LCTRL || key == SDLK_RCTRL) c->InstantOpen(true); + else if (key == SDLK_F1) + searchHelp(); } void SearchView::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) diff --git a/src/gui/search/SearchView.h b/src/gui/search/SearchView.h index 6a2b26dbd..49d55b8f8 100644 --- a/src/gui/search/SearchView.h +++ b/src/gui/search/SearchView.h @@ -42,6 +42,7 @@ private: ui::Button * unpublishSelected; ui::Button * favouriteSelected; ui::Button * clearSelection; + void searchHelp(); void clearSearch(); void doSearch(); void textChanged();