mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Add uplay syncrhonization
This commit is contained in:
@@ -11,6 +11,9 @@ create_symlinks = true
|
|||||||
enabled = false
|
enabled = false
|
||||||
create_symlinks = true
|
create_symlinks = true
|
||||||
|
|
||||||
|
[uplay]
|
||||||
|
enabled = false
|
||||||
|
|
||||||
[legendary]
|
[legendary]
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform {
|
|||||||
let shortcuts_res = self.get_shortcuts();
|
let shortcuts_res = self.get_shortcuts();
|
||||||
match shortcuts_res {
|
match shortcuts_res {
|
||||||
Ok(_) => SettingsValidity::Valid,
|
Ok(_) => SettingsValidity::Valid,
|
||||||
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
Err(err) => SettingsValidity::Invalid {
|
||||||
|
reason: format!("{}", err),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ pub fn get_default_location() -> Option<PathBuf> {
|
|||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
let path = match location_from_registry(){
|
let path = match location_from_registry() {
|
||||||
Some(path) => path,
|
Some(path) => path,
|
||||||
None => guess_default_location()
|
None => guess_default_location(),
|
||||||
};
|
};
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
Some(path)
|
Some(path)
|
||||||
|
|||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
|
mod epic_platform;
|
||||||
mod get_manifests;
|
mod get_manifests;
|
||||||
mod manifest_item;
|
mod manifest_item;
|
||||||
mod settings;
|
mod settings;
|
||||||
mod epic_platform;
|
|
||||||
|
|
||||||
pub(crate) use manifest_item::*;
|
|
||||||
use get_manifests::get_egs_manifests;
|
|
||||||
pub use get_manifests::get_default_location;
|
|
||||||
pub use settings::EpicGamesLauncherSettings;
|
|
||||||
pub use epic_platform::*;
|
pub use epic_platform::*;
|
||||||
|
pub use get_manifests::get_default_location;
|
||||||
|
use get_manifests::get_egs_manifests;
|
||||||
|
pub(crate) use manifest_item::*;
|
||||||
|
pub use settings::EpicGamesLauncherSettings;
|
||||||
|
|||||||
+2
-4
@@ -1,6 +1,6 @@
|
|||||||
use serde::{Serialize,Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug,Serialize, Deserialize,Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct EpicGamesLauncherSettings {
|
pub struct EpicGamesLauncherSettings {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub location: Option<String>,
|
pub location: Option<String>,
|
||||||
@@ -8,5 +8,3 @@ pub struct EpicGamesLauncherSettings {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub create_symlinks: bool,
|
pub create_symlinks: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -23,14 +23,13 @@ pub(crate) struct PlayTask {
|
|||||||
pub task_type: String,
|
pub task_type: String,
|
||||||
#[serde(alias = "workingDir")]
|
#[serde(alias = "workingDir")]
|
||||||
pub working_dir: Option<String>,
|
pub working_dir: Option<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct GogShortcut {
|
pub(crate) struct GogShortcut {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub game_folder: String,
|
pub game_folder: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub working_dir:String,
|
pub working_dir: String,
|
||||||
pub game_id: String,
|
pub game_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,9 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
|||||||
let shortcuts_res = self.get_shortcuts();
|
let shortcuts_res = self.get_shortcuts();
|
||||||
match shortcuts_res {
|
match shortcuts_res {
|
||||||
Ok(_) => SettingsValidity::Valid,
|
Ok(_) => SettingsValidity::Valid,
|
||||||
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)},
|
Err(err) => SettingsValidity::Invalid {
|
||||||
|
reason: format!("{}", err),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,5 +7,4 @@ pub struct GogSettings {
|
|||||||
pub wine_c_drive: Option<String>,
|
pub wine_c_drive: Option<String>,
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub create_symlinks: bool,
|
pub create_symlinks: bool,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,9 +64,10 @@ impl Platform<ItchGame, ItchErrors> for ItchPlatform {
|
|||||||
let shortcuts_res = self.get_shortcuts();
|
let shortcuts_res = self.get_shortcuts();
|
||||||
match shortcuts_res {
|
match shortcuts_res {
|
||||||
Ok(_) => SettingsValidity::Valid,
|
Ok(_) => SettingsValidity::Valid,
|
||||||
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
Err(err) => SettingsValidity::Invalid {
|
||||||
|
reason: format!("{}", err),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +103,11 @@ pub fn get_default_location() -> String {
|
|||||||
pub fn get_default_location() -> String {
|
pub fn get_default_location() -> String {
|
||||||
let key = "APPDATA";
|
let key = "APPDATA";
|
||||||
let appdata = std::env::var(key).expect("Expected a APPDATA variable to be defined");
|
let appdata = std::env::var(key).expect("Expected a APPDATA variable to be defined");
|
||||||
Path::new(&appdata).join("itch").to_str().unwrap().to_string()
|
Path::new(&appdata)
|
||||||
|
.join("itch")
|
||||||
|
.to_str()
|
||||||
|
.unwrap()
|
||||||
|
.to_string()
|
||||||
//C:\Users\phili\AppData\Local\itch
|
//C:\Users\phili\AppData\Local\itch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
mod settings;
|
mod butler_db_parser;
|
||||||
mod itch_game;
|
mod itch_game;
|
||||||
mod itch_platform;
|
mod itch_platform;
|
||||||
mod butler_db_parser;
|
|
||||||
mod receipt;
|
mod receipt;
|
||||||
|
mod settings;
|
||||||
|
|
||||||
pub use settings::*;
|
|
||||||
pub use itch_game::*;
|
pub use itch_game::*;
|
||||||
pub use itch_platform::*;
|
pub use itch_platform::*;
|
||||||
|
pub use settings::*;
|
||||||
|
|||||||
+4
-4
@@ -1,11 +1,11 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub(crate) struct Receipt{
|
pub(crate) struct Receipt {
|
||||||
pub game:Game,
|
pub game: Game,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub(crate) struct Game{
|
pub(crate) struct Game {
|
||||||
pub title:String
|
pub title: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use serde::{Serialize,Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct ItchSettings {
|
pub struct ItchSettings {
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ impl Platform<LegendaryGame, Box<dyn Error>> for LegendaryPlatform {
|
|||||||
let shortcuts_res = self.get_shortcuts();
|
let shortcuts_res = self.get_shortcuts();
|
||||||
match shortcuts_res {
|
match shortcuts_res {
|
||||||
Ok(_) => SettingsValidity::Valid,
|
Ok(_) => SettingsValidity::Valid,
|
||||||
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
Err(err) => SettingsValidity::Invalid {
|
||||||
|
reason: format!("{}", err),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
mod legendary_game;
|
mod legendary_game;
|
||||||
mod settings;
|
|
||||||
mod legendary_platform;
|
mod legendary_platform;
|
||||||
|
mod settings;
|
||||||
|
|
||||||
pub use legendary_game::*;
|
pub use legendary_game::*;
|
||||||
pub use settings::*;
|
|
||||||
pub use legendary_platform::*;
|
pub use legendary_platform::*;
|
||||||
|
pub use settings::*;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use serde::{Serialize,Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize,Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub struct LegendarySettings {
|
pub struct LegendarySettings {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub executable: Option<String>,
|
pub executable: Option<String>,
|
||||||
|
|||||||
+2
-2
@@ -5,9 +5,10 @@ mod legendary;
|
|||||||
mod origin;
|
mod origin;
|
||||||
mod platform;
|
mod platform;
|
||||||
mod settings;
|
mod settings;
|
||||||
mod sync;
|
|
||||||
mod steam;
|
mod steam;
|
||||||
mod steamgriddb;
|
mod steamgriddb;
|
||||||
|
mod sync;
|
||||||
|
mod uplay;
|
||||||
|
|
||||||
#[cfg(feature = "ui")]
|
#[cfg(feature = "ui")]
|
||||||
mod ui;
|
mod ui;
|
||||||
@@ -26,4 +27,3 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
sync::run_sync(&settings).await
|
sync::run_sync(&settings).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
mod settings;
|
|
||||||
mod origin_platform;
|
|
||||||
mod origin_game;
|
mod origin_game;
|
||||||
|
mod origin_platform;
|
||||||
|
mod settings;
|
||||||
|
|
||||||
pub use origin_platform::*;
|
pub use origin_platform::*;
|
||||||
pub use settings::*;
|
pub use settings::*;
|
||||||
@@ -67,13 +67,13 @@ impl Platform<OriginGame, OriginErrors> for OriginPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn settings_valid(&self) -> crate::platform::SettingsValidity {
|
fn settings_valid(&self) -> crate::platform::SettingsValidity {
|
||||||
let shortcuts_res = self.get_shortcuts();
|
let shortcuts_res = self.get_shortcuts();
|
||||||
match shortcuts_res {
|
match shortcuts_res {
|
||||||
Ok(_) => SettingsValidity::Valid,
|
Ok(_) => SettingsValidity::Valid,
|
||||||
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
Err(err) => SettingsValidity::Invalid {
|
||||||
|
reason: format!("{}", err),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -16,8 +16,7 @@ where
|
|||||||
fn create_symlinks(&self) -> bool;
|
fn create_symlinks(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum SettingsValidity {
|
||||||
pub enum SettingsValidity{
|
|
||||||
Valid,
|
Valid,
|
||||||
Invalid{reason:String},
|
Invalid { reason: String },
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
egs::EpicGamesLauncherSettings, gog::GogSettings, itch::ItchSettings,
|
egs::EpicGamesLauncherSettings, gog::GogSettings, itch::ItchSettings,
|
||||||
legendary::LegendarySettings, origin::OriginSettings, steam::SteamSettings,
|
legendary::LegendarySettings, origin::OriginSettings, steam::SteamSettings,
|
||||||
steamgriddb::SteamGridDbSettings,
|
steamgriddb::SteamGridDbSettings, uplay::UplaySettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
use config::{Config, ConfigError, Environment, File};
|
use config::{Config, ConfigError, Environment, File};
|
||||||
@@ -18,6 +18,7 @@ pub struct Settings {
|
|||||||
pub steam: SteamSettings,
|
pub steam: SteamSettings,
|
||||||
pub origin: OriginSettings,
|
pub origin: OriginSettings,
|
||||||
pub gog: GogSettings,
|
pub gog: GogSettings,
|
||||||
|
pub uplay: UplaySettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
mod utils;
|
|
||||||
mod settings;
|
mod settings;
|
||||||
|
mod utils;
|
||||||
|
|
||||||
pub use utils::*;
|
|
||||||
pub use settings::SteamSettings;
|
pub use settings::SteamSettings;
|
||||||
|
pub use utils::*;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use serde::{Serialize,Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct SteamSettings{
|
pub struct SteamSettings {
|
||||||
pub location: Option<String>,
|
pub location: Option<String>,
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::{ fs::File, io::Write, path::Path};
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
|
use std::{fs::File, io::Write, path::Path};
|
||||||
|
|
||||||
type SearchMap = DashMap<u32, (String, usize)>;
|
type SearchMap = DashMap<u32, (String, usize)>;
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use std::path::PathBuf;
|
|||||||
use std::{collections::HashMap, path::Path};
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
use futures::{stream, StreamExt};
|
use futures::{stream, StreamExt};
|
||||||
use steamgriddb_api::query_parameters::GridDimentions; // 0.3.1
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use steamgriddb_api::query_parameters::GridDimentions; // 0.3.1
|
||||||
|
|
||||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||||
use steamgriddb_api::Client;
|
use steamgriddb_api::Client;
|
||||||
@@ -18,7 +18,11 @@ use super::CachedSearch;
|
|||||||
|
|
||||||
const CONCURRENT_REQUESTS: usize = 10;
|
const CONCURRENT_REQUESTS: usize = 10;
|
||||||
|
|
||||||
pub async fn download_images_for_users<'b>(settings: &Settings, users: &[SteamUsersInfo], download_animated:bool) {
|
pub async fn download_images_for_users<'b>(
|
||||||
|
settings: &Settings,
|
||||||
|
users: &[SteamUsersInfo],
|
||||||
|
download_animated: bool,
|
||||||
|
) {
|
||||||
let auth_key = &settings.steamgrid_db.auth_key;
|
let auth_key = &settings.steamgrid_db.auth_key;
|
||||||
if let Some(auth_key) = auth_key {
|
if let Some(auth_key) = auth_key {
|
||||||
println!("Checking for game images");
|
println!("Checking for game images");
|
||||||
@@ -76,7 +80,7 @@ async fn search_fo_to_download(
|
|||||||
shortcuts: &[ShortcutOwned],
|
shortcuts: &[ShortcutOwned],
|
||||||
search: &CachedSearch<'_>,
|
search: &CachedSearch<'_>,
|
||||||
client: &Client,
|
client: &Client,
|
||||||
download_animated:bool,
|
download_animated: bool,
|
||||||
) -> Result<Vec<ToDownload>, Box<dyn Error>> {
|
) -> Result<Vec<ToDownload>, Box<dyn Error>> {
|
||||||
let shortcuts_to_search_for = shortcuts.iter().filter(|s| {
|
let shortcuts_to_search_for = shortcuts.iter().filter(|s| {
|
||||||
let images = vec![
|
let images = vec![
|
||||||
@@ -110,7 +114,12 @@ async fn search_fo_to_download(
|
|||||||
for (app_id, search) in search_results_a.into_iter().flatten() {
|
for (app_id, search) in search_results_a.into_iter().flatten() {
|
||||||
search_results.insert(app_id, search);
|
search_results.insert(app_id, search);
|
||||||
}
|
}
|
||||||
let types = vec![ImageType::Logo, ImageType::Hero, ImageType::Grid, ImageType::BigPicture];
|
let types = vec![
|
||||||
|
ImageType::Logo,
|
||||||
|
ImageType::Hero,
|
||||||
|
ImageType::Grid,
|
||||||
|
ImageType::BigPicture,
|
||||||
|
];
|
||||||
let mut to_download = vec![];
|
let mut to_download = vec![];
|
||||||
for image_type in types {
|
for image_type in types {
|
||||||
let mut images_needed = shortcuts
|
let mut images_needed = shortcuts
|
||||||
@@ -122,41 +131,39 @@ async fn search_fo_to_download(
|
|||||||
.filter_map(|s| search_results.get(&s.app_id))
|
.filter_map(|s| search_results.get(&s.app_id))
|
||||||
.copied()
|
.copied()
|
||||||
.collect();
|
.collect();
|
||||||
use steamgriddb_api::query_parameters::QueryType::*;
|
|
||||||
use steamgriddb_api::query_parameters::AnimtionType;
|
use steamgriddb_api::query_parameters::AnimtionType;
|
||||||
|
use steamgriddb_api::query_parameters::QueryType::*;
|
||||||
let anymation_type = if download_animated {
|
let anymation_type = if download_animated {
|
||||||
Some(&[AnimtionType::Animated][..])
|
Some(&[AnimtionType::Animated][..])
|
||||||
}else{
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let big_picture_dims = [GridDimentions::D920x430, GridDimentions::D460x215];
|
let big_picture_dims = [GridDimentions::D920x430, GridDimentions::D460x215];
|
||||||
|
|
||||||
use steamgriddb_api::query_parameters::GridQueryParameters;
|
use steamgriddb_api::query_parameters::GridQueryParameters;
|
||||||
let big_picture_parameters = GridQueryParameters{
|
let big_picture_parameters = GridQueryParameters {
|
||||||
dimentions: Some(&big_picture_dims),
|
dimentions: Some(&big_picture_dims),
|
||||||
types: anymation_type,
|
types: anymation_type,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
use steamgriddb_api::query_parameters::HeroQueryParameters;
|
use steamgriddb_api::query_parameters::HeroQueryParameters;
|
||||||
let hero_parameters = HeroQueryParameters{
|
let hero_parameters = HeroQueryParameters {
|
||||||
types: anymation_type,
|
types: anymation_type,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let grid_parameters = GridQueryParameters{
|
let grid_parameters = GridQueryParameters {
|
||||||
types: anymation_type,
|
types: anymation_type,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
use steamgriddb_api::query_parameters::LogoQueryParameters;
|
use steamgriddb_api::query_parameters::LogoQueryParameters;
|
||||||
let logo_parameters = LogoQueryParameters{
|
let logo_parameters = LogoQueryParameters {
|
||||||
types: anymation_type,
|
types: anymation_type,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let query_type = match image_type {
|
let query_type = match image_type {
|
||||||
ImageType::Hero => Hero(Some(hero_parameters)),
|
ImageType::Hero => Hero(Some(hero_parameters)),
|
||||||
ImageType::BigPicture => Grid(Some(big_picture_parameters)),
|
ImageType::BigPicture => Grid(Some(big_picture_parameters)),
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
#[derive(Debug,Clone,Copy)]
|
|
||||||
pub enum ImageType {
|
pub enum ImageType {
|
||||||
Hero,
|
Hero,
|
||||||
Grid,
|
Grid,
|
||||||
Logo,
|
Logo,
|
||||||
BigPicture
|
BigPicture,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImageType {
|
impl ImageType {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
mod settings;
|
|
||||||
mod image_type;
|
|
||||||
mod cached_search;
|
mod cached_search;
|
||||||
mod downloader;
|
mod downloader;
|
||||||
|
mod image_type;
|
||||||
|
mod settings;
|
||||||
|
|
||||||
pub use image_type::ImageType;
|
|
||||||
pub use settings::SteamGridDbSettings;
|
|
||||||
pub use cached_search::CachedSearch;
|
pub use cached_search::CachedSearch;
|
||||||
pub use downloader::*;
|
pub use downloader::*;
|
||||||
|
pub use image_type::ImageType;
|
||||||
|
pub use settings::SteamGridDbSettings;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use serde::{Serialize,Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug,Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct SteamGridDbSettings {
|
pub struct SteamGridDbSettings {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub auth_key: Option<String>,
|
pub auth_key: Option<String>,
|
||||||
pub prefer_animated:bool,
|
pub prefer_animated: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-10
@@ -5,15 +5,16 @@ use crate::{
|
|||||||
legendary::LegendaryPlatform,
|
legendary::LegendaryPlatform,
|
||||||
platform::Platform,
|
platform::Platform,
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
steam::{get_shortcuts_for_user, get_shortcuts_paths, SteamUsersInfo, ShortcutInfo},
|
steam::{get_shortcuts_for_user, get_shortcuts_paths, ShortcutInfo, SteamUsersInfo},
|
||||||
steamgriddb::download_images_for_users,
|
steamgriddb::download_images_for_users,
|
||||||
|
uplay::Uplay,
|
||||||
};
|
};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use crate::{gog::GogPlatform, itch::ItchPlatform, origin::OriginPlatform};
|
use crate::{gog::GogPlatform, itch::ItchPlatform, origin::OriginPlatform};
|
||||||
use std::{fs::File, io::Write, path::Path};
|
use std::{fs::File, io::Write, path::Path};
|
||||||
|
|
||||||
const BOILR_TAG : &str ="boilr";
|
const BOILR_TAG: &str = "boilr";
|
||||||
|
|
||||||
pub async fn run_sync(settings: &Settings) -> Result<(), Box<dyn Error>> {
|
pub async fn run_sync(settings: &Settings) -> Result<(), Box<dyn Error>> {
|
||||||
let mut userinfo_shortcuts = get_shortcuts_paths(&settings.steam)?;
|
let mut userinfo_shortcuts = get_shortcuts_paths(&settings.steam)?;
|
||||||
@@ -41,17 +42,19 @@ pub async fn run_sync(settings: &Settings) -> Result<(), Box<dyn Error>> {
|
|||||||
if settings.steamgrid_db.enabled {
|
if settings.steamgrid_db.enabled {
|
||||||
if settings.steamgrid_db.prefer_animated {
|
if settings.steamgrid_db.prefer_animated {
|
||||||
println!("downloading animated images");
|
println!("downloading animated images");
|
||||||
download_images_for_users(settings, &userinfo_shortcuts,true).await;
|
download_images_for_users(settings, &userinfo_shortcuts, true).await;
|
||||||
}
|
}
|
||||||
download_images_for_users(settings, &userinfo_shortcuts,false).await;
|
download_images_for_users(settings, &userinfo_shortcuts, false).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_old_shortcuts(shortcut_info: &mut ShortcutInfo){
|
fn remove_old_shortcuts(shortcut_info: &mut ShortcutInfo) {
|
||||||
let boilr_tag = BOILR_TAG.to_string();
|
let boilr_tag = BOILR_TAG.to_string();
|
||||||
shortcut_info.shortcuts.retain(|shortcut| !shortcut.tags.contains(&boilr_tag));
|
shortcut_info
|
||||||
|
.shortcuts
|
||||||
|
.retain(|shortcut| !shortcut.tags.contains(&boilr_tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fix_shortcut_icons(user: &SteamUsersInfo, shortcuts: &mut Vec<ShortcutOwned>) {
|
fn fix_shortcut_icons(user: &SteamUsersInfo, shortcuts: &mut Vec<ShortcutOwned>) {
|
||||||
@@ -77,8 +80,6 @@ fn fix_shortcut_icons(user: &SteamUsersInfo, shortcuts: &mut Vec<ShortcutOwned>)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn update_platforms(settings: &Settings, new_user_shortcuts: &mut Vec<ShortcutOwned>) {
|
fn update_platforms(settings: &Settings, new_user_shortcuts: &mut Vec<ShortcutOwned>) {
|
||||||
update_platform_shortcuts(
|
update_platform_shortcuts(
|
||||||
&EpicPlatform::new(settings.epic_games.clone()),
|
&EpicPlatform::new(settings.epic_games.clone()),
|
||||||
@@ -104,6 +105,12 @@ fn update_platforms(settings: &Settings, new_user_shortcuts: &mut Vec<ShortcutOw
|
|||||||
},
|
},
|
||||||
new_user_shortcuts,
|
new_user_shortcuts,
|
||||||
);
|
);
|
||||||
|
update_platform_shortcuts(
|
||||||
|
&Uplay {
|
||||||
|
settings: settings.uplay.clone(),
|
||||||
|
},
|
||||||
|
new_user_shortcuts,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_shortcuts(shortcuts: &[ShortcutOwned], path: &Path) {
|
fn save_shortcuts(shortcuts: &[ShortcutOwned], path: &Path) {
|
||||||
@@ -141,7 +148,11 @@ where
|
|||||||
{
|
{
|
||||||
if platform.enabled() {
|
if platform.enabled() {
|
||||||
if let crate::platform::SettingsValidity::Invalid { reason } = platform.settings_valid() {
|
if let crate::platform::SettingsValidity::Invalid { reason } = platform.settings_valid() {
|
||||||
eprintln!("Setting for platform {} are invalid, reason: {}",platform.name(),reason);
|
eprintln!(
|
||||||
|
"Setting for platform {} are invalid, reason: {}",
|
||||||
|
platform.name(),
|
||||||
|
reason
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +176,7 @@ where
|
|||||||
let boilr_tag = BOILR_TAG.to_string();
|
let boilr_tag = BOILR_TAG.to_string();
|
||||||
for shortcut in shortcuts_to_add {
|
for shortcut in shortcuts_to_add {
|
||||||
let mut shortcut_owned: ShortcutOwned = shortcut.into();
|
let mut shortcut_owned: ShortcutOwned = shortcut.into();
|
||||||
if !shortcut_owned.tags.contains(&boilr_tag){
|
if !shortcut_owned.tags.contains(&boilr_tag) {
|
||||||
shortcut_owned.tags.push(boilr_tag.clone());
|
shortcut_owned.tags.push(boilr_tag.clone());
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|||||||
+2
-3
@@ -1,6 +1,5 @@
|
|||||||
mod ui;
|
|
||||||
mod mainview;
|
mod mainview;
|
||||||
|
mod ui;
|
||||||
|
|
||||||
|
|
||||||
pub use ui::run_ui;
|
|
||||||
pub(crate) use mainview::UserInterface;
|
pub(crate) use mainview::UserInterface;
|
||||||
|
pub use ui::run_ui;
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ fn update_settings_with_ui_values(settings: &mut Settings, ui: &UserInterface) {
|
|||||||
settings.gog.wine_c_drive = empty_or_whitespace(ui.gog_winedrive_input.value());
|
settings.gog.wine_c_drive = empty_or_whitespace(ui.gog_winedrive_input.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn save_settings_to_file(settings: &Settings) {
|
fn save_settings_to_file(settings: &Settings) {
|
||||||
let toml = toml::to_string(&settings).unwrap();
|
let toml = toml::to_string(&settings).unwrap();
|
||||||
std::fs::write("config.toml", toml).unwrap();
|
std::fs::write("config.toml", toml).unwrap();
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
use steam_shortcuts_util::shortcut::{Shortcut, ShortcutOwned};
|
||||||
|
|
||||||
|
pub(crate) struct Game {
|
||||||
|
pub(crate) name: String,
|
||||||
|
pub(crate) icon: String,
|
||||||
|
pub(crate) id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Game> for ShortcutOwned {
|
||||||
|
fn from(game: Game) -> Self {
|
||||||
|
let launch = format!("uplay://launch/{}", game.id);
|
||||||
|
Shortcut::new(0, &game.name, &launch, "", &game.icon, "", "").to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
mod game;
|
||||||
|
mod platform;
|
||||||
|
mod settings;
|
||||||
|
|
||||||
|
pub use platform::Uplay;
|
||||||
|
pub use settings::UplaySettings;
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
use crate::platform::Platform;
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
use super::{game::Game, settings::UplaySettings};
|
||||||
|
|
||||||
|
pub struct Uplay {
|
||||||
|
pub settings: UplaySettings,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Platform<Game, Box<dyn Error>> for Uplay {
|
||||||
|
fn enabled(&self) -> bool {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
false
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
self.settings.enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"Uplay"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn settings_valid(&self) -> crate::platform::SettingsValidity {
|
||||||
|
crate::platform::SettingsValidity::Valid
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_shortcuts(&self) -> Result<Vec<Game>, Box<dyn Error>> {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
Ok(vec![])
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
get_games_from_winreg()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn get_games_from_winreg() -> Result<Vec<Game>, Box<dyn Error>> {
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use winreg::enums::*;
|
||||||
|
use winreg::RegKey;
|
||||||
|
|
||||||
|
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
|
||||||
|
let mut games = vec![];
|
||||||
|
let mut installed_ids = vec![];
|
||||||
|
if let Ok(installs) = hklm.open_subkey("SOFTWARE\\WOW6432Node\\Ubisoft\\Launcher\\Installs") {
|
||||||
|
for i in installs.enum_keys().filter_map(|i| i.ok()) {
|
||||||
|
if let Ok(install) = installs.open_subkey(&i) {
|
||||||
|
let install_dir: Result<String, _> = install.get_value("InstallDir");
|
||||||
|
if let Ok(folder) = install_dir {
|
||||||
|
let path = Path::new(&folder);
|
||||||
|
if path.exists() {
|
||||||
|
installed_ids.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for id in installed_ids {
|
||||||
|
let path = format!("SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Uplay Install {}",id);
|
||||||
|
let subkey = hklm.open_subkey(path);
|
||||||
|
if let Ok(subkey) = subkey {
|
||||||
|
let name: Result<String, _> = subkey.get_value("DisplayName");
|
||||||
|
if let Ok(name) = name {
|
||||||
|
let icon: String = subkey.get_value("DisplayName").unwrap_or_default();
|
||||||
|
games.push(Game { name, icon, id })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(games)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
|
pub struct UplaySettings {
|
||||||
|
pub enabled: bool,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user