From 40de342bb0a7442b2b0accbfdf826d14cdee7ee9 Mon Sep 17 00:00:00 2001 From: Barnaby <22575741+barnabwhy@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:01:44 +0100 Subject: [PATCH 1/4] dev: pre-read cams --- src-tauri/Cargo.lock | 5 +---- src-tauri/Cargo.toml | 3 ++- src-tauri/src/main.rs | 7 ++++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ed4bd1f..9ac2716 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3291,13 +3291,10 @@ dependencies = [ [[package]] name = "sourcepak" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c04d084e670e5227dd0c5a446515e861c102badc5987afb6737f439a1a2ba77" +version = "0.2.0" dependencies = [ "crc", "lzham-alpha-sys", - "once_cell", ] [[package]] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 90b5334..fd53d86 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -14,7 +14,8 @@ tauri-build = { version = "2.0.0-beta", features = [] } tauri = { version = "2.0.0-beta.22", features = ["linux-ipc-protocol"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -sourcepak = { version = "0.1.1", features = ["respawn"] } +#sourcepak = { version = "0.1.1", features = ["respawn"] } +sourcepak = { path = "../../sourcepak-rs", features = ["respawn"] } urlencoding = "2.1.3" rayon = "1.8.1" tauri-plugin-dialog = "2.0.0-beta.9" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 6eceda7..ba039fb 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -92,11 +92,16 @@ async fn load_vpk(state: tauri::State<'_, AppState>, vpk_path: String) -> Result let vpk = VPKRespawn::try_from(&mut file); match vpk { - Ok(vpk) => { + Ok(mut vpk) => { let mut state_guard = state.inner.lock().unwrap(); println!("VPK loaded: {}", &vpk_path); + let archive_path = vpk_archive_path(&vpk_path); + let vpk_name = get_vpk_name(&vpk_path); + println!("Attempting to read VPK CAM files from: {}", &archive_path); + vpk.read_all_cams(&archive_path, &vpk_name)?; + state_guard.vpk_path = Some(vpk_path); state_guard.loaded_format = Some(PakFormat::VPKRespawn); state_guard.revpk = Some(vpk); From 84832f9ee19b3e791212b4689106099c433aebed Mon Sep 17 00:00:00 2001 From: Barnaby <22575741+barnabwhy@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:17:19 +0100 Subject: [PATCH 2/4] sourcepak 0.2.0 --- README.md | 2 +- src-tauri/Cargo.lock | 2 ++ src-tauri/Cargo.toml | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f657af..5fe2043 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,4 @@ To build only the executable, instead run `yarn tauri build -b none`. ## Details: Uses [sourcepak](https://github.com/barnabwhy/sourcepak-rs) to unpack files from VPKs. -sourcepak version: [v0.1.1](https://crates.io/crates/sourcepak/0.1.1) +sourcepak version: [v0.2.0](https://crates.io/crates/sourcepak/0.2.0) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 9ac2716..c47b211 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3292,6 +3292,8 @@ dependencies = [ [[package]] name = "sourcepak" version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d757668ce7899a50a17f4bffe54f692a83217a7dd0294f1ec80f5a30bfd63a7" dependencies = [ "crc", "lzham-alpha-sys", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index fd53d86..8c75884 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -14,8 +14,7 @@ tauri-build = { version = "2.0.0-beta", features = [] } tauri = { version = "2.0.0-beta.22", features = ["linux-ipc-protocol"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -#sourcepak = { version = "0.1.1", features = ["respawn"] } -sourcepak = { path = "../../sourcepak-rs", features = ["respawn"] } +sourcepak = { version = "0.2.0", features = ["respawn"] } urlencoding = "2.1.3" rayon = "1.8.1" tauri-plugin-dialog = "2.0.0-beta.9" From 3fdbb05ae3c794c8e970a022fb671b55e46cf692 Mon Sep 17 00:00:00 2001 From: Barnaby <22575741+barnabwhy@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:18:25 +0100 Subject: [PATCH 3/4] add padding to error for long errors --- src/components/Error.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Error.vue b/src/components/Error.vue index 93efe11..fbd8db0 100644 --- a/src/components/Error.vue +++ b/src/components/Error.vue @@ -23,6 +23,7 @@ const mainStore = useStore(); height: 100%; grid-template-rows: 1fr auto 1fr 56px; line-height: 1.5; + padding: 2rem; } .error-text { From 02399ac5090888b852568eff9172f81d674f0448 Mon Sep 17 00:00:00 2001 From: Barnaby <22575741+barnabwhy@users.noreply.github.com> Date: Sat, 15 Jun 2024 17:08:44 +0100 Subject: [PATCH 4/4] more descriptive load progress --- src-tauri/src/main.rs | 8 +++++++- src/components/Loading.vue | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ba039fb..17b9091 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -80,7 +80,11 @@ async fn select_vpk(window: Window) -> Option { } #[tauri::command] -async fn load_vpk(state: tauri::State<'_, AppState>, vpk_path: String) -> Result<(), String> { +async fn load_vpk( + state: tauri::State<'_, AppState>, + window: tauri::Window, + vpk_path: String, +) -> Result<(), String> { let mut file = File::open(&vpk_path).expect("Failed to open file"); let pak_format = detect_pak_format(&mut file); @@ -100,6 +104,8 @@ async fn load_vpk(state: tauri::State<'_, AppState>, vpk_path: String) -> Result let archive_path = vpk_archive_path(&vpk_path); let vpk_name = get_vpk_name(&vpk_path); println!("Attempting to read VPK CAM files from: {}", &archive_path); + + let _ = window.emit("load_step", "Reading CAM files..."); vpk.read_all_cams(&archive_path, &vpk_name)?; state_guard.vpk_path = Some(vpk_path); diff --git a/src/components/Loading.vue b/src/components/Loading.vue index aff1dd7..bf788ae 100644 --- a/src/components/Loading.vue +++ b/src/components/Loading.vue @@ -1,10 +1,15 @@