chore: add command to check if osu is already running
This commit is contained in:
parent
7e524debb9
commit
c63b42cae3
@ -349,8 +349,8 @@ pub fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_osu(folder: String) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(folder).join("osu!.exe");
|
||||
pub fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
@ -371,6 +371,31 @@ pub fn run_osu(folder: String) -> Result<(), String> {
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
if patch {
|
||||
thread::sleep(Duration::from_secs(3));
|
||||
let patcher_exe_path = PathBuf::from(&folder)
|
||||
.join("EZPPLauncher")
|
||||
.join("patcher")
|
||||
.join("osu!.patcher.exe");
|
||||
|
||||
if patcher_exe_path.exists() {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let _ = Command::new(&patcher_exe_path)
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let _ = Command::new(&patcher_exe_path)
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
game_process.wait().map_err(|e| e.to_string())?;
|
||||
|
||||
Ok(())
|
||||
@ -571,3 +596,8 @@ pub fn is_osu_running() -> bool {
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn open_url_in_browser(url: String) -> Result<(), String> {
|
||||
open::that(&url).map_err(|e| format!("Failed to open URL: {}", e))
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ pub mod utils;
|
||||
use crate::commands::{
|
||||
download_ezpp_launcher_update_files, find_osu_installation, get_beatmapsets_count,
|
||||
get_ezpp_launcher_update_files, get_hwid, get_osu_release_stream, get_osu_skin,
|
||||
get_osu_version, get_skins_count, replace_ui_files, run_osu, run_osu_updater,
|
||||
set_osu_config_values, set_osu_user_config_values, valid_osu_folder, is_osu_running
|
||||
get_osu_version, get_skins_count, is_osu_running, open_url_in_browser, replace_ui_files,
|
||||
run_osu, run_osu_updater, set_osu_config_values, set_osu_user_config_values, valid_osu_folder,
|
||||
};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@ -41,7 +41,8 @@ pub fn run() {
|
||||
get_ezpp_launcher_update_files,
|
||||
download_ezpp_launcher_update_files,
|
||||
replace_ui_files,
|
||||
is_osu_running
|
||||
is_osu_running,
|
||||
open_url_in_browser
|
||||
])
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
Loading…
x
Reference in New Issue
Block a user