diff --git a/src/platforms/lutris/game_list_parser.rs b/src/platforms/lutris/game_list_parser.rs index 75b8dc0..fe43d96 100644 --- a/src/platforms/lutris/game_list_parser.rs +++ b/src/platforms/lutris/game_list_parser.rs @@ -29,7 +29,7 @@ mod tests { let games = parse_lutris_games(content); - assert_eq!(games[0].id, 1); + assert_eq!(games[0].id, 48); } #[test] @@ -40,7 +40,7 @@ mod tests { assert_eq!( games[5].name, - "The Witcher 3: Wild Hunt - Game of the Year Edition" + "Wolfenstein: The New Order" ); } @@ -52,7 +52,7 @@ mod tests { assert_eq!( games[5].slug, - "the-witcher-3-wild-hunt-game-of-the-year-edition" + "wolfenstein_the_new_order" ); } @@ -62,6 +62,6 @@ mod tests { let games = parse_lutris_games(content); - assert_eq!(games[1].runner, "steam"); + assert_eq!(games[1].service, "steam"); } } diff --git a/src/platforms/lutris/lutris_game.rs b/src/platforms/lutris/lutris_game.rs index 3d7eaf6..6d812f6 100644 --- a/src/platforms/lutris/lutris_game.rs +++ b/src/platforms/lutris/lutris_game.rs @@ -9,8 +9,9 @@ pub struct LutrisGame { pub id: i64, pub slug: String, pub name: String, - pub runner: String, - pub platform: String, + pub service: String, + pub installed: bool, + pub details: String, pub settings: Option, } @@ -40,7 +41,7 @@ impl LutrisGame { .unwrap_or_default(); if is_flatpak { format!( - "run {} lutris:rungame/{}", + "run {} lutris:{}", self.settings .as_ref() .map(|s| s.flatpak_image.clone()) @@ -48,7 +49,7 @@ impl LutrisGame { self.slug ) } else { - format!("lutris:rungame/{}", self.slug) + format!("lutris:{}", self.slug) } } diff --git a/src/platforms/lutris/lutris_platform.rs b/src/platforms/lutris/lutris_platform.rs index d658db9..5a23ef9 100644 --- a/src/platforms/lutris/lutris_platform.rs +++ b/src/platforms/lutris/lutris_platform.rs @@ -17,7 +17,7 @@ impl LutrisPlatform { let games = parse_lutris_games(output.as_str()); let mut res = vec![]; for mut game in games { - if game.runner != "steam" { + if game.service != "steam" { game.settings = Some(self.settings.clone()); res.push(game); } @@ -35,9 +35,13 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result command .arg("run") .arg(flatpak_image) - .arg("-lo") - .arg("--json") - .output()? + .arg("-a") + .arg("--json"); + if settings.installed { + command.arg("-o").output()? + } else { + command.output()? + } } #[cfg(feature = "flatpak")] { @@ -47,13 +51,22 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result .arg("flatpak") .arg("run") .arg(flatpak_image) - .arg("-lo") - .arg("--json") - .output()? + .arg("-a") + .arg("--json"); + if settings.installed { + command.arg("-o").output()? + } else { + command.output()? + } } } else { let mut command = Command::new(&settings.executable); - command.arg("-lo").arg("--json").output()? + command.arg("-a").arg("--json"); + if settings.installed { + command.arg("-o").output()? + } else { + command.output()? + } }; Ok(String::from_utf8_lossy(&output.stdout).to_string()) @@ -84,6 +97,7 @@ impl GamesPlatform for LutrisPlatform { ui.heading("Lutris"); ui.checkbox(&mut self.settings.enabled, "Import from Lutris"); if self.settings.enabled { + ui.checkbox(&mut self.settings.installed, "Search installed only"); ui.checkbox(&mut self.settings.flatpak, "Flatpak version"); if !self.settings.flatpak { ui.horizontal(|ui| { diff --git a/src/platforms/lutris/settings.rs b/src/platforms/lutris/settings.rs index 9523e45..39ae1b9 100644 --- a/src/platforms/lutris/settings.rs +++ b/src/platforms/lutris/settings.rs @@ -6,6 +6,7 @@ pub struct LutrisSettings { pub executable: String, pub flatpak: bool, pub flatpak_image: String, + pub installed: bool, } impl Default for LutrisSettings { @@ -21,6 +22,7 @@ impl Default for LutrisSettings { executable: "lutris".to_string(), flatpak: true, flatpak_image: "net.lutris.Lutris".to_string(), + installed: true, } } } diff --git a/src/platforms/lutris/test_output.txt b/src/platforms/lutris/test_output.txt index 8beefc3..44f4954 100644 --- a/src/platforms/lutris/test_output.txt +++ b/src/platforms/lutris/test_output.txt @@ -1,74 +1,50 @@ [ { - "id": 1, - "slug": "aperture-desk-job", - "name": "Aperture Desk Job", - "runner": "steam", - "platform": "Linux", - "year": null, - "directory": null, - "hidden": false, - "playtime": null, - "lastplayed": null + "id": 48, + "slug": "dishonored_2", + "name": "Dishonored 2", + "service": "gog", + "installed": false, + "details": "{\"isGalaxyCompatible\": true, \"tags\": [], \"id\": 1431426311, \"availability\": {\"isAvailable\": true, \"isAvailableInAccount\": true}, \"title\": \"Dishonored 2\", \"image\": \"//images-2.gog-statics.com/65811050eda91f39725b29a46ca7c7e68bdd7ec515ab4ef127dc96d77fab0c44\", \"url\": \"/en/game/dishonored_2\", \"worksOn\": {\"Windows\": true, \"Mac\": false, \"Linux\": false}, \"category\": \"Action\", \"rating\": 44, \"isComingSoon\": false, \"isMovie\": false, \"isGame\": true, \"slug\": \"dishonored_2\", \"updates\": 0, \"isNew\": true, \"dlcCount\": 0, \"releaseDate\": {\"date\": \"2016-11-11 00:00:00.000000\", \"timezone_type\": 3, \"timezone\": \"Europe/Nicosia\"}, \"isBaseProductMissing\": false, \"isHidingDisabled\": false, \"isInDevelopment\": false, \"extraInfo\": [], \"isHidden\": false}" }, { - "id": 2, - "slug": "dark-souls-iii", - "name": "DARK SOULS\u2122 III", - "runner": "steam", - "platform": "Linux", - "year": null, - "directory": null, - "hidden": false, - "playtime": null, - "lastplayed": null + "id": 41, + "slug": "middleearth_shadow_of_mordor", + "name": "Middle-earth\u2122: Shadow of Mordor\u2122 Game of the Year Edition", + "service": "steam", + "installed": false, + "details": "{\"isGalaxyCompatible\": true, \"tags\": [], \"id\": 1213504814, \"availability\": {\"isAvailable\": true, \"isAvailableInAccount\": true}, \"title\": \"Middle-earth\\u2122: Shadow of Mordor\\u2122 Game of the Year Edition\", \"image\": \"//images-2.gog-statics.com/455ff8097ca01fe893703d38b20f46bc9a539765256f9755ea9e592f48938763\", \"url\": \"/en/game/middleearth_shadow_of_mordor\", \"worksOn\": {\"Windows\": true, \"Mac\": false, \"Linux\": false}, \"category\": \"Action\", \"rating\": 0, \"isComingSoon\": false, \"isMovie\": false, \"isGame\": true, \"slug\": \"middleearth_shadow_of_mordor\", \"updates\": 0, \"isNew\": true, \"dlcCount\": 0, \"releaseDate\": {\"date\": \"2014-09-30 00:00:00.000000\", \"timezone_type\": 3, \"timezone\": \"Europe/Nicosia\"}, \"isBaseProductMissing\": false, \"isHidingDisabled\": false, \"isInDevelopment\": false, \"extraInfo\": [], \"isHidden\": false}" }, { - "id": 4, - "slug": "disco-elysium", - "name": "Disco Elysium", - "runner": "wine", - "platform": "Windows", - "year": 2019, - "directory": "/home/deck/Games/gog/disco-elysium", - "hidden": false, - "playtime": "0:01:16", - "lastplayed": "2022-07-25 23:21:56" + "id": 10, + "slug": "prey", + "name": "Prey", + "service": "gog", + "installed": false, + "details": "{\"isGalaxyCompatible\": true, \"tags\": [], \"id\": 1158493447, \"availability\": {\"isAvailable\": true, \"isAvailableInAccount\": true}, \"title\": \"Prey\", \"image\": \"//images-1.gog-statics.com/ed7a5f0cba0e3ee80bc5dd10683f6ce6fe692bb2b1764c4987aa97fbaaf142d1\", \"url\": \"/en/game/prey\", \"worksOn\": {\"Windows\": true, \"Mac\": false, \"Linux\": false}, \"category\": \"Action\", \"rating\": 44, \"isComingSoon\": false, \"isMovie\": false, \"isGame\": true, \"slug\": \"prey\", \"updates\": 1, \"isNew\": true, \"dlcCount\": 0, \"releaseDate\": {\"date\": \"2017-05-04 00:00:00.000000\", \"timezone_type\": 3, \"timezone\": \"Europe/Nicosia\"}, \"isBaseProductMissing\": false, \"isHidingDisabled\": false, \"isInDevelopment\": false, \"extraInfo\": [], \"isHidden\": false}" }, { - "id": 3, - "slug": "hollow-knight", - "name": "Hollow Knight", - "runner": "steam", - "platform": "Linux", - "year": null, - "directory": null, - "hidden": false, - "playtime": null, - "lastplayed": null + "id": 53, + "slug": "the_elder_scrolls_iii_morrowind_goty_edition_game", + "name": "The Elder Scrolls III: Morrowind GOTY Edition", + "service": "gog", + "installed": false, + "details": "{\"isGalaxyCompatible\": true, \"tags\": [], \"id\": 1435828767, \"availability\": {\"isAvailable\": false, \"isAvailableInAccount\": true}, \"title\": \"The Elder Scrolls III: Morrowind GOTY Edition\", \"image\": \"//images-2.gog-statics.com/e19e2055ee1d083793a4ea093872f15b749e3d75384bf8c0f3d81002a4a4fd47\", \"url\": \"/en/game/the_elder_scrolls_iii_morrowind_goty_edition\", \"worksOn\": {\"Windows\": true, \"Mac\": false, \"Linux\": false}, \"category\": \"Role-playing\", \"rating\": 0, \"isComingSoon\": false, \"isMovie\": false, \"isGame\": true, \"slug\": \"the_elder_scrolls_iii_morrowind_goty_edition_game\", \"updates\": 0, \"isNew\": true, \"dlcCount\": 0, \"releaseDate\": {\"date\": \"2003-11-07 00:00:00.000000\", \"timezone_type\": 3, \"timezone\": \"Europe/Nicosia\"}, \"isBaseProductMissing\": false, \"isHidingDisabled\": false, \"isInDevelopment\": false, \"extraInfo\": [], \"isHidden\": false}" }, { - "id": 7, - "slug": "lumino-city", - "name": "Lumino City", - "runner": "wine", - "platform": "Windows", - "year": null, - "directory": "/home/deck/Games/gog/lumino-city", - "hidden": false, - "playtime": null, - "lastplayed": null + "id": 24, + "slug": "the_witcher_2", + "name": "The Witcher 2: Assassins of Kings Enhanced Edition", + "service": "gog", + "installed": false, + "details": "{\"isGalaxyCompatible\": true, \"tags\": [], \"id\": 1207658930, \"availability\": {\"isAvailable\": true, \"isAvailableInAccount\": true}, \"title\": \"The Witcher 2: Assassins of Kings Enhanced Edition\", \"image\": \"//images-4.gog-statics.com/8355e657a19311b158a3553a154e109199d6991c7791a20c3305af1f84d15ed7\", \"url\": \"/en/game/the_witcher_2\", \"worksOn\": {\"Windows\": true, \"Mac\": true, \"Linux\": true}, \"category\": \"Role-playing\", \"rating\": 47, \"isComingSoon\": false, \"isMovie\": false, \"isGame\": true, \"slug\": \"the_witcher_2\", \"updates\": 1, \"isNew\": true, \"dlcCount\": 0, \"releaseDate\": {\"date\": \"2012-04-17 00:00:00.000000\", \"timezone_type\": 3, \"timezone\": \"Europe/Nicosia\"}, \"isBaseProductMissing\": false, \"isHidingDisabled\": false, \"isInDevelopment\": false, \"extraInfo\": [], \"isHidden\": false}" }, { - "id": 5, - "slug": "the-witcher-3-wild-hunt-game-of-the-year-edition", - "name": "The Witcher 3: Wild Hunt - Game of the Year Edition", - "runner": "wine", - "platform": "Windows", - "year": 2015, - "directory": "/home/deck/Games/gog/the-witcher-3-wild-hunt-game-of-the-year-edition", - "hidden": false, - "playtime": "0:00:54", - "lastplayed": "2022-07-25 23:20:40" + "id": 70, + "slug": "wolfenstein_the_new_order", + "name": "Wolfenstein: The New Order", + "service": "gog", + "installed": false, + "details": "{\"isGalaxyCompatible\": true, \"tags\": [], \"id\": 1943729964, \"availability\": {\"isAvailable\": true, \"isAvailableInAccount\": true}, \"title\": \"Wolfenstein: The New Order\", \"image\": \"//images-2.gog-statics.com/b2c4a0bae46c1432da6eddfd2783bfdb5ec91c04c72f712eb1b236aaf0d98519\", \"url\": \"/en/game/wolfenstein_the_new_order\", \"worksOn\": {\"Windows\": true, \"Mac\": false, \"Linux\": false}, \"category\": \"Shooter\", \"rating\": 38, \"isComingSoon\": false, \"isMovie\": false, \"isGame\": true, \"slug\": \"wolfenstein_the_new_order\", \"updates\": 0, \"isNew\": true, \"dlcCount\": 0, \"releaseDate\": {\"date\": \"2014-05-20 00:00:00.000000\", \"timezone_type\": 3, \"timezone\": \"Europe/Nicosia\"}, \"isBaseProductMissing\": false, \"isHidingDisabled\": false, \"isInDevelopment\": false, \"extraInfo\": [], \"isHidden\": false}" } ]