Compare commits
2 commits
06a8fcd807
...
4d8883218c
Author | SHA1 | Date | |
---|---|---|---|
Tipragot | 4d8883218c | ||
Tipragot | 67ae6a4e9c |
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -550,6 +550,7 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"glob",
|
"glob",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"winapi",
|
||||||
"winres",
|
"winres",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,9 +5,10 @@ edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11.22", features = ["blocking"] }
|
||||||
|
winapi = { version = "0.3", features = ["wincon"] }
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
glob = "0.3.1"
|
glob = "0.3.1"
|
||||||
reqwest = { version = "0.11.22", features = ["blocking"] }
|
|
||||||
zip = "0.6.6"
|
zip = "0.6.6"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -1,8 +1,12 @@
|
||||||
|
use anyhow::Context;
|
||||||
use launcher::{apply_zip, download};
|
use launcher::{apply_zip, download};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io::Write;
|
use std::io::{BufRead, BufReader, Write};
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::process::Stdio;
|
||||||
use std::{env::set_current_dir, fs, io, process::Command};
|
use std::{env::set_current_dir, fs, io, process::Command};
|
||||||
|
use winapi::um::winbase::DETACHED_PROCESS;
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
// Move to the project directory
|
// Move to the project directory
|
||||||
|
@ -38,10 +42,16 @@ fn main() -> anyhow::Result<()> {
|
||||||
apply_zip("config")?;
|
apply_zip("config")?;
|
||||||
apply_zip("mods")?;
|
apply_zip("mods")?;
|
||||||
|
|
||||||
|
// unsafe { winapi::um::wincon::FreeConsole() };
|
||||||
|
|
||||||
// Launch the game
|
// Launch the game
|
||||||
println!("Launching game...");
|
println!("Launching game...");
|
||||||
set_current_dir("data/game")?;
|
let process = Command::new("data/runtime/bin/java.exe")
|
||||||
Command::new("../runtime/bin/java.exe")
|
.creation_flags(DETACHED_PROCESS)
|
||||||
|
.current_dir("data/game")
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
|
.stdin(Stdio::null())
|
||||||
.args([
|
.args([
|
||||||
"-cp",
|
"-cp",
|
||||||
"../libraries/*",
|
"../libraries/*",
|
||||||
|
@ -53,7 +63,19 @@ fn main() -> anyhow::Result<()> {
|
||||||
"--username",
|
"--username",
|
||||||
username.trim(),
|
username.trim(),
|
||||||
])
|
])
|
||||||
.status()?;
|
.spawn()?;
|
||||||
|
|
||||||
|
let reader = BufReader::new(process.stdout.context("no stdout")?);
|
||||||
|
for line in reader.lines() {
|
||||||
|
let line = line?;
|
||||||
|
if line
|
||||||
|
.trim()
|
||||||
|
.ends_with("Backend library: LWJGL version 3.3.1 SNAPSHOT")
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
println!("{line}");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue