Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fancy Game Search #5442

Merged
merged 50 commits into from
May 13, 2024
Merged

Fancy Game Search #5442

merged 50 commits into from
May 13, 2024

Conversation

danieljohnson2
Copy link
Contributor

@danieljohnson2 danieljohnson2 commented Apr 20, 2024

This PR adds fancy search terms to the game search, and the runner search to boot. There are logical operators and 'tagged' searches that can match attributes of games. Some of them can override 'built in' filtering, so you can get views otherwise impossible.

There's almost no UI, just some tooltips. But hardcore Linux kernel hackers can probably manage a UI that works rather like Google search.

It's my hope that this will be the foundation for future features. I intend that you should sometime be able to save one o these searches a user-defined dynamic category, for instance. And we want a better UI to build fancy searches that just typing them in. But this seems to me to be a good start.

Stand by for screenshots! All the screenshots!

Here we see OR, which must be in all-caps, to find two sets of games:
image

Let's get fancier, with AND and the 'installed' attribute and some parentheses:
image

AND is mostly redundant though, and we assume AND if you have no conjunction. Like Google, we use "-" for negation, but there's some subtlty here.

Here's a search leaving out that time when there's only war:
image

But this still works:
image
Because the - is not initial here. To get it to treat - as negation, an explicit AND can help:
image

Because these tags override built in filters, we can do tricks. We can show hidden games in a category:
image

Just to be extra cute, you can conveniently get both hidden and visible games at once, like this:
image
You could do this with hidden:true OR hidden:false as well, but this is cuter.

Some tags are a bit fancier. Here's the games that took way too long:
image

But here's a more specific search:
image
Here, the search is matching games where the playtime rounds to 21 hours (ie, nearer that than 20 or 22 hours). This is about the only way to make that useful; exactly 21 hours is very unlikely. But change the search to playtime:20 hours 52 minutes and it rounds to the minute instead.

Here's one for the last-played time:
image
This is a bit limited. I could find no way to parse a date-time from a user (ie, without a specific format string), so you can only specify last-played in relative terms. These are the games I last played 3 months ago.

Here's a list of the tags supported, taken from the tooltip:
installed:true Only installed games.
hidden:true Only hidden games.
favorite:true Only favorite games.
categorized:true Only games in a category.
category:x Only games in category x.
source:steam Only Steam games
runner:wine Only Wine games
platform:windows Only Windows games
playtime:>2 hours Only games played for more than 2 hours.
lastplayed:<2 days Only games played in the last 2 days.
directory:game/dir Only games at the path.

Finally, this stuff also works in the runners tab of the preferences. Just so I can do this:
image

This sort of works, but sometimes the same game is both installed and not somehow.
…hout a service.

To do this, I've put a reference to the service in GameSearch as a field.
This means you can now search for installed (or non-installed) runners. Yay!
…' to search categories.

Sadly the category is case-sensitive for now.
More or less; SQLite COLLATE NOCASE is apparently crappy, but it's better than nothing.
This should support editing searches later, even editing invalid ones.
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.
'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.
…cutive text segments so text is order sensitive, and "-alien shooter" applies the negation to the whole thing.
But this is still super messy.
…han None to indicate 'bad tagness'.

This way the read_flag_token() function can return None for 'maybe', and raise for 'invalid argument'
…s, 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.
…ed tokens.

This way 'playtime: 20 hours' can be parsed, as this tag along can read the rest of the text to the next stop.
… hours playtime:<=20 hours" will work with no explicit AND.
This is treated as a duration, meaning how long ago you last played it. We can expand on this later.
…ate 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!
Thus, platform:win finds Windows, and runner:win finds Wine, and so on.

This should be more forgiving for messy carbon based life forms.
It will not be  stop token, so a search for "Ex-Zodiac" finds just that even without quotes; '-' must be at the start to count as negation. You can write Ex AND -Zodiac or "Ex" -Zodiac to override this.
@strycore strycore merged commit 075b531 into master May 13, 2024
4 checks passed
@danieljohnson2 danieljohnson2 deleted the dj/fancy_search branch May 13, 2024 08:23
@danieljohnson2
Copy link
Contributor Author

Thanks for the early merge!

Now I need to figure out a UI for saving these as 'dynamic categories'. Gtk.SearchEntry has been a bit of a pain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants