Merge branch 'tauri' of https://git.ez-pp.farm/EZPPFarm/EZPPLauncher into tauri
This commit is contained in:
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -1094,7 +1094,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ezpplauncher"
|
||||
version = "3.0.0-beta.3"
|
||||
version = "3.0.0-beta.4"
|
||||
dependencies = [
|
||||
"discord-rich-presence",
|
||||
"hardware-id",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ezpplauncher"
|
||||
version = "3.0.0-beta.3"
|
||||
version = "3.0.0-beta.4"
|
||||
description = "EZPPLauncher redefined."
|
||||
authors = ["HorizonCode"]
|
||||
edition = "2024"
|
||||
|
@@ -14,7 +14,7 @@ use tokio::time::{Duration, sleep};
|
||||
use crate::presence;
|
||||
use crate::utils::{
|
||||
check_folder_completeness, get_osu_config, get_osu_user_config, get_window_title_by_pid,
|
||||
set_osu_config_vals, set_osu_user_config_vals,
|
||||
set_osu_config_vals, set_osu_user_config_vals, is_wmctrl_available, is_osuwinello_available
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
@@ -282,8 +282,6 @@ pub fn set_osu_config_values(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
@@ -292,6 +290,7 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
let mut updater_process = {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
Command::new(&osu_exe_path)
|
||||
.arg("-repair")
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
@@ -301,7 +300,7 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
Command::new(&osu_exe_path)
|
||||
Command::new("osu-wine")
|
||||
.arg("-repair")
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
||||
@@ -372,8 +371,6 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
/* #[cfg(windows)]
|
||||
use std::os::windows::process::CommandExt; */
|
||||
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
@@ -382,6 +379,7 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
let mut game_process = {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
Command::new(&osu_exe_path)
|
||||
.arg("-devserver")
|
||||
.arg("ez-pp.farm")
|
||||
@@ -392,8 +390,8 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
Command::new(&osu_exe_path)
|
||||
.arg("-devserver")
|
||||
Command::new("osu-wine")
|
||||
.arg("--devserver")
|
||||
.arg("ez-pp.farm")
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
||||
@@ -416,13 +414,6 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
.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}"))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,3 +706,13 @@ pub async fn presence_update_user(user: PresenceUser) {
|
||||
pub async fn presence_is_connected() -> bool {
|
||||
presence::has_presence().await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn has_wmctrl() -> bool {
|
||||
is_wmctrl_available()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn has_osuwinello() -> bool {
|
||||
is_osuwinello_available()
|
||||
}
|
@@ -10,11 +10,17 @@ use crate::commands::{
|
||||
get_osu_release_stream, get_osu_skin, get_osu_version, get_platform, get_skins_count,
|
||||
is_osu_running, open_url_in_browser, presence_connect, presence_disconnect,
|
||||
presence_is_connected, presence_update_status, presence_update_user, replace_ui_files, run_osu,
|
||||
run_osu_updater, set_osu_config_values, set_osu_user_config_values, valid_osu_folder,
|
||||
run_osu_updater, set_osu_config_values, set_osu_user_config_values, valid_osu_folder, has_osuwinello, has_wmctrl
|
||||
};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
unsafe {
|
||||
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||
}
|
||||
|
||||
let mut builder = tauri::Builder::default();
|
||||
#[cfg(desktop)]
|
||||
{
|
||||
@@ -54,7 +60,9 @@ pub fn run() {
|
||||
presence_disconnect,
|
||||
presence_update_status,
|
||||
presence_update_user,
|
||||
presence_is_connected
|
||||
presence_is_connected,
|
||||
has_osuwinello,
|
||||
has_wmctrl
|
||||
])
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
@@ -1,5 +1,6 @@
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use sysinfo::Pid;
|
||||
|
||||
pub fn check_folder_completeness<P: AsRef<Path>>(folder_path: P, required_files: &[&str]) -> f32 {
|
||||
@@ -177,8 +178,68 @@ pub fn get_osu_config<P: AsRef<Path>>(
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn get_window_title_by_pid(_pid: Pid) -> String {
|
||||
"".to_string()
|
||||
pub fn is_osuwinello_available() -> bool {
|
||||
Command::new("osu-wine")
|
||||
.arg("--info") // A lightweight operation like getting the version is ideal.
|
||||
.stdout(std::process::Stdio::null()) // Suppress stdout
|
||||
.stderr(std::process::Stdio::null()) // Suppress stderr
|
||||
.status() // Execute the command and get its status
|
||||
.is_ok() // is_ok() will be true if the command was found and ran
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn is_osuwinello_available() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn is_wmctrl_available() -> bool {
|
||||
Command::new("wmctrl")
|
||||
.arg("-V") // A lightweight operation like getting the version is ideal.
|
||||
.stdout(std::process::Stdio::null()) // Suppress stdout
|
||||
.stderr(std::process::Stdio::null()) // Suppress stderr
|
||||
.status() // Execute the command and get its status
|
||||
.is_ok() // is_ok() will be true if the command was found and ran
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn is_wmctrl_available() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn get_window_title_by_pid(target_pid: Pid) -> String {
|
||||
let find_title = || -> Option<String> {
|
||||
// 1. Execute `wmctrl -lp`
|
||||
let output = Command::new("wmctrl").arg("-lp").output().ok()?;
|
||||
|
||||
if !output.status.success() {
|
||||
return None; // wmctrl command failed (e.g., not on X11)
|
||||
}
|
||||
|
||||
let output_str = String::from_utf8(output.stdout).ok()?;
|
||||
|
||||
// 2. Parse the output line by line
|
||||
for line in output_str.lines() {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
if parts.len() < 4 {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The PID is typically the 3rd column (index 2)
|
||||
if let Ok(pid) = parts[2].parse::<u32>() {
|
||||
if pid == target_pid.as_u32() {
|
||||
// 3. Extract the title and return it as Some(title)
|
||||
let title = parts[4..].join(" ");
|
||||
return Some(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
find_title().unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
|
Reference in New Issue
Block a user