feat: add 'games' to the manifest

This commit is contained in:
2025-04-19 20:09:32 +00:00
parent 3479804dca
commit dbbd80c6c3
5 changed files with 39 additions and 29 deletions

View File

@ -5,6 +5,7 @@
- Chunithm: added Lumi+ patches
- Added a button linking to the profile config folder
- Fixed the button linking to the data folder showing up when the folder does not exist
- Uninstalled tool packages are no longer automatically deselected, as that caused issues
## 0.11.1

View File

@ -14,7 +14,10 @@ pub struct PackageManifest {
pub dependencies: BTreeSet<PkgKeyVersion>,
#[serde(default)]
pub installers: Vec<BTreeMap<String, serde_json::Value>>
pub installers: Vec<BTreeMap<String, serde_json::Value>>,
#[serde(default)]
pub games: Option<Vec<Game>>,
}
pub type PackageList = BTreeMap<PkgKey, PackageListEntry>;

View File

@ -5,30 +5,30 @@ use crate::{model::{misc::{ConfigHook, ConfigHookAime, ConfigHookAimeUnit, Confi
use crate::pkg_store::PackageStore;
impl Segatools {
pub fn fix(&mut self, store: &PackageStore) {
macro_rules! remove_if_nonpresent {
($item:expr,$key:expr,$emptyval:expr,$store:expr) => {
if let Ok(pkg) = $store.get($key) {
if pkg.loc.is_none() {
$item = $emptyval;
}
} else {
$item = $emptyval;
}
}
}
pub fn fix(&mut self, _store: &PackageStore) {
// macro_rules! remove_if_nonpresent {
// ($item:expr,$key:expr,$emptyval:expr,$store:expr) => {
// if let Ok(pkg) = $store.get($key) {
// if pkg.loc.is_none() {
// $item = $emptyval;
// }
// } else {
// $item = $emptyval;
// }
// }
// }
if let Some(key) = &self.hook {
remove_if_nonpresent!(self.hook, key, None, store);
}
if let IOSelection::Custom(key) = &self.io2 {
remove_if_nonpresent!(self.io2, key, IOSelection::default(), store);
}
match &self.aime {
Aime::AMNet(key) => remove_if_nonpresent!(self.aime, key, Aime::BuiltIn, store),
Aime::Other(key) => remove_if_nonpresent!(self.aime, key, Aime::BuiltIn, store),
_ => {},
}
// if let Some(key) = &self.hook {
// remove_if_nonpresent!(self.hook, key, None, store);
// }
// if let IOSelection::Custom(key) = &self.io2 {
// remove_if_nonpresent!(self.io2, key, IOSelection::default(), store);
// }
// match &self.aime {
// Aime::AMNet(key) => remove_if_nonpresent!(self.aime, key, Aime::BuiltIn, store),
// Aime::Other(key) => remove_if_nonpresent!(self.aime, key, Aime::BuiltIn, store),
// _ => {},
// }
}
pub fn load_from_ini(&mut self, ini: &Ini, config_dir: impl AsRef<Path>) -> Result<()> {
log::debug!("loading sgt");

View File

@ -120,7 +120,7 @@ impl Package {
})
}
pub async fn from_dir(dir: PathBuf, source: PackageSource) -> Result<Package> {
pub async fn from_dir(dir: PathBuf, source: PackageSource) -> Result<(Package, Option<Vec<Game>>)> {
let str = fs::read_to_string(dir.join("manifest.json")).await?;
let mft: local::PackageManifest = serde_json::from_str(&str)?;
@ -133,7 +133,7 @@ impl Package {
let status = Self::parse_status(&mft, &dir);
let dependencies = Self::sanitize_deps(mft.dependencies);
Ok(Package {
Ok((Package {
namespace: Self::dir_to_namespace(&dir)?,
name: mft.name.clone(),
description: mft.description.clone(),
@ -146,7 +146,7 @@ impl Package {
}),
rmt: None,
source
})
}, mft.games))
}
pub fn key(&self) -> PkgKey {

View File

@ -83,7 +83,7 @@ impl PackageStore {
pub async fn reload_package(&mut self, key: PkgKey) {
let dir = util::pkg_dir().join(&key.0);
if let Ok(pkg) = Package::from_dir(dir, PackageSource::Rainy).await {
if let Ok((pkg, _)) = Package::from_dir(dir, PackageSource::Rainy).await {
self.update_nonremote(key, pkg);
} else {
log::error!("couldn't reload {}", key);
@ -102,7 +102,13 @@ impl PackageStore {
}
while let Some(res) = futures.join_next().await {
if let Ok(Ok(pkg)) = res {
if let Ok(Ok((pkg, locally_declared_games))) = res {
if let Some(games) = locally_declared_games {
self.meta_list.insert(pkg.key(), PackageListEntry {
version: pkg.loc.as_ref().unwrap().version.clone(),
games
});
}
self.update_nonremote(pkg.key(), pkg);
}
}