Add support for lutris flatpak version (#114)

This commit is contained in:
Philip Kristoffersen
2022-05-01 17:21:09 +02:00
committed by GitHub
parent 3f075f80f1
commit 81ddcb6959
6 changed files with 81 additions and 25 deletions
+43 -2
View File
@@ -1,3 +1,4 @@
use crate::lutris::settings::LutrisSettings;
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
#[derive(Clone)]
@@ -6,15 +7,17 @@ pub struct LutrisGame {
pub name: String,
pub id: String,
pub platform: String,
pub settings: Option<LutrisSettings>,
}
impl From<LutrisGame> for ShortcutOwned {
fn from(game: LutrisGame) -> Self {
let options = format!("lutris:rungame/{}", game.id);
let options = game.get_options();
let exectuable = game.get_executable();
Shortcut::new(
"0",
game.name.as_str(),
"lutris",
exectuable.as_str(),
"",
"",
"",
@@ -23,3 +26,41 @@ impl From<LutrisGame> for ShortcutOwned {
.to_owned()
}
}
impl LutrisGame {
pub fn get_options(&self) -> String {
let is_flatpak = self
.settings
.as_ref()
.map(|s| s.flatpak)
.unwrap_or_default();
if is_flatpak {
format!(
"run {} lutris:rungame/{}",
self.settings
.as_ref()
.map(|s| s.flatpak_image.clone())
.unwrap_or_default(),
self.id
)
} else {
format!("lutris:rungame/{}", self.id)
}
}
pub fn get_executable(&self) -> String {
let is_flatpak = self
.settings
.as_ref()
.map(|s| s.flatpak)
.unwrap_or_default();
if is_flatpak {
"flatpak".to_string()
} else {
self.settings
.as_ref()
.map(|s| s.executable.clone())
.unwrap_or_default()
}
}
}