mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 14:03:42 +02:00
Make platforms generic
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
use super::legendary_game::LegendaryGame;
|
||||
use serde_json::from_str;
|
||||
use std::process::Command;
|
||||
use std::{error::Error};
|
||||
|
||||
pub fn get_legendary_games() -> Result<Vec<LegendaryGame>, Box<dyn Error>> {
|
||||
let legendary_command = Command::new("legendary")
|
||||
.arg("list-installed")
|
||||
.arg("--json")
|
||||
.output()?;
|
||||
let json = String::from_utf8_lossy(&legendary_command.stdout);
|
||||
let legendary_ouput = from_str(&json)?;
|
||||
Ok(legendary_ouput)
|
||||
}
|
||||
@@ -11,8 +11,8 @@ pub struct LegendaryGame {
|
||||
pub executable: String,
|
||||
}
|
||||
|
||||
impl From<&LegendaryGame> for ShortcutOwned {
|
||||
fn from(game: &LegendaryGame) -> Self {
|
||||
impl From<LegendaryGame> for ShortcutOwned {
|
||||
fn from(game: LegendaryGame) -> Self {
|
||||
let exe = format!("\"{}\\{}\"", game.install_path, game.executable);
|
||||
let launch = format!("legendary launch {}", game.app_name);
|
||||
let mut start_dir = game.install_path.clone();
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
use super::{LegendaryGame, LegendarySettings};
|
||||
use crate::platform::Platform;
|
||||
use serde_json::from_str;
|
||||
use std::error::Error;
|
||||
use std::process::Command;
|
||||
|
||||
pub struct LegendaryPlatform {
|
||||
settings: LegendarySettings,
|
||||
}
|
||||
|
||||
impl LegendaryPlatform {
|
||||
pub fn new(settings: LegendarySettings) -> LegendaryPlatform {
|
||||
Self { settings }
|
||||
}
|
||||
}
|
||||
|
||||
impl Platform<LegendaryGame, Box<dyn Error>> for LegendaryPlatform {
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
"Legendary"
|
||||
}
|
||||
|
||||
fn get_shortcuts(&self) -> Result<Vec<LegendaryGame>, Box<dyn Error>> {
|
||||
let legendary_command = Command::new("legendary")
|
||||
.arg("list-installed")
|
||||
.arg("--json")
|
||||
.output()?;
|
||||
let json = String::from_utf8_lossy(&legendary_command.stdout);
|
||||
let legendary_ouput = from_str(&json)?;
|
||||
Ok(legendary_ouput)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
mod legendary_game;
|
||||
mod get_legendary_games;
|
||||
mod settings;
|
||||
mod legendary_platform;
|
||||
|
||||
|
||||
pub use get_legendary_games::*;
|
||||
pub use legendary_game::*;
|
||||
pub use settings::*;
|
||||
pub use settings::*;
|
||||
pub use legendary_platform::*;
|
||||
@@ -1,6 +1,6 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct LegendarySettings {
|
||||
pub enabled: bool,
|
||||
pub executable: Option<String>,
|
||||
|
||||
Reference in New Issue
Block a user