From 9ae2c8b85968ab1241ee479bc8d93892b036e3b3 Mon Sep 17 00:00:00 2001 From: alterwain Date: Sat, 15 Mar 2025 00:55:38 +0300 Subject: [PATCH] modified: src/launcher.rs modified: src/main.rs new file: src/www/icons/beta.png new file: src/www/icons/glowstone.png deleted: src/www/icons/new_era.png modified: src/www/icons/release.png --- src/launcher.rs | 37 +++++++++++++++++++++++++----------- src/main.rs | 1 + src/www/icons/beta.png | Bin 0 -> 266 bytes src/www/icons/glowstone.png | Bin 0 -> 283 bytes src/www/icons/new_era.png | Bin 263 -> 0 bytes src/www/icons/release.png | Bin 266 -> 263 bytes 6 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 src/www/icons/beta.png create mode 100644 src/www/icons/glowstone.png delete mode 100644 src/www/icons/new_era.png diff --git a/src/launcher.rs b/src/launcher.rs index 9439340..12126da 100644 --- a/src/launcher.rs +++ b/src/launcher.rs @@ -73,7 +73,14 @@ impl Launcher { p.push("client.json"); if let Ok(data) = std::fs::read(p) { let config: VersionConfig = serde_json::from_slice(&data).unwrap(); - v.push((config.id, config.r#type, format!("data:image/png;base64,{}", BASE64_STANDARD.encode(include_bytes!("www/icons/alpha.png"))))); + let c_type = config.r#type; + let c_type = c_type.as_str(); + v.push((config.id, c_type.to_string(), format!("data:image/png;base64,{}", BASE64_STANDARD.encode(match c_type { + "old_alpha" => include_bytes!("www/icons/alpha.png").to_vec(), + "old_beta" => include_bytes!("www/icons/beta.png").to_vec(), + "release" | "snapshot" => include_bytes!("www/icons/release.png").to_vec(), + _ => include_bytes!("www/icons/glowstone.png").to_vec() + })))); } } } @@ -135,8 +142,10 @@ impl Launcher { game_dir.push("instances"); game_dir.push(&instance_name); game_dir.push("data"); - println!("Username: {}", self.config.user_name); - cmd.args(&["--username", &self.config.user_name, "--version", &instance_name, "--gameDir", game_dir.to_str().unwrap(), "--assetsDir", "D:\\Documents\\RustroverProjects\\XCraft\\xcraft\\assets", "--assetIndex", &config.assetIndex.id, "--uuid", "51820246d9fe372b81592602a5239ad9", "--accessToken", "51820246d9fe372b81592602a5239ad9", "--userProperties", "{}", "--userType", "legacy", "--width", "925", "--height", "530"]); + + let mut assets_dir = self.config.launcher_dir(); + assets_dir.push("assets"); + cmd.args(&["--username", &self.config.user_name, "--version", &instance_name, "--gameDir", game_dir.to_str().unwrap(), "--assetsDir", assets_dir.to_str().unwrap(), "--assetIndex", &config.assetIndex.id, "--uuid", "51820246d9fe372b81592602a5239ad9", "--accessToken", "51820246d9fe372b81592602a5239ad9", "--userProperties", "{}", "--userType", "mojang", "--width", "925", "--height", "530"]); cmd.spawn(); } } @@ -177,26 +186,30 @@ impl Launcher { for i in 0..config.libraries.len() { let library = &config.libraries[i]; if let Some(artifact) = &library.downloads.artifact { - overall_size += artifact.size as usize; let mut dl_path = libraries.clone(); let mut dl_pp = libraries.clone(); dl_pp.push(library.to_pathbuf_path()); let _ = std::fs::create_dir_all(dl_pp); dl_path.push(library.to_pathbuf_file()); - let _ = util::download_file(&artifact.url, dl_path.to_str().unwrap(), sx.clone(), "Downloading libraries"); - cnt += 1; + if File::open(dl_path.to_str().unwrap()).await.is_err() { + overall_size += artifact.size as usize; + let _ = util::download_file(&artifact.url, dl_path.to_str().unwrap(), sx.clone(), "Downloading libraries"); + cnt += 1; + } } if let Some(classifiers) = &library.downloads.classifiers { if let Some(natives) = &classifiers.natives { - overall_size += natives.size as usize; let mut dl_path = libraries.clone(); dl_path.push(&natives.path); let t_p = dl_path.to_str().unwrap().split("/").collect::>(); let t_p = t_p[..t_p.len()-1].join("/"); let _ = std::fs::create_dir_all(&t_p); - let _ = util::download_file(&natives.url, dl_path.to_str().unwrap(), sx.clone(), "Downloading natives"); - cnt += 1; + if File::open(dl_path.to_str().unwrap()).await.is_err() { + overall_size += natives.size as usize; + let _ = util::download_file(&natives.url, dl_path.to_str().unwrap(), sx.clone(), "Downloading natives"); + cnt += 1; + } } } } @@ -233,8 +246,10 @@ impl Launcher { single_object_path.push(asset.to_small_path()); std::fs::create_dir_all(single_object_path); - util::download_file(&asset.to_url(), single_object.to_str().unwrap(), sx.clone(), "Downloading assets objects"); - cnt += 1; + if File::open(single_object.to_str().unwrap()).await.is_err() { + util::download_file(&asset.to_url(), single_object.to_str().unwrap(), sx.clone(), "Downloading assets objects"); + cnt += 1; + } } tokio::spawn(async move { diff --git a/src/main.rs b/src/main.rs index d0be580..5478e60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -99,6 +99,7 @@ async fn main() { if !launcher.is_config_exist() { responder.respond(Response::new(serde_json::to_vec(&UIMessage { params: vec!["show_login".to_string()] }).unwrap())) } else { + launcher.load_config(); responder.respond(Response::new(serde_json::to_vec(&UIMessage { params: vec!["show_add".to_string(), "sidebar_on".to_string()] }).unwrap())) } } diff --git a/src/www/icons/beta.png b/src/www/icons/beta.png new file mode 100644 index 0000000000000000000000000000000000000000..617d353e0d67a14a2952b2a98375eb8a50b97d79 GIT binary patch literal 266 zcmV+l0rmcgP)7w`V=NDEI+d2EruJ8Nt`?O29*Y((K z=DVK`tGLh7MTtz%ds&v@Ga&DZ$;xQ1!Z)iihj}Hm*4l8eo1~Im3;+ie&}VWdpbDk0 z+*Vd{tJH?~A!2frcub(;r0KIVImhR2X8sP4PM&T#KQlJngXEsPNu_c;# zj2A0tbfmyB_f1S^g6x^QT2YWaZ|9A0rZL;l$|NdG{#j@PkUL9jyh`*lke~QTKLZdW*|pr)|t351+rN9f>oG=xG^S; zN?R0VuEL%fXg$JI*`Jp7!l(s{*(XSg4CK`5;H2`IBJ!CW;NUeKm^A9Uc2&1@2=`)2 zT~+JA=gS23A5=4=j=|J`>e9i_)V0Mg9<@)l;cs5sBAYPiKTx$;n~|IaQ{s@2Zf%j4 h2{ literal 0 HcmV?d00001 diff --git a/src/www/icons/new_era.png b/src/www/icons/new_era.png deleted file mode 100644 index 710fef8eb3df53dad80c2ed44cd467cbd07b1c92..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 263 zcmV+i0r>ujP)zX}k5~RurpC zAILb*Esv+tVR0_+!m<0_1K8Aa8Uq(2rU3yCKt2rM%FPsJ zVje)gF_;r)B`x-ce-l-#Cyj|ygG{WkJ}c%h&>l>Qy_txcCQgafgnTuiAgkHI!v-br zN?F60!|b`nVD9&6GY2IAzCp#_0~%HXeVQ?`mcw5gCBOwhpliZ8kAHXeGMb9r9rpkL N002ovPDHLkV1k%@k&09zeb^m=k9uE%t|h6J%AaCyj|ygG{WkJ}c%h z&>l>Qy_txcCQgafgnTuiAgkHI!v-brN?F60!|b`nVD9&6GY2IAzCp#_0~%HXeVQ?` lmcw5gCBOwhpliZ8kAHXeGMb9r9rpkL002ovPDHLkV1mmKX&L|k delta 238 zcmViA>OYS(f25An%IF%4n{_H>)v+ zc_p;g+HkO&q>^0>00$M&XL2W?3Z<{yR#tMW)Q0yVVseytOlP3tr0KIVImhR2X8sP4 zPM&T#KQlJngXEsPNu_c;#j2A0tbfmyB_f1S^g6x^QT2YWaZ|9A0rZL;l o$|NdG{#j@PkUL