[Scummvm-git-logs] scummvm master -> 6aa05f4c18ec6cdcb617a2b58bcccf70542e4edc
sev-
sev at scummvm.org
Mon Nov 1 14:29:40 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
498f0ac8aa GUI: Extend ListWidget to use custom filter matchers
46f11f6c77 GUI: Use custom matcher for games list
6aa05f4c18 DOCS: Add documentation for the advanced search box usage
Commit: 498f0ac8aacf0aeaf977eb153737ef82392b83fd
https://github.com/scummvm/scummvm/commit/498f0ac8aacf0aeaf977eb153737ef82392b83fd
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-11-01T15:29:34+01:00
Commit Message:
GUI: Extend ListWidget to use custom filter matchers
Changed paths:
gui/widgets/list.cpp
gui/widgets/list.h
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 8d3c500565..89a86256b6 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -33,6 +33,10 @@
namespace GUI {
+bool ListWidgetDefaultMatcher(void *, int, const Common::U32String &item, Common::U32String token) {
+ return item.contains(token);
+}
+
ListWidget::ListWidget(Dialog *boss, const String &name, const U32String &tooltip, uint32 cmd)
: EditableWidget(boss, name, tooltip), _cmd(cmd) {
@@ -62,6 +66,9 @@ ListWidget::ListWidget(Dialog *boss, const String &name, const U32String &toolti
_editColor = ThemeEngine::kFontColorNormal;
_dictionarySelect = false;
+ _filterMatcher = ListWidgetDefaultMatcher;
+ _filterMatcherArg = nullptr;
+
_lastRead = -1;
_hlLeftPadding = _hlRightPadding = 0;
@@ -98,6 +105,9 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const U32String
_editColor = ThemeEngine::kFontColorNormal;
_dictionarySelect = false;
+ _filterMatcher = ListWidgetDefaultMatcher;
+ _filterMatcherArg = nullptr;
+
_lastRead = -1;
_hlLeftPadding = _hlRightPadding = 0;
@@ -757,8 +767,7 @@ void ListWidget::setFilter(const U32String &filter, bool redraw) {
_list = _dataList;
_listIndex.clear();
} else {
- // Restrict the list to everything which contains all words in _filter
- // as substrings, ignoring case.
+ // Restrict the list to everything which matches all tokens in _filter, ignoring case.
Common::U32StringTokenizer tok(_filter);
U32String tmp;
@@ -773,7 +782,7 @@ void ListWidget::setFilter(const U32String &filter, bool redraw) {
bool matches = true;
tok.reset();
while (!tok.empty()) {
- if (!tmp.contains(tok.nextToken())) {
+ if (!_filterMatcher(_filterMatcherArg, n, tmp, tok.nextToken())) {
matches = false;
break;
}
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index c0590536e6..2be92d1419 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -56,6 +56,8 @@ public:
typedef Common::Array<Common::U32String> U32StringArray;
typedef Common::Array<ThemeEngine::FontColor> ColorList;
+
+ typedef bool (*FilterMatcher)(void *arg, int idx, const Common::U32String &item, Common::U32String token);
protected:
U32StringArray _list;
U32StringArray _dataList;
@@ -91,6 +93,9 @@ protected:
int _lastRead;
+ FilterMatcher _filterMatcher;
+ void *_filterMatcherArg;
+
public:
ListWidget(Dialog *boss, const String &name, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
ListWidget(Dialog *boss, int x, int y, int w, int h, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
@@ -123,6 +128,7 @@ public:
bool isEditable() const { return _editable; }
void setEditable(bool editable) { _editable = editable; }
void setEditColor(ThemeEngine::FontColor color) { _editColor = color; }
+ void setFilterMatcher(FilterMatcher matcher, void *arg) { _filterMatcher = matcher; _filterMatcherArg = arg; }
// Made startEditMode/endEditMode for SaveLoadChooser
void startEditMode() override;
Commit: 46f11f6c772e5bdfb7e2d09fd32f49ec7cb60644
https://github.com/scummvm/scummvm/commit/46f11f6c772e5bdfb7e2d09fd32f49ec7cb60644
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-11-01T15:29:34+01:00
Commit Message:
GUI: Use custom matcher for games list
Changed paths:
gui/launcher.cpp
gui/launcher.h
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 3ca3c3c3fa..fda00e49f0 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -94,6 +94,54 @@ enum {
#pragma mark -
+bool LauncherFilterMatcher(void *boss, int idx, const Common::U32String &item, Common::U32String token) {
+ bool invert = false;
+ while (token.size() && token[0] == '!') {
+ token = token.substr(1);
+ invert = !invert;
+ }
+
+ bool result = false;
+ Common::String token8 = token;
+ size_t pos = token8.findFirstOf(":=~");
+ if (pos != token8.npos) {
+ Common::String key = token8.substr(0, token8.findFirstOf(token8[pos]));
+ Common::String filter = token8.substr(token8.findFirstOf(token8[pos]) + 1);
+
+ if (key.size()) {
+ if (Common::String("description").hasPrefix(key)) {
+ key = "description";
+ } else if (Common::String("engineid").hasPrefix(key)) {
+ key = "engineid";
+ } else if (Common::String("gameid").hasPrefix(key)) {
+ key = "gameid";
+ } else if (Common::String("language").hasPrefix(key)) {
+ key = "language";
+ } else if (Common::String("path").hasPrefix(key)) {
+ key = "path";
+ } else if (Common::String("platform").hasPrefix(key)) {
+ key = "platform";
+ }
+ }
+
+ LauncherDialog *launcher = (LauncherDialog *)(boss);
+ Common::String data = launcher->getGameConfig(idx, key);
+ data.toLowercase();
+
+ if (token8[pos] == ':') {
+ result = data.contains(filter);
+ } else if (token8[pos] == '=') {
+ result = data == filter;
+ } else if (token8[pos] == '~') {
+ result = data.matchString(filter, false, false);
+ }
+ } else {
+ result = item.contains(token);
+ }
+
+ return invert ? !result : result;
+}
+
LauncherDialog::LauncherDialog()
: Dialog("Launcher") {
@@ -191,6 +239,7 @@ void LauncherDialog::build() {
_list->setEditable(false);
_list->enableDictionarySelect(true);
_list->setNumberingMode(kListNumberingOff);
+ _list->setFilterMatcher(LauncherFilterMatcher, this);
// Populate the list
updateListing();
@@ -410,6 +459,13 @@ void LauncherDialog::massAddGame() {
}
}
+Common::String LauncherDialog::getGameConfig(int item, Common::String key) {
+ if (ConfMan.hasKey(key, _domains[item])) {
+ return ConfMan.get(key, _domains[item]);
+ }
+ return "";
+}
+
void LauncherDialog::removeGame(int item) {
MessageDialog alert(_("Do you really want to remove this game configuration?"), _("Yes"), _("No"));
diff --git a/gui/launcher.h b/gui/launcher.h
index d44771e2e7..e6d38b66b3 100644
--- a/gui/launcher.h
+++ b/gui/launcher.h
@@ -56,6 +56,7 @@ public:
void handleKeyUp(Common::KeyState state) override;
void handleOtherEvent(const Common::Event &evt) override;
bool doGameDetection(const Common::String &path);
+ Common::String getGameConfig(int item, Common::String key);
protected:
EditTextWidget *_searchWidget;
ListWidget *_list;
Commit: 6aa05f4c18ec6cdcb617a2b58bcccf70542e4edc
https://github.com/scummvm/scummvm/commit/6aa05f4c18ec6cdcb617a2b58bcccf70542e4edc
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-11-01T15:29:34+01:00
Commit Message:
DOCS: Add documentation for the advanced search box usage
Changed paths:
A doc/docportal/advanced_topics/understand_search_box.rst
doc/docportal/advanced_topics/configuration_file.rst
doc/docportal/index.rst
doc/docportal/use_scummvm/the_launcher.rst
diff --git a/doc/docportal/advanced_topics/configuration_file.rst b/doc/docportal/advanced_topics/configuration_file.rst
index 88756ca105..aece1e08bb 100755
--- a/doc/docportal/advanced_topics/configuration_file.rst
+++ b/doc/docportal/advanced_topics/configuration_file.rst
@@ -124,6 +124,7 @@ Example of a configuration file
path=C:\amiga_mi2\
music_driver=windows
+.. _configuration_keys:
Configuration keys
=====================
diff --git a/doc/docportal/advanced_topics/understand_search_box.rst b/doc/docportal/advanced_topics/understand_search_box.rst
new file mode 100644
index 0000000000..70271d6c14
--- /dev/null
+++ b/doc/docportal/advanced_topics/understand_search_box.rst
@@ -0,0 +1,137 @@
+======================================================
+Understanding the search box
+======================================================
+
+This guide expands on the information contained on the :ref:`The search box <search_box>` section of the Launcher interface description.
+
+
+Main functionality
+===========================================
+
+The filter is applied as you type, there is no need to press Enter or click anything to perform the search.
+
+All searchs are case insensitive, there is no way to force the case sensitive search.
+
+To reset the filter and get the full list of games, you could click on a cross icon on the right.
+
+
+Search patterns
+===========================================
+
+Whitespace breaks the search input into separate tokens, search patterns.
+
+Simple patterns
+___________________________________________
+
+If search pattern does not contain ``:``/``=``/``~`` characters and it does not start with ``!`` character, then it's used for a case insensitive substring search.
+
+For example, if you type ``m`` you would get all the games containing letter 'M' in description.
+
+If you type ``monkey``, you would get games like "The Curse of Monkey Island (Demo/Windows)", "Infinite Monkeys", "Three Monkeys, One Cage", etc.
+
+This is what you need in most simple cases, but is not enough to search for more complex things.
+
+Let's search the configuration key's values
+___________________________________________
+
+Game properties listed at :doc:`configuration_file` can be checked with the filter as well.
+
+Advanced patterns
+*******************************************
+
+There are currently 3 types of patterns, that can be used for accessing configuration file:
+
+.. csv-table::
+ :header-rows: 1
+ :class: config
+
+ Type,Description,Example,Example result
+ "<key>=<value>", check exact value of ``<key>``, ``gameid=reversion2``, games with exact gameid "reversion2"
+ "<key>:<value>", search substring at ``<key>``, ``description::``, games with ":" substring at description
+ "<key>~<value>", match wildcard against ``<key>``, ``path~D:\\games\\*``, games located at Windows folder D:\\Games\\
+
+Available configuration keys
+*******************************************
+
+.. note::
+
+ The ``\`` character used at Windows paths should be escaped as ``\\`` when using wildcards.
+
+You can use any :ref:`configuration_keys` as a ``<key>`` part of the search pattern.
+
+Here are some more examples:
+
+- ``show_fps=true`` - games with "Show FPS" option set to true
+- ``extra~?*`` - games with non-empty extra part of the description
+- ``guioptions:noLang`` - games without displayed language
+- ``keymap_engine-default_LCLK:MOUSE_RIGHT`` - games with right mouse button remapped to left mouse button
+
+Abbrivating configuration keys
+*******************************************
+
+Some common used configuration keys can be abbrivated, just type any prefix instead of full strings for those 6 keys:
+
+.. csv-table::
+ :header-rows: 1
+ :class: config
+
+ Full key,Description,Examples
+ ``description``, game description as displayed at the game list,"
+
+ - ``d:monkey``
+ - ``desc:monkey``
+ - ``descr:monkey``
+ - ``description:monkey``"
+ ``engineid``, internal ID of the game engine,"
+
+ - ``e:ags``
+ - ``engine:monkey``
+ - ``engineed:monkey``"
+ ``gameid``, internal ID of the game,"
+
+ - ``g:monkey``
+ - ``game:monkey``
+ - ``gameid:monkey``"
+ ``language``, internal ID of the language (usually 2 letter code like "de"/"en"/"fr"/"jp"/etc),"
+
+ - ``l=en``
+ - ``lang=en``
+ - ``language=en``"
+ ``path``, Filesystem path for the game,"
+
+ - ``p~D:*``
+ - ``path~D:*``"
+ ``path``, Filesystem path for the game,"
+
+ - ``pl~windows``
+ - ``platform~windows``"
+
+.. note::
+
+ The ``platform`` key can't be abbrivated to ``p``, since ``p`` is already used for ``path``.
+
+
+Inverting any search pattern
+___________________________________________
+
+Prefixing search pattern with `!` character inverts the result:
+
+- ``!GOG`` - games that don't contain "GOG" substring in description
+- ``!lang=ru`` - games not in Russian languange
+- ``!p:demo`` - games that don't have "demo" substring in game path
+- ``!engine~sword#`` - games not made with "sword1" and "sword2" engines (but "sword25" is fine)
+
+
+How do the search patterns work together?
+===========================================
+
+If you have provided several search patterns, only games that match all of them are displayed.
+
+The matches are independent and not ordered, which means that when you are looking for ``Monkey Island``, you would get all the games with words "Monkey" and "Island" in description. Note that imaginary titles like "My Island with some Monkeys" would also be displayed.
+
+Here are some more examples of complex requests:
+
+- ``engine=ags path:steamapps !extra:Steam`` - AGS games at your /SteamApps/ folder, but not marked as Steam game at "extra"
+- ``e=wintermute l=`` - Wintermute games with empty "language" property
+- ``pl:dos lang=he desc~a*`` - Hebrew games for DOS with description starting with letter "A"
+
diff --git a/doc/docportal/index.rst b/doc/docportal/index.rst
index 2dde41fe79..1c7e8482fa 100644
--- a/doc/docportal/index.rst
+++ b/doc/docportal/index.rst
@@ -52,6 +52,7 @@
advanced_topics/configuration_file
advanced_topics/understand_audio
advanced_topics/understand_graphics
+ advanced_topics/understand_search_box
.. toctree::
:caption: Help
diff --git a/doc/docportal/use_scummvm/the_launcher.rst b/doc/docportal/use_scummvm/the_launcher.rst
index 01dc0c7bdd..2f429d0750 100755
--- a/doc/docportal/use_scummvm/the_launcher.rst
+++ b/doc/docportal/use_scummvm/the_launcher.rst
@@ -17,13 +17,14 @@ The games list
The pane on the left is the games list, which lists all the games that have been added to ScummVM. The games list usually offers some additional information about each game, such as original platform and language. To highlight any game on the list, type the first letter(s) of its title, or click on it.
+.. _search_box:
The search box
********************
The search box lets you filter the games list. It is located at the top of the page next to the magnifying glass icon. The filter is applied as you type, and is not case sensitive. To clear the filter, click **X**.
-There are many ways to filter games. For example, you can type "Monkey Island" to locate all "Monkey Island" games on the list, or you can type "German" to find German games.
+There are many ways to filter games. For example, you can type "Monkey Island" to locate all "Monkey Island" games on the list, or you can type "lang:de" to find German games. For a comprehensive look at how to use the search box, check out our :doc:`../advanced_topics/understand_search_box` guide.
The buttons
************************
More information about the Scummvm-git-logs
mailing list