Skip to content

Commit

Permalink
Merge pull request #44 from Garulf/implement-score-cutoff
Browse files Browse the repository at this point in the history
Implement score cutoff
  • Loading branch information
Garulf authored Feb 15, 2023
2 parents 4479006 + 510dbaf commit 920dc7e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
10 changes: 8 additions & 2 deletions SettingsTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ body:
- type: input
attributes:
name: steam_path
label: 'Steam Executable Directory:'
description: Location of steam.exe
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"
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 16 additions & 16 deletions plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
flox-lib==0.19.0
flox-lib==0.19.2
vdf==3.4

0 comments on commit 920dc7e

Please sign in to comment.