diff --git a/SettingsTemplate.yaml b/SettingsTemplate.yaml index a4e03d6..f69c92c 100644 --- a/SettingsTemplate.yaml +++ b/SettingsTemplate.yaml @@ -7,5 +7,11 @@ body: - type: input attributes: name: steam_path - label: 'Steam Executable Directory:' - description: Location of steam.exe \ No newline at end of file + label: "Steam Executable Directory:" + description: Location of steam.exe + - type: checkbox + attributes: + name: show_on_empty_search + label: "Show all games with empty search" + defaultValue: "true" + description: "Shows all games when search Query is empty and the Action Keyword is used" diff --git a/plugin.json b/plugin.json index 2d624a7..14c4c1f 100644 --- a/plugin.json +++ b/plugin.json @@ -4,7 +4,7 @@ "Name": "Steam Search", "Description": "Search and launch your Steam Game library", "Author": "Garulf", - "Version": "7.1.1", + "Version": "7.2.0", "Language": "executable", "Website": "https://github.com/Garulf/Steam-Search", "IcoPath": "run.exe", diff --git a/plugin/main.py b/plugin/main.py index 3c6093f..bc9591d 100644 --- a/plugin/main.py +++ b/plugin/main.py @@ -4,13 +4,12 @@ from .steam import Steam, SteamLibraryNotFound, SteamExecutableNotFound from flox import Flox, ICON_SETTINGS -from flox.string_matcher import string_matcher +from flox.string_matcher import string_matcher, DEFAULT_QUERY_SEARCH_PRECISION, QUERY_SEARCH_PRECISION class SteamSearch(Flox): - + def query(self, query): - self.logger try: self._steam = Steam(self.settings.get('steam_path', None)) if not self.settings.get('steam_path'): @@ -29,19 +28,20 @@ def query(self, query): return for item in shortcuts + games: # subtitle = str(game.install_path()) if game.install_path() is not None else None - icon = item.icon or str(item.path) - match = string_matcher(query, item.name) - score = match[-1] if match else 0 - - self.add_item( - title=item.name, - subtitle=str(item.unquoted_path()), - icon=str(icon), - method="launch_game", - parameters=[item.id], - context=[item.id], - score=int(score) - ) + query_search_precision = QUERY_SEARCH_PRECISION[self.query_search_precision] + match = string_matcher(query, item.name, query_search_precision=query_search_precision or DEFAULT_QUERY_SEARCH_PRECISION) + if match.matched or (query == "" and self.settings.get('show_on_empty_search', False)): + icon = item.icon or str(item.path) + score = match.score + self.add_item( + title=item.name, + subtitle=str(item.unquoted_path()), + icon=str(icon), + method="launch_game", + parameters=[item.id], + context=[item.id], + score=int(score) + ) def context_menu(self, data): game_id = data[0] diff --git a/requirements.txt b/requirements.txt index 009df67..5f8ee5d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -flox-lib==0.19.0 +flox-lib==0.19.2 vdf==3.4