Compare commits
43 Commits
Author | SHA1 | Date | |
---|---|---|---|
0378f19a75 | |||
64f4ae6429 | |||
b2cc21aed0 | |||
dc5957ea41 | |||
54abce4d30 | |||
6ae33cdcb3 | |||
c9d30fa95a | |||
dc81430f6b | |||
9c122506ce | |||
f2ba92c31d | |||
c92fb88e83 | |||
1e0e0090f5 | |||
48f6a96a01 | |||
f4fe1c6699 | |||
59f1b09337 | |||
237fa8c16f | |||
78e155408e | |||
3033dd2315 | |||
48851fa8d3 | |||
84ea4e48af | |||
b408f13cce | |||
959c3a8a61 | |||
73df20ebb6 | |||
08814a8c3e | |||
65094d4701 | |||
a20b1acdda | |||
75b1d6254b | |||
65f05a5a1c | |||
fa6bdc9f29 | |||
7595a46b44 | |||
c41a843315 | |||
a90a60ec3a | |||
209b599120 | |||
9f00b0c0e7 | |||
aaede9b6cb | |||
8a14008706 | |||
ad7e78ec47 | |||
140f4c335f | |||
3e1a266c3e | |||
92663425ef | |||
ffa379e6dd | |||
a41375a791 | |||
ac76e9bb89 |
13
.github/workflows/release.yml
vendored
13
.github/workflows/release.yml
vendored
@ -18,14 +18,21 @@ jobs:
|
|||||||
upload-assets:
|
upload-assets:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
include:
|
||||||
- ubuntu-20.04
|
- target: x86_64-unknown-linux-gnu
|
||||||
- windows-latest
|
os: ubuntu-20.04
|
||||||
|
- target: i686-unknown-linux-gnu
|
||||||
|
os: ubuntu-20.04
|
||||||
|
- target: x86_64-pc-windows-msvc
|
||||||
|
os: windows-latest
|
||||||
|
- target: i686-pc-windows-msvc
|
||||||
|
os: windows-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: taiki-e/upload-rust-binary-action@v1
|
- uses: taiki-e/upload-rust-binary-action@v1
|
||||||
with:
|
with:
|
||||||
|
target: ${{ matrix.target }}
|
||||||
bin: alterware-launcher
|
bin: alterware-launcher
|
||||||
tar: unix
|
tar: unix
|
||||||
zip: windows
|
zip: windows
|
||||||
|
96
Cargo.lock
generated
96
Cargo.lock
generated
@ -30,8 +30,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.7"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"colored",
|
||||||
"http_req",
|
"http_req",
|
||||||
"mslnk",
|
"mslnk",
|
||||||
"rand",
|
"rand",
|
||||||
@ -41,7 +42,6 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"sha1_smol",
|
"sha1_smol",
|
||||||
"steamlocate",
|
"steamlocate",
|
||||||
"windows-sys",
|
|
||||||
"winres",
|
"winres",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
@ -137,6 +137,17 @@ dependencies = [
|
|||||||
"inout",
|
"inout",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colored"
|
||||||
|
version = "2.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6"
|
||||||
|
dependencies = [
|
||||||
|
"is-terminal",
|
||||||
|
"lazy_static",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "constant_time_eq"
|
name = "constant_time_eq"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
@ -199,23 +210,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "5.0.1"
|
version = "3.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys"
|
name = "dirs-sys"
|
||||||
version = "0.4.1"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"option-ext",
|
|
||||||
"redox_users",
|
"redox_users",
|
||||||
"windows-sys",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -285,6 +295,12 @@ dependencies = [
|
|||||||
"wasi",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hmac"
|
name = "hmac"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
@ -296,9 +312,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http_req"
|
name = "http_req"
|
||||||
version = "0.9.2"
|
version = "0.9.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f680177f2ebe4aabd573d07b322d15a5e0fbc97cd739fd627b08043c89041f8"
|
checksum = "42ce34c74ec562d68f2c23a532c62c1332ff1d1b6147fd118bd1938e090137d0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"unicase",
|
"unicase",
|
||||||
@ -324,6 +340,17 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-terminal"
|
||||||
|
version = "0.4.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
@ -373,6 +400,12 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.147"
|
version = "0.2.147"
|
||||||
@ -417,24 +450,12 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nom"
|
|
||||||
version = "1.2.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.17.2"
|
version = "1.17.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
|
checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "option-ext"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "password-hash"
|
name = "password-hash"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
@ -685,9 +706,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "self-replace"
|
name = "self-replace"
|
||||||
version = "1.3.6"
|
version = "1.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c56335359191626938ef6fdeb478f9f6a7c6020254d7f4641c7d810369fa0ec1"
|
checksum = "525db198616b2bcd0f245daf7bfd8130222f7ee6af9ff9984c19a61bf1160c55"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand 1.9.0",
|
"fastrand 1.9.0",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
@ -696,9 +717,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.18"
|
version = "1.0.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
|
checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
@ -722,9 +743,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.105"
|
version = "1.0.107"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
|
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
@ -767,27 +788,17 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "steamlocate"
|
name = "steamlocate"
|
||||||
version = "1.2.1"
|
version = "2.0.0-alpha.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ec01c74611d14a808cb212d17c6e03f0e30736a15ed1d5736f8a53154cea3ae"
|
checksum = "2b1568c4a70a26c4373fe1131ffa4eff055459631b6e40c6bc118615f2d870c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
"keyvalues-parser",
|
"keyvalues-parser",
|
||||||
"keyvalues-serde",
|
"keyvalues-serde",
|
||||||
"serde",
|
"serde",
|
||||||
"steamy-vdf",
|
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "steamy-vdf"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "533127ad49314bfe71c3d3fd36b3ebac3d24f40618092e70e1cfe8362c7fac79"
|
|
||||||
dependencies = [
|
|
||||||
"nom",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
@ -1082,11 +1093,10 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winreg"
|
name = "winreg"
|
||||||
version = "0.11.0"
|
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 = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189"
|
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
17
Cargo.toml
17
Cargo.toml
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.7"
|
version = "0.5.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "res/build.rs"
|
build = "res/build.rs"
|
||||||
|
|
||||||
@ -15,24 +15,21 @@ 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.9.2", default-features = false, features = [
|
http_req = { version = "0.9.3", default-features = false, features = [
|
||||||
"rust-tls",
|
"rust-tls",
|
||||||
] }
|
] }
|
||||||
sha1_smol = "1.0.0"
|
sha1_smol = "1.0.0"
|
||||||
serde = { version = "1.0.188", features = ["derive"] }
|
serde = { version = "1.0.188", features = ["derive"] }
|
||||||
serde_json = "1.0.105"
|
serde_json = "1.0.107"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
semver = "1.0.18"
|
semver = "1.0.19"
|
||||||
zip = "0.6.6"
|
zip = "0.6.6"
|
||||||
|
colored = "2.0.4"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
steamlocate = "1.2.1"
|
steamlocate = "2.0.0-alpha.0"
|
||||||
mslnk = "0.1.8"
|
mslnk = "0.1.8"
|
||||||
# https://github.com/mitsuhiko/self-replace/pull/16/
|
self-replace = "1.3.7"
|
||||||
windows-sys = { version = "0.48", features = [
|
|
||||||
"Win32_Security",
|
|
||||||
] }
|
|
||||||
self-replace = "1.3.6"
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
winres = "0.1.12"
|
winres = "0.1.12"
|
||||||
|
67
README.md
67
README.md
@ -1,14 +1,69 @@
|
|||||||
# alterware-launcher
|
# AlterWare Launcher
|
||||||
|
|
||||||
1. Download [latest release](https://github.com/mxve/alterware-launcher/releases/latest/download/alterware-launcher-x86_64-pc-windows-msvc.zip)
|
### [AlterWare.dev](https://alterware.dev)
|
||||||
2. Unpack the archive and place alterware-launcher.exe in the game directory
|
|
||||||
|
##### IW4x | IW4-SP | IW5-Mod | IW6-Mod | S1-Mod
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
|
||||||
|
1. Download the [latest alterware-launcher.exe](https://github.com/mxve/alterware-launcher/releases/latest/download/alterware-launcher.exe)
|
||||||
|
2. Place alterware-launcher.exe in the game directory
|
||||||
3. Run alterware-launcher.exe, after updating the game will launch automatically
|
3. Run alterware-launcher.exe, after updating the game will launch automatically
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
- Passing ```iw4-sp```, ```iw5-mod```, ```iw6-mod``` or ```s1-mod``` as the first argument will skip automatic game detection
|
#### Command line arguments
|
||||||
- Passing ```update``` will stop the launcher from launching the game
|
|
||||||
- ```skip-launcher-update``` skips self-update
|
- ```iw4-sp```, ```iw4x```, ```iw5-mod```, ```iw6-mod```, ```s1-mod```
|
||||||
|
- Skip automatic detection and launch the specified game
|
||||||
|
- This should always be the first argument if used
|
||||||
|
- ```--update```, ```-u```
|
||||||
|
- Only update the game, don't launch it
|
||||||
|
- ```--skip-launcher-update```
|
||||||
|
- Don't update the launcher
|
||||||
|
- ```--bonus```
|
||||||
|
- Download bonus content
|
||||||
|
- ```--force```, ```-f```
|
||||||
|
- Force file hash recheck
|
||||||
|
- ```--path```, ```-p```
|
||||||
|
- Set the game path
|
||||||
|
- Do not include a trailing backslash in the path
|
||||||
|
- ```--pass```
|
||||||
|
- Pass additional arguments to the game
|
||||||
|
- ```--version```, ```-v```
|
||||||
|
- Print the launcher version
|
||||||
|
|
||||||
|
Example: ```alterware-launcher.exe iw4x --bonus -u --path "C:\Games\IW4x" --pass "-console"```
|
||||||
|
|
||||||
|
Some arguments can be set in alterware-launcher.json, args generally override the values of the config.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Support
|
||||||
|
|
||||||
|
Visit the [AlterWare Forum](https://forum.alterware.dev/) or [Discord](https://discord.gg/2ETE8engZM) for support.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Building from Source
|
||||||
|
|
||||||
|
- [Install Rust](https://rustup.rs/)
|
||||||
|
- Clone the repository
|
||||||
|
- Run ```cargo build --release```
|
||||||
|
- The executable will be located in ```target/release```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Note for server owners:
|
### Note for server owners:
|
||||||
When the launcher updates itself it needs to be restarted. It will return exit code 201 in this case.
|
When the launcher updates itself it needs to be restarted. It will return exit code 201 in this case.
|
||||||
|
|
||||||
|
```
|
||||||
|
@echo off
|
||||||
|
:loop
|
||||||
|
start /wait alterware-launcher.exe --update
|
||||||
|
if %errorlevel% equ 201 (
|
||||||
|
goto loop
|
||||||
|
)
|
||||||
|
```
|
30
src/config.rs
Normal file
30
src/config.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
use crate::structs::Config;
|
||||||
|
|
||||||
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
|
pub fn load(config_path: PathBuf) -> Config {
|
||||||
|
if config_path.exists() {
|
||||||
|
let cfg = fs::read_to_string(&config_path).unwrap();
|
||||||
|
let cfg: Config = serde_json::from_str(&cfg).unwrap_or(Config::default());
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
save(config_path.clone(), Config::default());
|
||||||
|
Config::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save(config_path: PathBuf, config: Config) {
|
||||||
|
fs::write(config_path, serde_json::to_string_pretty(&config).unwrap()).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save_value(config_path: PathBuf, key: &str, value: bool) {
|
||||||
|
let mut config = load(config_path.clone());
|
||||||
|
match key {
|
||||||
|
"update_only" => config.update_only = value,
|
||||||
|
"skip_self_update" => config.skip_self_update = value,
|
||||||
|
"download_bonus_content" => config.download_bonus_content = value,
|
||||||
|
"ask_bonus_content" => config.ask_bonus_content = value,
|
||||||
|
"force_update" => config.force_update = value,
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
save(config_path, config);
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
use semver::Version;
|
use semver::Version;
|
||||||
|
|
||||||
pub fn latest(owner: &str, repo: &str) -> String {
|
pub fn latest_tag(owner: &str, repo: &str) -> String {
|
||||||
let github_body = crate::http::get_body_string(
|
let github_body = crate::http::get_body_string(
|
||||||
format!(
|
format!(
|
||||||
"https://api.github.com/repos/{}/{}/releases/latest",
|
"https://api.github.com/repos/{}/{}/releases/latest",
|
||||||
@ -9,13 +9,12 @@ pub fn latest(owner: &str, repo: &str) -> String {
|
|||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap();
|
let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap();
|
||||||
github_json["tag_name"]
|
github_json["tag_name"].to_string().replace('"', "")
|
||||||
.to_string()
|
|
||||||
.replace(['v', '"'].as_ref(), "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn latest_version(owner: &str, repo: &str) -> Version {
|
pub fn latest_version(owner: &str, repo: &str) -> Version {
|
||||||
Version::parse(&latest(owner, repo)).unwrap()
|
let tag = latest_tag(owner, repo).replace('v', "");
|
||||||
|
Version::parse(&tag).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn latest_release_url(owner: &str, repo: &str) -> String {
|
pub fn latest_release_url(owner: &str, repo: &str) -> String {
|
||||||
|
45
src/iw4x.rs
45
src/iw4x.rs
@ -1,8 +1,9 @@
|
|||||||
use crate::github;
|
use crate::github;
|
||||||
|
use crate::global::*;
|
||||||
use crate::http;
|
use crate::http;
|
||||||
use crate::misc;
|
use crate::misc;
|
||||||
use crate::global::*;
|
|
||||||
|
|
||||||
|
use colored::*;
|
||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
pub fn local_revision(dir: &Path) -> u16 {
|
pub fn local_revision(dir: &Path) -> u16 {
|
||||||
@ -14,30 +15,28 @@ pub fn local_revision(dir: &Path) -> u16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn remote_revision() -> u16 {
|
pub fn remote_revision() -> u16 {
|
||||||
misc::rev_to_int(&github::latest(GH_IW4X_OWNER, GH_IW4X_REPO))
|
misc::rev_to_int(&github::latest_tag(GH_IW4X_OWNER, GH_IW4X_REPO))
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update_available(dir: &Path) -> bool {
|
|
||||||
if !dir.join("iw4x.dll").exists() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
local_revision(dir) < remote_revision()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(dir: &Path) {
|
pub fn update(dir: &Path) {
|
||||||
if update_available(dir) {
|
let remote = remote_revision();
|
||||||
println!("Updating IW4x...");
|
let local = local_revision(dir);
|
||||||
http::download_file(
|
|
||||||
&format!(
|
if remote <= local && dir.join("iw4x.dll").exists() {
|
||||||
"{}/download/iw4x.dll",
|
return;
|
||||||
github::latest_release_url(GH_IW4X_OWNER, GH_IW4X_REPO)
|
|
||||||
),
|
|
||||||
&dir.join("iw4x.dll"),
|
|
||||||
);
|
|
||||||
fs::write(
|
|
||||||
dir.join(".iw4xrevision"),
|
|
||||||
github::latest(GH_IW4X_OWNER, GH_IW4X_REPO),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"[{}] {}",
|
||||||
|
"Downloading".bright_yellow(),
|
||||||
|
dir.join("iw4x.dll").display()
|
||||||
|
);
|
||||||
|
http::download_file(
|
||||||
|
&format!(
|
||||||
|
"{}/download/iw4x.dll",
|
||||||
|
github::latest_release_url(GH_IW4X_OWNER, GH_IW4X_REPO)
|
||||||
|
),
|
||||||
|
&dir.join("iw4x.dll"),
|
||||||
|
);
|
||||||
|
fs::write(dir.join(".iw4xrevision"), format!("r{}", remote)).unwrap();
|
||||||
}
|
}
|
||||||
|
252
src/main.rs
252
src/main.rs
@ -1,3 +1,4 @@
|
|||||||
|
mod config;
|
||||||
mod github;
|
mod github;
|
||||||
mod global;
|
mod global;
|
||||||
mod http;
|
mod http;
|
||||||
@ -9,9 +10,10 @@ mod structs;
|
|||||||
use global::*;
|
use global::*;
|
||||||
use structs::*;
|
use structs::*;
|
||||||
|
|
||||||
|
use colored::*;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use mslnk::ShellLink;
|
use mslnk::ShellLink;
|
||||||
use std::{fs, path::Path, path::PathBuf};
|
use std::{borrow::Cow, collections::HashMap, fs, path::Path, path::PathBuf};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use steamlocate::SteamDir;
|
use steamlocate::SteamDir;
|
||||||
|
|
||||||
@ -21,7 +23,7 @@ fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
|
|||||||
let mut steamdir = match SteamDir::locate() {
|
let mut steamdir = match SteamDir::locate() {
|
||||||
Some(steamdir) => steamdir,
|
Some(steamdir) => steamdir,
|
||||||
None => {
|
None => {
|
||||||
println!("Steam not found.");
|
println!("{}", "Steam not found!".yellow());
|
||||||
return installed_games;
|
return installed_games;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -38,7 +40,7 @@ fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn setup_client_links(game: &Game, game_dir: &Path) {
|
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 on the desktop) to launch a specific client.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let target = game_dir.join("alterware-launcher.exe");
|
let target = game_dir.join("alterware-launcher.exe");
|
||||||
@ -90,16 +92,18 @@ fn setup_desktop_links(path: &Path, game: &Game) {
|
|||||||
fn auto_install(path: &Path, game: &Game) {
|
fn auto_install(path: &Path, game: &Game) {
|
||||||
setup_client_links(game, path);
|
setup_client_links(game, path);
|
||||||
setup_desktop_links(path, game);
|
setup_desktop_links(path, game);
|
||||||
update(game, path);
|
update(game, path, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn windows_launcher_install(games: &Vec<Game>) {
|
fn windows_launcher_install(games: &Vec<Game>) {
|
||||||
println!("No game specified/found. Checking for installed Steam games..");
|
println!(
|
||||||
|
"{}",
|
||||||
|
"No game specified/found. Checking for installed Steam games..".yellow()
|
||||||
|
);
|
||||||
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();
|
let current_dir = std::env::current_dir().unwrap();
|
||||||
for (id, path) in installed_games.iter() {
|
for (id, path) in installed_games.iter() {
|
||||||
if current_dir.starts_with(path) {
|
if current_dir.starts_with(path) {
|
||||||
@ -165,78 +169,225 @@ fn prompt_client_selection(games: &[Game]) -> String {
|
|||||||
fn manual_install(games: &[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(), false, false);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(game: &Game, dir: &Path) {
|
fn update_dir(
|
||||||
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
cdn_info: &Vec<CdnFile>,
|
||||||
format!("{}/files.json", MASTER).as_str(),
|
remote_dir: &str,
|
||||||
))
|
dir: &Path,
|
||||||
.unwrap();
|
hashes: &mut HashMap<String, String>,
|
||||||
|
) {
|
||||||
|
let remote_dir = format!("{}/", remote_dir);
|
||||||
|
|
||||||
for file in cdn_info {
|
for file in cdn_info {
|
||||||
if !file.name.starts_with(game.engine) || file.name == "iw4/iw4x.dll" {
|
if !file.name.starts_with(&remote_dir) || file.name == "iw4/iw4x.dll" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_path = dir.join(&file.name.replace(&format!("{}/", game.engine), ""));
|
let sha1_remote = file.hash.to_lowercase();
|
||||||
|
let file_name = &file.name.replace(remote_dir.as_str(), "");
|
||||||
|
let file_path = dir.join(file_name);
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
let sha1_local = misc::get_file_sha1(&file_path).to_lowercase();
|
let sha1_local = hashes
|
||||||
let sha1_remote = file.hash.to_lowercase();
|
.get(file_name)
|
||||||
|
.map(Cow::Borrowed)
|
||||||
|
.unwrap_or_else(|| Cow::Owned(misc::get_file_sha1(&file_path)))
|
||||||
|
.to_string();
|
||||||
|
|
||||||
if sha1_local != sha1_remote {
|
if sha1_local != sha1_remote {
|
||||||
println!(
|
println!(
|
||||||
"Updating {}...\nLocal hash: {}\nRemote hash: {}",
|
"[{}] {}",
|
||||||
file_path.display(),
|
"Updating".bright_yellow(),
|
||||||
sha1_local,
|
file_path.display()
|
||||||
sha1_remote
|
|
||||||
);
|
);
|
||||||
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
||||||
|
} else {
|
||||||
|
println!("[{}] {}", "Checked".bright_blue(), file_path.display());
|
||||||
}
|
}
|
||||||
|
hashes.insert(file_name.to_owned(), sha1_remote.to_owned());
|
||||||
} else {
|
} else {
|
||||||
println!("Downloading {}...", file_path.display());
|
println!(
|
||||||
|
"[{}] {}",
|
||||||
|
"Downloading".bright_yellow(),
|
||||||
|
file_path.display()
|
||||||
|
);
|
||||||
if let Some(parent) = file_path.parent() {
|
if let Some(parent) = file_path.parent() {
|
||||||
if !parent.exists() {
|
if !parent.exists() {
|
||||||
fs::create_dir_all(parent).unwrap();
|
fs::create_dir_all(parent).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
||||||
|
hashes.insert(file_name.to_owned(), sha1_remote.to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(game: &Game, dir: &Path, bonus_content: bool, force: bool) {
|
||||||
|
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
||||||
|
format!("{}/files.json", MASTER).as_str(),
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut hashes = HashMap::new();
|
||||||
|
let hash_file = dir.join(".sha-sums");
|
||||||
|
if hash_file.exists() && !force {
|
||||||
|
let hash_file = fs::read_to_string(hash_file).unwrap();
|
||||||
|
for line in hash_file.lines() {
|
||||||
|
let mut split = line.split_whitespace();
|
||||||
|
let hash = split.next().unwrap();
|
||||||
|
let file = split.next().unwrap();
|
||||||
|
hashes.insert(file.to_owned(), hash.to_owned());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update_dir(&cdn_info, game.engine, dir, &mut hashes);
|
||||||
|
|
||||||
if game.engine == "iw4" {
|
if game.engine == "iw4" {
|
||||||
iw4x::update(dir);
|
iw4x::update(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bonus_content && !game.bonus.is_empty() {
|
||||||
|
for bonus in game.bonus.iter() {
|
||||||
|
update_dir(&cdn_info, bonus, dir, &mut hashes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut hash_file_content = String::new();
|
||||||
|
for (file, hash) in hashes.iter() {
|
||||||
|
hash_file_content.push_str(&format!("{} {}\n", hash, file));
|
||||||
|
}
|
||||||
|
fs::write(dir.join(".sha-sums"), hash_file_content).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn launch(file_path: &PathBuf) {
|
fn launch(file_path: &PathBuf, args: &str) {
|
||||||
println!("Launching {}...", file_path.display());
|
println!("Launching {} {}", file_path.display(), args);
|
||||||
std::process::Command::new(file_path)
|
std::process::Command::new(file_path)
|
||||||
|
.args(args.trim().split(' '))
|
||||||
|
.current_dir(file_path.parent().unwrap())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to launch the game")
|
.expect("Failed to launch the game")
|
||||||
.wait()
|
.wait()
|
||||||
.expect("Failed to wait for the game process to finish");
|
.expect("Failed to wait for the game process to finish");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn setup_env() {
|
||||||
|
colored::control::set_virtual_terminal(true).unwrap_or_else(|error| {
|
||||||
|
println!("{:#?}", error);
|
||||||
|
colored::control::SHOULD_COLORIZE.set_override(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn arg_value(args: &[String], arg: &str) -> Option<String> {
|
||||||
|
args.iter()
|
||||||
|
.position(|r| r == arg)
|
||||||
|
.map(|e| args[e + 1].clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn arg_bool(args: &[String], arg: &str) -> bool {
|
||||||
|
args.iter().any(|r| r == arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn arg_remove(args: &mut Vec<String>, arg: &str) {
|
||||||
|
args.iter().position(|r| r == arg).map(|e| args.remove(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn arg_remove_value(args: &mut Vec<String>, arg: &str) {
|
||||||
|
if let Some(e) = args.iter().position(|r| r == arg) {
|
||||||
|
args.remove(e);
|
||||||
|
args.remove(e);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[cfg(windows)]
|
||||||
|
setup_env();
|
||||||
|
|
||||||
let mut args: Vec<String> = std::env::args().collect();
|
let mut args: Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
let mut update_only = false;
|
if arg_bool(&args, "--help") {
|
||||||
if args.contains(&String::from("update")) {
|
println!("CLI Args:");
|
||||||
update_only = true;
|
println!(" <client>: Specify the client to launch");
|
||||||
args.iter()
|
println!(" --help: Display this help message");
|
||||||
.position(|r| r == "update")
|
println!(" --version: Display the launcher version");
|
||||||
.map(|e| args.remove(e));
|
println!(" --path/-p <path>: Specify the game directory");
|
||||||
|
println!(" --update/-u: Update only, don't launch the game");
|
||||||
|
println!(" --bonus: Download bonus content");
|
||||||
|
println!(" --force/-f: Force file hash recheck");
|
||||||
|
println!(" --pass <args>: Pass arguments to the game");
|
||||||
|
println!(" --skip-launcher-update: Skip launcher self-update");
|
||||||
|
println!(
|
||||||
|
"\nExample:\n alterware-launcher.exe iw4x --bonus --pass \"-console -nointro\""
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !args.contains(&String::from("skip-launcher-update")) {
|
if arg_bool(&args, "--version") || arg_bool(&args, "-v") {
|
||||||
self_update::run(update_only);
|
println!(
|
||||||
|
"{} v{}",
|
||||||
|
"AlterWare Launcher".bright_green(),
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
);
|
||||||
|
println!("https://github.com/{}/{}", GH_OWNER, GH_REPO);
|
||||||
|
println!(
|
||||||
|
"\n{}{}{}{}{}{}{}",
|
||||||
|
"For ".on_black(),
|
||||||
|
"Alter".bright_blue().on_black().underline(),
|
||||||
|
"Ware".white().on_black().underline(),
|
||||||
|
".dev".on_black().underline(),
|
||||||
|
" by ".on_black(),
|
||||||
|
"mxve".bright_magenta().on_black().underline(),
|
||||||
|
".de".on_black().underline()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let install_path: PathBuf;
|
||||||
|
if let Some(path) = arg_value(&args, "--path") {
|
||||||
|
install_path = PathBuf::from(path);
|
||||||
|
arg_remove_value(&mut args, "--path");
|
||||||
|
} else if let Some(path) = arg_value(&args, "-p") {
|
||||||
|
install_path = PathBuf::from(path);
|
||||||
|
arg_remove_value(&mut args, "-p");
|
||||||
} else {
|
} else {
|
||||||
args.iter()
|
install_path = std::env::current_dir().unwrap();
|
||||||
.position(|r| r == "skip-launcher-update")
|
}
|
||||||
.map(|e| args.remove(e));
|
|
||||||
|
let mut cfg = config::load(install_path.join("alterware-launcher.json"));
|
||||||
|
|
||||||
|
if !arg_bool(&args, "--skip-launcher-update") && !cfg.skip_self_update {
|
||||||
|
self_update::run(cfg.update_only);
|
||||||
|
} else {
|
||||||
|
arg_remove(&mut args, "--skip-launcher-update");
|
||||||
|
}
|
||||||
|
|
||||||
|
if arg_bool(&args, "--update") || arg_bool(&args, "-u") {
|
||||||
|
cfg.update_only = true;
|
||||||
|
arg_remove(&mut args, "--update");
|
||||||
|
arg_remove(&mut args, "-u");
|
||||||
|
}
|
||||||
|
|
||||||
|
if arg_bool(&args, "--bonus") {
|
||||||
|
cfg.download_bonus_content = true;
|
||||||
|
cfg.ask_bonus_content = false;
|
||||||
|
arg_remove(&mut args, "--bonus");
|
||||||
|
}
|
||||||
|
|
||||||
|
if arg_bool(&args, "--force") || arg_bool(&args, "-f") {
|
||||||
|
cfg.force_update = true;
|
||||||
|
arg_remove(&mut args, "--force");
|
||||||
|
arg_remove(&mut args, "-f");
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(pass) = arg_value(&args, "--pass") {
|
||||||
|
cfg.args = pass;
|
||||||
|
arg_remove_value(&mut args, "--pass");
|
||||||
|
} else if cfg.args.is_empty() {
|
||||||
|
cfg.args = String::from("");
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
@ -248,9 +399,9 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
'main: for g in games.iter() {
|
'main: for g in games.iter() {
|
||||||
for r in g.references.iter() {
|
for r in g.references.iter() {
|
||||||
if std::path::Path::new(r).exists() {
|
if install_path.join(r).exists() {
|
||||||
if g.client.len() > 1 {
|
if g.client.len() > 1 {
|
||||||
if update_only {
|
if cfg.update_only {
|
||||||
game = String::from(g.client[0]);
|
game = String::from(g.client[0]);
|
||||||
break 'main;
|
break 'main;
|
||||||
}
|
}
|
||||||
@ -277,9 +428,30 @@ 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, &std::env::current_dir().unwrap());
|
if cfg.ask_bonus_content && !g.bonus.is_empty() {
|
||||||
if !update_only {
|
println!("Download bonus content? (Y/n)");
|
||||||
launch(&PathBuf::from(format!("{}.exe", c)));
|
let input = misc::stdin().to_ascii_lowercase();
|
||||||
|
cfg.download_bonus_content = input != "n";
|
||||||
|
config::save_value(
|
||||||
|
install_path.join("alterware-launcher.json"),
|
||||||
|
"download_bonus_content",
|
||||||
|
cfg.download_bonus_content,
|
||||||
|
);
|
||||||
|
config::save_value(
|
||||||
|
install_path.join("alterware-launcher.json"),
|
||||||
|
"ask_bonus_content",
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
g,
|
||||||
|
install_path.as_path(),
|
||||||
|
cfg.download_bonus_content,
|
||||||
|
cfg.force_update,
|
||||||
|
);
|
||||||
|
if !cfg.update_only {
|
||||||
|
launch(&install_path.join(format!("{}.exe", c)), &cfg.args);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -292,7 +464,7 @@ fn main() {
|
|||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
manual_install(&games);
|
manual_install(&games);
|
||||||
|
|
||||||
println!("Game not found!");
|
println!("{}", "Game not found!".bright_red());
|
||||||
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...");
|
||||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||||
|
@ -13,5 +13,8 @@ pub fn stdin() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn rev_to_int(rev: &str) -> u16 {
|
pub fn rev_to_int(rev: &str) -> u16 {
|
||||||
rev.strip_prefix('r').unwrap().parse::<u16>().unwrap_or(0)
|
rev.strip_prefix('r')
|
||||||
|
.unwrap_or("0")
|
||||||
|
.parse::<u16>()
|
||||||
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ pub fn self_update_available() -> bool {
|
|||||||
pub fn run(_update_only: bool) {
|
pub fn run(_update_only: bool) {
|
||||||
if self_update_available() {
|
if self_update_available() {
|
||||||
println!("A new version of the AlterWare launcher is available.");
|
println!("A new version of the AlterWare launcher is available.");
|
||||||
println!("Download it at {}", github::latest_release_url(GH_OWNER, GH_REPO));
|
println!(
|
||||||
|
"Download it at {}",
|
||||||
|
github::latest_release_url(GH_OWNER, GH_REPO)
|
||||||
|
);
|
||||||
println!("Launching in 10 seconds..");
|
println!("Launching in 10 seconds..");
|
||||||
thread::sleep(time::Duration::from_secs(10));
|
thread::sleep(time::Duration::from_secs(10));
|
||||||
}
|
}
|
||||||
@ -57,10 +60,17 @@ pub fn run(update_only: bool) {
|
|||||||
fs::remove_file(&update_binary).unwrap();
|
fs::remove_file(&update_binary).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let launcher_name = if cfg!(target_arch = "x86") {
|
||||||
|
"alterware-launcher-x86.exe"
|
||||||
|
} else {
|
||||||
|
"alterware-launcher.exe"
|
||||||
|
};
|
||||||
|
println!("{}", launcher_name);
|
||||||
http::download_file(
|
http::download_file(
|
||||||
&format!(
|
&format!(
|
||||||
"{}/download/alterware-launcher.exe",
|
"{}/download/{}",
|
||||||
github::latest_release_url(GH_OWNER, GH_REPO)
|
github::latest_release_url(GH_OWNER, GH_REPO),
|
||||||
|
launcher_name
|
||||||
),
|
),
|
||||||
&file_path,
|
&file_path,
|
||||||
);
|
);
|
||||||
|
@ -11,4 +11,28 @@ pub struct Game<'a> {
|
|||||||
pub client: Vec<&'a str>,
|
pub client: Vec<&'a str>,
|
||||||
pub references: Vec<&'a str>,
|
pub references: Vec<&'a str>,
|
||||||
pub app_id: u32,
|
pub app_id: u32,
|
||||||
|
pub bonus: Vec<&'a str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(serde::Deserialize, serde::Serialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub update_only: bool,
|
||||||
|
pub skip_self_update: bool,
|
||||||
|
pub download_bonus_content: bool,
|
||||||
|
pub ask_bonus_content: bool,
|
||||||
|
pub force_update: bool,
|
||||||
|
pub args: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
update_only: false,
|
||||||
|
skip_self_update: false,
|
||||||
|
download_bonus_content: false,
|
||||||
|
ask_bonus_content: true,
|
||||||
|
force_update: false,
|
||||||
|
args: String::from(""),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user