linting
This commit is contained in:
parent
5ad73dcc1c
commit
030c869fec
18
src/main.rs
18
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)]
|
||||||
@ -134,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.");
|
||||||
}
|
}
|
||||||
@ -170,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);
|
||||||
@ -240,8 +240,10 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prompt_client_selection(games: &Vec<Game>) -> String {
|
fn prompt_client_selection(games: &[Game]) -> String {
|
||||||
println!("Couldn't detect any games, please select a client to install in the current directory:");
|
println!(
|
||||||
|
"Couldn't detect any games, please select a client to install in the current directory:"
|
||||||
|
);
|
||||||
for (i, g) in games.iter().enumerate() {
|
for (i, g) in games.iter().enumerate() {
|
||||||
for c in g.client.iter() {
|
for c in g.client.iter() {
|
||||||
println!("{}: {}", i, c);
|
println!("{}: {}", i, c);
|
||||||
@ -251,7 +253,7 @@ fn prompt_client_selection(games: &Vec<Game>) -> String {
|
|||||||
String::from(games[input].client[0])
|
String::from(games[input].client[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manual_install(games: &Vec<Game>) {
|
fn manual_install(games: &[Game]) {
|
||||||
let selection = prompt_client_selection(games);
|
let selection = prompt_client_selection(games);
|
||||||
let game = games.iter().find(|&g| g.client[0] == selection).unwrap();
|
let game = games.iter().find(|&g| g.client[0] == selection).unwrap();
|
||||||
update(game, &std::env::current_dir().unwrap());
|
update(game, &std::env::current_dir().unwrap());
|
||||||
@ -260,7 +262,7 @@ fn manual_install(games: &Vec<Game>) {
|
|||||||
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(),
|
||||||
))
|
))
|
||||||
@ -375,7 +377,7 @@ fn main() {
|
|||||||
windows_launcher_install(&games);
|
windows_launcher_install(&games);
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
prompt_client_selection(&games);
|
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)");
|
||||||
|
Loading…
Reference in New Issue
Block a user