mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 16:51:18 +10:00
feat: add backend for template launching
This commit is contained in:
@ -54,6 +54,10 @@ pub enum ApplicationTransientStatus {
|
||||
Running {},
|
||||
}
|
||||
|
||||
fn default_template() -> String {
|
||||
"{}".to_owned()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GameVersion {
|
||||
@ -64,9 +68,14 @@ pub struct GameVersion {
|
||||
|
||||
pub launch_command: String,
|
||||
pub launch_args: Vec<String>,
|
||||
#[serde(default = "default_template")]
|
||||
pub launch_command_template: String,
|
||||
|
||||
pub setup_command: String,
|
||||
pub setup_args: Vec<String>,
|
||||
#[serde(default = "default_template")]
|
||||
pub setup_command_template: String,
|
||||
|
||||
|
||||
pub only_setup: bool,
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ pub enum ProcessError {
|
||||
InvalidID,
|
||||
InvalidVersion,
|
||||
IOError(Error),
|
||||
FormatError(String), // String errors supremacy
|
||||
InvalidPlatform,
|
||||
}
|
||||
|
||||
@ -25,6 +26,7 @@ impl Display for ProcessError {
|
||||
ProcessError::InvalidVersion => "Invalid Game version",
|
||||
ProcessError::IOError(error) => &error.to_string(),
|
||||
ProcessError::InvalidPlatform => "This Game cannot be played on the current platform",
|
||||
ProcessError::FormatError(e) => &format!("Failed to format template: {}", e),
|
||||
};
|
||||
write!(f, "{}", s)
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ use std::{
|
||||
thread::spawn,
|
||||
};
|
||||
|
||||
use dynfmt::Format;
|
||||
use dynfmt::SimpleCurlyFormat;
|
||||
use log::{debug, info, warn};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared_child::SharedChild;
|
||||
@ -259,6 +261,11 @@ impl ProcessManager<'_> {
|
||||
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);
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
|
||||
Reference in New Issue
Block a user