Skip to content

Commit

Permalink
Switched to own gh api impl so it's easier to work with; Installer ca…
Browse files Browse the repository at this point in the history
…n now install bepinex
  • Loading branch information
funlennysub committed Oct 16, 2022
1 parent ab44945 commit 835fbde
Show file tree
Hide file tree
Showing 18 changed files with 371 additions and 193 deletions.
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
[workspace]
members = ["bepinex_installer/", "bepinex_helpers/"]
members = ["bepinex_installer/", "bepinex_helpers/", "bepinex_sources/"]

[workspace.dependencies]
semver = "1.0.14"
lazy_static = "1"
lazy_static = "1"

[profile.release]
strip = true
lto = true
panic = "abort"
codegen-units = 1
opt-level = "z"
2 changes: 1 addition & 1 deletion bepinex_helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
[dependencies]
steamlocate = "1"
pelite = "0.9.1"
semver = { workspace = true }
semver.workspace = true
45 changes: 0 additions & 45 deletions bepinex_helpers/src/error.rs

This file was deleted.

41 changes: 19 additions & 22 deletions bepinex_helpers/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,20 @@ use std::{
fmt::Display,
fs,
path::{Path, PathBuf},
str::FromStr,
};
use steamlocate::SteamDir;

use crate::error::Error;

#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub enum GameType {
UnityMono,
UnityIL2CPP,
}

impl ToString for GameType {
fn to_string(&self) -> String {
impl Display for GameType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::UnityMono => "UnityMono".into(),
Self::UnityIL2CPP => "UnityIL2CPP".into(),
}
}
}

impl FromStr for GameType {
type Err = Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"UnityMono" => Ok(Self::UnityMono),
"Mono" => Ok(Self::UnityMono),
"UnityIL2CPP" => Ok(Self::UnityIL2CPP),
"IL2CPP" => Ok(Self::UnityIL2CPP),
_ => Err(Error::invalid_game_type()),
GameType::UnityMono => write!(f, "UnityMono"),
GameType::UnityIL2CPP => write!(f, "UnityIL2CPP"),
}
}
}
Expand Down Expand Up @@ -113,6 +96,20 @@ impl Default for Game {
}
}

impl Game {
pub fn to_query(&self, target: &Version) -> String {
match target.major {
6 => format!(
"BepInEx_{}_{}_{}.zip",
self.ty.as_ref().unwrap(),
self.arch,
target
),
_ => format!("BepInEx_{}_{}.0.zip", self.arch, target),
}
}
}

impl Display for Game {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name)
Expand All @@ -132,7 +129,7 @@ pub fn get_unity_games() -> Result<Vec<Game>, Box<dyn error::Error>> {
true => {
let mut game = Game {
name: app.name.clone().unwrap_or_default(),
arch: "a".to_owned(),
arch: "x64".to_owned(),
path: app.path.to_owned(),
bepinex_version: None,
ty: None,
Expand Down
1 change: 0 additions & 1 deletion bepinex_helpers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pub mod error;
pub mod game;
7 changes: 4 additions & 3 deletions bepinex_installer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ edition = "2021"

[dependencies]
bepinex_helpers = { path = "../bepinex_helpers" }
tokio = { version = "1", features = ["full"] }
octocrab = "0.17.0"
bepinex_sources = { path = "../bepinex_sources" }
eframe = "0.19.0"
egui_extras = "0.19.0"
semver = { workspace = true }
lazy_static = { workspace = true }
lazy_static = { workspace = true }
reqwest = { version = "0.11.12", features = ["json", "blocking"] }
egui-toast = "0.4.0"
80 changes: 0 additions & 80 deletions bepinex_installer/src/bepinex.rs

This file was deleted.

Loading

0 comments on commit 835fbde

Please sign in to comment.