Skip to content

Commit

Permalink
more descriptive load progress
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabwhy committed Jun 15, 2024
1 parent 3fdbb05 commit 02399ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ async fn select_vpk(window: Window) -> Option<String> {
}

#[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);
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/components/Loading.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { useStore } from '../stores/main';
import { listen } from '@tauri-apps/api/event';
const mainStore = useStore();
let step = ref("Parsing VPK directory tree...");
listen<string>('load_step', (event) => {
step.value = event.payload;
});
</script>

<template>
Expand Down

0 comments on commit 02399ac

Please sign in to comment.