Skip to content

Commit

Permalink
Show an error when trying to install bix < 6 for il2cpp game; Fix an …
Browse files Browse the repository at this point in the history
…error when parsing bix 5.*.* dll
  • Loading branch information
funlennysub committed Oct 16, 2022
1 parent 835fbde commit fce10a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions bepinex_helpers/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ pub fn get_dll_version(path: PathBuf) -> Result<Version, Box<dyn error::Error>>
.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::<Vec<&str>>()[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())
}
9 changes: 7 additions & 2 deletions bepinex_installer/src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -147,14 +147,19 @@ 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(
Duration::from_secs(5),
)
};

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
Expand Down
2 changes: 1 addition & 1 deletion bepinex_sources/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit fce10a5

Please sign in to comment.