feat(queue & game): queue and library UIs

This commit is contained in:
DecDuck
2024-12-17 20:29:54 +11:00
parent 3f71149289
commit 0a20139a7c
12 changed files with 255 additions and 26 deletions

View File

@ -26,9 +26,6 @@ pub struct DatabaseAuth {
#[serde(tag = "type")]
pub enum DatabaseGameStatus {
Remote {},
Queued {
version_name: String,
},
Downloading {
version_name: String,
},

View File

@ -11,6 +11,8 @@ use tauri::utils::acl::Permission;
use std::fs::{set_permissions, Permissions};
use std::io::Read;
use std::os::unix::fs::PermissionsExt;
use std::thread::sleep;
use std::time::Duration;
use std::{
fs::{File, OpenOptions},
io::{self, BufWriter, Seek, SeekFrom, Write},

View File

@ -51,7 +51,6 @@ pub enum DownloadManagerStatus {
pub enum GameDownloadStatus {
Queued,
Downloading,
Paused,
Error,
}
@ -143,6 +142,10 @@ impl DownloadManager {
.unwrap();
}
pub fn rearrange(&self, current_index: usize, new_index: usize) {
if current_index == new_index {
return;
};
let needs_pause = current_index == 0 || new_index == 0;
if needs_pause {
self.command_sender

View File

@ -257,7 +257,7 @@ impl DownloadManagerBuilder {
.insert(interface_data.id.clone(), download_agent);
self.download_queue.append(interface_data);
self.set_game_status(id, DatabaseGameStatus::Queued { version_name });
self.set_game_status(id, DatabaseGameStatus::Downloading { version_name });
self.sender.send(DownloadManagerSignal::Update).unwrap();
}
@ -309,9 +309,16 @@ impl DownloadManagerBuilder {
};
}));
// Set status for game
let mut status_handle = agent_data.status.lock().unwrap();
*status_handle = GameDownloadStatus::Downloading;
// Set status for games
for queue_game in self.download_queue.read() {
let mut status_handle = queue_game.status.lock().unwrap();
if queue_game.id == agent_data.id {
*status_handle = GameDownloadStatus::Downloading;
} else {
*status_handle = GameDownloadStatus::Queued;
}
drop(status_handle);
}
// Set flags for download manager
active_control_flag.set(DownloadThreadControlFlag::Go);
@ -320,6 +327,8 @@ impl DownloadManagerBuilder {
self.current_download_agent.as_ref().unwrap().id.clone(),
DatabaseGameStatus::Downloading { version_name },
);
self.sender.send(DownloadManagerSignal::Update).unwrap();
}
fn manage_error_signal(&mut self, error: GameDownloadError) {
let current_status = self.current_download_agent.clone().unwrap();

View File

@ -195,7 +195,7 @@ pub fn run() {
tauri::WebviewUrl::App("index.html".into()),
)
.title("Drop Desktop App")
.min_inner_size(900.0, 900.0)
.min_inner_size(1000.0, 500.0)
.inner_size(1536.0, 864.0)
.decorations(false)
.data_directory(DATA_ROOT_DIR.lock().unwrap().join(".webview"))

View File

@ -176,7 +176,10 @@ fn fetch_game_logic(
}
#[tauri::command]
pub fn fetch_game(id: String, app: tauri::AppHandle) -> Result<FetchGameStruct, String> {
pub fn fetch_game(
id: String,
app: tauri::AppHandle,
) -> Result<FetchGameStruct, String> {
let result = fetch_game_logic(id, app);
if result.is_err() {