mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
feat: Add itch.io as possible platform
This commit is contained in:
Generated
+13
@@ -200,6 +200,18 @@ version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82cf52a69f51e16cffda2993f68b33a0fafd0d664163f87fa80e5e4fec2fc232"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crc32fast",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fltk"
|
||||
version = "1.2.3"
|
||||
@@ -1091,6 +1103,7 @@ dependencies = [
|
||||
"config",
|
||||
"failure",
|
||||
"fl2rust",
|
||||
"flate2",
|
||||
"fltk",
|
||||
"nom 7.0.0",
|
||||
"nom_locate",
|
||||
|
||||
@@ -17,6 +17,7 @@ failure = "^0.1.8"
|
||||
fltk = { version = "^1.2", features = ["fltk-bundled"], optional = true }
|
||||
nom = "^7.0.*"
|
||||
nom_locate = "^3.0.*"
|
||||
flate2 = "^1.0.22"
|
||||
|
||||
[build-dependencies]
|
||||
fl2rust = { version = "0.4", optional = true }
|
||||
|
||||
@@ -27,7 +27,7 @@ pub enum EpicGamesManifestsError {
|
||||
ReadDirError { path: String, error: std::io::Error },
|
||||
}
|
||||
|
||||
pub fn get_egs_manifests(
|
||||
pub(crate) fn get_egs_manifests(
|
||||
settings: &EpicGamesLauncherSettings,
|
||||
) -> Result<Vec<ManifestItem>, EpicGamesManifestsError> {
|
||||
use EpicGamesManifestsError::*;
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use steam_shortcuts_util::{Shortcut, shortcut::ShortcutOwned};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct ManifestItem {
|
||||
pub(crate) struct ManifestItem {
|
||||
#[serde(alias = "LaunchExecutable")]
|
||||
pub launch_executable: String,
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ use nom::{
|
||||
IResult,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct DbPaths<'a> {
|
||||
pub(crate) base_path: &'a str,
|
||||
pub(crate) path: &'a str,
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
use super::butler_db_parser::*;
|
||||
use super::receipt::Receipt;
|
||||
use super::{ItchGame, ItchSettings};
|
||||
use crate::platform::Platform;
|
||||
use _core::iter::FromIterator;
|
||||
use failure::*;
|
||||
use flate2::read::GzDecoder;
|
||||
use std::collections::HashSet;
|
||||
use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
|
||||
pub struct ItchPlatform {
|
||||
@@ -36,7 +41,7 @@ impl Platform<ItchGame, ItchErrors> for ItchPlatform {
|
||||
|
||||
let shortcut_bytes = std::fs::read(&itch_db_location).unwrap();
|
||||
|
||||
let res = match parse_butler_db(&shortcut_bytes) {
|
||||
let paths = match parse_butler_db(&shortcut_bytes) {
|
||||
Ok((_, shortcuts)) => Ok(shortcuts),
|
||||
Err(e) => Err(ItchErrors::ParseError {
|
||||
error: e.to_string(),
|
||||
@@ -44,18 +49,35 @@ impl Platform<ItchGame, ItchErrors> for ItchPlatform {
|
||||
}),
|
||||
}?;
|
||||
|
||||
let res = res
|
||||
.iter()
|
||||
.map(|paths| ItchGame {
|
||||
install_path: paths.base_path.to_owned(),
|
||||
executable: paths.path.to_owned(),
|
||||
title: paths.path.to_owned(),
|
||||
})
|
||||
.collect();
|
||||
//This is done to remove douplicates
|
||||
let paths: HashSet<&DbPaths> = HashSet::from_iter(paths.iter());
|
||||
|
||||
let res = paths.iter().filter_map(|e| dbpath_to_game(*e)).collect();
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
fn dbpath_to_game(paths: &DbPaths<'_>) -> Option<ItchGame> {
|
||||
let recipt = Path::new(paths.base_path)
|
||||
.join(".itch")
|
||||
.join("receipt.json.gz");
|
||||
if !&recipt.exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let gz_bytes = std::fs::read(&recipt).unwrap();
|
||||
let mut d = GzDecoder::new(gz_bytes.as_slice());
|
||||
let mut s = String::new();
|
||||
d.read_to_string(&mut s).unwrap();
|
||||
|
||||
let receipt_op: Option<Receipt> = serde_json::from_str(&s).ok();
|
||||
receipt_op.map(|re| ItchGame {
|
||||
install_path: paths.base_path.to_owned(),
|
||||
executable: paths.path.to_owned(),
|
||||
title: re.game.title,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_default_location() -> String {
|
||||
//If we don't have a home drive we have to just die
|
||||
|
||||
@@ -2,6 +2,7 @@ mod settings;
|
||||
mod itch_game;
|
||||
mod itch_platform;
|
||||
mod butler_db_parser;
|
||||
mod receipt;
|
||||
|
||||
pub use settings::*;
|
||||
pub use itch_game::*;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub(crate) struct Receipt{
|
||||
pub game:Game,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub(crate) struct Game{
|
||||
pub title:String
|
||||
}
|
||||
Reference in New Issue
Block a user