You've already forked AstralRinth
forked from didirus/AstralRinth
Modpack support (#60)
* Modpack support * Finish feature * Tauri errors fix (#61) * async impl * working * fmt and redundancy * moved ? to if let Ok block * Finish modpacks support * remove generated file * fix compile err * fix lint * Fix code review comments + forge support --------- Co-authored-by: Wyatt Verchere <wverchere@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ use thiserror::Error;
|
||||
|
||||
pub mod auth;
|
||||
|
||||
pub mod pack;
|
||||
pub mod process;
|
||||
pub mod profile;
|
||||
pub mod profile_create;
|
||||
|
||||
17
theseus_gui/src-tauri/src/api/pack.rs
Normal file
17
theseus_gui/src-tauri/src/api/pack.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use crate::api::Result;
|
||||
use std::path::{Path, PathBuf};
|
||||
use theseus::prelude::*;
|
||||
|
||||
// Creates a pack from a version ID (returns a path to the created profile)
|
||||
// invoke('pack_install_version_id', version_id)
|
||||
#[tauri::command]
|
||||
pub async fn pack_install_version_id(version_id: String) -> Result<PathBuf> {
|
||||
let res = pack::install_pack_from_version_id(version_id).await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn pack_install_file(path: &Path) -> Result<PathBuf> {
|
||||
let res = pack::install_pack_from_file(path.to_path_buf()).await?;
|
||||
Ok(res)
|
||||
}
|
||||
@@ -2,30 +2,11 @@ use crate::api::Result;
|
||||
use std::path::{Path, PathBuf};
|
||||
use theseus::prelude::*;
|
||||
|
||||
// Add a profile to the in-memory state
|
||||
// invoke('profile_add',profile)
|
||||
#[tauri::command]
|
||||
pub async fn profile_add(profile: Profile) -> Result<()> {
|
||||
profile::add(profile).await?;
|
||||
State::sync().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Add a path as a profile in-memory
|
||||
// invoke('profile_add_path',path)
|
||||
#[tauri::command]
|
||||
pub async fn profile_add_path(path: &Path) -> Result<()> {
|
||||
profile::add_path(path).await?;
|
||||
State::sync().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Remove a profile
|
||||
// invoke('profile_add_path',path)
|
||||
#[tauri::command]
|
||||
pub async fn profile_remove(path: &Path) -> Result<()> {
|
||||
profile::remove(path).await?;
|
||||
State::sync().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -34,25 +15,6 @@ pub async fn profile_remove(path: &Path) -> Result<()> {
|
||||
#[tauri::command]
|
||||
pub async fn profile_get(path: &Path) -> Result<Option<Profile>> {
|
||||
let res = profile::get(path).await?;
|
||||
State::sync().await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// Check if a profile is already managed by Theseus
|
||||
// invoke('profile_is_managed',profile)
|
||||
#[tauri::command]
|
||||
pub async fn profile_is_managed(profile: &Path) -> Result<bool> {
|
||||
let res = profile::is_managed(profile).await?;
|
||||
State::sync().await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// Check if a profile is loaded
|
||||
// invoke('profile_is_loaded',profile)
|
||||
#[tauri::command]
|
||||
pub async fn profile_is_loaded(profile: &Path) -> Result<bool> {
|
||||
let res = profile::is_loaded(profile).await?;
|
||||
State::sync().await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
@@ -60,9 +22,8 @@ pub async fn profile_is_loaded(profile: &Path) -> Result<bool> {
|
||||
// invoke('profile_list')
|
||||
#[tauri::command]
|
||||
pub async fn profile_list(
|
||||
) -> Result<std::collections::HashMap<PathBuf, Option<Profile>>> {
|
||||
) -> Result<std::collections::HashMap<PathBuf, Profile>> {
|
||||
let res = profile::list().await?;
|
||||
State::sync().await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
@@ -71,10 +32,7 @@ pub async fn profile_list(
|
||||
// for the actual Child in the state.
|
||||
// invoke('profile_run')
|
||||
#[tauri::command]
|
||||
pub async fn profile_run(
|
||||
path: &Path,
|
||||
credentials: theseus::auth::Credentials,
|
||||
) -> Result<u32> {
|
||||
pub async fn profile_run(path: &Path, credentials: Credentials) -> Result<u32> {
|
||||
let proc_lock = profile::run(path, &credentials).await?;
|
||||
let pid = proc_lock.read().await.child.id().ok_or_else(|| {
|
||||
theseus::Error::from(theseus::ErrorKind::LauncherError(
|
||||
@@ -89,7 +47,7 @@ pub async fn profile_run(
|
||||
#[tauri::command]
|
||||
pub async fn profile_run_wait(
|
||||
path: &Path,
|
||||
credentials: theseus::auth::Credentials,
|
||||
credentials: Credentials,
|
||||
) -> Result<()> {
|
||||
let proc_lock = profile::run(path, &credentials).await?;
|
||||
let mut proc = proc_lock.write().await;
|
||||
|
||||
@@ -25,10 +25,10 @@ pub async fn profile_create(
|
||||
name,
|
||||
game_version,
|
||||
modloader,
|
||||
loader_version,
|
||||
Some(loader_version),
|
||||
icon,
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
State::sync().await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user