From 4bcfd7ec092eb130f47f6c7386e16fe65b49c467 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 21 Apr 2023 17:03:04 -0700 Subject: [PATCH] more options --- src-tauri/src/config.rs | 2 +- src-tauri/src/main.rs | 32 +++++++++++++++++++++++++------- src-tauri/src/system_helpers.rs | 2 ++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index 8e52edf..d51c440 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -12,7 +12,7 @@ pub struct Configuration { pub close_action: u64, pub startup_launch: bool, pub last_ip: String, - pub last_port: u64, + pub last_port: String, pub language: String, pub customBackground: String, pub cert_generated: bool, diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ab93f81..deee81e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -45,15 +45,16 @@ async fn parse_args(inp: &Vec) -> Result { ); args.flag("h", "help", "Print various CLI args"); args.flag("p", "proxy", "Start the proxy server"); - args.flag("g", "launch-game", "Launch the game"); + args.flag("G", "launch-game", "Launch the game"); args.flag( - "na", + "A", "no-admin", "Launch without requiring admin permissions", ); - args.flag("ng", "no-gui", "Run in CLI mode"); + args.flag("g", "no-gui", "Run in CLI mode"); + args.flag("s", "server", "Launch the configured GC server"); - args.parse(inp); + args.parse(inp).unwrap(); let config = config::get_config(); @@ -62,7 +63,24 @@ async fn parse_args(inp: &Vec) -> Result { std::process::exit(0); } - if args.value_of("launch-game")? {} + if args.value_of("launch-game")? { + let game_path = config.game_install_path; + system_helpers::run_program(game_path.to_string(), None) + } + + if args.value_of("server")? { + let server_jar = config.grasscutter_path; + let mut server_path = server_jar.clone(); + let java_path = config.java_path; + + server_path.pop(); + + system_helpers::run_jar( + server_jar.to_string(), + server_path.to_string(), + java_path.to_string(), + ); + } if args.value_of("proxy")? { println!("Starting proxy server..."); @@ -80,12 +98,12 @@ fn main() -> Result<(), ArgsError> { let args: Vec = std::env::args().collect(); let parsed_args = block_on(parse_args(&args)).unwrap(); - if !is_elevated() && parsed_args.value_of("no-admin")? { + if !is_elevated() && !parsed_args.value_of("no-admin")? { println!("==============================================================================="); println!("You running as a non-elevated user. Some stuff will almost definitely not work."); println!("==============================================================================="); - //reopen_as_admin(); + reopen_as_admin(); } // Setup datadir/cultivation just in case something went funky and it wasn't made diff --git a/src-tauri/src/system_helpers.rs b/src-tauri/src/system_helpers.rs index 50eec24..7d09fa9 100644 --- a/src-tauri/src/system_helpers.rs +++ b/src-tauri/src/system_helpers.rs @@ -67,6 +67,8 @@ pub fn run_jar(path: String, execute_in: String, java_path: String) { format!("\"{}\" -jar \"{}\"", java_path, path) }; + println!("Launching .jar with command: {}", &command); + // Open the program from the specified path. match open::with( format!("/k cd /D \"{}\" & {}", &execute_in, &command),