Skip to content

Commit

Permalink
core: 增加 NeoForge 安装及解析支持
Browse files Browse the repository at this point in the history
scl-gui-widgets: 修正 DownloadModuleItem 组件问题
  • Loading branch information
Steve-xmh committed Feb 16, 2024
1 parent b67e308 commit 6e8bfc6
Show file tree
Hide file tree
Showing 7 changed files with 566 additions and 15 deletions.
2 changes: 1 addition & 1 deletion scl-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rust-version = "1.75"
anyhow = "^1.0"
base64 = "^0.21"
futures = "^0.3.21"
surf = { version = "^2.3", default-features = false, features = [ "h1-client", "encoding" ] }
surf = { version = "^2.3", default-features = false, features = [ "h1-client" ] }
image = { version = "^0.24", default-features = false, features = ["jpeg", "png", "gif", "bmp", "rgb"] }
webp = "^0.2"
nom = "^7.1"
Expand Down
14 changes: 14 additions & 0 deletions scl-core/src/download/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod fabric;
pub mod forge;
pub mod mcmod;
pub mod modrinth;
pub mod neoforge;
pub mod optifine;
pub mod quiltmc;
pub mod structs;
Expand All @@ -17,6 +18,7 @@ use anyhow::Context;
pub use authlib::AuthlibDownloadExt;
pub use fabric::FabricDownloadExt;
pub use forge::ForgeDownloadExt;
pub use neoforge::NeoForgeDownloadExt;
pub use optifine::OptifineDownloadExt;
pub use quiltmc::QuiltMCDownloadExt;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -249,13 +251,15 @@ pub trait GameDownload:
FabricDownloadExt + ForgeDownloadExt + VanillaDownloadExt + QuiltMCDownloadExt
{
/// 根据参数安装一个游戏,允许安装模组加载器
#[allow(clippy::too_many_arguments)]
async fn download_game(
&self,
version_name: &str,
vanilla: VersionInfo,
fabric: &str,
quiltmc: &str,
forge: &str,
neoforge: &str,
optifine: &str,
) -> DynResult;
}
Expand All @@ -268,6 +272,7 @@ impl<R: Reporter> GameDownload for Downloader<R> {
fabric: &str,
quiltmc: &str,
forge: &str,
neoforge: &str,
optifine: &str,
) -> DynResult {
self.reporter
Expand Down Expand Up @@ -304,6 +309,15 @@ impl<R: Reporter> GameDownload for Downloader<R> {
.await?;
self.install_forge_post(version_name, &vanilla.id, forge)
.await?;
} else if !neoforge.is_empty() {
self.install_vanilla(&vanilla.id, &vanilla).await?; // NeoForge 安装需要原版,如果安装器没有解析到则会从官方源下载,速度很慢
crate::prelude::inner_future::future::try_zip(
self.install_vanilla(version_name, &vanilla),
self.install_neoforge_pre(version_name, &vanilla.id, neoforge),
)
.await?;
self.install_neoforge_post(version_name, &vanilla.id, neoforge)
.await?;
} else {
self.install_vanilla(version_name, &vanilla).await?;
}
Expand Down

0 comments on commit 6e8bfc6

Please sign in to comment.