diff options
| author | 2026-01-14 04:40:03 +0000 | |
|---|---|---|
| committer | 2026-01-14 04:40:03 +0000 | |
| commit | cd82fabfac3120179f947fba331025676dc1af7f (patch) | |
| tree | 531cf91f50ed494c36e70b5b9c47245e809e81cc /src-tauri/src/main.rs | |
| parent | e8e139c07d05e2f29f04906019dff5f3c520f8cc (diff) | |
| download | DropOut-cd82fabfac3120179f947fba331025676dc1af7f.tar.gz DropOut-cd82fabfac3120179f947fba331025676dc1af7f.zip | |
feat: add functionality to retrieve installed game versions
Diffstat (limited to 'src-tauri/src/main.rs')
| -rw-r--r-- | src-tauri/src/main.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index d7ae9a4..bf7504d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -587,6 +587,42 @@ async fn get_versions() -> Result<Vec<core::manifest::Version>, String> { } #[tauri::command] +async fn get_installed_versions(app_handle: tauri::AppHandle) -> Result<Vec<String>, String> { + let game_dir = app_handle + .path() + .app_data_dir() + .map_err(|e| format!("Failed to get app data dir: {}", e))?; + + let versions_dir = game_dir.join("versions"); + + if !versions_dir.exists() { + return Ok(Vec::new()); + } + + let mut installed_versions = Vec::new(); + + if let Ok(entries) = std::fs::read_dir(versions_dir) { + for entry in entries { + if let Ok(entry) = entry { + if let Ok(file_type) = entry.file_type() { + if file_type.is_dir() { + if let Ok(file_name) = entry.file_name().into_string() { + // Optionally verify if {version_id}.json exists inside + let json_path = entry.path().join(format!("{}.json", file_name)); + if json_path.exists() { + installed_versions.push(file_name); + } + } + } + } + } + } + } + + Ok(installed_versions) +} + +#[tauri::command] async fn login_offline( window: Window, state: State<'_, core::auth::AccountState>, @@ -784,6 +820,7 @@ fn main() { .invoke_handler(tauri::generate_handler![ start_game, get_versions, + get_installed_versions, login_offline, get_active_account, logout, |