mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 08:34:43 +01:00
Implement launching the game on Linux
This commit is contained in:
@@ -10,6 +10,13 @@ use {
|
||||
windows_service::service_manager::{ServiceManager, ServiceManagerAccess},
|
||||
};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::AAGL_THREAD;
|
||||
#[cfg(target_os = "linux")]
|
||||
use anime_launcher_sdk::genshin::game;
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::thread;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_program(path: String, args: Option<String>) {
|
||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||
@@ -22,6 +29,7 @@ pub fn run_program(path: String, args: Option<String>) {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[tauri::command]
|
||||
pub fn run_program_relative(path: String, args: Option<String>) {
|
||||
// Save the current working directory
|
||||
@@ -41,6 +49,13 @@ pub fn run_program_relative(path: String, args: Option<String>) {
|
||||
std::env::set_current_dir(cwd).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[tauri::command]
|
||||
pub fn run_program_relative(path: String, args: Option<String>) {
|
||||
// This program should not run as root
|
||||
run_un_elevated(path, args)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_command(program: &str, args: Vec<&str>, relative: Option<bool>) {
|
||||
let prog = program.to_string();
|
||||
@@ -90,6 +105,7 @@ pub fn run_jar(path: String, execute_in: String, java_path: String) {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[tauri::command]
|
||||
pub fn run_un_elevated(path: String, args: Option<String>) {
|
||||
// Open the program non-elevated.
|
||||
@@ -106,6 +122,20 @@ pub fn run_un_elevated(path: String, args: Option<String>) {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[tauri::command]
|
||||
pub fn run_un_elevated(path: String, args: Option<String>) {
|
||||
drop(path);
|
||||
drop(args);
|
||||
let t = thread::spawn(|| {
|
||||
game::run().expect("doo doo");
|
||||
});
|
||||
{
|
||||
let mut l = AAGL_THREAD.lock().unwrap();
|
||||
l.replace(t);
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn open_in_browser(url: String) {
|
||||
// Open the URL in the default browser.
|
||||
|
||||
Reference in New Issue
Block a user