Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
601abd008f | |||
322fd2f98a | |||
e061bca7a3 | |||
87e86cc954 | |||
d5d847df75 | |||
d620bc9838 | |||
76a7d8b2c6 | |||
6c7fbd1ff1 |
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -13,7 +13,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"http_req",
|
"http_req",
|
||||||
"mslnk",
|
"mslnk",
|
||||||
@ -538,18 +538,18 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.183"
|
version = "1.0.185"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
|
checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.183"
|
version = "1.0.185"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
|
checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -558,9 +558,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.104"
|
version = "1.0.105"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
|
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "res/build.rs"
|
build = "res/build.rs"
|
||||||
|
|
||||||
@ -19,8 +19,8 @@ http_req = { version = "0.9.2", default-features = false, features = [
|
|||||||
"rust-tls",
|
"rust-tls",
|
||||||
] }
|
] }
|
||||||
sha1_smol = "1.0.0"
|
sha1_smol = "1.0.0"
|
||||||
serde = { version = "1.0.183", features = ["derive"] }
|
serde = { version = "1.0.185", features = ["derive"] }
|
||||||
serde_json = "1.0.104"
|
serde_json = "1.0.105"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
semver = "1.0.18"
|
semver = "1.0.18"
|
||||||
|
|
||||||
|
@ -11,4 +11,4 @@
|
|||||||
- ```skip-launcher-update``` skips self-update
|
- ```skip-launcher-update``` skips self-update
|
||||||
|
|
||||||
### Note for server owners:
|
### Note for server owners:
|
||||||
When the launcher updates itself it needs to be restarted. It will return exit code 101 in this case.
|
When the launcher updates itself it needs to be restarted. It will return exit code 201 in this case.
|
51
src/main.rs
51
src/main.rs
@ -2,7 +2,7 @@ mod http;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use mslnk::ShellLink;
|
use mslnk::ShellLink;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::Path, path::PathBuf};
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use std::{thread, time};
|
use std::{thread, time};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -109,14 +109,20 @@ fn self_update(update_only: bool) {
|
|||||||
if !update_only {
|
if !update_only {
|
||||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||||
}
|
}
|
||||||
std::process::exit(101);
|
std::process::exit(201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
|
fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
|
||||||
let mut installed_games = Vec::new();
|
let mut installed_games = Vec::new();
|
||||||
let mut steamdir = SteamDir::locate().unwrap();
|
let mut steamdir = match SteamDir::locate() {
|
||||||
|
Some(steamdir) => steamdir,
|
||||||
|
None => {
|
||||||
|
println!("Steam not found.");
|
||||||
|
return installed_games;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for game in games {
|
for game in games {
|
||||||
if let Some(app) = steamdir.app(&game.app_id) {
|
if let Some(app) = steamdir.app(&game.app_id) {
|
||||||
@ -128,7 +134,7 @@ fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn setup_client_links(game: &Game, game_dir: &PathBuf) {
|
fn setup_client_links(game: &Game, game_dir: &Path) {
|
||||||
if game.client.len() > 1 {
|
if game.client.len() > 1 {
|
||||||
println!("Multiple clients installed, use the shortcuts (launch-<client>.lnk in the game directory or desktop shortcuts) to launch a specific client.");
|
println!("Multiple clients installed, use the shortcuts (launch-<client>.lnk in the game directory or desktop shortcuts) to launch a specific client.");
|
||||||
}
|
}
|
||||||
@ -164,7 +170,7 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
println!("Installing AlterWare client for {}.", id);
|
println!("Installing AlterWare client for {}.", id);
|
||||||
let game = games.iter().find(|&g| g.app_id == *id).unwrap();
|
let game = games.iter().find(|&g| g.app_id == *id).unwrap();
|
||||||
setup_client_links(game, path);
|
setup_client_links(game, path);
|
||||||
update(&game, path);
|
update(game, path);
|
||||||
println!("Installation complete. Please run the launcher again or use a shortcut to launch the game.");
|
println!("Installation complete. Please run the launcher again or use a shortcut to launch the game.");
|
||||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
@ -177,9 +183,13 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
println!("{}: {}", id, path.display());
|
println!("{}: {}", id, path.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Enter the ID of the game you want to install the AlterWare client for:");
|
println!("Enter the ID of the game you want to install the AlterWare client for, enter 0 for manual selection:");
|
||||||
let input: u32 = get_input().parse().unwrap();
|
let input: u32 = get_input().parse().unwrap();
|
||||||
|
|
||||||
|
if input == 0 {
|
||||||
|
return manual_install(games);
|
||||||
|
}
|
||||||
|
|
||||||
for (id, path) in installed_games.iter() {
|
for (id, path) in installed_games.iter() {
|
||||||
if *id == input {
|
if *id == input {
|
||||||
let game = games.iter().find(|&g| g.app_id == input).unwrap();
|
let game = games.iter().find(|&g| g.app_id == input).unwrap();
|
||||||
@ -224,15 +234,35 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
|
} else {
|
||||||
|
manual_install(games);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
println!("No installed Steam games found. Please install a supported game first or place the launcher in the game folder.");
|
fn prompt_client_selection(games: &[Game]) -> String {
|
||||||
|
println!(
|
||||||
|
"Couldn't detect any games, please select a client to install in the current directory:"
|
||||||
|
);
|
||||||
|
for (i, g) in games.iter().enumerate() {
|
||||||
|
for c in g.client.iter() {
|
||||||
|
println!("{}: {}", i, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let input: usize = get_input().parse().unwrap();
|
||||||
|
String::from(games[input].client[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn manual_install(games: &[Game]) {
|
||||||
|
let selection = prompt_client_selection(games);
|
||||||
|
let game = games.iter().find(|&g| g.client[0] == selection).unwrap();
|
||||||
|
update(game, &std::env::current_dir().unwrap());
|
||||||
|
println!("Installation complete. Please run the launcher again or use a shortcut to launch the game.");
|
||||||
|
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(game: &Game, dir: &PathBuf) {
|
fn update(game: &Game, dir: &Path) {
|
||||||
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
||||||
format!("{}/files.json", MASTER).as_str(),
|
format!("{}/files.json", MASTER).as_str(),
|
||||||
))
|
))
|
||||||
@ -346,6 +376,9 @@ fn main() {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
windows_launcher_install(&games);
|
windows_launcher_install(&games);
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
manual_install(&games);
|
||||||
|
|
||||||
println!("Game not found!");
|
println!("Game not found!");
|
||||||
println!("Place the launcher in the game folder, if that doesn't work specify the client on the command line (ex. alterware-launcher.exe iw4-sp)");
|
println!("Place the launcher in the game folder, if that doesn't work specify the client on the command line (ex. alterware-launcher.exe iw4-sp)");
|
||||||
println!("Press enter to exit...");
|
println!("Press enter to exit...");
|
||||||
|
Reference in New Issue
Block a user