mirror of
https://github.com/lutris/lutris
synced 2024-10-04 14:59:37 +00:00
Add a "directory:" tag for the game search
This commit is contained in:
parent
7d38dd032d
commit
3c3480322a
|
@ -191,7 +191,9 @@ class BaseSearch:
|
|||
|
||||
|
||||
class GameSearch(BaseSearch):
|
||||
tags = set(["installed", "hidden", "favorite", "categorized", "category", "runner", "platform", "playtime"])
|
||||
tags = set(
|
||||
["installed", "hidden", "favorite", "categorized", "category", "runner", "platform", "playtime", "directory"]
|
||||
)
|
||||
|
||||
def __init__(self, text: str, service) -> None:
|
||||
self.service = service
|
||||
|
@ -216,6 +218,10 @@ class GameSearch(BaseSearch):
|
|||
if name == "playtime":
|
||||
return self.get_playtime_predicate(tokens)
|
||||
|
||||
if name == "directory":
|
||||
directory = tokens.get_cleaned_token_sequence(stop_tokens=ITEM_STOP_TOKENS) or ""
|
||||
return self.get_directory_predicate(directory)
|
||||
|
||||
# All flags handle the 'maybe' option the same way, so we'll
|
||||
# group them at the end.
|
||||
flag = read_flag_token(tokens)
|
||||
|
@ -281,6 +287,13 @@ class GameSearch(BaseSearch):
|
|||
|
||||
return matcher
|
||||
|
||||
def get_directory_predicate(self, directory: str) -> Callable:
|
||||
def match_directory(db_game):
|
||||
game_dir = db_game.get("directory")
|
||||
return game_dir and directory in game_dir
|
||||
|
||||
return match_directory
|
||||
|
||||
def get_installed_predicate(self, installed: bool) -> Callable:
|
||||
def match_installed(db_game):
|
||||
is_installed = self._is_installed(db_game)
|
||||
|
|
|
@ -313,7 +313,8 @@
|
|||
<b>category:</b><i>x</i> Only games in cateogry <i>x</i>.
|
||||
<b>runner:</b><i>wine</i> Only Wine games
|
||||
<b>platform:</b><i>windows</i> Only Windows games
|
||||
<b>playtime:</b><i>&gt;2 hours</i> Only games played for more than 2 hours.</property>
|
||||
<b>playtime:</b><i>&gt;2 hours</i> Only games played for more than 2 hours.
|
||||
<b>directory:</b><i>game/dir</i> Only games at the path.</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="width-chars">30</property>
|
||||
|
|
Loading…
Reference in a new issue