Compare commits

..

2 commits

Author SHA1 Message Date
Tipragot 4d8883218c Suppression du code non utilisé 2023-11-18 23:47:59 +01:00
Tipragot 67ae6a4e9c Retirage de la console après le démarage 2023-11-18 23:45:55 +01:00
3 changed files with 29 additions and 5 deletions

1
Cargo.lock generated
View file

@ -550,6 +550,7 @@ dependencies = [
"anyhow",
"glob",
"reqwest",
"winapi",
"winres",
"zip",
]

View file

@ -5,9 +5,10 @@ edition = "2021"
build = "build.rs"
[dependencies]
reqwest = { version = "0.11.22", features = ["blocking"] }
winapi = { version = "0.3", features = ["wincon"] }
anyhow = "1.0.75"
glob = "0.3.1"
reqwest = { version = "0.11.22", features = ["blocking"] }
zip = "0.6.6"
[build-dependencies]

View file

@ -1,8 +1,12 @@
use anyhow::Context;
use launcher::{apply_zip, download};
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::process::Stdio;
use std::{env::set_current_dir, fs, io, process::Command};
use winapi::um::winbase::DETACHED_PROCESS;
fn main() -> anyhow::Result<()> {
// Move to the project directory
@ -38,10 +42,16 @@ fn main() -> anyhow::Result<()> {
apply_zip("config")?;
apply_zip("mods")?;
// unsafe { winapi::um::wincon::FreeConsole() };
// Launch the game
println!("Launching game...");
set_current_dir("data/game")?;
Command::new("../runtime/bin/java.exe")
let process = Command::new("data/runtime/bin/java.exe")
.creation_flags(DETACHED_PROCESS)
.current_dir("data/game")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.stdin(Stdio::null())
.args([
"-cp",
"../libraries/*",
@ -53,7 +63,19 @@ fn main() -> anyhow::Result<()> {
"--username",
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(())
}