Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
18651a68ca | |||
79559fe46a | |||
8fd66d16af | |||
4d3c6b9dab |
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -13,7 +13,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.2"
|
version = "0.4.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"http_req",
|
"http_req",
|
||||||
"mslnk",
|
"mslnk",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.2"
|
version = "0.4.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "res/build.rs"
|
build = "res/build.rs"
|
||||||
|
|
||||||
|
29
src/main.rs
29
src/main.rs
@ -156,6 +156,21 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
let installed_games = get_installed_games(games);
|
let installed_games = get_installed_games(games);
|
||||||
|
|
||||||
if !installed_games.is_empty() {
|
if !installed_games.is_empty() {
|
||||||
|
// if current directory is in the steamapps/common folder of a game, use that game
|
||||||
|
let current_dir = std::env::current_dir().unwrap();
|
||||||
|
for (id, path) in installed_games.iter() {
|
||||||
|
if current_dir.starts_with(path) {
|
||||||
|
println!("Found game in current directory.");
|
||||||
|
println!("Installing AlterWare client for {}.", id);
|
||||||
|
let game = games.iter().find(|&g| g.app_id == *id).unwrap();
|
||||||
|
setup_client_links(game, path);
|
||||||
|
update(&game, path);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
println!("Installed games:");
|
println!("Installed games:");
|
||||||
|
|
||||||
for (id, path) in installed_games.iter() {
|
for (id, path) in installed_games.iter() {
|
||||||
@ -203,6 +218,9 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update(game, path);
|
||||||
|
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();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +232,7 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(game: &Game) {
|
fn update(game: &Game, dir: &PathBuf) {
|
||||||
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(),
|
||||||
))
|
))
|
||||||
@ -225,7 +243,7 @@ fn update(game: &Game) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_path = PathBuf::from(&file.name.replace(&format!("{}/", game.engine), ""));
|
let file_path = dir.join(&file.name.replace(&format!("{}/", game.engine), ""));
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
let sha1_local = get_file_sha1(&file_path).to_lowercase();
|
let sha1_local = get_file_sha1(&file_path).to_lowercase();
|
||||||
let sha1_remote = file.hash.to_lowercase();
|
let sha1_remote = file.hash.to_lowercase();
|
||||||
@ -289,6 +307,11 @@ fn main() {
|
|||||||
for r in g.references.iter() {
|
for r in g.references.iter() {
|
||||||
if std::path::Path::new(r).exists() {
|
if std::path::Path::new(r).exists() {
|
||||||
if g.client.len() > 1 {
|
if g.client.len() > 1 {
|
||||||
|
if update_only {
|
||||||
|
game = String::from(g.client[0]);
|
||||||
|
break 'main;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
setup_client_links(g, &std::env::current_dir().unwrap());
|
setup_client_links(g, &std::env::current_dir().unwrap());
|
||||||
|
|
||||||
@ -311,7 +334,7 @@ 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 {
|
||||||
update(g);
|
update(g, &std::env::current_dir().unwrap());
|
||||||
if !update_only {
|
if !update_only {
|
||||||
launch(&PathBuf::from(format!("{}.exe", c)));
|
launch(&PathBuf::from(format!("{}.exe", c)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user