working on more launch stuff
This commit is contained in:
parent
1fe3be506c
commit
276f208984
@ -31,7 +31,7 @@ fn greet(name: &str) -> String {
|
|||||||
fn main() {
|
fn main() {
|
||||||
prism::install_prism();
|
prism::install_prism();
|
||||||
tauri::Builder::default()
|
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!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
use crate::ftp;
|
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::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
use std::process::Command;
|
||||||
use std::{io::Cursor, path::PathBuf};
|
use std::{io::Cursor, path::PathBuf};
|
||||||
use std::io::{Read, Seek};
|
use std::io::{Read, Seek};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@ -58,7 +59,9 @@ fn check_modpack_needs_update(id: String) -> bool{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
pub fn launch_modpack(id: String){
|
pub fn launch_modpack(id: String){
|
||||||
|
|
||||||
if check_modpack_needs_update(id.clone()) {
|
if check_modpack_needs_update(id.clone()) {
|
||||||
install_modpack(id.clone());
|
install_modpack(id.clone());
|
||||||
}
|
}
|
||||||
@ -66,7 +69,12 @@ pub fn launch_modpack(id: String){
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn install_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]
|
#[tauri::command]
|
||||||
|
Loading…
Reference in New Issue
Block a user