Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
c3e3d9a7d5 | |||
47a6eaf4cf | |||
1451dab658 | |||
618033e18f | |||
2b891276a4 | |||
5ed9fd4710 | |||
4763759997 | |||
6ebb421a7b | |||
6ef80be01f | |||
1a3c090612 | |||
fe7c8d2834 | |||
b3168b0a58 | |||
b1cffb44ad | |||
5414213a19 |
117
Cargo.lock
generated
117
Cargo.lock
generated
@ -28,7 +28,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.6.0"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"colored",
|
"colored",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@ -442,11 +442,8 @@ version = "0.10.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a536d8715c89f5647abd1563c490b75a76221de4b57833a1f243cf5c5fe7860c"
|
checksum = "a536d8715c89f5647abd1563c490b75a76221de4b57833a1f243cf5c5fe7860c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"native-tls",
|
||||||
"rustls-pemfile",
|
|
||||||
"unicase",
|
"unicase",
|
||||||
"webpki",
|
|
||||||
"webpki-roots",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -989,35 +986,6 @@ dependencies = [
|
|||||||
"winreg 0.50.0",
|
"winreg 0.50.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ring"
|
|
||||||
version = "0.16.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"spin 0.5.2",
|
|
||||||
"untrusted 0.7.1",
|
|
||||||
"web-sys",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ring"
|
|
||||||
version = "0.17.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "911b295d2d302948838c8ac142da1ee09fa7863163b44e6715bc9357905878b8"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"getrandom",
|
|
||||||
"libc",
|
|
||||||
"spin 0.9.8",
|
|
||||||
"untrusted 0.9.0",
|
|
||||||
"windows-sys 0.48.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.23"
|
version = "0.1.23"
|
||||||
@ -1037,37 +1005,6 @@ dependencies = [
|
|||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustls"
|
|
||||||
version = "0.21.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
"ring 0.16.20",
|
|
||||||
"rustls-webpki",
|
|
||||||
"sct",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustls-pemfile"
|
|
||||||
version = "1.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2"
|
|
||||||
dependencies = [
|
|
||||||
"base64",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustls-webpki"
|
|
||||||
version = "0.101.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe"
|
|
||||||
dependencies = [
|
|
||||||
"ring 0.16.20",
|
|
||||||
"untrusted 0.7.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.13"
|
version = "1.0.13"
|
||||||
@ -1083,16 +1020,6 @@ dependencies = [
|
|||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sct"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
|
|
||||||
dependencies = [
|
|
||||||
"ring 0.16.20",
|
|
||||||
"untrusted 0.7.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "security-framework"
|
name = "security-framework"
|
||||||
version = "2.9.2"
|
version = "2.9.2"
|
||||||
@ -1222,18 +1149,6 @@ dependencies = [
|
|||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spin"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spin"
|
|
||||||
version = "0.9.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "steamlocate"
|
name = "steamlocate"
|
||||||
version = "2.0.0-alpha.0"
|
version = "2.0.0-alpha.0"
|
||||||
@ -1467,18 +1382,6 @@ version = "0.1.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "untrusted"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "untrusted"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "2.4.1"
|
version = "2.4.1"
|
||||||
@ -1606,22 +1509,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "webpki"
|
|
||||||
version = "0.22.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53"
|
|
||||||
dependencies = [
|
|
||||||
"ring 0.17.2",
|
|
||||||
"untrusted 0.9.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "webpki-roots"
|
|
||||||
version = "0.25.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.6.0"
|
version = "0.6.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "res/build.rs"
|
build = "res/build.rs"
|
||||||
|
|
||||||
@ -15,9 +15,7 @@ panic = "abort"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
http_req = { version = "0.10.1", default-features = false, features = [
|
http_req = "0.10.1"
|
||||||
"rust-tls",
|
|
||||||
] }
|
|
||||||
sha1_smol = "1.0.0"
|
sha1_smol = "1.0.0"
|
||||||
serde = { version = "1.0.190", features = ["derive"] }
|
serde = { version = "1.0.190", features = ["derive"] }
|
||||||
serde_json = "1.0.107"
|
serde_json = "1.0.107"
|
||||||
@ -29,6 +27,9 @@ futures-util = "0.3.29"
|
|||||||
indicatif = "0.17.7"
|
indicatif = "0.17.7"
|
||||||
tokio = {version="1.33.0", features = ["rt-multi-thread", "macros"]}
|
tokio = {version="1.33.0", features = ["rt-multi-thread", "macros"]}
|
||||||
|
|
||||||
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
openssl = { version = "0.10.58", default-features = false, features = ["vendored"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
steamlocate = "2.0.0-alpha.0"
|
steamlocate = "2.0.0-alpha.0"
|
||||||
mslnk = "0.1.8"
|
mslnk = "0.1.8"
|
||||||
|
@ -40,3 +40,13 @@ pub fn save_value(config_path: PathBuf, key: &str, value: bool) {
|
|||||||
}
|
}
|
||||||
save(config_path, config);
|
save(config_path, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn save_value_s(config_path: PathBuf, key: &str, value: String) {
|
||||||
|
let mut config = load(config_path.clone());
|
||||||
|
match key {
|
||||||
|
"args" => config.args = value.to_string(),
|
||||||
|
"engine" => config.engine = value.to_string(),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
save(config_path, config);
|
||||||
|
}
|
@ -19,6 +19,14 @@ pub async fn download_file(
|
|||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let res = client
|
let res = client
|
||||||
.get(url)
|
.get(url)
|
||||||
|
.header(
|
||||||
|
"User-Agent",
|
||||||
|
&format!(
|
||||||
|
"AlterWare Launcher | github.com/{}/{}",
|
||||||
|
crate::global::GH_OWNER,
|
||||||
|
crate::global::GH_REPO
|
||||||
|
),
|
||||||
|
)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.or(Err(format!("Failed to GET from '{}'", &url)))?;
|
.or(Err(format!("Failed to GET from '{}'", &url)))?;
|
||||||
|
19
src/main.rs
19
src/main.rs
@ -227,6 +227,7 @@ async fn update_dir(
|
|||||||
"Checked".bright_blue(),
|
"Checked".bright_blue(),
|
||||||
misc::cute_path(&file_path)
|
misc::cute_path(&file_path)
|
||||||
));
|
));
|
||||||
|
hashes.insert(file_name.to_owned(), file.hash.to_lowercase());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
files_to_download.push(file.clone());
|
files_to_download.push(file.clone());
|
||||||
@ -373,7 +374,6 @@ fn arg_remove_value(args: &mut Vec<String>, arg: &str) {
|
|||||||
async fn main() {
|
async fn main() {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
setup_env();
|
setup_env();
|
||||||
|
|
||||||
let mut args: Vec<String> = env::args().collect();
|
let mut args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
if arg_bool(&args, "--help") {
|
if arg_bool(&args, "--help") {
|
||||||
@ -495,6 +495,23 @@ async fn main() {
|
|||||||
for g in games.iter() {
|
for g in games.iter() {
|
||||||
for c in g.client.iter() {
|
for c in g.client.iter() {
|
||||||
if c == &game {
|
if c == &game {
|
||||||
|
if cfg.engine.is_empty() {
|
||||||
|
cfg.engine = String::from(g.engine);
|
||||||
|
config::save_value_s(
|
||||||
|
install_path.join("alterware-launcher.json"),
|
||||||
|
"engine",
|
||||||
|
cfg.engine.clone(),
|
||||||
|
);
|
||||||
|
if cfg.engine == "iw4" && cfg.args.is_empty() {
|
||||||
|
cfg.args = String::from("-stdout");
|
||||||
|
config::save_value_s(
|
||||||
|
install_path.join("alterware-launcher.json"),
|
||||||
|
"args",
|
||||||
|
cfg.args.clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if cfg.ask_bonus_content && !g.bonus.is_empty() {
|
if cfg.ask_bonus_content && !g.bonus.is_empty() {
|
||||||
println!("Download bonus content? (Y/n)");
|
println!("Download bonus content? (Y/n)");
|
||||||
let input = misc::stdin().to_ascii_lowercase();
|
let input = misc::stdin().to_ascii_lowercase();
|
||||||
|
@ -25,6 +25,19 @@ pub fn run(_update_only: bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn restart() -> std::io::Error {
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
match std::process::Command::new(std::env::current_exe().unwrap())
|
||||||
|
.args(std::env::args().skip(1))
|
||||||
|
.creation_flags(0x00000010) // CREATE_NEW_CONSOLE
|
||||||
|
.spawn()
|
||||||
|
{
|
||||||
|
Ok(_) => std::process::exit(0),
|
||||||
|
Err(err) => err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn run(update_only: bool) {
|
pub fn run(update_only: bool) {
|
||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
@ -43,7 +56,9 @@ pub fn run(update_only: bool) {
|
|||||||
&& (file_name.contains(".__relocated__.exe")
|
&& (file_name.contains(".__relocated__.exe")
|
||||||
|| file_name.contains(".__selfdelete__.exe"))
|
|| file_name.contains(".__selfdelete__.exe"))
|
||||||
{
|
{
|
||||||
fs::remove_file(file.path()).unwrap();
|
fs::remove_file(file.path()).unwrap_or_else(|_| {
|
||||||
|
println!("Failed to remove old launcher file.");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +81,7 @@ pub fn run(update_only: bool) {
|
|||||||
} else {
|
} else {
|
||||||
"alterware-launcher.exe"
|
"alterware-launcher.exe"
|
||||||
};
|
};
|
||||||
println!("{}", launcher_name);
|
|
||||||
http::download_file(
|
http::download_file(
|
||||||
&format!(
|
&format!(
|
||||||
"{}/download/{}",
|
"{}/download/{}",
|
||||||
@ -83,12 +98,12 @@ pub fn run(update_only: bool) {
|
|||||||
|
|
||||||
self_replace::self_replace("alterware-launcher-update.exe").unwrap();
|
self_replace::self_replace("alterware-launcher-update.exe").unwrap();
|
||||||
fs::remove_file(&file_path).unwrap();
|
fs::remove_file(&file_path).unwrap();
|
||||||
println!(
|
|
||||||
"Launcher updated. View the changelog at https://github.com/{}/{}/releases/latest",
|
// restarting spawns a new console, automation should manually restart on exit code 201
|
||||||
GH_OWNER, GH_REPO,
|
|
||||||
);
|
|
||||||
println!("Please restart the launcher.");
|
|
||||||
if !update_only {
|
if !update_only {
|
||||||
|
let restart_error = restart().to_string();
|
||||||
|
println!("Failed to restart launcher: {}", restart_error);
|
||||||
|
println!("Please restart the launcher manually.");
|
||||||
misc::stdin();
|
misc::stdin();
|
||||||
}
|
}
|
||||||
std::process::exit(201);
|
std::process::exit(201);
|
||||||
|
@ -22,6 +22,8 @@ pub struct Config {
|
|||||||
pub ask_bonus_content: bool,
|
pub ask_bonus_content: bool,
|
||||||
pub force_update: bool,
|
pub force_update: bool,
|
||||||
pub args: String,
|
pub args: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub engine: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@ -33,6 +35,7 @@ impl Default for Config {
|
|||||||
ask_bonus_content: true,
|
ask_bonus_content: true,
|
||||||
force_update: false,
|
force_update: false,
|
||||||
args: String::default(),
|
args: String::default(),
|
||||||
|
engine: String::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user