mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-06-22 04:11:37 +10:00
Fix Windows exe launch through cmd routing (#190)
* feat: modify_command in process manager * fix: import windows extension
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::{fs::create_dir_all, path::PathBuf};
|
use std::{fs::create_dir_all, path::PathBuf, process::Command};
|
||||||
|
|
||||||
use client::compat::{COMPAT_INFO, UMU_LAUNCHER_EXECUTABLE};
|
use client::compat::{COMPAT_INFO, UMU_LAUNCHER_EXECUTABLE};
|
||||||
use database::{
|
use database::{
|
||||||
@@ -7,8 +7,8 @@ use database::{
|
|||||||
|
|
||||||
use crate::{error::ProcessError, process_manager::ProcessHandler};
|
use crate::{error::ProcessError, process_manager::ProcessHandler};
|
||||||
|
|
||||||
pub struct NativeGameLauncher;
|
pub struct MacLauncher;
|
||||||
impl ProcessHandler for NativeGameLauncher {
|
impl ProcessHandler for MacLauncher {
|
||||||
fn create_launch_process(
|
fn create_launch_process(
|
||||||
&self,
|
&self,
|
||||||
_meta: &DownloadableMetadata,
|
_meta: &DownloadableMetadata,
|
||||||
@@ -23,6 +23,37 @@ impl ProcessHandler for NativeGameLauncher {
|
|||||||
fn valid_for_platform(&self, _db: &Database, _target: &Platform) -> bool {
|
fn valid_for_platform(&self, _db: &Database, _target: &Platform) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn modify_command(&self, _command: &mut Command) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
|
||||||
|
pub struct WindowsLauncher;
|
||||||
|
impl ProcessHandler for WindowsLauncher {
|
||||||
|
fn create_launch_process(
|
||||||
|
&self,
|
||||||
|
_meta: &DownloadableMetadata,
|
||||||
|
launch_command: String,
|
||||||
|
_game_version: &GameVersion,
|
||||||
|
_current_dir: &str,
|
||||||
|
_database: &Database,
|
||||||
|
) -> Result<String, ProcessError> {
|
||||||
|
Ok(format!("cmd /C \"{}\"", launch_command))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn valid_for_platform(&self, _db: &Database, _target: &Platform) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
fn modify_command(&self, command: &mut Command) {
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
command.creation_flags(CREATE_NO_WINDOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UMUNativeLauncher;
|
pub struct UMUNativeLauncher;
|
||||||
@@ -68,6 +99,8 @@ impl ProcessHandler for UMUNativeLauncher {
|
|||||||
};
|
};
|
||||||
compat_info.umu_installed
|
compat_info.umu_installed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn modify_command(&self, _command: &mut Command) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UMUCompatLauncher;
|
pub struct UMUCompatLauncher;
|
||||||
@@ -133,6 +166,8 @@ impl ProcessHandler for UMUCompatLauncher {
|
|||||||
};
|
};
|
||||||
compat_info.umu_installed
|
compat_info.umu_installed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn modify_command(&self, _command: &mut Command) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AsahiMuvmLauncher;
|
pub struct AsahiMuvmLauncher;
|
||||||
@@ -191,4 +226,6 @@ impl ProcessHandler for AsahiMuvmLauncher {
|
|||||||
|
|
||||||
compat_info.umu_installed
|
compat_info.umu_installed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn modify_command(&self, _command: &mut Command) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use crate::{
|
|||||||
format::DropFormatArgs,
|
format::DropFormatArgs,
|
||||||
parser::{LaunchParameters, ParsedCommand},
|
parser::{LaunchParameters, ParsedCommand},
|
||||||
process_handlers::{
|
process_handlers::{
|
||||||
AsahiMuvmLauncher, NativeGameLauncher, UMUCompatLauncher, UMUNativeLauncher,
|
AsahiMuvmLauncher, MacLauncher, UMUCompatLauncher, UMUNativeLauncher, WindowsLauncher,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ impl ProcessManager<'_> {
|
|||||||
// Current platform to target platform
|
// Current platform to target platform
|
||||||
(
|
(
|
||||||
(Platform::Windows, Platform::Windows),
|
(Platform::Windows, Platform::Windows),
|
||||||
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
&WindowsLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
(Platform::Linux, Platform::Linux),
|
(Platform::Linux, Platform::Linux),
|
||||||
@@ -82,7 +82,7 @@ impl ProcessManager<'_> {
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
(Platform::macOS, Platform::macOS),
|
(Platform::macOS, Platform::macOS),
|
||||||
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
&MacLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
(Platform::Linux, Platform::Windows),
|
(Platform::Linux, Platform::Windows),
|
||||||
@@ -149,10 +149,7 @@ impl ProcessManager<'_> {
|
|||||||
db_handle.applications.transient_statuses.remove(&meta);
|
db_handle.applications.transient_statuses.remove(&meta);
|
||||||
|
|
||||||
let current_state = db_handle.applications.game_statuses.get_mut(&game_id);
|
let current_state = db_handle.applications.game_statuses.get_mut(&game_id);
|
||||||
if let Some(GameDownloadStatus::Installed {
|
if let Some(GameDownloadStatus::Installed { install_type, .. }) = current_state
|
||||||
install_type,
|
|
||||||
..
|
|
||||||
}) = current_state
|
|
||||||
&& let Ok(exit_code) = result
|
&& let Ok(exit_code) = result
|
||||||
&& exit_code.success()
|
&& exit_code.success()
|
||||||
{
|
{
|
||||||
@@ -479,6 +476,8 @@ impl ProcessManager<'_> {
|
|||||||
.env_remove("RUST_LOG")
|
.env_remove("RUST_LOG")
|
||||||
.current_dir(launch_parameters.1);
|
.current_dir(launch_parameters.1);
|
||||||
|
|
||||||
|
process_handler.modify_command(&mut command);
|
||||||
|
|
||||||
let child = command.spawn()?;
|
let child = command.spawn()?;
|
||||||
|
|
||||||
let launch_process_handle = Arc::new(SharedChild::new(child)?);
|
let launch_process_handle = Arc::new(SharedChild::new(child)?);
|
||||||
@@ -528,4 +527,6 @@ pub trait ProcessHandler: Send + 'static {
|
|||||||
) -> Result<String, ProcessError>;
|
) -> Result<String, ProcessError>;
|
||||||
|
|
||||||
fn valid_for_platform(&self, db: &Database, target: &Platform) -> bool;
|
fn valid_for_platform(&self, db: &Database, target: &Platform) -> bool;
|
||||||
|
|
||||||
|
fn modify_command(&self, command: &mut Command);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user