Commit graph

10378 commits

Author SHA1 Message Date
Daniel Johnson 1785a6ecf3 Add a playtime parse that keeps separate parts, use it do an approximate match so:
playtime:2 hours -> playtime rounded to hours is 2 hours

playtime:120 minutes -> playtime rounded to minutes is 120 minutes

These are not the same thing!
2024-05-12 17:36:06 -07:00
Daniel Johnson 24b4fe0903 Add a 'lastplayed' search tag.
This is treated as a duration, meaning how long ago you last played it. We can expand on this later.
2024-05-12 17:36:06 -07:00
Daniel Johnson 3c3480322a Add a "directory:" tag for the game search 2024-05-12 17:36:06 -07:00
Daniel Johnson 7d38dd032d Add tooltips to explain search terms a bit 2024-05-12 17:36:06 -07:00
Daniel Johnson ce8961fce2 Bug fixes for conjunction handling 2024-05-12 17:36:06 -07:00
Daniel Johnson 7654ac7173 Rework playtime so >= and <= are operators, and so that "playtime:>=3 hours playtime:<=20 hours" will work with no explicit AND. 2024-05-12 17:36:06 -07:00
Daniel Johnson 67f5078079 Rely more heavily on the TokenReader to handle whitespace and conjoined tokens.
This way 'playtime: 20 hours' can be parsed, as this tag along can read the rest of the text to the next stop.
2024-05-12 17:36:06 -07:00
Daniel Johnson dc1a9dfebc First cut of a playtime search tag - with just >, < and equals matches, but the equals match is too precise to be useful.
The search syntax is "playtime: >9 hours 3 minutes"; quotes are allowed but not required.
2024-05-12 17:36:06 -07:00
Daniel Johnson 59bdf379e7 Factor out flag handling into a function, and use exceptions rather than None to indicate 'bad tagness'.
This way the read_flag_token() function can return None for 'maybe', and raise for 'invalid argument'
2024-05-12 17:36:06 -07:00
Daniel Johnson c8519f546e Commenting about the tokenization code; also make it a bit less search-specific. 2024-05-12 17:36:06 -07:00
Daniel Johnson c43b890982 Move tokenization code into its own module, down in 'lutris.util'. 2024-05-12 17:36:06 -07:00
Daniel Johnson 05e85634c3 Pass the token reader around more so we can have multi-token arguments to the tags 2024-05-12 17:36:06 -07:00
Daniel Johnson 47f452a803 Move away from using iterators, since they proved inadequate. 2024-05-12 17:36:06 -07:00
Daniel Johnson 48210dc7b3 Add support for parenthesis grouping too 2024-05-12 17:36:06 -07:00
Daniel Johnson 11f039aa14 Restore awareness of valid tags, so more ':' characters can be searched for normally 2024-05-12 17:36:06 -07:00
Daniel Johnson 5429cab292 More cleanup using helpful functions 2024-05-12 17:36:06 -07:00
Daniel Johnson 279d49e53b Replace List[Callable] with SearchPredicate functions for simplicity 2024-05-12 17:36:06 -07:00
Daniel Johnson 070c493265 Clean up recursive descent code via various helper methods. 2024-05-12 17:36:06 -07:00
Daniel Johnson e1c52b9a92 Add support for the AND conjunction
But this is still super messy.
2024-05-12 17:36:06 -07:00
Daniel Johnson 5112d3c60c Give up on using iterators; add a TokenReader class that can go backwards, allowing lookahead. 2024-05-12 17:36:06 -07:00
Daniel Johnson 3c50d7d208 Rework the parser again, now pre-combining unquoted text runs and handling the OR conjunction 2024-05-12 17:36:06 -07:00
Daniel Johnson 617ec2cbde Rework the search parser to recursive descent, and also conjoin consecutive text segments so text is order sensitive, and "-alien shooter" applies the negation to the whole thing. 2024-05-12 17:36:06 -07:00
Daniel Johnson 9c4f637f31 More aggressive tokenization; allows forms like "hidden: true" with a space in it. 2024-05-12 17:36:06 -07:00
Daniel Johnson c20aad4fbb Extend the search with '-' as a negation operator 2024-05-12 17:36:06 -07:00
Daniel Johnson c1082ab94a Replace split with a tokenization function that knows about quotations 2024-05-12 17:36:06 -07:00
Daniel Johnson e555175d91 Add 'hidden:maybe' support. This is just too cute to resist.
'installed:maybe' is also useful; you can override the UI menu settings with these.

