Fix syncing, repairing, add edit method (#111)

* Fix syncing, repairing, add edit method

* comp err

* temp push up

* fixes

* fix more

* add frontend
This commit is contained in:
Geometrically
2023-05-11 10:26:00 -07:00
committed by GitHub
parent 71cf2c53f5
commit 7a0798d9d0
24 changed files with 501 additions and 352 deletions

View File

@@ -2,15 +2,15 @@ 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,
pack_title: Option<String>,
pack_title: String,
pack_icon: Option<String>,
) -> Result<PathBuf> {
let res =
pack::install_pack_from_version_id(version_id, pack_title).await?;
pack::install_pack_from_version_id(version_id, pack_title, pack_icon)
.await?;
Ok(res)
}

View File

@@ -1,4 +1,6 @@
use crate::api::Result;
use daedalus::modded::LoaderVersion;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use theseus::prelude::*;
use uuid::Uuid;
@@ -59,7 +61,7 @@ pub async fn profile_update_project(
path: &Path,
project_path: &Path,
) -> Result<()> {
profile::update_project(path, project_path, None).await?;
profile::update_project(path, project_path).await?;
Ok(())
}
@@ -165,3 +167,53 @@ pub async fn profile_run_wait_credentials(
let mut proc = proc_lock.write().await;
Ok(process::wait_for(&mut proc).await?)
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EditProfile {
pub metadata: Option<EditProfileMetadata>,
pub java: Option<JavaSettings>,
pub memory: Option<MemorySettings>,
pub resolution: Option<WindowSize>,
pub hooks: Option<Hooks>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct EditProfileMetadata {
pub name: Option<String>,
pub game_version: Option<String>,
pub loader: Option<ModLoader>,
pub loader_version: Option<LoaderVersion>,
}
// Edits a profile
// invoke('profile_edit', {path, editProfile})
#[tauri::command]
pub async fn profile_edit(
path: &Path,
edit_profile: EditProfile,
) -> Result<()> {
profile::edit(&path, |prof| {
if let Some(metadata) = edit_profile.metadata.clone() {
if let Some(name) = metadata.name {
prof.metadata.name = name
}
if let Some(game_version) = metadata.game_version {
prof.metadata.game_version = game_version
}
if let Some(loader) = metadata.loader {
prof.metadata.loader = loader
}
prof.metadata.loader_version = metadata.loader_version
}
prof.java = edit_profile.java.clone();
prof.memory = edit_profile.memory;
prof.resolution = edit_profile.resolution;
prof.hooks = edit_profile.hooks.clone();
async { Ok(()) }
})
.await?;
Ok(())
}

View File

@@ -28,6 +28,7 @@ pub async fn profile_create(
icon,
None,
None,
None,
)
.await?;
Ok(res)