mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 08:12:44 +10:00
feat: add backend for template launching
This commit is contained in:
26
src-tauri/Cargo.lock
generated
26
src-tauri/Cargo.lock
generated
@ -1291,6 +1291,7 @@ dependencies = [
|
|||||||
"deranged",
|
"deranged",
|
||||||
"directories",
|
"directories",
|
||||||
"droplet-rs",
|
"droplet-rs",
|
||||||
|
"dynfmt",
|
||||||
"gethostname 1.0.1",
|
"gethostname 1.0.1",
|
||||||
"hex 0.4.3",
|
"hex 0.4.3",
|
||||||
"http 1.2.0",
|
"http 1.2.0",
|
||||||
@ -1370,6 +1371,20 @@ version = "1.0.17"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dynfmt"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b1c298552016db86f0d49e5de09818dd86c536f66095013cc415f4f85744033f"
|
||||||
|
dependencies = [
|
||||||
|
"erased-serde 0.3.31",
|
||||||
|
"lazy_static",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"thiserror 1.0.69",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.13.0"
|
version = "1.13.0"
|
||||||
@ -1438,6 +1453,15 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "erased-serde"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "erased-serde"
|
name = "erased-serde"
|
||||||
version = "0.4.5"
|
version = "0.4.5"
|
||||||
@ -4561,7 +4585,7 @@ version = "0.1.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2676ba99bd82f75cae5cbd2c8eda6fa0b8760f18978ea840e980dd5567b5c5b6"
|
checksum = "2676ba99bd82f75cae5cbd2c8eda6fa0b8760f18978ea840e980dd5567b5c5b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"erased-serde",
|
"erased-serde 0.4.5",
|
||||||
"serde",
|
"serde",
|
||||||
"typeid",
|
"typeid",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -59,6 +59,10 @@ deranged = "=0.4.0"
|
|||||||
droplet-rs = "0.7.3"
|
droplet-rs = "0.7.3"
|
||||||
gethostname = "1.0.1"
|
gethostname = "1.0.1"
|
||||||
|
|
||||||
|
[dependencies.dynfmt]
|
||||||
|
version = "0.1.5"
|
||||||
|
features = ["curly"]
|
||||||
|
|
||||||
[dependencies.tauri]
|
[dependencies.tauri]
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
features = ["tray-icon"]
|
features = ["tray-icon"]
|
||||||
|
|||||||
@ -54,6 +54,10 @@ pub enum ApplicationTransientStatus {
|
|||||||
Running {},
|
Running {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_template() -> String {
|
||||||
|
"{}".to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GameVersion {
|
pub struct GameVersion {
|
||||||
@ -64,9 +68,14 @@ pub struct GameVersion {
|
|||||||
|
|
||||||
pub launch_command: String,
|
pub launch_command: String,
|
||||||
pub launch_args: Vec<String>,
|
pub launch_args: Vec<String>,
|
||||||
|
#[serde(default = "default_template")]
|
||||||
|
pub launch_command_template: String,
|
||||||
|
|
||||||
pub setup_command: String,
|
pub setup_command: String,
|
||||||
pub setup_args: Vec<String>,
|
pub setup_args: Vec<String>,
|
||||||
|
#[serde(default = "default_template")]
|
||||||
|
pub setup_command_template: String,
|
||||||
|
|
||||||
|
|
||||||
pub only_setup: bool,
|
pub only_setup: bool,
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ pub enum ProcessError {
|
|||||||
InvalidID,
|
InvalidID,
|
||||||
InvalidVersion,
|
InvalidVersion,
|
||||||
IOError(Error),
|
IOError(Error),
|
||||||
|
FormatError(String), // String errors supremacy
|
||||||
InvalidPlatform,
|
InvalidPlatform,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ impl Display for ProcessError {
|
|||||||
ProcessError::InvalidVersion => "Invalid Game version",
|
ProcessError::InvalidVersion => "Invalid Game version",
|
||||||
ProcessError::IOError(error) => &error.to_string(),
|
ProcessError::IOError(error) => &error.to_string(),
|
||||||
ProcessError::InvalidPlatform => "This Game cannot be played on the current platform",
|
ProcessError::InvalidPlatform => "This Game cannot be played on the current platform",
|
||||||
|
ProcessError::FormatError(e) => &format!("Failed to format template: {}", e),
|
||||||
};
|
};
|
||||||
write!(f, "{}", s)
|
write!(f, "{}", s)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,8 @@ use std::{
|
|||||||
thread::spawn,
|
thread::spawn,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use dynfmt::Format;
|
||||||
|
use dynfmt::SimpleCurlyFormat;
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use shared_child::SharedChild;
|
use shared_child::SharedChild;
|
||||||
@ -259,6 +261,11 @@ impl ProcessManager<'_> {
|
|||||||
install_dir,
|
install_dir,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let launch_string = SimpleCurlyFormat
|
||||||
|
.format(&game_version.launch_command_template, &[launch_string])
|
||||||
|
.map_err(|e| ProcessError::FormatError(e.to_string()))?
|
||||||
|
.to_string();
|
||||||
|
|
||||||
info!("launching process {} in {}", launch_string, install_dir);
|
info!("launching process {} in {}", launch_string, install_dir);
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
|||||||
Reference in New Issue
Block a user