feat: amnet integration
This commit is contained in:
@ -3,6 +3,7 @@ use derive_more::Display;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::BTreeSet, path::{Path, PathBuf}};
|
||||
use tokio::fs;
|
||||
use enumflags2::{bitflags, BitFlags};
|
||||
use crate::{model::{local::{self, PackageManifest}, rainy}, util};
|
||||
|
||||
// {namespace}-{name}
|
||||
@ -24,25 +25,33 @@ pub struct Package {
|
||||
pub rmt: Option<Remote>
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Kind {
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Status {
|
||||
Unchecked,
|
||||
Unsupported,
|
||||
#[default] Mod,
|
||||
Hook,
|
||||
IO,
|
||||
OK(BitFlags<Feature>)
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize)]
|
||||
#[bitflags]
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Feature {
|
||||
Hook,
|
||||
GameIO,
|
||||
Aime,
|
||||
AMNet,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Local {
|
||||
pub version: String,
|
||||
pub path: PathBuf,
|
||||
pub dependencies: BTreeSet<PkgKey>,
|
||||
pub kind: Kind
|
||||
pub status: Status,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Remote {
|
||||
pub version: String,
|
||||
@ -90,7 +99,7 @@ impl Package {
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
|
||||
let kind = Self::parse_kind(&mft);
|
||||
let status = Self::parse_status(&mft);
|
||||
let dependencies = Self::sanitize_deps(mft.dependencies);
|
||||
|
||||
Ok(Package {
|
||||
@ -101,7 +110,7 @@ impl Package {
|
||||
loc: Some(Local {
|
||||
version: mft.version_number,
|
||||
path: dir.to_owned(),
|
||||
kind,
|
||||
status,
|
||||
dependencies
|
||||
}),
|
||||
rmt: None
|
||||
@ -174,24 +183,31 @@ impl Package {
|
||||
res
|
||||
}
|
||||
|
||||
fn parse_kind(mft: &PackageManifest) -> Kind {
|
||||
fn parse_status(mft: &PackageManifest) -> Status {
|
||||
if mft.installers.len() == 0 {
|
||||
return Kind::Mod;//Unchecked
|
||||
return Status::OK(BitFlags::default());//Unchecked
|
||||
} else if mft.installers.len() == 1 {
|
||||
if let Some(serde_json::Value::String(id)) = &mft.installers[0].get("identifier") {
|
||||
if id == "rainycolor" {
|
||||
return Kind::Mod
|
||||
return Status::OK(BitFlags::default());
|
||||
} else if id == "segatools" {
|
||||
// Multiple features in the same dll (yubideck etc.) should be supported at some point
|
||||
let mut flags = BitFlags::default();
|
||||
if let Some(serde_json::Value::String(module)) = mft.installers[0].get("module") {
|
||||
if module.ends_with("hook") {
|
||||
return Kind::Hook;
|
||||
flags |= Feature::Hook;
|
||||
} else if module == "amnet" {
|
||||
flags |= Feature::AMNet | Feature::Aime;
|
||||
} else if module == "aimeio" {
|
||||
flags |= Feature::Aime;
|
||||
} else if module.ends_with("io") {
|
||||
return Kind::IO;
|
||||
flags |= Feature::GameIO;
|
||||
}
|
||||
}
|
||||
return Status::OK(flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Kind::Unsupported
|
||||
Status::Unsupported
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user