aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2023-02-08 03:02:28 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2023-02-08 03:02:28 +0100
commitc60b7b606dd0b4bc7108f9a768a4545f0781730c (patch)
tree84566aca1cd4499288c00f236563541c00aef070
parent9fd1b18373b495a777edd724c875cd376ee8fb2f (diff)
parent7df1f2dbc038d0d93463249f15ca2e1e7ec23094 (diff)
downloadFlightCore-c60b7b606dd0b4bc7108f9a768a4545f0781730c.tar.gz
FlightCore-c60b7b606dd0b4bc7108f9a768a4545f0781730c.zip
Merge branch 'main' into feat/basic-log-parsing
-rw-r--r--src-tauri/Cargo.lock152
-rw-r--r--src-tauri/Cargo.toml4
-rw-r--r--src-tauri/bindings/NorthstarMod.ts2
-rw-r--r--src-tauri/src/lib.rs7
-rw-r--r--src-tauri/src/main.rs2
-rw-r--r--src-tauri/src/mod_management/mod.rs91
-rw-r--r--src-tauri/tauri.conf.json4
-rw-r--r--src-vue/src/assets/thunderstore-icon.pngbin0 -> 7091 bytes
-rw-r--r--src-vue/src/views/mods/LocalModsView.vue8
9 files changed, 141 insertions, 129 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 5a0a5256..2c04ae71 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -87,7 +87,7 @@ checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
[[package]]
name = "app"
-version = "1.6.1"
+version = "1.7.0"
dependencies = [
"anyhow",
"async-recursion",
@@ -461,20 +461,6 @@ dependencies = [
]
[[package]]
-name = "console"
-version = "0.15.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c"
-dependencies = [
- "encode_unicode",
- "lazy_static",
- "libc",
- "terminal_size",
- "unicode-width",
- "winapi",
-]
-
-[[package]]
name = "constant_time_eq"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -855,12 +841,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
[[package]]
-name = "encode_unicode"
-version = "0.3.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
-
-[[package]]
name = "encoding_rs"
version = "0.8.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1629,18 +1609,6 @@ dependencies = [
]
[[package]]
-name = "indicatif"
-version = "0.17.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4295cbb7573c16d310e99e713cf9e75101eb190ab31fccd35f2d2691b4352b19"
-dependencies = [
- "console",
- "number_prefix",
- "portable-atomic",
- "unicode-width",
-]
-
-[[package]]
name = "infer"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1825,17 +1793,16 @@ dependencies = [
[[package]]
name = "libthermite"
-version = "0.4.0"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "31ec1288a3f54f21ee6bd7eec92c5d098d9acc82d3bfdcf3c5ae29498ddfdc0e"
+checksum = "80ab0312cd1bab244b8b1abd8a0f48b771d4591d4521344468e91a26d6d9fad0"
dependencies = [
- "futures-util",
- "indicatif",
- "log",
- "reqwest",
+ "json5",
"serde",
"serde_json",
"thiserror",
+ "tracing",
+ "ureq",
"zip",
]
@@ -2197,12 +2164,6 @@ dependencies = [
]
[[package]]
-name = "number_prefix"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
-
-[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2630,12 +2591,6 @@ dependencies = [
]
[[package]]
-name = "portable-atomic"
-version = "0.3.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "15eb2c6e362923af47e13c23ca5afb859e83d54452c55b0b9ac763b8f7c1ac16"
-
-[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2965,7 +2920,6 @@ dependencies = [
"serde_urlencoded",
"tokio",
"tokio-native-tls",
- "tokio-util",
"tower-service",
"url",
"wasm-bindgen",
@@ -2999,6 +2953,21 @@ dependencies = [
]
[[package]]
+name = "ring"
+version = "0.16.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
+dependencies = [
+ "cc",
+ "libc",
+ "once_cell",
+ "spin",
+ "untrusted",
+ "web-sys",
+ "winapi",
+]
+
+[[package]]
name = "rusqlite"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3038,6 +3007,18 @@ dependencies = [
]
[[package]]
+name = "rustls"
+version = "0.20.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f"
+dependencies = [
+ "log",
+ "ring",
+ "sct",
+ "webpki",
+]
+
+[[package]]
name = "rustversion"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3093,6 +3074,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
[[package]]
+name = "sct"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
name = "security-framework"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3472,6 +3463,12 @@ dependencies = [
]
[[package]]
+name = "spin"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
+
+[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3929,16 +3926,6 @@ dependencies = [
]
[[package]]
-name = "terminal_size"
-version = "0.1.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
-dependencies = [
- "libc",
- "winapi",
-]
-
-[[package]]
name = "thin-slice"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4251,6 +4238,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
+name = "untrusted"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
+
+[[package]]
+name = "ureq"
+version = "2.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "338b31dd1314f68f3aabf3ed57ab922df95ffcd902476ca7ba3c4ce7b908c46d"
+dependencies = [
+ "base64",
+ "flate2",
+ "log",
+ "once_cell",
+ "rustls",
+ "url",
+ "webpki",
+ "webpki-roots",
+]
+
+[[package]]
name = "url"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4477,6 +4486,25 @@ dependencies = [
]
[[package]]
+name = "webpki"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
+name = "webpki-roots"
+version = "0.22.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
+dependencies = [
+ "webpki",
+]
+
+[[package]]
name = "webview2-com"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 9c0ad2b8..d88b8231 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "app"
-version = "1.6.1"
+version = "1.7.0"
description = "A Tauri App"
authors = ["you"]
license = ""
@@ -25,7 +25,7 @@ steamlocate = "1.0.2"
# Error messages
anyhow = "1.0"
# libthermite for Northstar/mod install handling
-libthermite = "0.4.0"
+libthermite = "0.5.2"
# zip stuff
zip = "0.6.2"
# Regex
diff --git a/src-tauri/bindings/NorthstarMod.ts b/src-tauri/bindings/NorthstarMod.ts
index ed9d9297..3686485b 100644
--- a/src-tauri/bindings/NorthstarMod.ts
+++ b/src-tauri/bindings/NorthstarMod.ts
@@ -1,3 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
-export interface NorthstarMod { name: string, thunderstore_mod_string: string | null, enabled: boolean, directory: string, } \ No newline at end of file
+export interface NorthstarMod { name: string, version: string | null, thunderstore_mod_string: string | null, enabled: boolean, directory: string, } \ No newline at end of file
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index e43e5935..5688512c 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -36,6 +36,7 @@ pub struct GameInstall {
#[ts(export)]
pub struct NorthstarMod {
pub name: String,
+ pub version: Option<String>,
pub thunderstore_mod_string: Option<String>,
pub enabled: bool,
pub directory: String,
@@ -192,9 +193,7 @@ async fn do_install(nmod: &thermite::model::ModVersion, game_path: &std::path::P
let download_path = format!("{}/{}", download_directory.clone(), filename);
println!("{}", download_path);
- let nfile = thermite::core::manage::download_file(&nmod.url, download_path)
- .await
- .unwrap();
+ let nfile = thermite::core::manage::download_file(&nmod.url, download_path).unwrap();
println!("Extracting Northstar...");
extract(nfile, game_path)?;
@@ -223,7 +222,7 @@ pub async fn install_northstar(
None => "Northstar".to_string(),
};
- let index = thermite::api::get_package_index().await.unwrap().to_vec();
+ let index = thermite::api::get_package_index().unwrap().to_vec();
let nmod = index
.iter()
.find(|f| f.name.to_lowercase() == northstar_package_name.to_lowercase())
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 015ac925..ce7708b1 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -188,7 +188,7 @@ async fn check_is_northstar_outdated(
None => "Northstar".to_string(),
};
- let index = thermite::api::get_package_index().await.unwrap().to_vec();
+ let index = thermite::api::get_package_index().unwrap().to_vec();
let nmod = index
.iter()
.find(|f| f.name.to_lowercase() == northstar_package_name.to_lowercase())
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index d269a627..75d63972 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -51,6 +51,16 @@ pub struct ThunderstoreManifest {
version_number: String,
}
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct ModJson {
+ #[serde(rename = "Name")]
+ name: String,
+ #[serde(rename = "ThunderstoreModString")]
+ thunderstore_mod_string: Option<String>,
+ #[serde(rename = "Version")]
+ version: Option<String>,
+}
+
/// Gets all currently installed and enabled/disabled mods to rebuild `enabledmods.json`
pub fn rebuild_enabled_mods_json(game_install: GameInstall) -> Result<(), String> {
let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path);
@@ -124,56 +134,11 @@ pub fn set_mod_enabled_status(
Ok(())
}
-/// Parses `mod.json` for mod name
-// TODO: Maybe pass PathBuf or serde json object
-fn parse_mod_json_for_mod_name(mod_json_path: String) -> Result<String, anyhow::Error> {
- // Read file into string and parse it
- let data = std::fs::read_to_string(mod_json_path)?;
- let parsed_json: serde_json::Value = json5::from_str(&data)?;
-
- // Extract mod name
- let mod_name = match parsed_json.get("Name").and_then(|value| value.as_str()) {
- Some(name) => name,
- None => return Err(anyhow!("No name found")),
- };
-
- Ok(mod_name.to_string())
-}
-
-/// Parses `mod.json` for Thunderstore mod string
-/// This is a legacy function as nowadays `manifest.json` should be in Northtar mods folder and read from there
-// TODO: Maybe pass PathBuf or serde json object
-fn parse_mod_json_for_thunderstore_mod_string(
- mod_json_path: String,
-) -> Result<String, anyhow::Error> {
- // Read file into string and parse it
- let data = std::fs::read_to_string(mod_json_path)?;
- let parsed_json: serde_json::Value = json5::from_str(&data)?;
-
- // Extract TS mod string
- let thunderstore_mod_string = match parsed_json
- .get("ThunderstoreModString")
- .and_then(|value| value.as_str())
- {
- Some(thunderstore_mod_string) => thunderstore_mod_string,
- None => return Err(anyhow!("No ThunderstoreModString found")),
- };
-
- Ok(thunderstore_mod_string.to_string())
-}
-
/// Parses `manifest.json` for Thunderstore mod string
fn parse_for_thunderstore_mod_string(nsmod_path: String) -> Result<String, anyhow::Error> {
- let mod_json_path = format!("{}/mod.json", nsmod_path);
let manifest_json_path = format!("{}/manifest.json", nsmod_path);
let ts_author_txt_path = format!("{}/thunderstore_author.txt", nsmod_path);
- // Attempt legacy method for getting Thunderstore string first
- match parse_mod_json_for_thunderstore_mod_string(mod_json_path) {
- Ok(thunderstore_mod_string) => return Ok(thunderstore_mod_string),
- Err(_err) => (),
- }
-
// Check if `manifest.json` exists and parse
let data = std::fs::read_to_string(manifest_json_path)?;
let thunderstore_manifest: ThunderstoreManifest = json5::from_str(&data)?;
@@ -193,12 +158,12 @@ fn parse_for_thunderstore_mod_string(nsmod_path: String) -> Result<String, anyho
}
/// Parse `mods` folder for installed mods.
-fn parse_installed_mods(game_install: GameInstall) -> Result<Vec<NorthstarMod>, String> {
+fn parse_installed_mods(game_install: GameInstall) -> Result<Vec<NorthstarMod>, anyhow::Error> {
let ns_mods_folder = format!("{}/R2Northstar/mods/", game_install.game_path);
let paths = match std::fs::read_dir(ns_mods_folder) {
Ok(paths) => paths,
- Err(_err) => return Err("No mods folder found".to_string()),
+ Err(_err) => return Err(anyhow!("No mods folder found")),
};
let mut directories: Vec<PathBuf> = Vec::new();
@@ -224,23 +189,32 @@ fn parse_installed_mods(game_install: GameInstall) -> Result<Vec<NorthstarMod>,
}
// Parse mod.json and get mod name
- let mod_name = match parse_mod_json_for_mod_name(mod_json_path.clone()) {
- Ok(mod_name) => mod_name,
+
+ // Read file into string and parse it
+ let data = std::fs::read_to_string(mod_json_path.clone())?;
+ let parsed_mod_json: ModJson = match json5::from_str(&data) {
+ Ok(parsed_json) => parsed_json,
Err(err) => {
println!("Failed parsing {} with {}", mod_json_path, err.to_string());
continue;
}
};
// Get Thunderstore mod string if it exists
- let thunderstore_mod_string = match parse_for_thunderstore_mod_string(directory_str) {
- Ok(thunderstore_mod_string) => Some(thunderstore_mod_string),
- Err(_err) => None,
+ let thunderstore_mod_string = match parsed_mod_json.thunderstore_mod_string {
+ // Attempt legacy method for getting Thunderstore string first
+ Some(ts_mod_string) => Some(ts_mod_string),
+ // Legacy method failed
+ None => match parse_for_thunderstore_mod_string(directory_str) {
+ Ok(thunderstore_mod_string) => Some(thunderstore_mod_string),
+ Err(_err) => None,
+ },
};
// Get directory path
let mod_directory = directory.to_str().unwrap().to_string();
let ns_mod = NorthstarMod {
- name: mod_name,
+ name: parsed_mod_json.name,
+ version: parsed_mod_json.version,
thunderstore_mod_string: thunderstore_mod_string,
enabled: false, // Placeholder
directory: mod_directory,
@@ -261,7 +235,10 @@ pub fn get_installed_mods_and_properties(
game_install: GameInstall,
) -> Result<Vec<NorthstarMod>, String> {
// Get actually installed mods
- let found_installed_mods = parse_installed_mods(game_install.clone())?;
+ let found_installed_mods = match parse_installed_mods(game_install.clone()) {
+ Ok(res) => res,
+ Err(err) => return Err(err.to_string()),
+ };
// Get enabled mods as JSON
let enabled_mods: serde_json::Value = match get_enabled_mods(game_install) {
@@ -287,7 +264,7 @@ pub fn get_installed_mods_and_properties(
async fn get_ns_mod_download_url(thunderstore_mod_string: String) -> Result<String, String> {
// TODO: This will crash the thread if not internet connection exist. `match` should be used instead
- let index = thermite::api::get_package_index().await.unwrap().to_vec();
+ let index = thermite::api::get_package_index().unwrap().to_vec();
// Parse mod string
let parsed_ts_mod_string: ParsedThunderstoreModString = match thunderstore_mod_string.parse() {
@@ -323,7 +300,7 @@ async fn get_mod_dependencies(
dbg!(thunderstore_mod_string.clone());
// TODO: This will crash the thread if not internet connection exist. `match` should be used instead
- let index = thermite::api::get_package_index().await.unwrap().to_vec();
+ let index = thermite::api::get_package_index().unwrap().to_vec();
// String replace works but more care should be taken in the future
let ts_mod_string_url = thunderstore_mod_string.replace("-", "/");
@@ -405,7 +382,7 @@ pub async fn fc_download_mod_and_install(
);
// Download the mod
- let f = match thermite::core::manage::download_file(&download_url, path.clone()).await {
+ let f = match thermite::core::manage::download_file(&download_url, path.clone()) {
Ok(f) => f,
Err(e) => return Err(e.to_string()),
};
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 13c745a5..e11e05f3 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -8,7 +8,7 @@
},
"package": {
"productName": "FlightCore",
- "version": "1.6.1"
+ "version": "1.7.0"
},
"tauri": {
"allowlist": {
@@ -66,7 +66,7 @@
"title": "FlightCore",
"height": 600,
"minHeight": 300,
- "width": 1000,
+ "width": 1010,
"minWidth": 600
}
]
diff --git a/src-vue/src/assets/thunderstore-icon.png b/src-vue/src/assets/thunderstore-icon.png
new file mode 100644
index 00000000..c286ab11
--- /dev/null
+++ b/src-vue/src/assets/thunderstore-icon.png
Binary files differ
diff --git a/src-vue/src/views/mods/LocalModsView.vue b/src-vue/src/views/mods/LocalModsView.vue
index 6e2d4be0..ed801b7a 100644
--- a/src-vue/src/views/mods/LocalModsView.vue
+++ b/src-vue/src/views/mods/LocalModsView.vue
@@ -14,6 +14,14 @@
</template>
</el-popconfirm>
{{ mod.name }}
+ <span v-if="mod.version != null">(v{{ mod.version }})</span>
+ <img
+ v-if="mod.thunderstore_mod_string != null"
+ title="This Northstar mod is part of a Thunderstore mod"
+ src="/src/assets/thunderstore-icon.png"
+ class="image"
+ height="16"
+ />
</el-card>
</div>
</el-scrollbar>