mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Add utility to help format the code (#247)
Signed-off-by: Aisuko <urakiny@gmail.com>
This commit is contained in:
@@ -106,6 +106,15 @@ If you want to revert back to the original name, just clear the name and click r
|
|||||||
|
|
||||||
### How can I help/contribute?
|
### How can I help/contribute?
|
||||||
If you are a coder, you are very welcome! You can fork this repo and then create a pull request.
|
If you are a coder, you are very welcome! You can fork this repo and then create a pull request.
|
||||||
|
|
||||||
|
To check formats and errors of code before run the code:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cargo fmt
|
||||||
|
|
||||||
|
cargo check
|
||||||
|
```
|
||||||
|
|
||||||
To run BoilR just write:
|
To run BoilR just write:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
+18
-18
@@ -52,39 +52,39 @@ pub fn get_boilr_links_path() -> PathBuf {
|
|||||||
get_config_folder().join("links")
|
get_config_folder().join("links")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests{
|
mod tests {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use super::get_config_folder;
|
use super::get_config_folder;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
fn check_return_xdg_config_path(){
|
fn check_return_xdg_config_path() {
|
||||||
|
|
||||||
// Parameters for set environment 'XDG_CONFIG_HOME'
|
// Parameters for set environment 'XDG_CONFIG_HOME'
|
||||||
std::env::set_var("XDG_CONFIG_HOME", std::env::var("HOME").unwrap()+"/.config/boilr");
|
std::env::set_var(
|
||||||
|
"XDG_CONFIG_HOME",
|
||||||
|
std::env::var("HOME").unwrap() + "/.config/boilr",
|
||||||
|
);
|
||||||
|
|
||||||
let xdg_config_home=std::env::var("XDG_CONFIG_HOME").unwrap();
|
let xdg_config_home = std::env::var("XDG_CONFIG_HOME").unwrap();
|
||||||
let config_path=get_config_folder();
|
let config_path = get_config_folder();
|
||||||
let test_path=PathBuf::from(xdg_config_home);
|
let test_path = PathBuf::from(xdg_config_home);
|
||||||
|
|
||||||
assert_eq!(config_path,test_path);
|
assert_eq!(config_path, test_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
fn check_return_config_path(){
|
fn check_return_config_path() {
|
||||||
|
std::env::set_var(
|
||||||
|
"XDG_CONFIG_HOME",
|
||||||
|
std::env::var("HOME").unwrap() + "/.config/boilr",
|
||||||
|
);
|
||||||
|
|
||||||
std::env::set_var("XDG_CONFIG_HOME", std::env::var("HOME").unwrap()+"/.config/boilr");
|
let config_path = get_config_folder();
|
||||||
|
let current_path = std::env::var("HOME").unwrap() + "/.config/boilr";
|
||||||
|
|
||||||
let config_path=get_config_folder();
|
assert_eq!(config_path, PathBuf::from(current_path));
|
||||||
let current_path=std::env::var("HOME").unwrap()+"/.config/boilr";
|
|
||||||
|
|
||||||
assert_eq!(config_path,PathBuf::from(current_path));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -9,7 +9,7 @@ mod ui;
|
|||||||
|
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
|
|
||||||
fn main() -> Result<()>{
|
fn main() -> Result<()> {
|
||||||
color_eyre::install()?;
|
color_eyre::install()?;
|
||||||
ensure_config_folder();
|
ensure_config_folder();
|
||||||
migration::migrate_config();
|
migration::migrate_config();
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::{settings::save_settings, platforms::get_platforms};
|
use crate::{platforms::get_platforms, settings::save_settings};
|
||||||
|
|
||||||
pub fn migrate_config() {
|
pub fn migrate_config() {
|
||||||
let version = &crate::settings::Settings::new()
|
let version = &crate::settings::Settings::new()
|
||||||
|
|||||||
@@ -3,17 +3,20 @@ use sqlite::State;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
||||||
|
|
||||||
use crate::platforms::{to_shortcuts_simple, ShortcutToImport, FromSettingsString, load_settings, GamesPlatform};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts_simple, FromSettingsString, GamesPlatform, ShortcutToImport,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AmazonPlatform {
|
pub struct AmazonPlatform {
|
||||||
pub settings: AmazonSettings,
|
pub settings: AmazonSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromSettingsString for AmazonPlatform {
|
||||||
impl FromSettingsString for AmazonPlatform{
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
fn from_settings_string<S:AsRef<str>>(s:S) -> Self {
|
AmazonPlatform {
|
||||||
AmazonPlatform { settings: load_settings(s) }
|
settings: load_settings(s),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,19 +54,17 @@ fn get_launcher_path() -> eyre::Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GamesPlatform for AmazonPlatform{
|
impl GamesPlatform for AmazonPlatform {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Amazon"
|
"Amazon"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn enabled(&self) -> bool {
|
fn enabled(&self) -> bool {
|
||||||
self.settings.enabled
|
self.settings.enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_shortcut_info(&self) -> eyre::Result<Vec<ShortcutToImport>> {
|
fn get_shortcut_info(&self) -> eyre::Result<Vec<ShortcutToImport>> {
|
||||||
to_shortcuts_simple(self.get_amazon_games())
|
to_shortcuts_simple(self.get_amazon_games())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
||||||
@@ -80,9 +81,7 @@ impl GamesPlatform for AmazonPlatform{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl AmazonPlatform {
|
impl AmazonPlatform {
|
||||||
|
|
||||||
fn get_amazon_games(&self) -> eyre::Result<Vec<AmazonGame>> {
|
fn get_amazon_games(&self) -> eyre::Result<Vec<AmazonGame>> {
|
||||||
let sqllite_path = get_sqlite_path()?;
|
let sqllite_path = get_sqlite_path()?;
|
||||||
let launcher_path = get_launcher_path()?;
|
let launcher_path = get_launcher_path()?;
|
||||||
@@ -141,7 +140,7 @@ pub struct AmazonSettings {
|
|||||||
pub launcher_location: Option<String>,
|
pub launcher_location: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AmazonSettings{
|
impl Default for AmazonSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let enabled = false;
|
let enabled = false;
|
||||||
@@ -149,6 +148,9 @@ impl Default for AmazonSettings{
|
|||||||
#[cfg(not(target_family = "unix"))]
|
#[cfg(not(target_family = "unix"))]
|
||||||
let enabled = true;
|
let enabled = true;
|
||||||
|
|
||||||
Self { enabled, launcher_location: Default::default() }
|
Self {
|
||||||
|
enabled,
|
||||||
|
launcher_location: Default::default(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
mod amazon_platform;
|
mod amazon_platform;
|
||||||
|
|
||||||
pub use amazon_platform::AmazonPlatform;
|
|
||||||
pub use amazon_platform::AmazonGame;
|
pub use amazon_platform::AmazonGame;
|
||||||
|
pub use amazon_platform::AmazonPlatform;
|
||||||
|
|||||||
@@ -5,16 +5,20 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
||||||
|
|
||||||
use crate::platforms::{to_shortcuts_simple, ShortcutToImport, FromSettingsString, load_settings, GamesPlatform};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts_simple, FromSettingsString, GamesPlatform, ShortcutToImport,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub struct BottlesPlatform {
|
pub struct BottlesPlatform {
|
||||||
pub settings: BottlesSettings,
|
pub settings: BottlesSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromSettingsString for BottlesPlatform{
|
impl FromSettingsString for BottlesPlatform {
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
BottlesPlatform { settings: load_settings(s) }
|
BottlesPlatform {
|
||||||
|
settings: load_settings(s),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +33,7 @@ pub struct BottlesSettings {
|
|||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BottlesSettings{
|
impl Default for BottlesSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let enabled = true;
|
let enabled = true;
|
||||||
@@ -124,8 +128,7 @@ impl BottlesPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GamesPlatform for BottlesPlatform {
|
||||||
impl GamesPlatform for BottlesPlatform{
|
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Bottles"
|
"Bottles"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::platforms::{
|
use crate::platforms::{
|
||||||
load_settings, to_shortcuts, FromSettingsString, NeedsPorton, ShortcutToImport, GamesPlatform,
|
load_settings, to_shortcuts, FromSettingsString, GamesPlatform, NeedsPorton, ShortcutToImport,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{get_egs_manifests, settings::EpicGamesLauncherSettings, ManifestItem};
|
use super::{get_egs_manifests, settings::EpicGamesLauncherSettings, ManifestItem};
|
||||||
@@ -32,7 +32,7 @@ impl NeedsPorton<EpicPlatform> for ManifestItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GamesPlatform for EpicPlatform{
|
impl GamesPlatform for EpicPlatform {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Epic"
|
"Epic"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub(crate) fn get_egs_manifests(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut manifests :Vec<ManifestItem> = all_manifests
|
let mut manifests: Vec<ManifestItem> = all_manifests
|
||||||
.filter(is_game_installed)
|
.filter(is_game_installed)
|
||||||
.filter(is_game_launchable)
|
.filter(is_game_launchable)
|
||||||
.collect();
|
.collect();
|
||||||
@@ -71,7 +71,6 @@ pub(crate) fn get_egs_manifests(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn is_game_installed(manifest: &ManifestItem) -> bool {
|
fn is_game_installed(manifest: &ManifestItem) -> bool {
|
||||||
Path::new(manifest.manifest_location.as_str()).exists()
|
Path::new(manifest.manifest_location.as_str()).exists()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ fn launcher_shortcut(manifest: ManifestItem) -> ShortcutOwned {
|
|||||||
.to_owned()
|
.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl From<ManifestItem> for ShortcutOwned {
|
impl From<ManifestItem> for ShortcutOwned {
|
||||||
fn from(manifest: ManifestItem) -> Self {
|
fn from(manifest: ManifestItem) -> Self {
|
||||||
let mut owned_shortcut = if manifest.needs_launcher() {
|
let mut owned_shortcut = if manifest.needs_launcher() {
|
||||||
@@ -164,7 +163,7 @@ impl ManifestItem {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dedupe_key(&self)-> String {
|
pub fn dedupe_key(&self) -> String {
|
||||||
format!(
|
format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
self.install_location, self.launch_executable, self.is_managed
|
self.install_location, self.launch_executable, self.is_managed
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
mod epic_platform;
|
mod epic_platform;
|
||||||
|
mod epic_ui;
|
||||||
mod get_manifests;
|
mod get_manifests;
|
||||||
mod manifest_item;
|
mod manifest_item;
|
||||||
mod paths;
|
mod paths;
|
||||||
mod settings;
|
mod settings;
|
||||||
mod epic_ui;
|
|
||||||
|
|
||||||
pub use epic_platform::*;
|
pub use epic_platform::*;
|
||||||
use get_manifests::get_egs_manifests;
|
use get_manifests::get_egs_manifests;
|
||||||
pub(crate) use manifest_item::*;
|
pub(crate) use manifest_item::*;
|
||||||
use paths::*;
|
use paths::*;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::platforms::{NeedsPorton, to_shortcuts, ShortcutToImport, GamesPlatform, FromSettingsString, load_settings};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts, FromSettingsString, GamesPlatform, NeedsPorton, ShortcutToImport,
|
||||||
|
};
|
||||||
|
|
||||||
use super::FlatpakSettings;
|
use super::FlatpakSettings;
|
||||||
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
||||||
@@ -23,7 +25,7 @@ impl From<FlatpakApp> for ShortcutOwned {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NeedsPorton<FlatpakPlatform> for FlatpakApp{
|
impl NeedsPorton<FlatpakPlatform> for FlatpakApp {
|
||||||
fn needs_proton(&self, _platform: &FlatpakPlatform) -> bool {
|
fn needs_proton(&self, _platform: &FlatpakPlatform) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -34,7 +36,6 @@ impl NeedsPorton<FlatpakPlatform> for FlatpakApp{
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FlatpakPlatform {
|
impl FlatpakPlatform {
|
||||||
|
|
||||||
fn get_flatpak_apps(&self) -> eyre::Result<Vec<FlatpakApp>> {
|
fn get_flatpak_apps(&self) -> eyre::Result<Vec<FlatpakApp>> {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
let mut command = Command::new("flatpak");
|
let mut command = Command::new("flatpak");
|
||||||
@@ -60,8 +61,7 @@ impl FlatpakPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromSettingsString for FlatpakPlatform {
|
||||||
impl FromSettingsString for FlatpakPlatform{
|
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
FlatpakPlatform {
|
FlatpakPlatform {
|
||||||
settings: load_settings(s),
|
settings: load_settings(s),
|
||||||
@@ -69,12 +69,11 @@ impl FromSettingsString for FlatpakPlatform{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GamesPlatform for FlatpakPlatform{
|
impl GamesPlatform for FlatpakPlatform {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Flatpak"
|
"Flatpak"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn enabled(&self) -> bool {
|
fn enabled(&self) -> bool {
|
||||||
self.settings.enabled
|
self.settings.enabled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ pub struct FlatpakSettings {
|
|||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FlatpakSettings{
|
impl Default for FlatpakSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let enabled = true;
|
let enabled = true;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::platforms::{to_shortcuts, ShortcutToImport, NeedsPorton, GamesPlatform, FromSettingsString, load_settings};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts, FromSettingsString, GamesPlatform, NeedsPorton, ShortcutToImport,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
gog_config::GogConfig,
|
gog_config::GogConfig,
|
||||||
@@ -161,7 +163,7 @@ fn get_games_from_game_folders(game_folders: Vec<PathBuf>) -> Vec<(GogGame, Path
|
|||||||
games
|
games
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NeedsPorton<GogPlatform> for GogShortcut{
|
impl NeedsPorton<GogPlatform> for GogShortcut {
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
fn needs_proton(&self, _platform: &GogPlatform) -> bool {
|
fn needs_proton(&self, _platform: &GogPlatform) -> bool {
|
||||||
true
|
true
|
||||||
@@ -222,8 +224,7 @@ pub fn default_location() -> PathBuf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromSettingsString for GogPlatform {
|
||||||
impl FromSettingsString for GogPlatform{
|
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
GogPlatform {
|
GogPlatform {
|
||||||
settings: load_settings(s),
|
settings: load_settings(s),
|
||||||
@@ -231,7 +232,7 @@ impl FromSettingsString for GogPlatform{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GamesPlatform for GogPlatform{
|
impl GamesPlatform for GogPlatform {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"GOG"
|
"GOG"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl Default for GogSettings {
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
#[cfg(not(target_family = "unix"))]
|
#[cfg(not(target_family = "unix"))]
|
||||||
enabled: true,
|
enabled: true,
|
||||||
location:None,
|
location: None,
|
||||||
wine_c_drive: None,
|
wine_c_drive: None,
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
create_symlinks: true,
|
create_symlinks: true,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ mod gog_game;
|
|||||||
mod gog_platform;
|
mod gog_platform;
|
||||||
mod gog_settings;
|
mod gog_settings;
|
||||||
|
|
||||||
pub(crate) use gog_settings::GogSettings;
|
pub use gog_game::GogShortcut;
|
||||||
pub use gog_platform::get_gog_shortcuts_from_game_folders;
|
pub use gog_platform::get_gog_shortcuts_from_game_folders;
|
||||||
pub use gog_platform::GogPlatform;
|
pub use gog_platform::GogPlatform;
|
||||||
pub use gog_game::GogShortcut;
|
pub(crate) use gog_settings::GogSettings;
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ impl HeroicGameType {
|
|||||||
HeroicGameType::Epic(g) => g.app_name.as_ref(),
|
HeroicGameType::Epic(g) => g.app_name.as_ref(),
|
||||||
HeroicGameType::Gog(g, _) => g.game_id.as_ref(),
|
HeroicGameType::Gog(g, _) => g.game_id.as_ref(),
|
||||||
HeroicGameType::Heroic {
|
HeroicGameType::Heroic {
|
||||||
title:_,
|
title: _,
|
||||||
app_name,
|
app_name,
|
||||||
install_mode:_,
|
install_mode: _,
|
||||||
} => app_name,
|
} => app_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,8 +34,8 @@ impl HeroicGameType {
|
|||||||
HeroicGameType::Gog(g, _) => g.name.as_ref(),
|
HeroicGameType::Gog(g, _) => g.name.as_ref(),
|
||||||
HeroicGameType::Heroic {
|
HeroicGameType::Heroic {
|
||||||
title,
|
title,
|
||||||
app_name:_,
|
app_name: _,
|
||||||
install_mode:_,
|
install_mode: _,
|
||||||
} => title.as_ref(),
|
} => title.as_ref(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use super::{HeroicGame, HeroicGameType, HeroicSettings};
|
use super::{HeroicGame, HeroicGameType, HeroicSettings};
|
||||||
use crate::platforms::{GamesPlatform, FromSettingsString, load_settings};
|
use crate::platforms::{load_settings, FromSettingsString, GamesPlatform};
|
||||||
use crate::platforms::{to_shortcuts, NeedsPorton, ShortcutToImport};
|
use crate::platforms::{to_shortcuts, NeedsPorton, ShortcutToImport};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -86,7 +86,7 @@ impl HeroicPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NeedsPorton<HeroicPlatform> for HeroicGameType{
|
impl NeedsPorton<HeroicPlatform> for HeroicGameType {
|
||||||
#[cfg(not(target_family = "unix"))]
|
#[cfg(not(target_family = "unix"))]
|
||||||
fn needs_proton(&self, _platform: &HeroicPlatform) -> bool {
|
fn needs_proton(&self, _platform: &HeroicPlatform) -> bool {
|
||||||
false
|
false
|
||||||
@@ -107,7 +107,10 @@ impl NeedsPorton<HeroicPlatform> for HeroicGameType{
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl HeroicPlatform {
|
impl HeroicPlatform {
|
||||||
pub fn get_epic_games(&self, install_modes: &[InstallationMode]) -> eyre::Result<Vec<HeroicGameType>> {
|
pub fn get_epic_games(
|
||||||
|
&self,
|
||||||
|
install_modes: &[InstallationMode],
|
||||||
|
) -> eyre::Result<Vec<HeroicGameType>> {
|
||||||
let mut shortcuts = vec![];
|
let mut shortcuts = vec![];
|
||||||
for install_mode in install_modes {
|
for install_mode in install_modes {
|
||||||
if let Ok(mut games) = get_shortcuts_from_install_mode(install_mode) {
|
if let Ok(mut games) = get_shortcuts_from_install_mode(install_mode) {
|
||||||
@@ -199,22 +202,20 @@ fn get_gog_games(
|
|||||||
Ok(gog_shortcuts)
|
Ok(gog_shortcuts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromSettingsString for HeroicPlatform {
|
||||||
impl FromSettingsString for HeroicPlatform{
|
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
HeroicPlatform{
|
HeroicPlatform {
|
||||||
heroic_games: None,
|
heroic_games: None,
|
||||||
settings : load_settings(s)
|
settings: load_settings(s),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GamesPlatform for HeroicPlatform{
|
impl GamesPlatform for HeroicPlatform {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Heroic"
|
"Heroic"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn enabled(&self) -> bool {
|
fn enabled(&self) -> bool {
|
||||||
self.settings.enabled
|
self.settings.enabled
|
||||||
}
|
}
|
||||||
@@ -226,39 +227,37 @@ impl GamesPlatform for HeroicPlatform{
|
|||||||
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.heading("Heroic");
|
ui.heading("Heroic");
|
||||||
ui.checkbox(&mut self.settings.enabled, "Import from Heroic");
|
ui.checkbox(&mut self.settings.enabled, "Import from Heroic");
|
||||||
ui.checkbox(&mut self.settings.default_launch_through_heroic, "Always launch games through Heroic");
|
ui.checkbox(
|
||||||
let safe_mode_header = match (self.settings.default_launch_through_heroic,self.settings.launch_games_through_heroic.len()) {
|
&mut self.settings.default_launch_through_heroic,
|
||||||
(false,0) => "Force games to launch through Heroic Launcher".to_string(),
|
"Always launch games through Heroic",
|
||||||
(false,1) => "One game forced to launch through Heroic Launcher".to_string(),
|
);
|
||||||
(false,x) => format!("{} games forced to launch through Heroic Launcher", x),
|
let safe_mode_header = match (
|
||||||
|
self.settings.default_launch_through_heroic,
|
||||||
(true,0) => "Force games to launch directly".to_string(),
|
self.settings.launch_games_through_heroic.len(),
|
||||||
(true,1) => "One game forced to launch directly".to_string(),
|
) {
|
||||||
(true,x) => format!("{} games forced to launch directly", x),
|
(false, 0) => "Force games to launch through Heroic Launcher".to_string(),
|
||||||
|
(false, 1) => "One game forced to launch through Heroic Launcher".to_string(),
|
||||||
|
(false, x) => format!("{} games forced to launch through Heroic Launcher", x),
|
||||||
|
|
||||||
|
(true, 0) => "Force games to launch directly".to_string(),
|
||||||
|
(true, 1) => "One game forced to launch directly".to_string(),
|
||||||
|
(true, x) => format!("{} games forced to launch directly", x),
|
||||||
};
|
};
|
||||||
egui::CollapsingHeader::new(safe_mode_header)
|
|
||||||
.id_source("Heroic_Launcher_safe_launch")
|
egui::CollapsingHeader::new(safe_mode_header).id_source("Heroic_Launcher_safe_launch").show(ui, |ui| {
|
||||||
.show(ui, |ui| {
|
if self.settings.default_launch_through_heroic{
|
||||||
if
|
|
||||||
self.settings.default_launch_through_heroic{
|
|
||||||
ui.label("Some games work best when launched directly, select those games below and BoilR will create shortcuts that launch the games directly.");
|
ui.label("Some games work best when launched directly, select those games below and BoilR will create shortcuts that launch the games directly.");
|
||||||
|
} else {
|
||||||
} else{
|
|
||||||
ui.label("Some games must be started from the Heroic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Heroic Launcher.");
|
ui.label("Some games must be started from the Heroic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Heroic Launcher.");
|
||||||
|
|
||||||
}
|
}
|
||||||
let manifests =self.heroic_games.get_or_insert_with(||{
|
|
||||||
let heroic_setting = self.settings.clone();
|
|
||||||
|
|
||||||
let heroic_platform = HeroicPlatform{
|
let manifests = self.heroic_games.get_or_insert_with(|| {
|
||||||
settings:heroic_setting,
|
let heroic_setting = self.settings.clone();
|
||||||
heroic_games:None
|
let heroic_platform = HeroicPlatform{ settings:heroic_setting, heroic_games:None};
|
||||||
};
|
|
||||||
heroic_platform.get_heroic_games().unwrap_or_default()
|
heroic_platform.get_heroic_games().unwrap_or_default()
|
||||||
});
|
});
|
||||||
|
|
||||||
let safe_open_games = &mut self.settings.launch_games_through_heroic;
|
let safe_open_games = &mut self.settings.launch_games_through_heroic;
|
||||||
|
|
||||||
for manifest in manifests{
|
for manifest in manifests{
|
||||||
let key = manifest.app_name();
|
let key = manifest.app_name();
|
||||||
let display_name = manifest.title();
|
let display_name = manifest.title();
|
||||||
@@ -271,8 +270,7 @@ self.settings.default_launch_through_heroic{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) ;
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_settings_serilizable(&self) -> String {
|
fn get_settings_serilizable(&self) -> String {
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ impl From<ItchGame> for ShortcutOwned {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl NeedsPorton<ItchPlatform> for ItchGame {
|
||||||
|
|
||||||
impl NeedsPorton<ItchPlatform> for ItchGame{
|
|
||||||
fn needs_proton(&self, _platform: &ItchPlatform) -> bool {
|
fn needs_proton(&self, _platform: &ItchPlatform) -> bool {
|
||||||
self.executable.ends_with("exe")
|
self.executable.ends_with("exe")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
use crate::platforms::{to_shortcuts, ShortcutToImport, load_settings, FromSettingsString, GamesPlatform};
|
use super::butler_db_parser::*;
|
||||||
use super::itch_game::ItchGame;
|
use super::itch_game::ItchGame;
|
||||||
use super::receipt::Receipt;
|
use super::receipt::Receipt;
|
||||||
use super::ItchSettings;
|
use super::ItchSettings;
|
||||||
use super::{butler_db_parser::*};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts, FromSettingsString, GamesPlatform, ShortcutToImport,
|
||||||
|
};
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use is_executable::IsExecutable;
|
use is_executable::IsExecutable;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@@ -90,8 +92,6 @@ pub fn get_default_location() -> String {
|
|||||||
//C:\Users\phili\AppData\Local\itch
|
//C:\Users\phili\AppData\Local\itch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
impl FromSettingsString for ItchPlatform {
|
impl FromSettingsString for ItchPlatform {
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
ItchPlatform {
|
ItchPlatform {
|
||||||
@@ -100,8 +100,7 @@ impl FromSettingsString for ItchPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GamesPlatform for ItchPlatform {
|
||||||
impl GamesPlatform for ItchPlatform{
|
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Itch"
|
"Itch"
|
||||||
}
|
}
|
||||||
@@ -120,11 +119,7 @@ impl GamesPlatform for ItchPlatform{
|
|||||||
if self.settings.enabled {
|
if self.settings.enabled {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let mut empty_string = "".to_string();
|
let mut empty_string = "".to_string();
|
||||||
let itch_location = self
|
let itch_location = self.settings.location.as_mut().unwrap_or(&mut empty_string);
|
||||||
.settings
|
|
||||||
.location
|
|
||||||
.as_mut()
|
|
||||||
.unwrap_or(&mut empty_string);
|
|
||||||
ui.label("Itch.io Folder: ");
|
ui.label("Itch.io Folder: ");
|
||||||
if ui.text_edit_singleline(itch_location).changed() {
|
if ui.text_edit_singleline(itch_location).changed() {
|
||||||
self.settings.location = if itch_location.is_empty() {
|
self.settings.location = if itch_location.is_empty() {
|
||||||
@@ -132,10 +127,12 @@ impl GamesPlatform for ItchPlatform{
|
|||||||
} else {
|
} else {
|
||||||
Some(itch_location.to_string())
|
Some(itch_location.to_string())
|
||||||
};
|
};
|
||||||
} else if !itch_location.is_empty() && ui
|
} else if !itch_location.is_empty()
|
||||||
|
&& ui
|
||||||
.button("Reset")
|
.button("Reset")
|
||||||
.on_hover_text("Reset the itch path, let BoilR guess again")
|
.on_hover_text("Reset the itch path, let BoilR guess again")
|
||||||
.clicked() {
|
.clicked()
|
||||||
|
{
|
||||||
self.settings.location = None;
|
self.settings.location = None;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
use super::legendary_game::LegendaryGame;
|
use super::legendary_game::LegendaryGame;
|
||||||
use super::LegendarySettings;
|
use super::LegendarySettings;
|
||||||
use crate::platforms::{to_shortcuts_simple, GamesPlatform, ShortcutToImport, FromSettingsString, load_settings};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts_simple, FromSettingsString, GamesPlatform, ShortcutToImport,
|
||||||
|
};
|
||||||
use serde_json::from_str;
|
use serde_json::from_str;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
@@ -73,10 +75,10 @@ impl GamesPlatform for LegendaryPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromSettingsString for LegendaryPlatform{
|
impl FromSettingsString for LegendaryPlatform {
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
LegendaryPlatform{
|
LegendaryPlatform {
|
||||||
settings:load_settings(s)
|
settings: load_settings(s),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,5 @@ mod legendary_game;
|
|||||||
mod legendary_platform;
|
mod legendary_platform;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
|
|
||||||
pub use settings::LegendarySettings;
|
|
||||||
pub use legendary_platform::LegendaryPlatform;
|
pub use legendary_platform::LegendaryPlatform;
|
||||||
|
pub use settings::LegendarySettings;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
use super::game_list_parser::parse_lutris_games;
|
use super::game_list_parser::parse_lutris_games;
|
||||||
use super::lutris_game::LutrisGame;
|
use super::lutris_game::LutrisGame;
|
||||||
use super::settings::LutrisSettings;
|
use super::settings::LutrisSettings;
|
||||||
use crate::platforms::{to_shortcuts_simple, ShortcutToImport, FromSettingsString, load_settings, GamesPlatform};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts_simple, FromSettingsString, GamesPlatform, ShortcutToImport,
|
||||||
|
};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -57,25 +59,25 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result<String>
|
|||||||
Ok(String::from_utf8_lossy(&output.stdout).to_string())
|
Ok(String::from_utf8_lossy(&output.stdout).to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromSettingsString for LutrisPlatform{
|
impl FromSettingsString for LutrisPlatform {
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
LutrisPlatform { settings: load_settings(s) }
|
LutrisPlatform {
|
||||||
|
settings: load_settings(s),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GamesPlatform for LutrisPlatform{
|
impl GamesPlatform for LutrisPlatform {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Lutris"
|
"Lutris"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn enabled(&self) -> bool {
|
fn enabled(&self) -> bool {
|
||||||
self.settings.enabled
|
self.settings.enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_shortcut_info(&self) -> eyre::Result<Vec<ShortcutToImport>> {
|
fn get_shortcut_info(&self) -> eyre::Result<Vec<ShortcutToImport>> {
|
||||||
to_shortcuts_simple(self.get_shortcuts())
|
to_shortcuts_simple(self.get_shortcuts())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
||||||
@@ -106,5 +108,4 @@ impl GamesPlatform for LutrisPlatform{
|
|||||||
fn code_name(&self) -> &str {
|
fn code_name(&self) -> &str {
|
||||||
"lutris"
|
"lutris"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
mod platform;
|
|
||||||
mod egs;
|
|
||||||
mod amazon;
|
mod amazon;
|
||||||
mod bottles;
|
mod bottles;
|
||||||
mod uplay;
|
mod egs;
|
||||||
mod itch;
|
|
||||||
mod flatpak;
|
mod flatpak;
|
||||||
mod origin;
|
|
||||||
mod gog;
|
mod gog;
|
||||||
mod heroic;
|
mod heroic;
|
||||||
mod lutris;
|
mod itch;
|
||||||
mod legendary;
|
mod legendary;
|
||||||
|
mod lutris;
|
||||||
|
mod origin;
|
||||||
|
mod platform;
|
||||||
mod platforms_load;
|
mod platforms_load;
|
||||||
|
mod uplay;
|
||||||
|
|
||||||
pub(crate) use platform::*;
|
pub(crate) use platform::*;
|
||||||
|
|
||||||
pub(crate) use gog::get_gog_shortcuts_from_game_folders;
|
pub(crate) use gog::get_gog_shortcuts_from_game_folders;
|
||||||
pub(crate) use gog::GogShortcut;
|
pub(crate) use gog::GogShortcut;
|
||||||
pub(crate) use platforms_load::FromSettingsString;
|
|
||||||
pub(crate) use platforms_load::load_settings;
|
|
||||||
pub use platforms_load::Platforms;
|
|
||||||
pub use platforms_load::get_platforms;
|
pub use platforms_load::get_platforms;
|
||||||
|
pub(crate) use platforms_load::load_settings;
|
||||||
|
pub(crate) use platforms_load::FromSettingsString;
|
||||||
|
pub use platforms_load::Platforms;
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ mod origin_game;
|
|||||||
mod origin_platform;
|
mod origin_platform;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
pub use settings::OriginSettings;
|
|
||||||
pub(crate) use origin_platform::OriginPlatform;
|
pub(crate) use origin_platform::OriginPlatform;
|
||||||
|
pub use settings::OriginSettings;
|
||||||
|
|||||||
@@ -13,12 +13,10 @@ pub struct OriginGame {
|
|||||||
impl From<OriginGame> for ShortcutOwned {
|
impl From<OriginGame> for ShortcutOwned {
|
||||||
fn from(game: OriginGame) -> Self {
|
fn from(game: OriginGame) -> Self {
|
||||||
let launch = match game.origin_compat_folder{
|
let launch = match game.origin_compat_folder{
|
||||||
Some(compat_folder) =>
|
Some(compat_folder) => format!
|
||||||
format!("STEAM_COMPAT_DATA_PATH=\"{}\" %command% \"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"", compat_folder.to_string_lossy(), game.id)
|
("STEAM_COMPAT_DATA_PATH=\"{}\" %command% \"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",
|
||||||
,
|
compat_folder.to_string_lossy(), game.id),
|
||||||
None => format!(
|
None => format!("\"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",game.id)
|
||||||
"\"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",
|
|
||||||
game.id)
|
|
||||||
};
|
};
|
||||||
let origin_location = format!("\"{}\"", game.origin_location.to_string_lossy());
|
let origin_location = format!("\"{}\"", game.origin_location.to_string_lossy());
|
||||||
let mut owned_shortcut = Shortcut::new(
|
let mut owned_shortcut = Shortcut::new(
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
use crate::platforms::{to_shortcuts, GamesPlatform, NeedsPorton, ShortcutToImport, FromSettingsString, load_settings};
|
use crate::platforms::{
|
||||||
|
load_settings, to_shortcuts, FromSettingsString, GamesPlatform, NeedsPorton, ShortcutToImport,
|
||||||
|
};
|
||||||
use nom::bytes::complete::take_until;
|
use nom::bytes::complete::take_until;
|
||||||
use std::{
|
use std::{
|
||||||
fs::DirEntry,
|
fs::DirEntry,
|
||||||
@@ -205,13 +207,12 @@ impl GamesPlatform for OriginPlatform {
|
|||||||
fn code_name(&self) -> &str {
|
fn code_name(&self) -> &str {
|
||||||
"origin"
|
"origin"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromSettingsString for OriginPlatform {
|
||||||
impl FromSettingsString for OriginPlatform{
|
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||||
OriginPlatform { settings: load_settings(s) }
|
OriginPlatform {
|
||||||
|
settings: load_settings(s),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ pub struct OriginSettings {
|
|||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for OriginSettings{
|
impl Default for OriginSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { enabled: true }
|
Self { enabled: true }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
|
||||||
use dyn_clone::DynClone;
|
use dyn_clone::DynClone;
|
||||||
|
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||||
|
|
||||||
pub trait GamesPlatform
|
pub trait GamesPlatform
|
||||||
where
|
where
|
||||||
@@ -29,7 +29,6 @@ pub struct ShortcutToImport {
|
|||||||
pub needs_symlinks: bool,
|
pub needs_symlinks: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub(crate) fn to_shortcuts<T, P>(
|
pub(crate) fn to_shortcuts<T, P>(
|
||||||
platform: &P,
|
platform: &P,
|
||||||
into_shortcuts: Result<Vec<T>, eyre::ErrReport>,
|
into_shortcuts: Result<Vec<T>, eyre::ErrReport>,
|
||||||
@@ -79,4 +78,3 @@ pub trait NeedsPorton<P> {
|
|||||||
|
|
||||||
fn create_symlinks(&self, platform: &P) -> bool;
|
fn create_symlinks(&self, platform: &P) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
|
||||||
use crate::settings::load_setting_sections;
|
use crate::settings::load_setting_sections;
|
||||||
|
|
||||||
use super::GamesPlatform;
|
|
||||||
use super::amazon::AmazonPlatform;
|
use super::amazon::AmazonPlatform;
|
||||||
use super::bottles::BottlesPlatform;
|
use super::bottles::BottlesPlatform;
|
||||||
use super::egs::EpicPlatform;
|
use super::egs::EpicPlatform;
|
||||||
@@ -17,6 +15,7 @@ use super::legendary::LegendaryPlatform;
|
|||||||
use super::lutris::LutrisPlatform;
|
use super::lutris::LutrisPlatform;
|
||||||
use super::origin::OriginPlatform;
|
use super::origin::OriginPlatform;
|
||||||
use super::uplay::UplayPlatform;
|
use super::uplay::UplayPlatform;
|
||||||
|
use super::GamesPlatform;
|
||||||
|
|
||||||
const PLATFORM_NAMES: [&str; 11] = [
|
const PLATFORM_NAMES: [&str; 11] = [
|
||||||
"amazon",
|
"amazon",
|
||||||
@@ -56,7 +55,6 @@ pub fn load_platform<A: AsRef<str>, B: AsRef<str>>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn get_platforms() -> Platforms {
|
pub fn get_platforms() -> Platforms {
|
||||||
let sections = load_setting_sections();
|
let sections = load_setting_sections();
|
||||||
let sections = match sections {
|
let sections = match sections {
|
||||||
@@ -72,7 +70,7 @@ pub fn get_platforms() -> Platforms {
|
|||||||
|
|
||||||
let mut platforms = vec![];
|
let mut platforms = vec![];
|
||||||
for name in PLATFORM_NAMES {
|
for name in PLATFORM_NAMES {
|
||||||
let default =String::from("");
|
let default = String::from("");
|
||||||
let settings = sections.get(name).unwrap_or(&default);
|
let settings = sections.get(name).unwrap_or(&default);
|
||||||
match load_platform(name, settings) {
|
match load_platform(name, settings) {
|
||||||
Ok(platform) => platforms.push(platform),
|
Ok(platform) => platforms.push(platform),
|
||||||
@@ -91,7 +89,7 @@ where
|
|||||||
match toml::from_str(str) {
|
match toml::from_str(str) {
|
||||||
Ok(k) => k,
|
Ok(k) => k,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if !str.is_empty(){
|
if !str.is_empty() {
|
||||||
eprintln!("Error reading settings file {:?}", err);
|
eprintln!("Error reading settings file {:?}", err);
|
||||||
}
|
}
|
||||||
Setting::default()
|
Setting::default()
|
||||||
@@ -99,7 +97,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn load<T>(s: &str) -> eyre::Result<Box<dyn GamesPlatform>>
|
fn load<T>(s: &str) -> eyre::Result<Box<dyn GamesPlatform>>
|
||||||
where
|
where
|
||||||
T: FromSettingsString,
|
T: FromSettingsString,
|
||||||
@@ -109,7 +106,6 @@ where
|
|||||||
Ok(Box::new(T::from_settings_string(s)))
|
Ok(Box::new(T::from_settings_string(s)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub trait FromSettingsString {
|
pub trait FromSettingsString {
|
||||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self;
|
fn from_settings_string<S: AsRef<str>>(s: S) -> Self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ use std::path::Path;
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::platforms::FromSettingsString;
|
|
||||||
use crate::platforms::GamesPlatform;
|
|
||||||
use crate::platforms::load_settings;
|
use crate::platforms::load_settings;
|
||||||
use crate::platforms::to_shortcuts_simple;
|
use crate::platforms::to_shortcuts_simple;
|
||||||
|
use crate::platforms::FromSettingsString;
|
||||||
|
use crate::platforms::GamesPlatform;
|
||||||
use crate::platforms::ShortcutToImport;
|
use crate::platforms::ShortcutToImport;
|
||||||
|
|
||||||
use super::{game::UplayGame, settings::UplaySettings};
|
use super::{game::UplayGame, settings::UplaySettings};
|
||||||
@@ -98,8 +98,7 @@ impl FromSettingsString for UplayPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GamesPlatform for UplayPlatform {
|
||||||
impl GamesPlatform for UplayPlatform{
|
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Uplay"
|
"Uplay"
|
||||||
}
|
}
|
||||||
@@ -124,5 +123,4 @@ impl GamesPlatform for UplayPlatform{
|
|||||||
fn code_name(&self) -> &str {
|
fn code_name(&self) -> &str {
|
||||||
"uplay"
|
"uplay"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,5 +7,3 @@ pub use synchronization::download_images;
|
|||||||
pub use synchronization::IsBoilRShortcut;
|
pub use synchronization::IsBoilRShortcut;
|
||||||
pub use synchronization::SyncProgress;
|
pub use synchronization::SyncProgress;
|
||||||
pub use synchronization::*;
|
pub use synchronization::*;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ impl MyEguiApp {
|
|||||||
ui.heading(&user.path.to_string_lossy().to_string());
|
ui.heading(&user.path.to_string_lossy().to_string());
|
||||||
}
|
}
|
||||||
for shortcut in user.shortcuts.iter() {
|
for shortcut in user.shortcuts.iter() {
|
||||||
if shortcut.is_boilr_shortcut() && ui.button(&shortcut.app_name).clicked() && disconnect_shortcut(&self.settings, shortcut.app_id).is_ok() {
|
if shortcut.is_boilr_shortcut()
|
||||||
|
&& ui.button(&shortcut.app_name).clicked()
|
||||||
|
&& disconnect_shortcut(&self.settings, shortcut.app_id).is_ok()
|
||||||
|
{
|
||||||
redraw = shortcut.app_id;
|
redraw = shortcut.app_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-21
@@ -13,7 +13,7 @@ use crate::sync;
|
|||||||
|
|
||||||
use crate::sync::{download_images, SyncProgress};
|
use crate::sync::{download_images, SyncProgress};
|
||||||
|
|
||||||
use super::{backup_shortcuts, all_ready, get_all_games};
|
use super::{all_ready, backup_shortcuts, get_all_games};
|
||||||
use super::{
|
use super::{
|
||||||
ui_colors::{BACKGROUND_COLOR, EXTRA_BACKGROUND_COLOR},
|
ui_colors::{BACKGROUND_COLOR, EXTRA_BACKGROUND_COLOR},
|
||||||
MyEguiApp,
|
MyEguiApp,
|
||||||
@@ -101,12 +101,11 @@ impl MyEguiApp {
|
|||||||
if response.clicked(){
|
if response.clicked(){
|
||||||
if !self.settings.blacklisted_games.contains(&shortcut.app_id){
|
if !self.settings.blacklisted_games.contains(&shortcut.app_id){
|
||||||
self.settings.blacklisted_games.push(shortcut.app_id);
|
self.settings.blacklisted_games.push(shortcut.app_id);
|
||||||
}else{
|
} else {
|
||||||
self.settings.blacklisted_games.retain(|id| *id != shortcut.app_id);
|
self.settings.blacklisted_games.retain(|id| *id != shortcut.app_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -114,7 +113,6 @@ impl MyEguiApp {
|
|||||||
ui.label("Failed finding games").on_hover_text(format!("Error message: {err}"));
|
ui.label("Failed finding games").on_hover_text(format!("Error message: {err}"));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +123,7 @@ impl MyEguiApp {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_sync(&mut self, wait: bool) {
|
||||||
pub fn run_sync(&mut self, wait: bool ) {
|
|
||||||
let (sender, reciever) = watch::channel(SyncProgress::NotStarted);
|
let (sender, reciever) = watch::channel(SyncProgress::NotStarted);
|
||||||
let settings = self.settings.clone();
|
let settings = self.settings.clone();
|
||||||
if settings.steam.stop_steam {
|
if settings.steam.stop_steam {
|
||||||
@@ -137,12 +134,11 @@ impl MyEguiApp {
|
|||||||
|
|
||||||
self.status_reciever = reciever;
|
self.status_reciever = reciever;
|
||||||
let renames = self.rename_map.clone();
|
let renames = self.rename_map.clone();
|
||||||
let all_ready= all_ready(&self.games_to_sync);
|
let all_ready = all_ready(&self.games_to_sync);
|
||||||
let _ = sender.send(SyncProgress::Starting);
|
let _ = sender.send(SyncProgress::Starting);
|
||||||
if all_ready{
|
if all_ready {
|
||||||
let shortcuts_to_import = get_all_games(&self.games_to_sync);
|
let shortcuts_to_import = get_all_games(&self.games_to_sync);
|
||||||
let handle = self.rt.spawn_blocking(move || {
|
let handle = self.rt.spawn_blocking(move || {
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
setup_proton(shortcuts_to_import.iter());
|
setup_proton(shortcuts_to_import.iter());
|
||||||
|
|
||||||
@@ -150,11 +146,13 @@ impl MyEguiApp {
|
|||||||
|
|
||||||
let mut some_sender = Some(sender);
|
let mut some_sender = Some(sender);
|
||||||
backup_shortcuts(&settings.steam);
|
backup_shortcuts(&settings.steam);
|
||||||
let usersinfo = sync::sync_shortcuts(&settings, &import_games, &mut some_sender,&renames).unwrap();
|
let usersinfo =
|
||||||
|
sync::sync_shortcuts(&settings, &import_games, &mut some_sender, &renames)
|
||||||
|
.unwrap();
|
||||||
let task = download_images(&settings, &usersinfo, &mut some_sender);
|
let task = download_images(&settings, &usersinfo, &mut some_sender);
|
||||||
block_on(task);
|
block_on(task);
|
||||||
//Run a second time to fix up shortcuts after images are downloaded
|
//Run a second time to fix up shortcuts after images are downloaded
|
||||||
sync::sync_shortcuts(&settings, &import_games, &mut some_sender,&renames).unwrap();
|
sync::sync_shortcuts(&settings, &import_games, &mut some_sender, &renames).unwrap();
|
||||||
|
|
||||||
if let Some(sender) = some_sender {
|
if let Some(sender) = some_sender {
|
||||||
let _ = sender.send(SyncProgress::Done);
|
let _ = sender.send(SyncProgress::Done);
|
||||||
@@ -168,31 +166,31 @@ impl MyEguiApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_shortcut_owned(shortcuts_to_import: Vec<(String, Vec<ShortcutToImport>)>) -> Vec<(String, Vec<ShortcutOwned>)> {
|
fn to_shortcut_owned(
|
||||||
|
shortcuts_to_import: Vec<(String, Vec<ShortcutToImport>)>,
|
||||||
|
) -> Vec<(String, Vec<ShortcutOwned>)> {
|
||||||
let mut import_games = vec![];
|
let mut import_games = vec![];
|
||||||
for(name,infos) in shortcuts_to_import{
|
for (name, infos) in shortcuts_to_import {
|
||||||
let mut shortcuts = vec![];
|
let mut shortcuts = vec![];
|
||||||
for info in infos{
|
for info in infos {
|
||||||
shortcuts.push(info.shortcut);
|
shortcuts.push(info.shortcut);
|
||||||
}
|
}
|
||||||
import_games.push((name,shortcuts));
|
import_games.push((name, shortcuts));
|
||||||
}
|
}
|
||||||
import_games
|
import_games
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
fn setup_proton<'a, I>(shortcut_infos: I)
|
fn setup_proton<'a, I>(shortcut_infos: I)
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = &'a (String,Vec<ShortcutToImport>)>{
|
I: IntoIterator<Item = &'a (String, Vec<ShortcutToImport>)>,
|
||||||
|
{
|
||||||
let mut shortcuts_to_proton = vec![];
|
let mut shortcuts_to_proton = vec![];
|
||||||
|
|
||||||
for (name,shortcuts) in shortcut_infos {
|
for (name, shortcuts) in shortcut_infos {
|
||||||
for shortcut_info in shortcuts{
|
for shortcut_info in shortcuts {
|
||||||
if shortcut_info.needs_proton {
|
if shortcut_info.needs_proton {
|
||||||
crate::sync::symlinks::ensure_links_folder_created(name);
|
crate::sync::symlinks::ensure_links_folder_created(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ impl MyEguiApp {
|
|||||||
|
|
||||||
self.render_steam_settings(ui);
|
self.render_steam_settings(ui);
|
||||||
|
|
||||||
for platform in &mut self.platforms{
|
for platform in &mut self.platforms {
|
||||||
platform.render_ui(ui);
|
platform.render_ui(ui);
|
||||||
ui.add_space(SECTION_SPACING);
|
ui.add_space(SECTION_SPACING);
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,6 @@ impl MyEguiApp {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn render_steam_settings(&mut self, ui: &mut egui::Ui) {
|
fn render_steam_settings(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.heading("Steam");
|
ui.heading("Steam");
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
@@ -51,12 +50,11 @@ impl MyEguiApp {
|
|||||||
.unwrap_or(&mut empty_string);
|
.unwrap_or(&mut empty_string);
|
||||||
ui.label("Steam Location: ");
|
ui.label("Steam Location: ");
|
||||||
if ui.text_edit_singleline(steam_location).changed() {
|
if ui.text_edit_singleline(steam_location).changed() {
|
||||||
if steam_location.trim().is_empty(){
|
if steam_location.trim().is_empty() {
|
||||||
self.settings.steam.location = None;
|
self.settings.steam.location = None;
|
||||||
}else{
|
} else {
|
||||||
self.settings.steam.location = Some(steam_location.to_string());
|
self.settings.steam.location = Some(steam_location.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.checkbox(
|
ui.checkbox(
|
||||||
@@ -97,7 +95,7 @@ impl MyEguiApp {
|
|||||||
self.settings.steamgrid_db.auth_key = Some(auth_key.to_string());
|
self.settings.steamgrid_db.auth_key = Some(auth_key.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if auth_key.is_empty() && ui.button("Paste from clipboard").clicked(){
|
if auth_key.is_empty() && ui.button("Paste from clipboard").clicked() {
|
||||||
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
|
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
|
||||||
if let Ok(content) = clipboard_ctx.get_contents() {
|
if let Ok(content) = clipboard_ctx.get_contents() {
|
||||||
self.settings.steamgrid_db.auth_key = Some(content);
|
self.settings.steamgrid_db.auth_key = Some(content);
|
||||||
|
|||||||
Reference in New Issue
Block a user