diff --git a/Cargo.lock b/Cargo.lock index cee6f466b..bec38fae3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -957,9 +957,9 @@ dependencies = [ [[package]] name = "daedalus" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b8590e725889bb981febb438f133f8ef6b62f610f92835c961338e771222b1a" +checksum = "314dac850cbf02b728fb531c1f3b1bec5b4ccdef6564db274470363792a6d302" dependencies = [ "bytes", "chrono", diff --git a/apps/app-frontend/src/App.vue b/apps/app-frontend/src/App.vue index d5c64055e..5c0c095cc 100644 --- a/apps/app-frontend/src/App.vue +++ b/apps/app-frontend/src/App.vue @@ -116,13 +116,13 @@ initialize_state() setupApp().catch((err) => { stateFailed.value = true console.error(err) - error.showError(err, false, 'state_init') + error.showError(err, null, false, 'state_init') }) }) .catch((err) => { stateFailed.value = true console.error('Failed to initialize app', err) - error.showError(err, false, 'state_init') + error.showError(err, null, false, 'state_init') }) const handleClose = async () => { diff --git a/apps/app-frontend/src/components/RowDisplay.vue b/apps/app-frontend/src/components/RowDisplay.vue index 75a184362..ff42de96f 100644 --- a/apps/app-frontend/src/components/RowDisplay.vue +++ b/apps/app-frontend/src/components/RowDisplay.vue @@ -122,7 +122,9 @@ const handleProjectClick = (event, passedInstance) => { const handleOptionsClick = async (args) => { switch (args.option) { case 'play': - await run(args.item.path).catch(handleSevereError) + await run(args.item.path).catch((err) => + handleSevereError(err, { profilePath: args.item.path }), + ) mixpanel_track('InstanceStart', { loader: args.item.loader, game_version: args.item.game_version, diff --git a/apps/app-frontend/src/components/ui/ErrorModal.vue b/apps/app-frontend/src/components/ui/ErrorModal.vue index 6e7442e79..4d8ac6b8c 100644 --- a/apps/app-frontend/src/components/ui/ErrorModal.vue +++ b/apps/app-frontend/src/components/ui/ErrorModal.vue @@ -1,5 +1,5 @@ + @@ -223,7 +250,8 @@ function retryDirectoryChange() { v-if=" errorType === 'directory_move' || errorType === 'minecraft_auth' || - errorType === 'state_init' + errorType === 'state_init' || + errorType === 'no_loader_version' " >
diff --git a/apps/app-frontend/src/components/ui/Instance.vue b/apps/app-frontend/src/components/ui/Instance.vue index 4fc5cc396..165e70e5e 100644 --- a/apps/app-frontend/src/components/ui/Instance.vue +++ b/apps/app-frontend/src/components/ui/Instance.vue @@ -40,7 +40,9 @@ const checkProcess = async () => { const play = async (e, context) => { e?.stopPropagation() modLoading.value = true - await run(props.instance.path).catch(handleSevereError) + await run(props.instance.path).catch((err) => + handleSevereError(err, { profilePath: props.instance.path }), + ) modLoading.value = false mixpanel_track('InstancePlay', { diff --git a/apps/app-frontend/src/pages/instance/Index.vue b/apps/app-frontend/src/pages/instance/Index.vue index d414845bb..3042e713b 100644 --- a/apps/app-frontend/src/pages/instance/Index.vue +++ b/apps/app-frontend/src/pages/instance/Index.vue @@ -179,7 +179,7 @@ const startInstance = async (context) => { await run(route.params.id) playing.value = true } catch (err) { - handleSevereError(err) + handleSevereError(err, { profilePath: route.params.id }) } loading.value = false diff --git a/apps/app-frontend/src/store/error.js b/apps/app-frontend/src/store/error.js index 0715c0e90..6c3c0c12e 100644 --- a/apps/app-frontend/src/store/error.js +++ b/apps/app-frontend/src/store/error.js @@ -8,14 +8,14 @@ export const useError = defineStore('errorsStore', { setErrorModal(ref) { this.errorModal = ref }, - showError(error, closable = true, source = null) { - this.errorModal.show(error, closable, source) + showError(error, context, closable = true, source = null) { + this.errorModal.show(error, context, closable, source) }, }, }) -export const handleSevereError = (err) => { +export const handleSevereError = (err, context) => { const error = useError() - error.showError(err) + error.showError(err, context) console.error(err) } diff --git a/apps/app-playground/src/main.rs b/apps/app-playground/src/main.rs index 7e8c48e45..a50002dc7 100644 --- a/apps/app-playground/src/main.rs +++ b/apps/app-playground/src/main.rs @@ -3,8 +3,6 @@ windows_subsystem = "windows" )] -use theseus::pack::install_from::{get_profile_from_pack, CreatePackLocation}; -use theseus::pack::install_mrpack::install_zipped_mrpack; use theseus::prelude::*; use theseus::profile::create::profile_create; @@ -64,39 +62,21 @@ async fn main() -> theseus::Result<()> { println!("Creating/adding profile."); - // let name = "Example".to_string(); - // let game_version = "1.21".to_string(); - // let modloader = ModLoader::Fabric; - // let loader_version = "stable".to_string(); + let name = "Example".to_string(); + let game_version = "1.16.1".to_string(); + let modloader = ModLoader::Forge; + let loader_version = "stable".to_string(); - let pack = CreatePackLocation::FromVersionId { - project_id: "1KVo5zza".to_string(), - version_id: "lKloE8SA".to_string(), - title: "Fabulously Optimized".to_string(), - icon_url: Some("https://cdn.modrinth.com/data/1KVo5zza/d8152911f8fd5d7e9a8c499fe89045af81fe816e.png".to_string()), - }; - - let profile = get_profile_from_pack(pack.clone()); let profile_path = profile_create( - profile.name, - profile.game_version, - profile.modloader, - profile.loader_version, + name, + game_version, + modloader, + Some(loader_version), None, None, None, ) .await?; - install_zipped_mrpack(pack, profile_path.to_string()).await?; - - let projects = profile::get_projects(&profile_path, None).await?; - - for (path, file) in projects { - println!( - "{path} {} {:?} {:?}", - file.file_name, file.update_version_id, file.metadata - ) - } println!("running"); // Run a profile, running minecraft and store the RwLock to the process diff --git a/apps/app/Cargo.toml b/apps/app/Cargo.toml index d1b2a19ed..2acee95a4 100644 --- a/apps/app/Cargo.toml +++ b/apps/app/Cargo.toml @@ -28,7 +28,7 @@ tokio = { version = "1", features = ["full"] } thiserror = "1.0" tokio-stream = { version = "0.1", features = ["fs"] } futures = "0.3" -daedalus = "0.2.2" +daedalus = "0.2.3" chrono = "0.4.26" dirs = "5.0.1" diff --git a/packages/app-lib/Cargo.toml b/packages/app-lib/Cargo.toml index f9b64f5b6..669c5bc01 100644 --- a/packages/app-lib/Cargo.toml +++ b/packages/app-lib/Cargo.toml @@ -24,7 +24,7 @@ urlencoding = "2.1.3" dashmap = { version = "6.0.1", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] } -daedalus = { version = "0.2.2" } +daedalus = { version = "0.2.3" } dirs = "5.0.1" regex = "1.5" diff --git a/packages/app-lib/src/launcher/mod.rs b/packages/app-lib/src/launcher/mod.rs index f4719f39c..43f34bced 100644 --- a/packages/app-lib/src/launcher/mod.rs +++ b/packages/app-lib/src/launcher/mod.rs @@ -227,13 +227,32 @@ pub async fn install_minecraft( .position(|x| x.id == "22w16a") .unwrap_or(0); - let loader_version = get_loader_version_from_profile( + let mut loader_version = get_loader_version_from_profile( &profile.game_version, profile.loader, profile.loader_version.as_deref(), ) .await?; + // If no loader version is selected, try to select the stable version! + if profile.loader != ModLoader::Vanilla && loader_version.is_none() { + loader_version = get_loader_version_from_profile( + &profile.game_version, + profile.loader, + Some("stable"), + ) + .await?; + + let loader_version_id = loader_version.clone(); + crate::api::profile::edit(&profile.path, |prof| { + prof.loader_version = + loader_version_id.clone().map(|x| x.id.clone()); + + async { Ok(()) } + }) + .await?; + } + let version_jar = loader_version.as_ref().map_or(version.id.clone(), |it| { format!("{}-{}", version.id.clone(), it.id.clone()) @@ -455,6 +474,14 @@ pub async fn launch_minecraft( ) .await?; + if profile.loader != ModLoader::Vanilla && loader_version.is_none() { + return Err(crate::ErrorKind::LauncherError(format!( + "No loader version selected for {}", + profile.loader.as_str() + )) + .into()); + } + let version_jar = loader_version.as_ref().map_or(version.id.clone(), |it| { format!("{}-{}", version.id.clone(), it.id.clone())