mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-09-23 08:32:51 +00:00
feat(LCELive): add -ip, -port and -quitondisconnect for neoLegacy
This commit is contained in:
+14
-5
@@ -1342,7 +1342,7 @@ async fn check_game_update(app: AppHandle, instance_id: String, url: String) ->
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
async fn launch_game(app: AppHandle, state: State<'_, GameState>, instance_id: String, mut servers: Vec<McServer>) -> Result<(), String> {
|
async fn launch_game(app: AppHandle, state: State<'_, GameState>, instance_id: String, mut servers: Vec<McServer>, game_args: Vec<String>) -> Result<(), String> {
|
||||||
perform_instance_sync(&app, &instance_id).await?;
|
perform_instance_sync(&app, &instance_id).await?;
|
||||||
let working_dir = get_instance_working_dir(&app, &instance_id);
|
let working_dir = get_instance_working_dir(&app, &instance_id);
|
||||||
let config = load_config(app.clone());
|
let config = load_config(app.clone());
|
||||||
@@ -1422,8 +1422,11 @@ async fn launch_game(app: AppHandle, state: State<'_, GameState>, instance_id: S
|
|||||||
cmd.env_remove("QT_PLUGIN_PATH");
|
cmd.env_remove("QT_PLUGIN_PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.arg(&game_exe)
|
cmd.arg(&game_exe);
|
||||||
.current_dir(&working_dir);
|
for a in &game_args {
|
||||||
|
cmd.arg(a);
|
||||||
|
}
|
||||||
|
cmd.current_dir(&working_dir);
|
||||||
|
|
||||||
let child = cmd.spawn().map_err(|e| e.to_string())?;
|
let child = cmd.spawn().map_err(|e| e.to_string())?;
|
||||||
{
|
{
|
||||||
@@ -1492,6 +1495,9 @@ async fn launch_game(app: AppHandle, state: State<'_, GameState>, instance_id: S
|
|||||||
c.arg(&game_exe);
|
c.arg(&game_exe);
|
||||||
c
|
c
|
||||||
};
|
};
|
||||||
|
for a in &game_args {
|
||||||
|
cmd.arg(a);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
cmd.process_group(0);
|
cmd.process_group(0);
|
||||||
@@ -1559,6 +1565,9 @@ async fn launch_game(app: AppHandle, state: State<'_, GameState>, instance_id: S
|
|||||||
#[cfg(all(not(target_os = "macos"), not(target_os = "linux")))]
|
#[cfg(all(not(target_os = "macos"), not(target_os = "linux")))]
|
||||||
{
|
{
|
||||||
let mut cmd = tokio::process::Command::new(&game_exe);
|
let mut cmd = tokio::process::Command::new(&game_exe);
|
||||||
|
for a in &game_args {
|
||||||
|
cmd.arg(a);
|
||||||
|
}
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
cmd.process_group(0);
|
cmd.process_group(0);
|
||||||
cmd.current_dir(&working_dir);
|
cmd.current_dir(&working_dir);
|
||||||
@@ -2462,7 +2471,7 @@ async fn join_game(
|
|||||||
port: host_port,
|
port: host_port,
|
||||||
};
|
};
|
||||||
|
|
||||||
launch_game(app, game_state, instance_id, vec![server]).await
|
launch_game(app, game_state, instance_id, vec![server], vec![]).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -2492,7 +2501,7 @@ pub fn run() {
|
|||||||
let _ = window.hide();
|
let _ = window.hide();
|
||||||
}
|
}
|
||||||
let state = app_handle.state::<GameState>();
|
let state = app_handle.state::<GameState>();
|
||||||
match launch_game(app_handle.clone(), state, instance_id, Vec::new()).await {
|
match launch_game(app_handle.clone(), state, instance_id, Vec::new(), vec![]).await {
|
||||||
Ok(_) => { app_handle.exit(0); }
|
Ok(_) => { app_handle.exit(0); }
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Auto-launch error: {}", e);
|
eprintln!("Auto-launch error: {}", e);
|
||||||
|
|||||||
@@ -64,9 +64,11 @@ export default function ChooseInstanceModal({
|
|||||||
const accessToken = lceLiveService.accessToken ?? "";
|
const accessToken = lceLiveService.accessToken ?? "";
|
||||||
await TauriService.startRelayProxy(baseUrl, accessToken, sessionId);
|
await TauriService.startRelayProxy(baseUrl, accessToken, sessionId);
|
||||||
setStatus("Launching game...");
|
setStatus("Launching game...");
|
||||||
await TauriService.launchGame(selectedInstance, [
|
await TauriService.launchGame(
|
||||||
{ name: invite.hostName || "LCELive Game", ip: "127.0.0.1", port: 61000 }
|
selectedInstance,
|
||||||
]);
|
[{ name: invite.hostName || "LCELive Game", ip: "127.0.0.1", port: 61000 }],
|
||||||
|
["-ip", "127.0.0.1", "-port", "61000", "-quitondisconnect"]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
setStatus("Launching game...");
|
setStatus("Launching game...");
|
||||||
await TauriService.stopAllProxies();
|
await TauriService.stopAllProxies();
|
||||||
|
|||||||
@@ -123,8 +123,9 @@ export class TauriService {
|
|||||||
static async launchGame(
|
static async launchGame(
|
||||||
instanceId: string,
|
instanceId: string,
|
||||||
servers: McServer[],
|
servers: McServer[],
|
||||||
|
extraArgs?: string[],
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return invoke("launch_game", { instanceId, servers });
|
return invoke("launch_game", { instanceId, servers, extraArgs: extraArgs ?? [] });
|
||||||
}
|
}
|
||||||
|
|
||||||
static async stopGame(instanceId: string): Promise<void> {
|
static async stopGame(instanceId: string): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user