Compare commits

...

2 Commits

Author SHA1 Message Date
b615c91c10 merge 2024-06-22 23:11:06 -06:00
276f208984 working on more launch stuff 2024-06-22 23:07:51 -06:00
2 changed files with 11 additions and 3 deletions

View File

@ -31,7 +31,7 @@ fn greet(name: &str) -> String {
fn main() {
prism::install_prism();
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet, modpack::get_modpacks])
.invoke_handler(tauri::generate_handler![greet, modpack::get_modpacks, modpack::launch_modpack])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -1,8 +1,9 @@
use crate::ftp;
use crate::system_dirs::get_local_data_directory;
use crate::system_dirs::{get_local_data_directory, get_prism_executable};
use std::env;
use std::fs::File;
use std::process::Command;
use std::{io::Cursor, path::PathBuf};
use std::io::{Read, Seek};
use serde_json::Value;
@ -58,7 +59,9 @@ fn check_modpack_needs_update(id: String) -> bool{
return false;
}
#[tauri::command]
pub fn launch_modpack(id: String){
if check_modpack_needs_update(id.clone()) {
install_modpack(id.clone());
}
@ -66,7 +69,12 @@ pub fn launch_modpack(id: String){
}
fn install_modpack(id: String){
let mut file = File::create(env::temp_dir().join(format!("{}.mrpack", get_modpack_name(id)))).unwrap();
let versions = get_versions(id.clone());
let path = env::temp_dir().join(format!("{}.mrpack", get_modpack_name(id.clone())));
let mut file = File::create(path.clone()).unwrap();
ftp::ftp_retr(PathBuf::new().join(id).join(versions[versions.len()-1].version.clone()), file, |_| return);
let child = Command::new(get_local_data_directory().join("prism").join(get_prism_executable())).arg("-I").arg(path).spawn().unwrap();
}
#[tauri::command]