'hidden:maybe' is useful to show hidden and non-hidden together.

You can use 'maybe' with other components, but it does nothing useful for them.
2024-05-12 17:36:06 -07:00
Daniel Johnson 8da7d719e3 Add 'hidden:yes/no' to the search
Also, make hidden and installed override the menu-based settings, so they can be used from the Game view freely.

This does mean doing less of the search in SQL, but I suspect this won't be a problem.
2024-05-12 17:36:06 -07:00
Daniel Johnson 1856e5e466 Add 'favorite:yes/no' to search for favorites. 2024-05-12 17:36:06 -07:00
Daniel Johnson cbd0e78653 Provide access to the search components; lazy load the predicates.
This should support editing searches later, even editing invalid ones.
2024-05-12 17:36:06 -07:00
Daniel Johnson f2c056be6d Add searches for 'runner:' and 'platform:' 2024-05-12 17:36:06 -07:00
Daniel Johnson d4d3959b05 Use a case-insensitive category name in the search.
More or less; SQLite COLLATE NOCASE is apparently crappy, but it's better than nothing.
2024-05-12 17:36:06 -07:00
Daniel Johnson fcfcdf8af5 Add additional game searches 'categorized:true/false' and 'category:x' to search categories.
Sadly the category is case-sensitive for now.
2024-05-12 17:36:06 -07:00
Daniel Johnson 901b5a0309 Create RunnerSearch and use it to search runners
This means you can now search for installed (or non-installed) runners. Yay!
2024-05-12 17:36:06 -07:00
Daniel Johnson 3cf7f28095 Generalize the BaseSearch class so it can work with non-games and without a service.
To do this, I've put a reference to the service in GameSearch as a field.
2024-05-12 17:36:06 -07:00
Daniel Johnson 1250dcbb84 Put search classes into search.py 2024-05-12 17:36:06 -07:00
Daniel Johnson 59b621a925 Break out a base class for searches that aren't of games.
I'm thinking runner search!
2024-05-12 17:36:06 -07:00
Daniel Johnson 8173d4098a Crude first cut at an "installed:yes/no" search term.
This sort of works, but sometimes the same game is both installed and not somehow.
2024-05-12 17:36:06 -07:00
Daniel Johnson b9cfaed683 Split game search logic into separate predicates, simplify the __init__ method. 2024-05-12 17:36:06 -07:00
Daniel Johnson 1bb998cda2 Generalize installer check so it works on non-service games and is clearer. 2024-05-12 17:36:06 -07:00
Daniel Johnson 5e93cac3ac Move the filter_games() matching logic into a new class GameSearch. 2024-05-12 17:36:06 -07:00
Daniel Johnson ce49b92904 Move the generation count out of NotificationSource.
This is used in only one place, and does not really fit with the argument-passing fire() method we have now, so I'll move it.
2024-05-12 08:41:52 -04:00
Daniel Johnson 189c02bf43 At last, Game can stop being a GObject. 2024-05-12 07:11:00 -04:00
Daniel Johnson b8af800c96 Convert "game-error" to a NotificationSource as well. 2024-05-12 07:07:53 -04:00
Daniel Johnson 2235a3d192 Convert "game-unhandled-error" to a NotificationSource 2024-05-12 06:50:01 -04:00
Daniel Johnson 26b1c33fc9 Convert "game-installed" into a NotificationSource 2024-05-12 06:43:56 -04:00
Daniel Johnson 4449dc8415 Convert "game-updated" into a NotificationSource.
I've also put MoveDialog into a separate module to break a circular dependency.
2024-05-12 06:40:28 -04:00
Daniel Johnson ace302a809 Convert "game-stopped" to a NotificationSource 2024-05-12 06:30:01 -04:00
Daniel Johnson c6bf26bb95 OK, PR #5421 looks nice to me, but it is not moving. Let's get Game.py off of GObject.
This commit replaces the game-start and game-started signals with NotificationSource.
2024-05-12 05:56:35 -04:00
Daniel Johnson cb147ee18e Move notification source to use registration objects.
This lets us avoid having to have None checks; we can initialize registration fields to EMPTY_NOTIFICATION_REGISTRATION and we can then blindly unregister them with no problems if they were never registered.
2024-05-12 05:49:48 -04:00
Daniel Johnson 28e5d2e35a Ubisoft YAML search should return its (None, None) signal value if any of the various keys or indices it looks for are missing.
Resolves #5469
2024-05-11 19:32:57 -04:00