New cli options to use lutris service_games (#365)

This commit is contained in:
culain-45124
2023-08-23 21:17:46 +02:00
committed by GitHub
parent a817241ce6
commit bea1d43229
5 changed files with 69 additions and 76 deletions
+4 -4
View File
@@ -29,7 +29,7 @@ mod tests {
let games = parse_lutris_games(content); let games = parse_lutris_games(content);
assert_eq!(games[0].id, 1); assert_eq!(games[0].id, 48);
} }
#[test] #[test]
@@ -40,7 +40,7 @@ mod tests {
assert_eq!( assert_eq!(
games[5].name, 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!( assert_eq!(
games[5].slug, 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); let games = parse_lutris_games(content);
assert_eq!(games[1].runner, "steam"); assert_eq!(games[1].service, "steam");
} }
} }
+5 -4
View File
@@ -9,8 +9,9 @@ pub struct LutrisGame {
pub id: i64, pub id: i64,
pub slug: String, pub slug: String,
pub name: String, pub name: String,
pub runner: String, pub service: String,
pub platform: String, pub installed: bool,
pub details: String,
pub settings: Option<LutrisSettings>, pub settings: Option<LutrisSettings>,
} }
@@ -40,7 +41,7 @@ impl LutrisGame {
.unwrap_or_default(); .unwrap_or_default();
if is_flatpak { if is_flatpak {
format!( format!(
"run {} lutris:rungame/{}", "run {} lutris:{}",
self.settings self.settings
.as_ref() .as_ref()
.map(|s| s.flatpak_image.clone()) .map(|s| s.flatpak_image.clone())
@@ -48,7 +49,7 @@ impl LutrisGame {
self.slug self.slug
) )
} else { } else {
format!("lutris:rungame/{}", self.slug) format!("lutris:{}", self.slug)
} }
} }
+22 -8
View File
@@ -17,7 +17,7 @@ impl LutrisPlatform {
let games = parse_lutris_games(output.as_str()); let games = parse_lutris_games(output.as_str());
let mut res = vec![]; let mut res = vec![];
for mut game in games { for mut game in games {
if game.runner != "steam" { if game.service != "steam" {
game.settings = Some(self.settings.clone()); game.settings = Some(self.settings.clone());
res.push(game); res.push(game);
} }
@@ -35,9 +35,13 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result<String>
command command
.arg("run") .arg("run")
.arg(flatpak_image) .arg(flatpak_image)
.arg("-lo") .arg("-a")
.arg("--json") .arg("--json");
.output()? if settings.installed {
command.arg("-o").output()?
} else {
command.output()?
}
} }
#[cfg(feature = "flatpak")] #[cfg(feature = "flatpak")]
{ {
@@ -47,13 +51,22 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result<String>
.arg("flatpak") .arg("flatpak")
.arg("run") .arg("run")
.arg(flatpak_image) .arg(flatpak_image)
.arg("-lo") .arg("-a")
.arg("--json") .arg("--json");
.output()? if settings.installed {
command.arg("-o").output()?
} else {
command.output()?
}
} }
} else { } else {
let mut command = Command::new(&settings.executable); 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()) Ok(String::from_utf8_lossy(&output.stdout).to_string())
@@ -84,6 +97,7 @@ impl GamesPlatform for LutrisPlatform {
ui.heading("Lutris"); ui.heading("Lutris");
ui.checkbox(&mut self.settings.enabled, "Import from Lutris"); ui.checkbox(&mut self.settings.enabled, "Import from Lutris");
if self.settings.enabled { if self.settings.enabled {
ui.checkbox(&mut self.settings.installed, "Search installed only");
ui.checkbox(&mut self.settings.flatpak, "Flatpak version"); ui.checkbox(&mut self.settings.flatpak, "Flatpak version");
if !self.settings.flatpak { if !self.settings.flatpak {
ui.horizontal(|ui| { ui.horizontal(|ui| {
+2
View File
@@ -6,6 +6,7 @@ pub struct LutrisSettings {
pub executable: String, pub executable: String,
pub flatpak: bool, pub flatpak: bool,
pub flatpak_image: String, pub flatpak_image: String,
pub installed: bool,
} }
impl Default for LutrisSettings { impl Default for LutrisSettings {
@@ -21,6 +22,7 @@ impl Default for LutrisSettings {
executable: "lutris".to_string(), executable: "lutris".to_string(),
flatpak: true, flatpak: true,
flatpak_image: "net.lutris.Lutris".to_string(), flatpak_image: "net.lutris.Lutris".to_string(),
installed: true,
} }
} }
} }
+36 -60
View File
@@ -1,74 +1,50 @@
[ [
{ {
"id": 1, "id": 48,
"slug": "aperture-desk-job", "slug": "dishonored_2",
"name": "Aperture Desk Job", "name": "Dishonored 2",
"runner": "steam", "service": "gog",
"platform": "Linux", "installed": false,
"year": null, "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}"
"directory": null,
"hidden": false,
"playtime": null,
"lastplayed": null
}, },
{ {
"id": 2, "id": 41,
"slug": "dark-souls-iii", "slug": "middleearth_shadow_of_mordor",
"name": "DARK SOULS\u2122 III", "name": "Middle-earth\u2122: Shadow of Mordor\u2122 Game of the Year Edition",
"runner": "steam", "service": "steam",
"platform": "Linux", "installed": false,
"year": null, "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}"
"directory": null,
"hidden": false,
"playtime": null,
"lastplayed": null
}, },
{ {
"id": 4, "id": 10,
"slug": "disco-elysium", "slug": "prey",
"name": "Disco Elysium", "name": "Prey",
"runner": "wine", "service": "gog",
"platform": "Windows", "installed": false,
"year": 2019, "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}"
"directory": "/home/deck/Games/gog/disco-elysium",
"hidden": false,
"playtime": "0:01:16",
"lastplayed": "2022-07-25 23:21:56"
}, },
{ {
"id": 3, "id": 53,
"slug": "hollow-knight", "slug": "the_elder_scrolls_iii_morrowind_goty_edition_game",
"name": "Hollow Knight", "name": "The Elder Scrolls III: Morrowind GOTY Edition",
"runner": "steam", "service": "gog",
"platform": "Linux", "installed": false,
"year": null, "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}"
"directory": null,
"hidden": false,
"playtime": null,
"lastplayed": null
}, },
{ {
"id": 7, "id": 24,
"slug": "lumino-city", "slug": "the_witcher_2",
"name": "Lumino City", "name": "The Witcher 2: Assassins of Kings Enhanced Edition",
"runner": "wine", "service": "gog",
"platform": "Windows", "installed": false,
"year": null, "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}"
"directory": "/home/deck/Games/gog/lumino-city",
"hidden": false,
"playtime": null,
"lastplayed": null
}, },
{ {
"id": 5, "id": 70,
"slug": "the-witcher-3-wild-hunt-game-of-the-year-edition", "slug": "wolfenstein_the_new_order",
"name": "The Witcher 3: Wild Hunt - Game of the Year Edition", "name": "Wolfenstein: The New Order",
"runner": "wine", "service": "gog",
"platform": "Windows", "installed": false,
"year": 2015, "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}"
"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"
} }
] ]