[client][server] file transfer working, ui not ready for it
This commit is contained in:
@ -28,7 +28,7 @@ fn request_games(state: tauri::State<LanSpreadState>) {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn run_game_backend(id: String, state: tauri::State<LanSpreadState>) -> String {
|
||||
fn install_game(id: String, state: tauri::State<LanSpreadState>) -> String {
|
||||
log::error!("Running game with id {id}");
|
||||
|
||||
// let result = Command::new(r#"C:\Users\ddidderr\scoop\apps\mpv\0.39.0\mpv.exe"#).spawn();
|
||||
@ -63,6 +63,12 @@ fn set_game_install_state_from_path(game_db: &mut GameDB, path: &Path, installed
|
||||
|
||||
#[tauri::command]
|
||||
fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
|
||||
app_handle
|
||||
.state::<LanSpreadState>()
|
||||
.client_ctrl
|
||||
.send(ClientCommand::SetGameDir(path.clone()))
|
||||
.unwrap();
|
||||
|
||||
let path = PathBuf::from(path);
|
||||
if !path.exists() {
|
||||
log::error!("game dir {path:?} does not exist");
|
||||
@ -185,7 +191,7 @@ pub fn run() {
|
||||
.plugin(tauri_logger_builder.build())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
run_game_backend,
|
||||
install_game,
|
||||
request_games,
|
||||
update_game_directory
|
||||
])
|
||||
@ -206,6 +212,19 @@ pub fn run() {
|
||||
log::debug!("Received client event: ListGames");
|
||||
update_game_db(games, app_handle.clone()).await;
|
||||
}
|
||||
ClientEvent::GotGameFiles(game_file_descs) => {
|
||||
log::debug!("Received client event: GotGameFiles");
|
||||
if let Err(e) = app_handle.emit("game-download-in-progress", Some(())) {
|
||||
log::error!("Failed to emit game-files event: {e}");
|
||||
}
|
||||
|
||||
app_handle
|
||||
.state::<LanSpreadState>()
|
||||
.inner()
|
||||
.client_ctrl
|
||||
.send(ClientCommand::DownloadGameFiles(game_file_descs))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user