From fce10a55b702955b0731978f4f211b29b5ac2abe Mon Sep 17 00:00:00 2001 From: funlennysub <26184007+funlennysub@users.noreply.github.com> Date: Sun, 16 Oct 2022 21:23:21 +0300 Subject: [PATCH] Show an error when trying to install bix < 6 for il2cpp game; Fix an error when parsing bix 5.*.* dll --- bepinex_helpers/src/game.rs | 6 ++++++ bepinex_installer/src/installer.rs | 9 +++++++-- bepinex_sources/examples/basic.rs | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bepinex_helpers/src/game.rs b/bepinex_helpers/src/game.rs index d414459..8976cde 100644 --- a/bepinex_helpers/src/game.rs +++ b/bepinex_helpers/src/game.rs @@ -169,6 +169,12 @@ pub fn get_dll_version(path: PathBuf) -> Result> .get("ProductVersion") .ok_or("Failed to get prod. version")?; + // "Converts" 5.*.*.* into 5.*.* becuase BepInEx devs decided to add build num 💀 + if version.starts_with('5') && version.split('.').count() > 3 { + let ver = version.split('.').into_iter().collect::>()[0..3].join("."); + return Ok(Version::parse(&ver).unwrap()); + } + // TODO: Do some proper handling of invalid semver that bix has in older versions 💀 Ok(Version::parse(version).unwrap()) } diff --git a/bepinex_installer/src/installer.rs b/bepinex_installer/src/installer.rs index 9781eef..be862e2 100644 --- a/bepinex_installer/src/installer.rs +++ b/bepinex_installer/src/installer.rs @@ -117,7 +117,7 @@ impl App for Installer { == Some(GameType::UnityIL2CPP) && selected_bix.version >= *MIN_IL2CPP_STABLE_VERSION; - let enabled = supported_ver + let supported = supported_ver || (selected_game.ty != Some(GameType::UnityIL2CPP)); strip.cell(|ui| { @@ -147,7 +147,7 @@ impl App for Installer { strip.cell(|ui| { ui.centered_and_justified(|ui| { let install_btn = Button::new("Install").small(); - if ui.add_enabled(enabled, install_btn).clicked() { + if ui.add(install_btn).clicked() { let options = ToastOptions { show_icon: true, ..ToastOptions::with_duration( @@ -155,6 +155,11 @@ impl App for Installer { ) }; + if !supported { + toasts.error(format!("Minimal BepInEx for this game is {}", *MIN_IL2CPP_STABLE_VERSION), options); + return; + } + let query = selected_game.to_query(&selected_bix.version); let res = selected_bix diff --git a/bepinex_sources/examples/basic.rs b/bepinex_sources/examples/basic.rs index 646d851..293c5dc 100644 --- a/bepinex_sources/examples/basic.rs +++ b/bepinex_sources/examples/basic.rs @@ -2,7 +2,7 @@ use bepinex_sources::{github::GitHubApi, models::bleeding_edge::bepinex::BepInEx use semver::Version; fn main() -> anyhow::Result<()> { - let min_ver = Version::parse("5.4.21").unwrap(); + let min_ver = Version::parse("5.4.11").unwrap(); let mut gh = GitHubApi::new("BepInEx", "BepInEx"); gh.set_pre_releases(true); gh.set_min_tag(Some(min_ver));