Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
757c1acf1b | |||
b15d0eb7d7 |
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "res/build.rs"
|
build = "res/build.rs"
|
||||||
|
|
||||||
|
@ -6,4 +6,5 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
- Passing iw4-sp, iw5-mod or iw6-mod as the first argument will skip automatic game detection
|
- Passing ```iw4-sp```, ```iw5-mod``` or ```iw6-mod``` as the first argument will skip automatic game detection
|
||||||
|
- Passing ```update``` will stop the launcher from launching the game
|
13
src/main.rs
13
src/main.rs
@ -93,11 +93,19 @@ fn launch(file_path: &PathBuf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let mut args: Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str());
|
let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str());
|
||||||
let games: Vec<Game> = serde_json::from_str(&games_json).unwrap();
|
let games: Vec<Game> = serde_json::from_str(&games_json).unwrap();
|
||||||
|
|
||||||
|
let mut update_only = false;
|
||||||
|
if args.contains(&String::from("update")) {
|
||||||
|
update_only = true;
|
||||||
|
args.iter()
|
||||||
|
.position(|r| r == "update")
|
||||||
|
.map(|e| args.remove(e));
|
||||||
|
}
|
||||||
|
|
||||||
let mut game: String = String::new();
|
let mut game: String = String::new();
|
||||||
if args.len() > 1 {
|
if args.len() > 1 {
|
||||||
game = String::from(&args[1]);
|
game = String::from(&args[1]);
|
||||||
@ -115,6 +123,9 @@ fn main() {
|
|||||||
for g in games.iter() {
|
for g in games.iter() {
|
||||||
if g.client == game {
|
if g.client == game {
|
||||||
update(g);
|
update(g);
|
||||||
|
if update_only {
|
||||||
|
return;
|
||||||
|
}
|
||||||
launch(&PathBuf::from(format!("{}.exe", g.client)));
|
launch(&PathBuf::from(format!("{}.exe", g.client)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user