You've already forked AstralRinth
forked from didirus/AstralRinth
Profile Options (#120)
* init profile settings * more work * finish everything * Switch to index approach * Fix settings str split * Run lint
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3818,7 +3818,6 @@ dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"theseus",
|
||||
"theseus_macros",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
|
||||
@@ -6,8 +6,6 @@ use std::path::PathBuf;
|
||||
use crate::event::emit::{emit_loading, init_loading};
|
||||
use crate::util::fetch::{fetch_advanced, fetch_json};
|
||||
use crate::{
|
||||
launcher::download,
|
||||
prelude::Profile,
|
||||
state::JavaGlobals,
|
||||
util::jre::{self, extract_java_majorminor_version, JavaVersion},
|
||||
LoadingBarType, State,
|
||||
@@ -39,48 +37,6 @@ pub async fn autodetect_java_globals() -> crate::Result<JavaGlobals> {
|
||||
Ok(java_globals)
|
||||
}
|
||||
|
||||
// Gets the optimal JRE key for the given profile, using Daedalus
|
||||
// Generally this would be used for profile_create, to get the optimal JRE key
|
||||
// this can be overwritten by the user a profile-by-profile basis
|
||||
pub async fn get_optimal_jre_key(profile: &Profile) -> crate::Result<String> {
|
||||
let state = State::get().await?;
|
||||
let metadata = state.metadata.read().await;
|
||||
|
||||
// Fetch version info from stored profile game_version
|
||||
let version = metadata
|
||||
.minecraft
|
||||
.versions
|
||||
.iter()
|
||||
.find(|it| it.id == profile.metadata.game_version)
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::LauncherError(format!(
|
||||
"Invalid or unknown Minecraft version: {}",
|
||||
profile.metadata.game_version
|
||||
))
|
||||
})?;
|
||||
|
||||
// Get detailed manifest info from Daedalus
|
||||
let version_info = download::download_version_info(
|
||||
&state,
|
||||
version,
|
||||
profile.metadata.loader_version.as_ref(),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
let optimal_key = match version_info
|
||||
.java_version
|
||||
.as_ref()
|
||||
.map(|it| it.major_version)
|
||||
.unwrap_or(0)
|
||||
{
|
||||
0..=15 => JAVA_8_KEY.to_string(),
|
||||
16..=17 => JAVA_17_KEY.to_string(),
|
||||
_ => JAVA_18PLUS_KEY.to_string(),
|
||||
};
|
||||
Ok(optimal_key)
|
||||
}
|
||||
|
||||
// Searches for jres on the system that are 1.18 or higher
|
||||
pub async fn find_java18plus_jres() -> crate::Result<Vec<JavaVersion>> {
|
||||
let version = extract_java_majorminor_version("1.18")?;
|
||||
|
||||
@@ -227,7 +227,7 @@ pub async fn install_pack_from_file(path: PathBuf) -> crate::Result<PathBuf> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(file))]
|
||||
#[theseus_macros::debug_pin]
|
||||
async fn install_pack(
|
||||
file: bytes::Bytes,
|
||||
|
||||
@@ -139,14 +139,14 @@ pub async fn wait_for_by_uuid(uuid: &Uuid) -> crate::Result<()> {
|
||||
}
|
||||
|
||||
// Kill a running child process directly, and wait for it to be killed
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(running))]
|
||||
pub async fn kill(running: &mut MinecraftChild) -> crate::Result<()> {
|
||||
running.current_child.write().await.kill().await?;
|
||||
wait_for(running).await
|
||||
}
|
||||
|
||||
// Await on the completion of a child process directly
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(running))]
|
||||
pub async fn wait_for(running: &mut MinecraftChild) -> crate::Result<()> {
|
||||
// We do not wait on the Child directly, but wait on the thread manager.
|
||||
// This way we can still run all cleanup hook functions that happen after.
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
//! Theseus profile management interface
|
||||
use crate::event::emit::{init_loading, loading_try_for_each_concurrent};
|
||||
use crate::event::LoadingBarType;
|
||||
use crate::prelude::JavaVersion;
|
||||
use crate::state::ProjectMetadata;
|
||||
use crate::{
|
||||
auth::{self, refresh},
|
||||
event::{emit::emit_profile, ProfilePayloadType},
|
||||
profile,
|
||||
state::MinecraftChild,
|
||||
};
|
||||
pub use crate::{
|
||||
@@ -87,6 +89,100 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Edits a profile's icon
|
||||
pub async fn edit_icon(
|
||||
path: &Path,
|
||||
icon_path: Option<&Path>,
|
||||
) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
|
||||
if let Some(icon) = icon_path {
|
||||
let bytes = tokio::fs::read(icon).await?;
|
||||
|
||||
let mut profiles = state.profiles.write().await;
|
||||
|
||||
match profiles.0.get_mut(path) {
|
||||
Some(ref mut profile) => {
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.path.clone(),
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
.await?;
|
||||
|
||||
profile
|
||||
.set_icon(
|
||||
&state.directories.caches_dir(),
|
||||
&state.io_semaphore,
|
||||
bytes::Bytes::from(bytes),
|
||||
&icon.to_string_lossy(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
None => Err(crate::ErrorKind::UnmanagedProfileError(
|
||||
path.display().to_string(),
|
||||
)
|
||||
.as_error()),
|
||||
}
|
||||
} else {
|
||||
edit(path, |profile| {
|
||||
profile.metadata.icon = None;
|
||||
async { Ok(()) }
|
||||
})
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the optimal JRE key for the given profile, using Daedalus
|
||||
// Generally this would be used for profile_create, to get the optimal JRE key
|
||||
// this can be overwritten by the user a profile-by-profile basis
|
||||
pub async fn get_optimal_jre_key(
|
||||
path: &Path,
|
||||
) -> crate::Result<Option<JavaVersion>> {
|
||||
let state = State::get().await?;
|
||||
|
||||
if let Some(profile) = get(path, None).await? {
|
||||
let metadata = state.metadata.read().await;
|
||||
|
||||
// Fetch version info from stored profile game_version
|
||||
let version = metadata
|
||||
.minecraft
|
||||
.versions
|
||||
.iter()
|
||||
.find(|it| it.id == profile.metadata.game_version)
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::LauncherError(format!(
|
||||
"Invalid or unknown Minecraft version: {}",
|
||||
profile.metadata.game_version
|
||||
))
|
||||
})?;
|
||||
|
||||
// Get detailed manifest info from Daedalus
|
||||
let version_info = crate::launcher::download::download_version_info(
|
||||
&state,
|
||||
version,
|
||||
profile.metadata.loader_version.as_ref(),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let version = crate::launcher::get_java_version_from_profile(
|
||||
&profile,
|
||||
&version_info,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(version)
|
||||
} else {
|
||||
Err(
|
||||
crate::ErrorKind::UnmanagedProfileError(path.display().to_string())
|
||||
.as_error(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a copy of the profile set
|
||||
#[tracing::instrument]
|
||||
pub async fn list(
|
||||
@@ -326,6 +422,7 @@ pub async fn remove_project(
|
||||
.as_error())
|
||||
}
|
||||
}
|
||||
|
||||
/// Run Minecraft using a profile and the default credentials, logged in credentials,
|
||||
/// failing with an error if no credentials are available
|
||||
#[tracing::instrument]
|
||||
@@ -351,7 +448,7 @@ pub async fn run(path: &Path) -> crate::Result<Arc<RwLock<MinecraftChild>>> {
|
||||
|
||||
/// Run Minecraft using a profile, and credentials for authentication
|
||||
/// Returns Arc pointer to RwLock to Child
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(credentials))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn run_credentials(
|
||||
path: &Path,
|
||||
@@ -403,7 +500,11 @@ pub async fn run_credentials(
|
||||
let memory = profile.memory.unwrap_or(settings.memory);
|
||||
let resolution = profile.resolution.unwrap_or(settings.game_resolution);
|
||||
|
||||
let env_args = &settings.custom_env_args;
|
||||
let env_args = profile
|
||||
.java
|
||||
.as_ref()
|
||||
.and_then(|x| x.custom_env_args.as_ref())
|
||||
.unwrap_or(&settings.custom_env_args);
|
||||
|
||||
// Post post exit hooks
|
||||
let post_exit_hook =
|
||||
|
||||
@@ -19,7 +19,7 @@ use daedalus::{
|
||||
use futures::prelude::*;
|
||||
use tokio::{fs, sync::OnceCell};
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
#[tracing::instrument(skip(st, version))]
|
||||
pub async fn download_minecraft(
|
||||
st: &State,
|
||||
version: &GameVersionInfo,
|
||||
|
||||
@@ -57,12 +57,12 @@ macro_rules! processor_rules {
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_java_version_from_profile(
|
||||
pub async fn get_java_version_from_profile(
|
||||
profile: &Profile,
|
||||
version_info: &VersionInfo,
|
||||
) -> crate::Result<JavaVersion> {
|
||||
) -> crate::Result<Option<JavaVersion>> {
|
||||
if let Some(java) = profile.java.clone().and_then(|x| x.override_version) {
|
||||
Ok(java)
|
||||
Ok(Some(java))
|
||||
} else {
|
||||
let optimal_keys = match version_info
|
||||
.java_version
|
||||
@@ -80,14 +80,11 @@ async fn get_java_version_from_profile(
|
||||
|
||||
for key in optimal_keys {
|
||||
if let Some(java) = settings.java_globals.get(&key.to_string()) {
|
||||
return Ok(java.clone());
|
||||
return Ok(Some(java.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
Err(crate::ErrorKind::LauncherError(
|
||||
"No available java installation".to_string(),
|
||||
)
|
||||
.into())
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,8 +146,13 @@ pub async fn install_minecraft(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let java_version =
|
||||
get_java_version_from_profile(profile, &version_info).await?;
|
||||
let java_version = get_java_version_from_profile(profile, &version_info)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::LauncherError(
|
||||
"No available java installation".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
// Download minecraft (5-90)
|
||||
download::download_minecraft(
|
||||
@@ -327,8 +329,13 @@ pub async fn launch_minecraft(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let java_version =
|
||||
get_java_version_from_profile(profile, &version_info).await?;
|
||||
let java_version = get_java_version_from_profile(profile, &version_info)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::LauncherError(
|
||||
"No available java installation".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
let client_path = state
|
||||
.directories
|
||||
|
||||
@@ -113,7 +113,7 @@ impl Children {
|
||||
// Spawns a new child process and inserts it into the hashmap
|
||||
// Also, as the process ends, it spawns the follow-up process if it exists
|
||||
// By convention, ExitStatus is last command's exit status, and we exit on the first non-zero exit status
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(current_child))]
|
||||
#[theseus_macros::debug_pin]
|
||||
async fn sequential_process_manager(
|
||||
uuid: Uuid,
|
||||
|
||||
@@ -54,7 +54,7 @@ impl Metadata {
|
||||
}
|
||||
|
||||
// Attempt to fetch metadata and store in sled DB
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(io_semaphore))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn init(
|
||||
dirs: &DirectoryInfo,
|
||||
|
||||
@@ -130,6 +130,8 @@ pub struct JavaSettings {
|
||||
pub override_version: Option<JavaVersion>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub extra_arguments: Option<Vec<String>>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub custom_env_args: Option<Vec<(String, String)>>,
|
||||
}
|
||||
|
||||
impl Profile {
|
||||
@@ -169,7 +171,7 @@ impl Profile {
|
||||
})
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(self, semaphore, icon))]
|
||||
pub async fn set_icon<'a>(
|
||||
&'a mut self,
|
||||
cache_dir: &Path,
|
||||
@@ -295,7 +297,7 @@ impl Profile {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(self))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn add_project_version(
|
||||
&self,
|
||||
@@ -342,7 +344,7 @@ impl Profile {
|
||||
Ok((path, version))
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(self, bytes))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn add_project_bytes(
|
||||
&self,
|
||||
@@ -412,7 +414,7 @@ impl Profile {
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(self))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn toggle_disable_project(
|
||||
&self,
|
||||
@@ -577,7 +579,7 @@ impl Profiles {
|
||||
};
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
#[tracing::instrument(skip(self, profile))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn insert(&mut self, profile: Profile) -> crate::Result<&Self> {
|
||||
emit_profile(
|
||||
|
||||
@@ -200,7 +200,7 @@ pub enum ProjectMetadata {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(io_semaphore))]
|
||||
#[theseus_macros::debug_pin]
|
||||
async fn read_icon_from_file(
|
||||
icon_path: Option<String>,
|
||||
@@ -251,7 +251,7 @@ async fn read_icon_from_file(
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(profile, io_semaphore, fetch_semaphore))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn infer_data_from_files(
|
||||
profile: Profile,
|
||||
|
||||
@@ -20,12 +20,12 @@ pub struct Tags {
|
||||
}
|
||||
|
||||
impl Tags {
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(io_semaphore, fetch_semaphore))]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn init(
|
||||
dirs: &DirectoryInfo,
|
||||
io_semaphore: &IoSemaphore,
|
||||
fetch_sempahore: &FetchSemaphore,
|
||||
fetch_semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<Self> {
|
||||
let mut tags = None;
|
||||
let tags_path = dirs.caches_meta_dir().join("tags.json");
|
||||
@@ -34,7 +34,7 @@ impl Tags {
|
||||
{
|
||||
tags = Some(tags_json);
|
||||
} else {
|
||||
match Self::fetch(fetch_sempahore).await {
|
||||
match Self::fetch(fetch_semaphore).await {
|
||||
Ok(tags_fetch) => tags = Some(tags_fetch),
|
||||
Err(err) => {
|
||||
tracing::warn!("Unable to fetch launcher tags: {err}")
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.2.0",
|
||||
"ofetch": "^1.0.1",
|
||||
"omorphia": "^0.4.13",
|
||||
"omorphia": "^0.4.16",
|
||||
"pinia": "^2.0.33",
|
||||
"vite-svg-loader": "^4.0.0",
|
||||
"vue": "^3.2.45",
|
||||
|
||||
@@ -16,11 +16,10 @@ regex = "1.5"
|
||||
|
||||
[dependencies]
|
||||
theseus = { path = "../../theseus", features = ["tauri"] }
|
||||
theseus_macros = { path = "../../theseus_macros" }
|
||||
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "1.2", features = ["dialog", "dialog-open", "protocol-asset", "window-close", "window-create"] }
|
||||
tauri = { version = "1.2", features = ["dialog", "dialog-open", "protocol-asset", "shell-open", "window-close", "window-create"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
thiserror = "1.0"
|
||||
tokio-stream = { version = "0.1", features = ["fs"] }
|
||||
|
||||
@@ -4,7 +4,6 @@ use theseus::prelude::*;
|
||||
/// Authenticate a user with Hydra - part 1
|
||||
/// This begins the authentication flow quasi-synchronously, returning a URL to visit (that the user will sign in at)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auth_authenticate_begin_flow() -> Result<url::Url> {
|
||||
Ok(auth::authenticate_begin_flow().await?)
|
||||
}
|
||||
@@ -13,7 +12,6 @@ pub async fn auth_authenticate_begin_flow() -> Result<url::Url> {
|
||||
/// This completes the authentication flow quasi-synchronously, returning the sign-in credentials
|
||||
/// (and also adding the credentials to the state)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auth_authenticate_await_completion() -> Result<Credentials> {
|
||||
Ok(auth::authenticate_await_complete_flow().await?)
|
||||
}
|
||||
@@ -21,13 +19,11 @@ pub async fn auth_authenticate_await_completion() -> Result<Credentials> {
|
||||
/// Refresh some credentials using Hydra, if needed
|
||||
// invoke('auth_refresh',user)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auth_refresh(user: uuid::Uuid) -> Result<Credentials> {
|
||||
Ok(auth::refresh(user).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auth_remove_user(user: uuid::Uuid) -> Result<()> {
|
||||
Ok(auth::remove_user(user).await?)
|
||||
}
|
||||
@@ -35,7 +31,6 @@ pub async fn auth_remove_user(user: uuid::Uuid) -> Result<()> {
|
||||
/// Check if a user exists in Theseus
|
||||
// invoke('auth_has_user',user)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auth_has_user(user: uuid::Uuid) -> Result<bool> {
|
||||
Ok(auth::has_user(user).await?)
|
||||
}
|
||||
@@ -43,7 +38,6 @@ pub async fn auth_has_user(user: uuid::Uuid) -> Result<bool> {
|
||||
/// Get a copy of the list of all user credentials
|
||||
// invoke('auth_users',user)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auth_users() -> Result<Vec<Credentials>> {
|
||||
Ok(auth::users().await?)
|
||||
}
|
||||
@@ -52,7 +46,6 @@ pub async fn auth_users() -> Result<Vec<Credentials>> {
|
||||
/// Prefer to use refresh instead, as it will refresh the credentials as well
|
||||
// invoke('auth_users',user)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auth_get_user(user: uuid::Uuid) -> Result<Credentials> {
|
||||
Ok(auth::get_user(user).await?)
|
||||
}
|
||||
|
||||
@@ -6,28 +6,24 @@ use theseus::prelude::*;
|
||||
|
||||
/// Get all JREs that exist on the system
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_get_all_jre() -> Result<Vec<JavaVersion>> {
|
||||
Ok(jre::get_all_jre().await?)
|
||||
}
|
||||
|
||||
// Finds the isntallation of Java 7, if it exists
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_find_jre_8_jres() -> Result<Vec<JavaVersion>> {
|
||||
Ok(jre::find_java8_jres().await?)
|
||||
}
|
||||
|
||||
// finds the installation of Java 17, if it exists
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_find_jre_17_jres() -> Result<Vec<JavaVersion>> {
|
||||
Ok(jre::find_java17_jres().await?)
|
||||
}
|
||||
|
||||
// Finds the highest version of Java 18+, if it exists
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_find_jre_18plus_jres() -> Result<Vec<JavaVersion>> {
|
||||
Ok(jre::find_java18plus_jres().await?)
|
||||
}
|
||||
@@ -35,7 +31,6 @@ pub async fn jre_find_jre_18plus_jres() -> Result<Vec<JavaVersion>> {
|
||||
// Autodetect Java globals, by searching the users computer.
|
||||
// Returns a *NEW* JavaGlobals that can be put into Settings
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_autodetect_java_globals() -> Result<JavaGlobals> {
|
||||
Ok(jre::autodetect_java_globals().await?)
|
||||
}
|
||||
@@ -43,7 +38,6 @@ pub async fn jre_autodetect_java_globals() -> Result<JavaGlobals> {
|
||||
// Validates java globals, by checking if the paths exist
|
||||
// If false, recommend to direct them to reassign, or to re-guess
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_validate_globals() -> Result<bool> {
|
||||
Ok(jre::validate_globals().await?)
|
||||
}
|
||||
@@ -51,21 +45,18 @@ pub async fn jre_validate_globals() -> Result<bool> {
|
||||
// Validates JRE at a given path
|
||||
// Returns None if the path is not a valid JRE
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_get_jre(path: PathBuf) -> Result<Option<JavaVersion>> {
|
||||
jre::check_jre(path).await.map_err(|e| e.into())
|
||||
}
|
||||
|
||||
// Auto installs java for the given java version
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_auto_install_java(java_version: u32) -> Result<PathBuf> {
|
||||
Ok(jre::auto_install_java(java_version).await?)
|
||||
}
|
||||
|
||||
// Gets the maximum memory a system has available.
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn jre_get_max_memory() -> Result<u64> {
|
||||
Ok(jre::get_max_memory().await?)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ pub struct Logs {
|
||||
|
||||
/// Get all Logs for a profile, sorted by datetime
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn logs_get_logs(
|
||||
profile_uuid: Uuid,
|
||||
clear_contents: Option<bool>,
|
||||
@@ -30,7 +29,6 @@ pub async fn logs_get_logs(
|
||||
|
||||
/// Get a Log struct for a profile by profile id and datetime string
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn logs_get_logs_by_datetime(
|
||||
profile_uuid: Uuid,
|
||||
datetime_string: String,
|
||||
@@ -40,7 +38,6 @@ pub async fn logs_get_logs_by_datetime(
|
||||
|
||||
/// Get the stdout for a profile by profile id and datetime string
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn logs_get_stdout_by_datetime(
|
||||
profile_uuid: Uuid,
|
||||
datetime_string: String,
|
||||
@@ -50,7 +47,6 @@ pub async fn logs_get_stdout_by_datetime(
|
||||
|
||||
/// Get the stderr for a profile by profile id and datetime string
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn logs_get_stderr_by_datetime(
|
||||
profile_uuid: Uuid,
|
||||
datetime_string: String,
|
||||
@@ -60,14 +56,12 @@ pub async fn logs_get_stderr_by_datetime(
|
||||
|
||||
/// Delete all logs for a profile by profile id
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn logs_delete_logs(profile_uuid: Uuid) -> Result<()> {
|
||||
Ok(logs::delete_logs(profile_uuid).await?)
|
||||
}
|
||||
|
||||
/// Delete a log for a profile by profile id and datetime string
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn logs_delete_logs_by_datetime(
|
||||
profile_uuid: Uuid,
|
||||
datetime_string: String,
|
||||
|
||||
@@ -4,28 +4,24 @@ use daedalus::modded::Manifest;
|
||||
|
||||
/// Gets the game versions from daedalus
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn metadata_get_game_versions() -> Result<VersionManifest> {
|
||||
Ok(theseus::metadata::get_minecraft_versions().await?)
|
||||
}
|
||||
|
||||
/// Gets the fabric versions from daedalus
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn metadata_get_fabric_versions() -> Result<Manifest> {
|
||||
Ok(theseus::metadata::get_fabric_versions().await?)
|
||||
}
|
||||
|
||||
/// Gets the forge versions from daedalus
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn metadata_get_forge_versions() -> Result<Manifest> {
|
||||
Ok(theseus::metadata::get_forge_versions().await?)
|
||||
}
|
||||
|
||||
/// Gets the quilt versions from daedalus
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn metadata_get_quilt_versions() -> Result<Manifest> {
|
||||
Ok(theseus::metadata::get_quilt_versions().await?)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ where
|
||||
// Create a new HashMap with the same keys
|
||||
// Values provided should not be used directly, as they are not guaranteed to be up-to-date
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn progress_bars_list(
|
||||
) -> Result<std::collections::HashMap<uuid::Uuid, theseus::LoadingBar>> {
|
||||
let res = theseus::EventState::list_progress_bars().await?;
|
||||
|
||||
@@ -3,7 +3,6 @@ use std::path::{Path, PathBuf};
|
||||
use theseus::prelude::*;
|
||||
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn pack_install_version_id(
|
||||
version_id: String,
|
||||
pack_title: String,
|
||||
@@ -16,7 +15,6 @@ pub async fn pack_install_version_id(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn pack_install_file(path: &Path) -> Result<PathBuf> {
|
||||
let res = pack::install_pack_from_file(path.to_path_buf()).await?;
|
||||
Ok(res)
|
||||
|
||||
@@ -6,14 +6,12 @@ use uuid::Uuid;
|
||||
|
||||
// Checks if a process has finished by process UUID
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_has_finished_by_uuid(uuid: Uuid) -> Result<bool> {
|
||||
Ok(process::has_finished_by_uuid(&uuid).await?)
|
||||
}
|
||||
|
||||
// Gets process exit status by process UUID
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_exit_status_by_uuid(
|
||||
uuid: Uuid,
|
||||
) -> Result<Option<i32>> {
|
||||
@@ -22,21 +20,18 @@ pub async fn process_get_exit_status_by_uuid(
|
||||
|
||||
// Gets all process UUIDs
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_all_uuids() -> Result<Vec<Uuid>> {
|
||||
Ok(process::get_all_uuids().await?)
|
||||
}
|
||||
|
||||
// Gets all running process UUIDs
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_all_running_uuids() -> Result<Vec<Uuid>> {
|
||||
Ok(process::get_all_running_uuids().await?)
|
||||
}
|
||||
|
||||
// Gets all process UUIDs by profile path
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_uuids_by_profile_path(
|
||||
profile_path: &Path,
|
||||
) -> Result<Vec<Uuid>> {
|
||||
@@ -45,42 +40,36 @@ pub async fn process_get_uuids_by_profile_path(
|
||||
|
||||
// Gets the Profile paths of each *running* stored process in the state
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_all_running_profile_paths() -> Result<Vec<PathBuf>> {
|
||||
Ok(process::get_all_running_profile_paths().await?)
|
||||
}
|
||||
|
||||
// Gets the Profiles (cloned) of each *running* stored process in the state
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_all_running_profiles() -> Result<Vec<Profile>> {
|
||||
Ok(process::get_all_running_profiles().await?)
|
||||
}
|
||||
|
||||
// Gets process stderr by process UUID
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_stderr_by_uuid(uuid: Uuid) -> Result<String> {
|
||||
Ok(process::get_stderr_by_uuid(&uuid).await?)
|
||||
}
|
||||
|
||||
// Gets process stdout by process UUID
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_get_stdout_by_uuid(uuid: Uuid) -> Result<String> {
|
||||
Ok(process::get_stdout_by_uuid(&uuid).await?)
|
||||
}
|
||||
|
||||
// Kill a process by process UUID
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_kill_by_uuid(uuid: Uuid) -> Result<()> {
|
||||
Ok(process::kill_by_uuid(&uuid).await?)
|
||||
}
|
||||
|
||||
// Wait for a process to finish by process UUID
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn process_wait_for_by_uuid(uuid: Uuid) -> Result<()> {
|
||||
Ok(process::wait_for_by_uuid(&uuid).await?)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use uuid::Uuid;
|
||||
// Remove a profile
|
||||
// invoke('profile_add_path',path)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_remove(path: &Path) -> Result<()> {
|
||||
profile::remove(path).await?;
|
||||
Ok(())
|
||||
@@ -18,7 +17,6 @@ pub async fn profile_remove(path: &Path) -> Result<()> {
|
||||
// Get a profile by path
|
||||
// invoke('profile_add_path',path)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_get(
|
||||
path: &Path,
|
||||
clear_projects: Option<bool>,
|
||||
@@ -27,10 +25,18 @@ pub async fn profile_get(
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// Get optimal java version from profile
|
||||
#[tauri::command]
|
||||
pub async fn profile_get_optimal_jre_key(
|
||||
path: &Path,
|
||||
) -> Result<Option<JavaVersion>> {
|
||||
let res = profile::get_optimal_jre_key(path).await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// Get a copy of the profile set
|
||||
// invoke('profile_list')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_list(
|
||||
clear_projects: Option<bool>,
|
||||
) -> Result<HashMap<PathBuf, Profile>> {
|
||||
@@ -39,7 +45,6 @@ pub async fn profile_list(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_check_installed(
|
||||
path: &Path,
|
||||
project_id: String,
|
||||
@@ -62,7 +67,6 @@ pub async fn profile_check_installed(
|
||||
/// Installs/Repairs a profile
|
||||
/// invoke('profile_install')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_install(path: &Path) -> Result<()> {
|
||||
profile::install(path).await?;
|
||||
Ok(())
|
||||
@@ -71,7 +75,6 @@ pub async fn profile_install(path: &Path) -> Result<()> {
|
||||
/// Updates all of the profile's projects
|
||||
/// invoke('profile_update_all')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_update_all(
|
||||
path: &Path,
|
||||
) -> Result<HashMap<PathBuf, PathBuf>> {
|
||||
@@ -81,7 +84,6 @@ pub async fn profile_update_all(
|
||||
/// Updates a specified project
|
||||
/// invoke('profile_update_project')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_update_project(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
@@ -92,7 +94,6 @@ pub async fn profile_update_project(
|
||||
// Adds a project to a profile from a version ID
|
||||
// invoke('profile_add_project_from_version')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_add_project_from_version(
|
||||
path: &Path,
|
||||
version_id: String,
|
||||
@@ -103,7 +104,6 @@ pub async fn profile_add_project_from_version(
|
||||
// Adds a project to a profile from a path
|
||||
// invoke('profile_add_project_from_path')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_add_project_from_path(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
@@ -117,7 +117,6 @@ pub async fn profile_add_project_from_path(
|
||||
// Toggles disabling a project from its path
|
||||
// invoke('profile_toggle_disable_project')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_toggle_disable_project(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
@@ -128,7 +127,6 @@ pub async fn profile_toggle_disable_project(
|
||||
// Removes a project from a profile
|
||||
// invoke('profile_remove_project')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_remove_project(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
@@ -141,7 +139,6 @@ pub async fn profile_remove_project(
|
||||
// for the actual Child in the state.
|
||||
// invoke('profile_run', path)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_run(path: &Path) -> Result<Uuid> {
|
||||
let minecraft_child = profile::run(path).await?;
|
||||
let uuid = minecraft_child.read().await.uuid;
|
||||
@@ -151,7 +148,6 @@ pub async fn profile_run(path: &Path) -> Result<Uuid> {
|
||||
// Run Minecraft using a profile using the default credentials, and wait for the result
|
||||
// invoke('profile_run_wait', path)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_run_wait(path: &Path) -> Result<()> {
|
||||
let proc_lock = profile::run(path).await?;
|
||||
let mut proc = proc_lock.write().await;
|
||||
@@ -163,7 +159,6 @@ pub async fn profile_run_wait(path: &Path) -> Result<()> {
|
||||
// for the actual Child in the state.
|
||||
// invoke('profile_run_credentials', {path, credentials})')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_run_credentials(
|
||||
path: &Path,
|
||||
credentials: Credentials,
|
||||
@@ -176,7 +171,6 @@ pub async fn profile_run_credentials(
|
||||
// Run Minecraft using a profile using the chosen credentials, and wait for the result
|
||||
// invoke('profile_run_wait', {path, credentials)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_run_wait_credentials(
|
||||
path: &Path,
|
||||
credentials: Credentials,
|
||||
@@ -206,7 +200,6 @@ pub struct EditProfileMetadata {
|
||||
// Edits a profile
|
||||
// invoke('profile_edit', {path, editProfile})
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_edit(
|
||||
path: &Path,
|
||||
edit_profile: EditProfile,
|
||||
@@ -236,3 +229,14 @@ pub async fn profile_edit(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Edits a profile's icon
|
||||
// invoke('profile_edit_icon')
|
||||
#[tauri::command]
|
||||
pub async fn profile_edit_icon(
|
||||
path: &Path,
|
||||
icon_path: Option<&Path>,
|
||||
) -> Result<()> {
|
||||
profile::edit_icon(path, icon_path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ use theseus::prelude::*;
|
||||
// Generic basic profile creation tool.
|
||||
// Creates an essentially empty dummy profile with profile_create
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_create_empty() -> Result<PathBuf> {
|
||||
let res = profile_create::profile_create_empty().await?;
|
||||
Ok(res)
|
||||
@@ -14,19 +13,18 @@ pub async fn profile_create_empty() -> Result<PathBuf> {
|
||||
// Creates a profile at the given filepath and adds it to the in-memory state
|
||||
// invoke('profile_add',profile)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn profile_create(
|
||||
name: String, // the name of the profile, and relative path
|
||||
game_version: String, // the game version of the profile
|
||||
modloader: ModLoader, // the modloader to use
|
||||
loader_version: String, // the modloader version to use, set to "latest", "stable", or the ID of your chosen loader
|
||||
icon: Option<PathBuf>, // the icon for the profile
|
||||
name: String, // the name of the profile, and relative path
|
||||
game_version: String, // the game version of the profile
|
||||
modloader: ModLoader, // the modloader to use
|
||||
loader_version: Option<String>, // the modloader version to use, set to "latest", "stable", or the ID of your chosen loader
|
||||
icon: Option<PathBuf>, // the icon for the profile
|
||||
) -> Result<PathBuf> {
|
||||
let res = profile_create::profile_create(
|
||||
name,
|
||||
game_version,
|
||||
modloader,
|
||||
Some(loader_version),
|
||||
loader_version,
|
||||
icon,
|
||||
None,
|
||||
None,
|
||||
|
||||
@@ -23,68 +23,15 @@ pub struct FrontendSettings {
|
||||
// Get full settings
|
||||
// invoke('settings_get')
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn settings_get() -> Result<FrontendSettings> {
|
||||
let backend_settings = settings::get().await?;
|
||||
let frontend_settings = FrontendSettings {
|
||||
theme: backend_settings.theme,
|
||||
memory: backend_settings.memory,
|
||||
game_resolution: backend_settings.game_resolution,
|
||||
custom_java_args: backend_settings.custom_java_args.join(" "),
|
||||
custom_env_args: backend_settings
|
||||
.custom_env_args
|
||||
.into_iter()
|
||||
.map(|(s1, s2)| format!("{s1}={s2}"))
|
||||
.collect::<Vec<String>>()
|
||||
.join(" "),
|
||||
java_globals: backend_settings.java_globals,
|
||||
default_user: backend_settings.default_user,
|
||||
hooks: backend_settings.hooks,
|
||||
max_concurrent_downloads: backend_settings.max_concurrent_downloads,
|
||||
max_concurrent_writes: backend_settings.max_concurrent_writes,
|
||||
version: backend_settings.version,
|
||||
collapsed_navigation: backend_settings.collapsed_navigation,
|
||||
};
|
||||
Ok(frontend_settings)
|
||||
pub async fn settings_get() -> Result<Settings> {
|
||||
let res = settings::get().await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// Set full settings
|
||||
// invoke('settings_set', settings)
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn settings_set(settings: FrontendSettings) -> Result<()> {
|
||||
let custom_env_args: Vec<(String, String)> = settings
|
||||
.custom_env_args
|
||||
.split_whitespace()
|
||||
.map(|s| s.to_string())
|
||||
.flat_map(|f| {
|
||||
let mut split = f.split('=');
|
||||
if let (Some(name), Some(value)) = (split.next(), split.next()) {
|
||||
Some((name.to_string(), value.to_string()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<(String, String)>>();
|
||||
|
||||
let backend_settings = Settings {
|
||||
theme: settings.theme,
|
||||
memory: settings.memory,
|
||||
game_resolution: settings.game_resolution,
|
||||
custom_java_args: settings
|
||||
.custom_java_args
|
||||
.split_whitespace()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
custom_env_args,
|
||||
java_globals: settings.java_globals,
|
||||
default_user: settings.default_user,
|
||||
hooks: settings.hooks,
|
||||
max_concurrent_downloads: settings.max_concurrent_downloads,
|
||||
max_concurrent_writes: settings.max_concurrent_writes,
|
||||
version: settings.version,
|
||||
collapsed_navigation: settings.collapsed_navigation,
|
||||
};
|
||||
settings::set(backend_settings).await?;
|
||||
pub async fn settings_set(settings: Settings) -> Result<()> {
|
||||
settings::set(settings).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -3,42 +3,36 @@ use theseus::tags::{Category, DonationPlatform, GameVersion, Loader, Tags};
|
||||
|
||||
/// Gets cached category tags from the database
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn tags_get_categories() -> Result<Vec<Category>> {
|
||||
Ok(theseus::tags::get_category_tags().await?)
|
||||
}
|
||||
|
||||
/// Gets cached report type tags from the database
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn tags_get_report_types() -> Result<Vec<String>> {
|
||||
Ok(theseus::tags::get_report_type_tags().await?)
|
||||
}
|
||||
|
||||
/// Gets cached loader tags from the database
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn tags_get_loaders() -> Result<Vec<Loader>> {
|
||||
Ok(theseus::tags::get_loader_tags().await?)
|
||||
}
|
||||
|
||||
/// Gets cached game version tags from the database
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn tags_get_game_versions() -> Result<Vec<GameVersion>> {
|
||||
Ok(theseus::tags::get_game_version_tags().await?)
|
||||
}
|
||||
|
||||
/// Gets cached donation platform tags from the database
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn tags_get_donation_platforms() -> Result<Vec<DonationPlatform>> {
|
||||
Ok(theseus::tags::get_donation_platform_tags().await?)
|
||||
}
|
||||
|
||||
/// Gets cached tag bundle from the database
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn tags_get_tag_bundle() -> Result<Tags> {
|
||||
Ok(theseus::tags::get_tag_bundle().await?)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ mod error;
|
||||
|
||||
// Should be called in launcher initialization
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
theseus::EventState::init(app).await?;
|
||||
State::get().await?;
|
||||
@@ -25,7 +24,6 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
// disables mouseover and fixes a random crash error only fixed by recent versions of macos
|
||||
#[cfg(target_os = "macos")]
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
async fn should_disable_mouseover() -> bool {
|
||||
// We try to match version to 12.2 or higher. If unrecognizable to pattern or lower, we default to the css with disabled mouseover for safety
|
||||
let os = os_info::get();
|
||||
@@ -39,7 +37,6 @@ async fn should_disable_mouseover() -> bool {
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[tauri::command]
|
||||
#[theseus_macros::debug_pin]
|
||||
async fn should_disable_mouseover() -> bool {
|
||||
false
|
||||
}
|
||||
@@ -81,6 +78,7 @@ fn main() {
|
||||
api::profile_create::profile_create,
|
||||
api::profile::profile_remove,
|
||||
api::profile::profile_get,
|
||||
api::profile::profile_get_optimal_jre_key,
|
||||
api::profile::profile_list,
|
||||
api::profile::profile_install,
|
||||
api::profile::profile_update_all,
|
||||
@@ -94,6 +92,7 @@ fn main() {
|
||||
api::profile::profile_run_credentials,
|
||||
api::profile::profile_run_wait_credentials,
|
||||
api::profile::profile_edit,
|
||||
api::profile::profile_edit_icon,
|
||||
api::profile::profile_check_installed,
|
||||
api::pack::pack_install_version_id,
|
||||
api::pack::pack_install_file,
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
"$CONFIG/caches/icons/*"
|
||||
]
|
||||
},
|
||||
"shell": {
|
||||
"open": true
|
||||
},
|
||||
"window": {
|
||||
"create": true,
|
||||
"close": true
|
||||
|
||||
@@ -91,7 +91,7 @@ const loading = useLoading()
|
||||
@click="() => $refs.installationModal.show()"
|
||||
>
|
||||
<PlusIcon />
|
||||
<span v-if="!themeStore.collapsedNavigation" class="no-wrap">New Instance</span>
|
||||
<span v-if="!themeStore.collapsedNavigation" class="no-wrap">New instance</span>
|
||||
</Button>
|
||||
<RouterLink
|
||||
to="/settings"
|
||||
|
||||
1
theseus_gui/src/assets/icons/hammer.svg
Normal file
1
theseus_gui/src/assets/icons/hammer.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m15 12-8.5 8.5c-.83.83-2.17.83-3 0 0 0 0 0 0 0a2.12 2.12 0 0 1 0-3L12 9"></path><path d="M17.64 15 22 10.64"></path><path d="m20.91 11.7-1.25-1.25c-.6-.6-.93-1.4-.93-2.25v-.86L16.01 4.6a5.56 5.56 0 0 0-3.94-1.64H9l.92.82A6.18 6.18 0 0 1 12 8.4v1.56l2 2h2.47l2.26 1.91"></path></svg>
|
||||
|
After Width: | Height: | Size: 473 B |
@@ -5,3 +5,4 @@ export { default as LoginIcon } from './log-in.svg'
|
||||
export { default as StopIcon } from './stop-circle.svg'
|
||||
export { default as TerminalIcon } from './terminal-square.svg'
|
||||
export { default as UsersIcon } from './users.svg'
|
||||
export { default as HammerIcon } from './hammer.svg'
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
import { Button, Modal, XIcon, DownloadIcon } from 'omorphia'
|
||||
import { install as pack_install } from '@/helpers/pack'
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const version = ref('')
|
||||
const title = ref('')
|
||||
@@ -23,9 +20,7 @@ defineExpose({
|
||||
|
||||
async function install() {
|
||||
installing.value = true
|
||||
let id = await pack_install(version.value)
|
||||
await pack_install(version.value, title.value, icon.value ? icon.value : null)
|
||||
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
|
||||
confirmModal.value.hide()
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
<p class="input-label">Name</p>
|
||||
<input v-model="profile_name" class="text-input" type="text" />
|
||||
</div>
|
||||
<div class="input-row">
|
||||
<p class="input-label">Loader</p>
|
||||
<Chips v-model="loader" :items="loaders" />
|
||||
</div>
|
||||
<div class="input-row">
|
||||
<p class="input-label">Game Version</p>
|
||||
<div class="versions">
|
||||
<DropdownSelect
|
||||
v-model="game_version"
|
||||
:options="game_versions"
|
||||
:render-up="!showAdvanced"
|
||||
/>
|
||||
<DropdownSelect v-model="game_version" :options="game_versions" render-up />
|
||||
<Checkbox
|
||||
v-if="showAdvanced"
|
||||
v-model="showSnapshots"
|
||||
@@ -34,15 +34,11 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-row">
|
||||
<p class="input-label">Loader</p>
|
||||
<Chips v-model="loader" :items="loaders" />
|
||||
</div>
|
||||
<div v-if="showAdvanced" class="input-row">
|
||||
<div v-if="showAdvanced && loader !== 'vanilla'" class="input-row">
|
||||
<p class="input-label">Loader Version</p>
|
||||
<Chips v-model="loader_version" :items="['stable', 'latest', 'other']" />
|
||||
</div>
|
||||
<div v-if="showAdvanced && loader_version === 'other'">
|
||||
<div v-if="showAdvanced && loader_version === 'other' && loader !== 'vanilla'">
|
||||
<div v-if="game_version" class="input-row">
|
||||
<p class="input-label">Select Version</p>
|
||||
<DropdownSelect
|
||||
@@ -98,7 +94,7 @@ const router = useRouter()
|
||||
|
||||
const profile_name = ref('')
|
||||
const game_version = ref('')
|
||||
const loader = ref('')
|
||||
const loader = ref('vanilla')
|
||||
const loader_version = ref('stable')
|
||||
const specified_loader_version = ref('')
|
||||
const showContent = ref(false)
|
||||
@@ -143,17 +139,31 @@ const [fabric_versions, forge_versions, quilt_versions, all_game_versions, loade
|
||||
)
|
||||
.then(ref),
|
||||
])
|
||||
loaders.value.push('vanilla')
|
||||
|
||||
const game_versions = computed(() => {
|
||||
return all_game_versions.value
|
||||
.filter((item) => item.version_type === 'release' || showSnapshots.value)
|
||||
.filter((item) => {
|
||||
let defaultVal = item.version_type === 'release' || showSnapshots.value
|
||||
if (loader.value === 'fabric') {
|
||||
defaultVal &= fabric_versions.value.gameVersions.some((x) => item.version === x.id)
|
||||
} else if (loader.value === 'forge') {
|
||||
defaultVal &= forge_versions.value.gameVersions.some((x) => item.version === x.id)
|
||||
} else if (loader.value === 'quilt') {
|
||||
defaultVal &= quilt_versions.value.gameVersions.some((x) => item.version === x.id)
|
||||
}
|
||||
|
||||
return defaultVal
|
||||
})
|
||||
.map((item) => item.version)
|
||||
})
|
||||
|
||||
const modal = ref(null)
|
||||
|
||||
const check_valid = computed(() => {
|
||||
return profile_name.value && game_version.value
|
||||
return (
|
||||
profile_name.value && game_version.value && game_versions.value.includes(game_version.value)
|
||||
)
|
||||
})
|
||||
|
||||
const create_instance = async () => {
|
||||
@@ -166,7 +176,7 @@ const create_instance = async () => {
|
||||
profile_name.value,
|
||||
game_version.value,
|
||||
loader.value,
|
||||
loader_version_value ?? 'stable',
|
||||
loader.value === 'vanilla' ? null : loader_version_value ?? 'stable',
|
||||
icon.value
|
||||
)
|
||||
|
||||
@@ -185,7 +195,7 @@ const upload_icon = async () => {
|
||||
filters: [
|
||||
{
|
||||
name: 'Image',
|
||||
extensions: ['png', 'jpeg'],
|
||||
extensions: ['png', 'jpeg', 'svg', 'webp', 'gif', 'jpg'],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
109
theseus_gui/src/components/ui/JavaDetectionModal.vue
Normal file
109
theseus_gui/src/components/ui/JavaDetectionModal.vue
Normal file
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<Modal ref="detectJavaModal" header="Select java version">
|
||||
<div class="auto-detect-modal">
|
||||
<div class="table">
|
||||
<div class="table-row table-head">
|
||||
<div class="table-cell table-text">Version</div>
|
||||
<div class="table-cell table-text">Path</div>
|
||||
<div class="table-cell table-text">Actions</div>
|
||||
</div>
|
||||
<div v-for="javaInstall in chosenInstallOptions" :key="javaInstall.path" class="table-row">
|
||||
<div class="table-cell table-text">
|
||||
<span>{{ javaInstall.version }}</span>
|
||||
</div>
|
||||
<div class="table-cell table-text">
|
||||
<span>{{ javaInstall.path }}</span>
|
||||
</div>
|
||||
<div class="table-cell table-text manage">
|
||||
<Button v-if="currentSelected.path === javaInstall.path" disabled
|
||||
><CheckIcon /> Selected</Button
|
||||
>
|
||||
<Button v-else @click="setJavaInstall(javaInstall)"><PlusIcon /> Select</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="chosenInstallOptions.length === 0" class="table-row entire-row">
|
||||
<div class="table-cell table-text">No JARS Found!</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="button-group">
|
||||
<Button @click="$refs.detectJavaModal.hide()">
|
||||
<XIcon />
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Modal, PlusIcon, CheckIcon, Button, XIcon } from 'omorphia'
|
||||
import { ref } from 'vue'
|
||||
import {
|
||||
find_jre_17_jres,
|
||||
find_jre_18plus_jres,
|
||||
find_jre_8_jres,
|
||||
get_all_jre,
|
||||
} from '@/helpers/jre.js'
|
||||
|
||||
const chosenInstallOptions = ref([])
|
||||
const detectJavaModal = ref(null)
|
||||
const currentSelected = ref({})
|
||||
|
||||
defineExpose({
|
||||
show: async (version, currentSelectedJava) => {
|
||||
if (version <= 8 && !!version) {
|
||||
console.log(version)
|
||||
chosenInstallOptions.value = await find_jre_8_jres()
|
||||
} else if (version >= 18) {
|
||||
chosenInstallOptions.value = await find_jre_18plus_jres()
|
||||
} else if (version) {
|
||||
chosenInstallOptions.value = await find_jre_17_jres()
|
||||
} else {
|
||||
console.log('get all')
|
||||
chosenInstallOptions.value = await get_all_jre()
|
||||
}
|
||||
|
||||
currentSelected.value = currentSelectedJava
|
||||
if (!currentSelected.value) {
|
||||
currentSelected.value = { path: '', version: '' }
|
||||
}
|
||||
|
||||
detectJavaModal.value.show()
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['submit'])
|
||||
|
||||
function setJavaInstall(javaInstall) {
|
||||
emit('submit', javaInstall)
|
||||
detectJavaModal.value.hide()
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.auto-detect-modal {
|
||||
padding: 1rem;
|
||||
|
||||
.table {
|
||||
.table-row {
|
||||
grid-template-columns: 1fr 4fr 1.5fr;
|
||||
}
|
||||
|
||||
span {
|
||||
display: inherit;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.button-group {
|
||||
margin-top: 1rem;
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.manage {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
149
theseus_gui/src/components/ui/JavaSelector.vue
Normal file
149
theseus_gui/src/components/ui/JavaSelector.vue
Normal file
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<JavaDetectionModal ref="detectJavaModal" @submit="(val) => emit('update:modelValue', val)" />
|
||||
<div class="toggle-setting">
|
||||
<input
|
||||
:disabled="props.disabled"
|
||||
:value="props.modelValue.path"
|
||||
type="text"
|
||||
class="installation-input"
|
||||
:placeholder="placeholder ?? '/path/to/java'"
|
||||
@input="
|
||||
(val) => {
|
||||
emit('update:modelValue', {
|
||||
...props.modelValue,
|
||||
path: val.target.value,
|
||||
})
|
||||
}
|
||||
"
|
||||
/>
|
||||
<span class="installation-buttons">
|
||||
<Button
|
||||
:disabled="props.disabled"
|
||||
@click="$refs.detectJavaModal.show(props.version, props.modelValue)"
|
||||
>
|
||||
<SearchIcon />
|
||||
Auto Detect
|
||||
</Button>
|
||||
<Button :disabled="props.disabled" @click="handleJavaFileInput()">
|
||||
<BrowseIcon />
|
||||
Browse
|
||||
</Button>
|
||||
<Button :disabled="props.disabled" @click="testJava">
|
||||
<PlayIcon />
|
||||
Test
|
||||
</Button>
|
||||
<AnimatedLogo v-if="testingJava === true" class="testing-loader" />
|
||||
<CheckIcon
|
||||
v-else-if="testingJavaSuccess === true && testingJava === false"
|
||||
class="test-success"
|
||||
/>
|
||||
<XIcon v-else-if="testingJavaSuccess === false && testingJava === false" class="test-fail" />
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Button, SearchIcon, PlayIcon, CheckIcon, XIcon, AnimatedLogo } from 'omorphia'
|
||||
import { BrowseIcon } from '@/assets/icons'
|
||||
import { get_jre } from '@/helpers/jre.js'
|
||||
import { ref } from 'vue'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import JavaDetectionModal from '@/components/ui/JavaDetectionModal.vue'
|
||||
|
||||
const props = defineProps({
|
||||
version: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
modelValue: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const testingJava = ref(false)
|
||||
const testingJavaSuccess = ref(null)
|
||||
async function testJava() {
|
||||
testingJava.value = true
|
||||
let result = await get_jre(props.modelValue.path)
|
||||
testingJava.value = false
|
||||
testingJavaSuccess.value = !!result
|
||||
|
||||
setTimeout(() => {
|
||||
testingJavaSuccess.value = null
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
async function handleJavaFileInput() {
|
||||
let filePath = await open()
|
||||
|
||||
if (filePath) {
|
||||
let result = await get_jre(filePath)
|
||||
if (!result) {
|
||||
result = {
|
||||
path: filePath,
|
||||
version: props.version.toString(),
|
||||
architecture: 'x86',
|
||||
}
|
||||
}
|
||||
|
||||
emit('update:modelValue', result)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.installation-input {
|
||||
width: 100% !important;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.toggle-setting {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.installation-buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.test-success {
|
||||
color: var(--color-green);
|
||||
}
|
||||
|
||||
.test-fail {
|
||||
color: var(--color-red);
|
||||
}
|
||||
</style>
|
||||
<style lang="scss">
|
||||
.testing-loader {
|
||||
height: 1rem !important;
|
||||
width: 1rem !important;
|
||||
|
||||
svg {
|
||||
height: inherit !important;
|
||||
width: inherit !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -36,6 +36,12 @@ export async function get(path, clearProjects) {
|
||||
return await invoke('profile_get', { path, clearProjects })
|
||||
}
|
||||
|
||||
// Get optimal java version from profile
|
||||
// Returns a java version
|
||||
export async function get_optimal_jre_key(path) {
|
||||
return await invoke('profile_get_optimal_jre_key', { path })
|
||||
}
|
||||
|
||||
// Get a copy of the profile set
|
||||
// Returns hashmap of path -> Profile
|
||||
export async function list(clearProjects) {
|
||||
@@ -99,3 +105,8 @@ export async function run_wait(path) {
|
||||
export async function edit(path, editProfile) {
|
||||
return await invoke('profile_edit', { path, editProfile })
|
||||
}
|
||||
|
||||
// Edits a profile's icon
|
||||
export async function edit_icon(path, iconPath) {
|
||||
return await invoke('profile_edit_icon', { path, iconPath })
|
||||
}
|
||||
|
||||
@@ -28,20 +28,6 @@ Memorysettings {
|
||||
|
||||
*/
|
||||
|
||||
// An example test function for getting/setting settings
|
||||
export async function test() {
|
||||
// First, print settings and store them to an object
|
||||
let settings = await get()
|
||||
console.log(JSON.stringify(settings))
|
||||
|
||||
// Then set some random settings in that object
|
||||
settings.java_8_path = '/example/path'
|
||||
|
||||
// Set the new settings object
|
||||
await set(settings)
|
||||
console.log(JSON.stringify(await get()))
|
||||
}
|
||||
|
||||
// Get full settings object
|
||||
export async function get() {
|
||||
return await invoke('settings_get')
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
NavRow,
|
||||
formatCategoryHeader,
|
||||
formatCategory,
|
||||
Promotion,
|
||||
} from 'omorphia'
|
||||
import Multiselect from 'vue-multiselect'
|
||||
import { useSearch } from '@/store/state'
|
||||
@@ -271,6 +272,7 @@ const handleInstanceSwitch = async (value) => {
|
||||
</Card>
|
||||
</aside>
|
||||
<div class="search">
|
||||
<Promotion class="promotion" />
|
||||
<Card class="project-type-container">
|
||||
<NavRow
|
||||
:links="
|
||||
@@ -393,11 +395,14 @@ const handleInstanceSwitch = async (value) => {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.promotion {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.project-type-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.search-panel-card {
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import {
|
||||
Card,
|
||||
Slider,
|
||||
DropdownSelect,
|
||||
Button,
|
||||
SearchIcon,
|
||||
PlayIcon,
|
||||
Modal,
|
||||
CheckIcon,
|
||||
XIcon,
|
||||
PlusIcon,
|
||||
AnimatedLogo,
|
||||
Toggle,
|
||||
} from 'omorphia'
|
||||
import { BrowseIcon } from '@/assets/icons'
|
||||
import { Card, Slider, DropdownSelect, Toggle } from 'omorphia'
|
||||
import { useTheming } from '@/store/state'
|
||||
import { get, set } from '@/helpers/settings'
|
||||
import { find_jre_8_jres, find_jre_17_jres, get_jre, get_max_memory } from '@/helpers/jre'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import { get_max_memory } from '@/helpers/jre'
|
||||
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
||||
|
||||
const themeStore = useTheming()
|
||||
|
||||
@@ -28,145 +14,44 @@ if (!fetchSettings.java_globals?.JAVA_8)
|
||||
fetchSettings.java_globals.JAVA_8 = { path: '', version: '' }
|
||||
if (!fetchSettings.java_globals?.JAVA_17)
|
||||
fetchSettings.java_globals.JAVA_17 = { path: '', version: '' }
|
||||
|
||||
fetchSettings.javaArgs = fetchSettings.custom_java_args.join(' ')
|
||||
fetchSettings.envArgs = fetchSettings.custom_env_args.map((x) => x.join('=')).join(' ')
|
||||
|
||||
const settings = ref(fetchSettings)
|
||||
const maxMemory = ref((await get_max_memory()) / 1024)
|
||||
|
||||
const chosenInstallOptions = ref([])
|
||||
const browsingInstall = ref(0)
|
||||
|
||||
const testingJava17 = ref(false)
|
||||
const java17Success = ref(null)
|
||||
const testingJava8 = ref(false)
|
||||
const java8Success = ref(null)
|
||||
|
||||
// DOM refs
|
||||
const detectJavaModal = ref(null)
|
||||
|
||||
const handleTheme = async (e) => {
|
||||
themeStore.setThemeState(e.option.toLowerCase())
|
||||
settings.value.theme = themeStore.selectedTheme
|
||||
await set(settings.value)
|
||||
}
|
||||
|
||||
const handleCollapse = async (e) => {
|
||||
themeStore.collapsedNavigation = e
|
||||
settings.value.collapsed_navigation = themeStore.collapsedNavigation
|
||||
await set(settings.value)
|
||||
}
|
||||
|
||||
const loadJavaModal = async (version) => {
|
||||
if (version === 17) chosenInstallOptions.value = await find_jre_17_jres()
|
||||
else if (version === 8) chosenInstallOptions.value = await find_jre_8_jres()
|
||||
|
||||
browsingInstall.value = version
|
||||
detectJavaModal.value.show()
|
||||
}
|
||||
|
||||
watch(settings.value, async (oldSettings, newSettings) => {
|
||||
if (newSettings.java_globals?.JAVA_8?.path === '') {
|
||||
newSettings.java_globals.JAVA_8 = undefined
|
||||
}
|
||||
if (newSettings.java_globals?.JAVA_17?.path === '') {
|
||||
newSettings.java_globals.JAVA_17 = undefined
|
||||
}
|
||||
|
||||
newSettings.custom_java_args = newSettings.javaArgs.trim().split(/\s+/).filter(Boolean)
|
||||
newSettings.custom_env_args = newSettings.envArgs
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.map((x) => x.split('=').filter(Boolean))
|
||||
|
||||
if (!newSettings.hooks.pre_launch) {
|
||||
newSettings.hooks.pre_launch = null
|
||||
}
|
||||
if (!newSettings.hooks.wrapper) {
|
||||
newSettings.hooks.wrapper = null
|
||||
}
|
||||
if (!newSettings.hooks.post_exit) {
|
||||
newSettings.hooks.post_exit = null
|
||||
}
|
||||
|
||||
await set(newSettings)
|
||||
})
|
||||
|
||||
const handleJava17FileInput = async () => {
|
||||
let filePath = await open()
|
||||
settings.value.java_globals.JAVA_17 = {
|
||||
path: filePath,
|
||||
version: '17',
|
||||
}
|
||||
}
|
||||
const handleJava8FileInput = async () => {
|
||||
let filePath = await open()
|
||||
settings.value.java_globals.JAVA_8 = {
|
||||
path: filePath,
|
||||
version: '8',
|
||||
}
|
||||
}
|
||||
|
||||
const handleJava17Test = async () => {
|
||||
let result
|
||||
testingJava17.value = true
|
||||
setTimeout(async () => {
|
||||
result = await get_jre(settings.value.java_globals.JAVA_17.path)
|
||||
testingJava17.value = false
|
||||
if (result) java17Success.value = true
|
||||
else java17Success.value = false
|
||||
|
||||
setTimeout(() => {
|
||||
java17Success.value = null
|
||||
}, 2000)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const handleJava8Test = async () => {
|
||||
let result
|
||||
testingJava8.value = true
|
||||
setTimeout(async () => {
|
||||
result = await get_jre(settings.value.java_globals.JAVA_8.path)
|
||||
testingJava8.value = false
|
||||
java8Success.value = !!result
|
||||
|
||||
setTimeout(() => {
|
||||
java8Success.value = null
|
||||
}, 2000)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const setJavaInstall = (javaInstall) => {
|
||||
if (browsingInstall.value === 17) settings.value.java_globals.JAVA_17 = javaInstall
|
||||
else if (browsingInstall.value === 8) settings.value.java_globals.JAVA_8 = javaInstall
|
||||
detectJavaModal.value.hide()
|
||||
chosenInstallOptions.value = []
|
||||
browsingInstall.value = 0
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Modal ref="detectJavaModal" header="Select java version">
|
||||
<div class="auto-detect-modal">
|
||||
<div class="table">
|
||||
<div class="table-row table-head">
|
||||
<div class="table-cell table-text">Version</div>
|
||||
<div class="table-cell table-text">Path</div>
|
||||
<div class="table-cell table-text">Actions</div>
|
||||
</div>
|
||||
<div
|
||||
v-for="javaInstall in chosenInstallOptions"
|
||||
:key="javaInstall.path"
|
||||
class="table-row"
|
||||
>
|
||||
<div class="table-cell table-text">
|
||||
<span>{{ javaInstall.version }}</span>
|
||||
</div>
|
||||
<div class="table-cell table-text">
|
||||
<span>{{ javaInstall.path }}</span>
|
||||
</div>
|
||||
<div class="table-cell table-text manage">
|
||||
<Button
|
||||
:disabled="
|
||||
settings.java_globals.JAVA_17.path === javaInstall.path ||
|
||||
settings.java_globals.JAVA_8.path === javaInstall.path
|
||||
"
|
||||
class="select-btn"
|
||||
@click="() => setJavaInstall(javaInstall)"
|
||||
>
|
||||
<span
|
||||
v-if="
|
||||
settings.java_globals.JAVA_17.path === javaInstall.path ||
|
||||
settings.java_globals.JAVA_8.path === javaInstall.path
|
||||
"
|
||||
>
|
||||
<CheckIcon />Selected
|
||||
</span>
|
||||
<span v-else><PlusIcon />Select</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="chosenInstallOptions.length === 0" class="table-row entire-row">
|
||||
<div class="table-cell table-text">No JARS Found!</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
<Card class="theming">
|
||||
<h2>Display</h2>
|
||||
<div class="toggle-setting">
|
||||
@@ -180,7 +65,12 @@ const setJavaInstall = (javaInstall) => {
|
||||
:default-value="settings.theme"
|
||||
:model-value="settings.theme"
|
||||
class="theme-dropdown"
|
||||
@change="handleTheme"
|
||||
@change="
|
||||
(e) => {
|
||||
themeStore.setThemeState(e.option.toLowerCase())
|
||||
settings.theme = themeStore.selectedTheme
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
@@ -191,133 +81,21 @@ const setJavaInstall = (javaInstall) => {
|
||||
<Toggle
|
||||
:model-value="themeStore.collapsedNavigation"
|
||||
:checked="themeStore.collapsedNavigation"
|
||||
@update:model-value="(value) => handleCollapse(value)"
|
||||
@update:model-value="
|
||||
(e) => {
|
||||
themeStore.collapsedNavigation = e
|
||||
settings.collapsed_navigation = themeStore.collapsedNavigation
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Java</h2>
|
||||
<h2 class="settings-title">Launcher settings</h2>
|
||||
<div class="settings-group">
|
||||
<h3>Java 17 Location</h3>
|
||||
<h3>Resource management</h3>
|
||||
<div class="toggle-setting">
|
||||
<input
|
||||
v-model="settings.java_globals.JAVA_17.path"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="/path/to/java17"
|
||||
/>
|
||||
<span class="installation-buttons">
|
||||
<Button @click="() => loadJavaModal(17)">
|
||||
<SearchIcon />
|
||||
Auto Detect
|
||||
</Button>
|
||||
<Button @click="handleJava17FileInput">
|
||||
<BrowseIcon />
|
||||
Browse
|
||||
</Button>
|
||||
<Button @click="handleJava17Test">
|
||||
<PlayIcon />
|
||||
Test
|
||||
</Button>
|
||||
<AnimatedLogo v-if="testingJava17 === true" class="testing-loader" />
|
||||
<CheckIcon
|
||||
v-else-if="java17Success === true && testingJava17 === false"
|
||||
class="test-success"
|
||||
/>
|
||||
<XIcon
|
||||
v-else-if="java17Success === false && testingJava17 === false"
|
||||
class="test-fail"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
<h3>Java 8 Location</h3>
|
||||
<div class="toggle-setting">
|
||||
<input
|
||||
v-model="settings.java_globals.JAVA_8.path"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="/path/to/java8"
|
||||
/>
|
||||
<span class="installation-buttons">
|
||||
<Button @click="() => loadJavaModal(8)">
|
||||
<SearchIcon />
|
||||
Auto Detect
|
||||
</Button>
|
||||
<Button @click="handleJava8FileInput">
|
||||
<BrowseIcon />
|
||||
Browse
|
||||
</Button>
|
||||
<Button @click="handleJava8Test">
|
||||
<PlayIcon />
|
||||
Test
|
||||
</Button>
|
||||
<AnimatedLogo v-if="testingJava8 === true" class="testing-loader" />
|
||||
<CheckIcon
|
||||
v-else-if="java8Success === true && testingJava8 === false"
|
||||
class="test-success"
|
||||
/>
|
||||
<XIcon v-else-if="java8Success === false && testingJava8 === false" class="test-fail" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<h3>Java Arguments</h3>
|
||||
<input
|
||||
v-model="settings.custom_java_args"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="Enter java arguments..."
|
||||
/>
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
<h3>Environment Arguments</h3>
|
||||
<input
|
||||
v-model="settings.custom_env_args"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="Enter environment arguments..."
|
||||
/>
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<div class="sliders">
|
||||
<span class="slider">
|
||||
Minimum Memory
|
||||
<Slider v-model="settings.memory.minimum" :min="256" :max="maxMemory" :step="10" />
|
||||
</span>
|
||||
<span class="slider">
|
||||
Maximum Memory
|
||||
<Slider v-model="settings.memory.maximum" :min="256" :max="maxMemory" :step="10" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Window Size</h2>
|
||||
<div class="settings-group">
|
||||
<div class="settings-group">
|
||||
<div class="sliders">
|
||||
<span class="slider">
|
||||
Width
|
||||
<Slider v-model="settings.game_resolution[0]" :min="400" :max="2562" :step="2" />
|
||||
</span>
|
||||
<span class="slider">
|
||||
Height
|
||||
<Slider v-model="settings.game_resolution[1]" :min="400" :max="2562" :step="2" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Launcher Settings</h2>
|
||||
<div class="settings-group">
|
||||
<h3>Resource Management</h3>
|
||||
<div class="toggle-setting">
|
||||
<span>Maximum Concurrent Downloads</span>
|
||||
<span>Maximum concurrent downloads</span>
|
||||
<Slider
|
||||
v-model="settings.max_concurrent_downloads"
|
||||
class="concurrent-downloads"
|
||||
@@ -326,13 +104,66 @@ const setJavaInstall = (javaInstall) => {
|
||||
:step="1"
|
||||
/>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
<span>Maximum concurrent writes</span>
|
||||
<Slider
|
||||
v-model="settings.max_concurrent_writes"
|
||||
class="concurrent-downloads"
|
||||
:min="1"
|
||||
:max="100"
|
||||
:step="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Commands</h2>
|
||||
<h2 class="settings-title">Java</h2>
|
||||
<div class="settings-group">
|
||||
<h3>Java 17 location</h3>
|
||||
<JavaSelector v-model="settings.java_globals.JAVA_17" :version="17" />
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
<h3>Java 8 location</h3>
|
||||
<JavaSelector v-model="settings.java_globals.JAVA_8" :version="8" />
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<h3>Java arguments</h3>
|
||||
<input
|
||||
v-model="settings.javaArgs"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="Enter java arguments..."
|
||||
/>
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
<h3>Environment variables</h3>
|
||||
<input
|
||||
v-model="settings.envArgs"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="Enter environment variables..."
|
||||
/>
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<div class="sliders">
|
||||
<span class="slider">
|
||||
Minimum memory
|
||||
<Slider v-model="settings.memory.minimum" :min="256" :max="maxMemory" :step="10" />
|
||||
</span>
|
||||
<span class="slider">
|
||||
Maximum memory
|
||||
<Slider v-model="settings.memory.maximum" :min="256" :max="maxMemory" :step="10" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Hooks</h2>
|
||||
<div class="settings-group">
|
||||
<div class="toggle-setting">
|
||||
Pre Launch
|
||||
Pre launch
|
||||
<input v-model="settings.hooks.pre_launch" type="text" class="input" />
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
@@ -340,46 +171,32 @@ const setJavaInstall = (javaInstall) => {
|
||||
<input v-model="settings.hooks.wrapper" type="text" class="input" />
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Post Launch
|
||||
Post exit
|
||||
<input v-model="settings.hooks.post_exit" type="text" class="input" />
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Window Size</h2>
|
||||
<div class="settings-group">
|
||||
<div class="toggle-setting">
|
||||
Width
|
||||
<input v-model="settings.game_resolution[0]" type="number" class="input" />
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Height
|
||||
<input v-model="settings.game_resolution[1]" type="number" class="input" />
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.testing-loader {
|
||||
height: 1rem !important;
|
||||
width: 1rem !important;
|
||||
|
||||
svg {
|
||||
height: inherit !important;
|
||||
width: inherit !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.concurrent-downloads {
|
||||
width: 80% !important;
|
||||
}
|
||||
|
||||
.auto-detect-modal {
|
||||
padding: 1rem;
|
||||
|
||||
.table {
|
||||
.table-row {
|
||||
grid-template-columns: 1fr 4fr 1.5fr;
|
||||
}
|
||||
|
||||
span {
|
||||
display: inherit;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.slider-input {
|
||||
width: 5rem !important;
|
||||
flex-basis: 5rem !important;
|
||||
@@ -393,9 +210,6 @@ const setJavaInstall = (javaInstall) => {
|
||||
.theming,
|
||||
.settings-card {
|
||||
margin: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.theming {
|
||||
@@ -411,7 +225,7 @@ const setJavaInstall = (javaInstall) => {
|
||||
.settings-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.settings-title {
|
||||
@@ -424,17 +238,12 @@ const setJavaInstall = (javaInstall) => {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.installation-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.installation-buttons {
|
||||
.toggle-setting {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sliders {
|
||||
@@ -448,25 +257,4 @@ const setJavaInstall = (javaInstall) => {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-setting {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.manage {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.test-success {
|
||||
color: var(--color-green);
|
||||
}
|
||||
|
||||
.test-fail {
|
||||
color: var(--color-red);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -18,8 +18,11 @@
|
||||
</span>
|
||||
</div>
|
||||
<span class="button-group">
|
||||
<Button v-if="instance.install_stage !== 'installed'" disabled class="instance-button">
|
||||
Installing...
|
||||
</Button>
|
||||
<Button
|
||||
v-if="playing === true"
|
||||
v-else-if="playing === true"
|
||||
color="danger"
|
||||
class="instance-button"
|
||||
@click="stopInstance"
|
||||
@@ -38,9 +41,13 @@
|
||||
<PlayIcon />
|
||||
Play
|
||||
</Button>
|
||||
<Button v-else-if="loading === true && playing === false" disabled class="instance-button"
|
||||
>Loading...</Button
|
||||
<Button
|
||||
v-else-if="loading === true && playing === false"
|
||||
disabled
|
||||
class="instance-button"
|
||||
>
|
||||
Loading...
|
||||
</Button>
|
||||
<!--TODO: https://github.com/tauri-apps/tauri/issues/4062 -->
|
||||
<Button class="instance-button" icon-only @click="open({ defaultPath: instance.path })">
|
||||
<OpenFolderIcon />
|
||||
@@ -52,14 +59,14 @@
|
||||
<BoxIcon />
|
||||
Mods
|
||||
</RouterLink>
|
||||
<RouterLink :to="`/instance/${encodeURIComponent($route.params.id)}/options`" class="btn">
|
||||
<SettingsIcon />
|
||||
Options
|
||||
</RouterLink>
|
||||
<RouterLink :to="`/instance/${encodeURIComponent($route.params.id)}/logs`" class="btn">
|
||||
<FileIcon />
|
||||
Logs
|
||||
</RouterLink>
|
||||
<RouterLink :to="`/instance/${encodeURIComponent($route.params.id)}/options`" class="btn">
|
||||
<SettingsIcon />
|
||||
Options
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
@@ -371,12 +378,4 @@ Button {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card-divider {
|
||||
background-color: var(--color-button-bg);
|
||||
border: none;
|
||||
color: var(--color-button-bg);
|
||||
height: 1px;
|
||||
margin: var(--gap-xl) 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,139 +1,504 @@
|
||||
<template>
|
||||
<Modal ref="changeVersionsModal" header="Change instance versions">
|
||||
<div class="change-versions-modal universal-body">
|
||||
<div class="input-row">
|
||||
<p class="input-label">Loader</p>
|
||||
<Chips v-model="loader" :items="loaders" />
|
||||
</div>
|
||||
<div class="input-row">
|
||||
<p class="input-label">Game Version</p>
|
||||
<div class="versions">
|
||||
<DropdownSelect v-model="gameVersion" :options="selectableGameVersions" render-up />
|
||||
<Checkbox v-model="showSnapshots" class="filter-checkbox" label="Include snapshots" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="loader !== 'vanilla'" class="input-row">
|
||||
<p class="input-label">Loader Version</p>
|
||||
<DropdownSelect
|
||||
:model-value="selectableLoaderVersions[loaderVersionIndex]"
|
||||
:options="selectableLoaderVersions"
|
||||
:display-name="(option) => option?.id"
|
||||
render-up
|
||||
@change="(value) => (loaderVersionIndex = value.index)"
|
||||
/>
|
||||
</div>
|
||||
<div class="button-group">
|
||||
<button class="btn" @click="$refs.changeVersionsModal.hide()">
|
||||
<XIcon />
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
:disabled="!isValid || editing"
|
||||
@click="saveGvLoaderEdits()"
|
||||
>
|
||||
<SaveIcon />
|
||||
{{ editing ? 'Saving...' : 'Save changes' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
<section class="card">
|
||||
<div class="label">
|
||||
<h3>
|
||||
<span class="label__title size-card-header">Profile</span>
|
||||
</h3>
|
||||
</div>
|
||||
<label for="instance-icon">
|
||||
<span class="label__title">Icon</span>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<Avatar
|
||||
:src="!icon || (icon && icon.startsWith('http')) ? icon : convertFileSrc(icon)"
|
||||
size="md"
|
||||
class="project__icon"
|
||||
/>
|
||||
<div class="input-stack">
|
||||
<button id="instance-icon" class="btn" @click="setIcon">
|
||||
<UploadIcon />
|
||||
Upload icon
|
||||
</button>
|
||||
<button class="btn" @click="resetIcon">
|
||||
<TrashIcon />
|
||||
Remove icon
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label for="project-name">
|
||||
<span class="label__title">Name</span>
|
||||
</label>
|
||||
<input id="profile-name" v-model="title" maxlength="80" type="text" />
|
||||
|
||||
<div class="adjacent-input">
|
||||
<label for="edit-versions">
|
||||
<span class="label__title">Edit mod loader/game versions</span>
|
||||
<span class="label__description">
|
||||
Allows you to change the mod loader, loader version, or game version of the profile.
|
||||
</span>
|
||||
</label>
|
||||
<button id="edit-versions" class="btn" @click="$refs.changeVersionsModal.show()">
|
||||
<EditIcon />
|
||||
Edit versions
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Java</h2>
|
||||
<div class="settings-group">
|
||||
<h3>Installation</h3>
|
||||
<Checkbox v-model="overrideJavaInstall" label="Override global java installations" />
|
||||
<JavaSelector v-model="javaInstall" :disabled="!overrideJavaInstall" />
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<h3>Java arguments</h3>
|
||||
<Checkbox v-model="overrideJavaArgs" label="Override global java arguments" />
|
||||
<input
|
||||
ref="javaPath"
|
||||
v-model="javaPath"
|
||||
v-model="javaArgs"
|
||||
:disabled="!overrideJavaArgs"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home"
|
||||
placeholder="Enter java arguments..."
|
||||
/>
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
<h3>Environment variables</h3>
|
||||
<Checkbox v-model="overrideEnvVars" label="Override global environment variables" />
|
||||
<input
|
||||
v-model="envVars"
|
||||
:disabled="!overrideEnvVars"
|
||||
type="text"
|
||||
class="input installation-input"
|
||||
placeholder="Enter environment variables..."
|
||||
/>
|
||||
<span class="installation-buttons">
|
||||
<Button @click="saveJavaPath">
|
||||
<SearchIcon />
|
||||
Auto Detect
|
||||
</Button>
|
||||
<Button @click="saveJavaPath">
|
||||
<BrowseIcon />
|
||||
Browse
|
||||
</Button>
|
||||
<Button @click="saveJavaPath">
|
||||
<PlayIcon />
|
||||
Test
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<h3>Arguments</h3>
|
||||
<input ref="javaArgs" v-model="javaArgs" type="text" class="input installation-input" />
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<Checkbox v-model="overrideMemorySettings" label="Override global memory settings" />
|
||||
<div class="sliders">
|
||||
<span class="slider">
|
||||
Minimum Memory
|
||||
<Slider v-model="javaMemory" :min="1024" :max="8192" :step="1024" />
|
||||
Minimum memory
|
||||
<Slider
|
||||
v-model="memory.minimum"
|
||||
:disabled="!overrideMemorySettings"
|
||||
:min="256"
|
||||
:max="maxMemory"
|
||||
:step="10"
|
||||
/>
|
||||
</span>
|
||||
<span class="slider">
|
||||
Maximum Memory
|
||||
<Slider v-model="javaMemory" :min="1024" :max="8192" :step="1024" />
|
||||
Maximum memory
|
||||
<Slider
|
||||
v-model="memory.maximum"
|
||||
:disabled="!overrideMemorySettings"
|
||||
:min="256"
|
||||
:max="maxMemory"
|
||||
:step="10"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Window</h2>
|
||||
<Checkbox v-model="overrideWindowSettings" label="Override global window settings" />
|
||||
<div class="settings-group">
|
||||
<div class="settings-group">
|
||||
<div class="sliders">
|
||||
<span class="slider">
|
||||
Width
|
||||
<Slider v-model="javaMemory" :min="1024" :max="8192" :step="1024" />
|
||||
</span>
|
||||
<span class="slider">
|
||||
Height
|
||||
<Slider v-model="javaMemory" :min="1024" :max="8192" :step="1024" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Start in Fullscreen
|
||||
<input
|
||||
id="fullscreen"
|
||||
v-model="fullscreen"
|
||||
type="checkbox"
|
||||
name="fullscreen"
|
||||
class="switch stylized-toggle"
|
||||
/>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Width
|
||||
<input
|
||||
v-model="resolution[0]"
|
||||
:disabled="!overrideWindowSettings"
|
||||
type="number"
|
||||
class="input"
|
||||
@change="updateProfile"
|
||||
/>
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="settings-group">
|
||||
<h3>Console</h3>
|
||||
<div class="toggle-setting">
|
||||
Show console while game is running
|
||||
<input
|
||||
id="fullscreen"
|
||||
v-model="fullscreen"
|
||||
type="checkbox"
|
||||
name="fullscreen"
|
||||
class="switch stylized-toggle"
|
||||
/>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Close console when game quits
|
||||
<input
|
||||
id="fullscreen"
|
||||
v-model="fullscreen"
|
||||
type="checkbox"
|
||||
name="fullscreen"
|
||||
class="switch stylized-toggle"
|
||||
/>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Show console when game crashes
|
||||
<input
|
||||
id="fullscreen"
|
||||
v-model="fullscreen"
|
||||
type="checkbox"
|
||||
name="fullscreen"
|
||||
class="switch stylized-toggle"
|
||||
/>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Height
|
||||
<input
|
||||
v-model="resolution[1]"
|
||||
:disabled="!overrideWindowSettings"
|
||||
type="number"
|
||||
class="input"
|
||||
@change="updateProfile"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Commands</h2>
|
||||
<h2 class="settings-title">Hooks</h2>
|
||||
<Checkbox v-model="overrideHooks" label="Override global hooks" />
|
||||
<div class="settings-group">
|
||||
<div class="toggle-setting">
|
||||
Pre Launch
|
||||
<input ref="javaArgs" v-model="javaArgs" type="text" class="input" />
|
||||
Pre launch
|
||||
<input v-model="hooks.pre_launch" :disabled="!overrideHooks" type="text" />
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Wrapper
|
||||
<input ref="javaArgs" v-model="javaArgs" type="text" class="input" />
|
||||
<input v-model="hooks.wrapper" :disabled="!overrideHooks" type="text" />
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Post Launch
|
||||
<input ref="javaArgs" v-model="javaArgs" type="text" class="input" />
|
||||
Post exit
|
||||
<input v-model="hooks.post_exit" :disabled="!overrideHooks" type="text" />
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card class="settings-card">
|
||||
<h2 class="settings-title">Profile management</h2>
|
||||
<div class="settings-group">
|
||||
<div class="toggle-setting">
|
||||
Repair profile
|
||||
<button class="btn btn-highlight" :disabled="repairing" @click="repairProfile">
|
||||
<HammerIcon /> Repair
|
||||
</button>
|
||||
</div>
|
||||
<div class="toggle-setting">
|
||||
Delete profile
|
||||
<button class="btn btn-danger" :disabled="removing" @click="removeProfile">
|
||||
<TrashIcon /> Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Card, Button, SearchIcon, Slider } from 'omorphia'
|
||||
import { BrowseIcon, PlayIcon } from '@/assets/icons'
|
||||
import {
|
||||
Card,
|
||||
Slider,
|
||||
TrashIcon,
|
||||
Checkbox,
|
||||
UploadIcon,
|
||||
Avatar,
|
||||
EditIcon,
|
||||
Modal,
|
||||
Chips,
|
||||
DropdownSelect,
|
||||
XIcon,
|
||||
SaveIcon,
|
||||
} from 'omorphia'
|
||||
import { HammerIcon } from '@/assets/icons'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { edit, edit_icon, get_optimal_jre_key, install, remove } from '@/helpers/profile.js'
|
||||
import { computed, readonly, ref, shallowRef, watch } from 'vue'
|
||||
import { get_max_memory } from '@/helpers/jre.js'
|
||||
import { get } from '@/helpers/settings.js'
|
||||
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
||||
import { convertFileSrc } from '@tauri-apps/api/tauri'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import { get_fabric_versions, get_forge_versions, get_quilt_versions } from '@/helpers/metadata.js'
|
||||
import { get_game_versions, get_loaders } from '@/helpers/tags.js'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const props = defineProps({
|
||||
instance: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const title = ref(props.instance.metadata.name)
|
||||
const icon = ref(props.instance.metadata.icon)
|
||||
|
||||
async function resetIcon() {
|
||||
icon.value = null
|
||||
await edit_icon(props.instance.path, null)
|
||||
}
|
||||
|
||||
async function setIcon() {
|
||||
const value = await open({
|
||||
multiple: false,
|
||||
filters: [
|
||||
{
|
||||
name: 'Image',
|
||||
extensions: ['png', 'jpeg', 'svg', 'webp', 'gif', 'jpg'],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
if (!value) return
|
||||
|
||||
icon.value = value
|
||||
await edit_icon(props.instance.path, icon.value)
|
||||
}
|
||||
|
||||
const globalSettings = await get()
|
||||
|
||||
const javaSettings = props.instance.java ?? {}
|
||||
|
||||
const overrideJavaInstall = ref(!!javaSettings.override_version)
|
||||
const optimalJava = readonly(await get_optimal_jre_key(props.instance.path))
|
||||
const javaInstall = ref(optimalJava ?? javaSettings.override_version ?? { path: '', version: '' })
|
||||
|
||||
const overrideJavaArgs = ref(!!javaSettings.extra_arguments)
|
||||
const javaArgs = ref((javaSettings.extra_arguments ?? globalSettings.custom_java_args).join(' '))
|
||||
|
||||
const overrideEnvVars = ref(!!javaSettings.custom_env_args)
|
||||
const envVars = ref(
|
||||
(javaSettings.custom_env_args ?? globalSettings.custom_env_args).map((x) => x.join('=')).join(' ')
|
||||
)
|
||||
|
||||
const overrideMemorySettings = ref(!!props.instance.memory)
|
||||
const memory = ref(props.instance.memory ?? globalSettings.memory)
|
||||
const maxMemory = (await get_max_memory()) / 1024
|
||||
|
||||
const overrideWindowSettings = ref(!!props.instance.resolution)
|
||||
const resolution = ref(props.instance.resolution ?? globalSettings.game_resolution)
|
||||
|
||||
const overrideHooks = ref(!!props.instance.hooks)
|
||||
const hooks = ref(props.instance.hooks ?? globalSettings.hooks)
|
||||
|
||||
watch(
|
||||
[
|
||||
title,
|
||||
overrideJavaInstall,
|
||||
javaInstall,
|
||||
overrideJavaArgs,
|
||||
javaArgs,
|
||||
overrideEnvVars,
|
||||
envVars,
|
||||
overrideMemorySettings,
|
||||
memory.value,
|
||||
overrideWindowSettings,
|
||||
resolution.value,
|
||||
overrideHooks,
|
||||
hooks.value,
|
||||
],
|
||||
async () => {
|
||||
const editProfile = {
|
||||
metadata: {
|
||||
name: title.value,
|
||||
},
|
||||
java: {},
|
||||
}
|
||||
|
||||
if (overrideJavaInstall.value) {
|
||||
if (javaInstall.value.path !== '') {
|
||||
editProfile.java.override_version = javaInstall.value
|
||||
}
|
||||
}
|
||||
|
||||
if (overrideJavaArgs.value) {
|
||||
if (javaArgs.value !== '') {
|
||||
editProfile.java.extra_arguments = javaArgs.value.trim().split(/\s+/).filter(Boolean)
|
||||
}
|
||||
}
|
||||
|
||||
if (overrideEnvVars.value) {
|
||||
if (envVars.value !== '') {
|
||||
editProfile.java.custom_env_args = envVars.value
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.map((x) => x.split('=').filter(Boolean))
|
||||
}
|
||||
}
|
||||
|
||||
if (overrideMemorySettings.value) {
|
||||
editProfile.memory = memory.value
|
||||
}
|
||||
|
||||
if (overrideWindowSettings.value) {
|
||||
editProfile.resolution = resolution.value
|
||||
}
|
||||
|
||||
if (overrideHooks.value) {
|
||||
editProfile.hooks = hooks.value
|
||||
}
|
||||
|
||||
await edit(props.instance.path, editProfile)
|
||||
}
|
||||
)
|
||||
|
||||
const repairing = ref(false)
|
||||
|
||||
async function repairProfile() {
|
||||
repairing.value = true
|
||||
await install(props.instance.path)
|
||||
repairing.value = false
|
||||
}
|
||||
|
||||
const removing = ref(false)
|
||||
async function removeProfile() {
|
||||
removing.value = true
|
||||
await remove(props.instance.path)
|
||||
removing.value = false
|
||||
|
||||
await router.push({ path: '/' })
|
||||
}
|
||||
|
||||
const changeVersionsModal = ref(null)
|
||||
const showSnapshots = ref(false)
|
||||
|
||||
const [fabric_versions, forge_versions, quilt_versions, all_game_versions, loaders] =
|
||||
await Promise.all([
|
||||
get_fabric_versions().then(shallowRef),
|
||||
get_forge_versions().then(shallowRef),
|
||||
get_quilt_versions().then(shallowRef),
|
||||
get_game_versions().then(shallowRef),
|
||||
get_loaders()
|
||||
.then((value) =>
|
||||
value
|
||||
.filter((item) => item.supported_project_types.includes('modpack'))
|
||||
.map((item) => item.name.toLowerCase())
|
||||
)
|
||||
.then(ref),
|
||||
])
|
||||
loaders.value.push('vanilla')
|
||||
|
||||
const loader = ref(props.instance.metadata.loader)
|
||||
|
||||
const gameVersion = ref(props.instance.metadata.game_version)
|
||||
const selectableGameVersions = computed(() => {
|
||||
return all_game_versions.value
|
||||
.filter((item) => {
|
||||
let defaultVal = item.version_type === 'release' || showSnapshots.value
|
||||
if (loader.value === 'fabric') {
|
||||
defaultVal &= fabric_versions.value.gameVersions.some((x) => item.version === x.id)
|
||||
} else if (loader.value === 'forge') {
|
||||
defaultVal &= forge_versions.value.gameVersions.some((x) => item.version === x.id)
|
||||
} else if (loader.value === 'quilt') {
|
||||
defaultVal &= quilt_versions.value.gameVersions.some((x) => item.version === x.id)
|
||||
}
|
||||
|
||||
return defaultVal
|
||||
})
|
||||
.map((item) => item.version)
|
||||
})
|
||||
|
||||
const selectableLoaderVersions = computed(() => {
|
||||
if (gameVersion.value) {
|
||||
if (loader.value === 'fabric') {
|
||||
return fabric_versions.value.gameVersions[0].loaders
|
||||
} else if (loader.value === 'forge') {
|
||||
return forge_versions.value.gameVersions.find((item) => item.id === gameVersion.value).loaders
|
||||
} else if (loader.value === 'quilt') {
|
||||
return quilt_versions.value.gameVersions[0].loaders
|
||||
}
|
||||
}
|
||||
return []
|
||||
})
|
||||
const loaderVersionIndex = ref(
|
||||
selectableLoaderVersions.value.findIndex(
|
||||
(x) => x.id === props.instance.metadata.loader_version?.id
|
||||
)
|
||||
)
|
||||
|
||||
const isValid = computed(() => {
|
||||
return (
|
||||
selectableGameVersions.value.includes(gameVersion.value) &&
|
||||
(loaderVersionIndex.value >= 0 || loader.value === 'vanilla')
|
||||
)
|
||||
})
|
||||
|
||||
watch(loader, () => (loaderVersionIndex.value = 0))
|
||||
|
||||
const editing = ref(false)
|
||||
async function saveGvLoaderEdits() {
|
||||
editing.value = true
|
||||
|
||||
const editProfile = {
|
||||
metadata: {
|
||||
game_version: gameVersion.value,
|
||||
loader: loader.value,
|
||||
},
|
||||
}
|
||||
|
||||
if (loader.value !== 'vanilla') {
|
||||
editProfile.metadata.loader_version = selectableLoaderVersions.value[loaderVersionIndex.value]
|
||||
}
|
||||
await edit(props.instance.path, editProfile)
|
||||
await repairProfile()
|
||||
|
||||
editing.value = false
|
||||
changeVersionsModal.value.hide()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.change-versions-modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
gap: 1rem;
|
||||
|
||||
.input-label {
|
||||
font-size: 1rem;
|
||||
font-weight: bolder;
|
||||
color: var(--color-contrast);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.versions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.input-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.settings-title {
|
||||
@@ -150,15 +515,6 @@ import { BrowseIcon, PlayIcon } from '@/assets/icons'
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.installation-buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sliders {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -186,4 +542,8 @@ import { BrowseIcon, PlayIcon } from '@/assets/icons'
|
||||
height: 1px;
|
||||
margin: var(--gap-sm) 0;
|
||||
}
|
||||
|
||||
:deep(button.checkbox) {
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -81,11 +81,11 @@
|
||||
</div>
|
||||
<hr class="card-divider" />
|
||||
<div class="button-group">
|
||||
<Button class="instance-button">
|
||||
<Button class="instance-button" disabled>
|
||||
<ReportIcon />
|
||||
Report
|
||||
</Button>
|
||||
<Button class="instance-button">
|
||||
<Button class="instance-button" disabled>
|
||||
<HeartIcon />
|
||||
Follow
|
||||
</Button>
|
||||
@@ -96,7 +96,8 @@
|
||||
v-if="data.issues_url"
|
||||
:href="data.issues_url"
|
||||
class="title"
|
||||
rel="noopener nofollow ugc"
|
||||
rel="noopener nofollow ugc external"
|
||||
target="_blank"
|
||||
>
|
||||
<IssuesIcon aria-hidden="true" />
|
||||
<span>Issues</span>
|
||||
@@ -105,16 +106,29 @@
|
||||
v-if="data.source_url"
|
||||
:href="data.source_url"
|
||||
class="title"
|
||||
rel="noopener nofollow ugc"
|
||||
target="_blank"
|
||||
rel="noopener nofollow ugc external"
|
||||
>
|
||||
<CodeIcon aria-hidden="true" />
|
||||
<span>Source</span>
|
||||
</a>
|
||||
<a v-if="data.wiki_url" :href="data.wiki_url" class="title" rel="noopener nofollow ugc">
|
||||
<a
|
||||
v-if="data.wiki_url"
|
||||
:href="data.wiki_url"
|
||||
class="title"
|
||||
rel="noopener nofollow ugc external"
|
||||
target="_blank"
|
||||
>
|
||||
<WikiIcon aria-hidden="true" />
|
||||
<span>Wiki</span>
|
||||
</a>
|
||||
<a v-if="data.wiki_url" :href="data.wiki_url" class="title" rel="noopener nofollow ugc">
|
||||
<a
|
||||
v-if="data.wiki_url"
|
||||
:href="data.wiki_url"
|
||||
class="title"
|
||||
rel="noopener nofollow ugc external"
|
||||
target="_blank"
|
||||
>
|
||||
<DiscordIcon aria-hidden="true" />
|
||||
<span>Discord</span>
|
||||
</a>
|
||||
@@ -122,7 +136,8 @@
|
||||
v-for="(donation, index) in data.donation_urls"
|
||||
:key="index"
|
||||
:href="donation.url"
|
||||
rel="noopener nofollow ugc"
|
||||
target="_blank"
|
||||
rel="noopener nofollow ugc external"
|
||||
>
|
||||
<BuyMeACoffeeIcon v-if="donation.id === 'bmac'" aria-hidden="true" />
|
||||
<PatreonIcon v-else-if="donation.id === 'patreon'" aria-hidden="true" />
|
||||
|
||||
@@ -1149,10 +1149,10 @@ ofetch@^1.0.1:
|
||||
node-fetch-native "^1.0.2"
|
||||
ufo "^1.1.0"
|
||||
|
||||
omorphia@^0.4.13:
|
||||
version "0.4.13"
|
||||
resolved "https://registry.yarnpkg.com/omorphia/-/omorphia-0.4.13.tgz#6141886b9c332e4a28afe31a743f0c85d4a09efe"
|
||||
integrity sha512-Yb76WoM4e42aAq3G/OPxQS6whCu+WIHVBhJxSzmUUycF1Pvf6tJZov+LefneSkk4xcQAjDZsgK8VOVD7q/siig==
|
||||
omorphia@^0.4.16:
|
||||
version "0.4.16"
|
||||
resolved "https://registry.yarnpkg.com/omorphia/-/omorphia-0.4.16.tgz#933a1e28c926cc10da1b0f4f1444c7a563f5a7b4"
|
||||
integrity sha512-bYAsyDuLgJtuL+/srxYf0wEILLH34LDb8st5L9+MEt1YqlWw5Bk8aQX8O2sOZNWji1V4Zr+NRGIRRXz7iiz+4w==
|
||||
dependencies:
|
||||
dayjs "^1.11.7"
|
||||
floating-vue "^2.0.0-beta.20"
|
||||
|
||||
@@ -6,31 +6,32 @@ use syn::{parse_macro_input, ItemFn};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn debug_pin(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
// Parse the input tokens into a syntax tree
|
||||
let input = parse_macro_input!(item as ItemFn);
|
||||
|
||||
let attrs = &input.attrs;
|
||||
let vis = &input.vis; // visibility modifier
|
||||
let sig = &input.sig; // function signature
|
||||
let vis = &input.vis;
|
||||
let sig = &input.sig;
|
||||
let body = &input.block;
|
||||
|
||||
// Use cfg attribute for conditional compilation
|
||||
// Generate tokens for the common part
|
||||
let common_tokens = quote! {
|
||||
#(#attrs)*
|
||||
#vis #sig
|
||||
};
|
||||
|
||||
let result = quote! {
|
||||
#[cfg(debug_assertions)]
|
||||
#(#attrs) *
|
||||
#vis #sig {
|
||||
#common_tokens {
|
||||
Box::pin(async move {
|
||||
#body
|
||||
}).await
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
#(#attrs) *
|
||||
#vis #sig {
|
||||
#common_tokens {
|
||||
#body
|
||||
}
|
||||
};
|
||||
|
||||
// Hand the output tokens back to the compiler
|
||||
TokenStream::from(result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user