Hide games with no platform info while the platform filter is on (v0.1.10)

This commit is contained in:
Jose Falanga 2026-08-07 22:19:51 -03:00
parent b0183b7c20
commit 7d5dedc0b9
2 changed files with 13 additions and 8 deletions

View file

@ -88,14 +88,19 @@ func _on_install_progressed(_id: String, current: int, total: int) -> void:
## Returns true unless the "only show games available on this platform" ## Returns true unless the "only show games available on this platform"
## filter is enabled and the game's platforms don't include the OS ## filter is enabled and the game's platforms don't include the OS
## OpenGamepadUI is running on. Games with no platform info at all (e.g. ## OpenGamepadUI is running on. Installed games always pass: they were
## HTML5) are kept, since there's nothing to filter on. ## installed on this machine, so they're runnable regardless of what
func _game_available_on_current_platform(game: Dictionary) -> bool: ## platform info butlerd reported. Everything else needs an explicit
## platform match, so games with no platform info at all (e.g. HTML5) are
## hidden while the filter is on.
func _game_available_on_current_platform(game: Dictionary, installed := false) -> bool:
if not _filter_unsupported(): if not _filter_unsupported():
return true return true
if installed:
return true
var platforms: Dictionary = game.get("platforms", {}) var platforms: Dictionary = game.get("platforms", {})
if platforms.is_empty(): if platforms.is_empty():
return true return false
var current := "windows" var current := "windows"
if OS.get_name() == "Linux": if OS.get_name() == "Linux":
current = "linux" current = "linux"
@ -116,10 +121,10 @@ func _make_item(game: Dictionary, caves_by_game_id: Dictionary) -> Variant:
return null return null
if game.get("classification", "game") != "game": if game.get("classification", "game") != "game":
return null return null
if not _game_available_on_current_platform(game):
return null
var game_id: int = game.get("id", 0) var game_id: int = game.get("id", 0)
var cave: Dictionary = caves_by_game_id.get(game_id, {}) var cave: Dictionary = caves_by_game_id.get(game_id, {})
if not _game_available_on_current_platform(game, not cave.is_empty()):
return null
var item := LibraryLaunchItem.new() var item := LibraryLaunchItem.new()
item.provider_app_id = cave.get("id", "") item.provider_app_id = cave.get("id", "")
@ -150,7 +155,7 @@ func _load_library(caching_flags: int = Cache.FLAGS.LOAD | Cache.FLAGS.SAVE) ->
for i in json_items: for i in json_items:
var item := LibraryLaunchItem.from_dict(i) var item := LibraryLaunchItem.from_dict(i)
var game: Dictionary = item.metadata.get("game", {}) var game: Dictionary = item.metadata.get("game", {})
if not _game_available_on_current_platform(game): if not _game_available_on_current_platform(game, item.installed):
continue continue
items.append(item) items.append(item)
_queue_boxart(items) _queue_boxart(items)

View file

@ -1,7 +1,7 @@
{ {
"plugin.id": "itch", "plugin.id": "itch",
"plugin.name": "itch.io", "plugin.name": "itch.io",
"plugin.version": "0.1.9", "plugin.version": "0.1.10",
"plugin.min-api-version": "1.1.0", "plugin.min-api-version": "1.1.0",
"plugin.link": "https://forge.thergic.ar/jose/itchio-opengamepadui-plugin", "plugin.link": "https://forge.thergic.ar/jose/itchio-opengamepadui-plugin",
"plugin.source": "https://forge.thergic.ar/jose/itchio-opengamepadui-plugin", "plugin.source": "https://forge.thergic.ar/jose/itchio-opengamepadui-plugin",