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?
|
||||
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:
|
||||
|
||||
```shell
|
||||
|
||||
+8
-8
@@ -52,7 +52,6 @@ pub fn get_boilr_links_path() -> PathBuf {
|
||||
get_config_folder().join("links")
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::PathBuf;
|
||||
@@ -60,12 +59,13 @@ mod tests{
|
||||
use super::get_config_folder;
|
||||
|
||||
#[test]
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
fn check_return_xdg_config_path() {
|
||||
|
||||
// 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 config_path = get_config_folder();
|
||||
@@ -74,13 +74,13 @@ mod tests{
|
||||
assert_eq!(config_path, test_path);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
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";
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{settings::save_settings, platforms::get_platforms};
|
||||
use crate::{platforms::get_platforms, settings::save_settings};
|
||||
|
||||
pub fn migrate_config() {
|
||||
let version = &crate::settings::Settings::new()
|
||||
|
||||
@@ -3,17 +3,20 @@ use sqlite::State;
|
||||
use std::path::{Path, PathBuf};
|
||||
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)]
|
||||
pub struct AmazonPlatform {
|
||||
pub settings: AmazonSettings,
|
||||
}
|
||||
|
||||
|
||||
impl FromSettingsString for AmazonPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
AmazonPlatform { settings: load_settings(s) }
|
||||
AmazonPlatform {
|
||||
settings: load_settings(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,14 +59,12 @@ impl GamesPlatform for AmazonPlatform{
|
||||
"Amazon"
|
||||
}
|
||||
|
||||
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
|
||||
fn get_shortcut_info(&self) -> eyre::Result<Vec<ShortcutToImport>> {
|
||||
to_shortcuts_simple(self.get_amazon_games())
|
||||
|
||||
}
|
||||
|
||||
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
||||
@@ -80,9 +81,7 @@ impl GamesPlatform for AmazonPlatform{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl AmazonPlatform {
|
||||
|
||||
fn get_amazon_games(&self) -> eyre::Result<Vec<AmazonGame>> {
|
||||
let sqllite_path = get_sqlite_path()?;
|
||||
let launcher_path = get_launcher_path()?;
|
||||
@@ -149,6 +148,9 @@ impl Default for AmazonSettings{
|
||||
#[cfg(not(target_family = "unix"))]
|
||||
let enabled = true;
|
||||
|
||||
Self { enabled, launcher_location: Default::default() }
|
||||
Self {
|
||||
enabled,
|
||||
launcher_location: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
mod amazon_platform;
|
||||
|
||||
pub use amazon_platform::AmazonPlatform;
|
||||
pub use amazon_platform::AmazonGame;
|
||||
pub use amazon_platform::AmazonPlatform;
|
||||
|
||||
@@ -5,7 +5,9 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
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)]
|
||||
pub struct BottlesPlatform {
|
||||
@@ -14,7 +16,9 @@ pub struct BottlesPlatform {
|
||||
|
||||
impl FromSettingsString for BottlesPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
BottlesPlatform { settings: load_settings(s) }
|
||||
BottlesPlatform {
|
||||
settings: load_settings(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +128,6 @@ impl BottlesPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl GamesPlatform for BottlesPlatform {
|
||||
fn name(&self) -> &str {
|
||||
"Bottles"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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};
|
||||
|
||||
@@ -71,7 +71,6 @@ pub(crate) fn get_egs_manifests(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn is_game_installed(manifest: &ManifestItem) -> bool {
|
||||
Path::new(manifest.manifest_location.as_str()).exists()
|
||||
}
|
||||
|
||||
@@ -124,7 +124,6 @@ fn launcher_shortcut(manifest: ManifestItem) -> ShortcutOwned {
|
||||
.to_owned()
|
||||
}
|
||||
|
||||
|
||||
impl From<ManifestItem> for ShortcutOwned {
|
||||
fn from(manifest: ManifestItem) -> Self {
|
||||
let mut owned_shortcut = if manifest.needs_launcher() {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
mod epic_platform;
|
||||
mod epic_ui;
|
||||
mod get_manifests;
|
||||
mod manifest_item;
|
||||
mod paths;
|
||||
mod settings;
|
||||
mod epic_ui;
|
||||
|
||||
pub use epic_platform::*;
|
||||
use get_manifests::get_egs_manifests;
|
||||
pub(crate) use manifest_item::*;
|
||||
use paths::*;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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 steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
||||
@@ -34,7 +36,6 @@ impl NeedsPorton<FlatpakPlatform> for FlatpakApp{
|
||||
}
|
||||
|
||||
impl FlatpakPlatform {
|
||||
|
||||
fn get_flatpak_apps(&self) -> eyre::Result<Vec<FlatpakApp>> {
|
||||
use std::process::Command;
|
||||
let mut command = Command::new("flatpak");
|
||||
@@ -60,7 +61,6 @@ impl FlatpakPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl FromSettingsString for FlatpakPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
FlatpakPlatform {
|
||||
@@ -74,7 +74,6 @@ impl GamesPlatform for FlatpakPlatform{
|
||||
"Flatpak"
|
||||
}
|
||||
|
||||
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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::{
|
||||
gog_config::GogConfig,
|
||||
@@ -222,7 +224,6 @@ pub fn default_location() -> PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl FromSettingsString for GogPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
GogPlatform {
|
||||
|
||||
@@ -3,7 +3,7 @@ mod gog_game;
|
||||
mod gog_platform;
|
||||
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::GogPlatform;
|
||||
pub use gog_game::GogShortcut;
|
||||
pub(crate) use gog_settings::GogSettings;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
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 std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
@@ -107,7 +107,10 @@ impl NeedsPorton<HeroicPlatform> for HeroicGameType{
|
||||
}
|
||||
|
||||
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![];
|
||||
for install_mode in install_modes {
|
||||
if let Ok(mut games) = get_shortcuts_from_install_mode(install_mode) {
|
||||
@@ -199,12 +202,11 @@ fn get_gog_games(
|
||||
Ok(gog_shortcuts)
|
||||
}
|
||||
|
||||
|
||||
impl FromSettingsString for HeroicPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
HeroicPlatform {
|
||||
heroic_games: None,
|
||||
settings : load_settings(s)
|
||||
settings: load_settings(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +216,6 @@ impl GamesPlatform for HeroicPlatform{
|
||||
"Heroic"
|
||||
}
|
||||
|
||||
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
@@ -226,8 +227,14 @@ impl GamesPlatform for HeroicPlatform{
|
||||
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
||||
ui.heading("Heroic");
|
||||
ui.checkbox(&mut self.settings.enabled, "Import from Heroic");
|
||||
ui.checkbox(&mut self.settings.default_launch_through_heroic, "Always launch games through Heroic");
|
||||
let safe_mode_header = match (self.settings.default_launch_through_heroic,self.settings.launch_games_through_heroic.len()) {
|
||||
ui.checkbox(
|
||||
&mut self.settings.default_launch_through_heroic,
|
||||
"Always launch games through Heroic",
|
||||
);
|
||||
let safe_mode_header = match (
|
||||
self.settings.default_launch_through_heroic,
|
||||
self.settings.launch_games_through_heroic.len(),
|
||||
) {
|
||||
(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),
|
||||
@@ -235,30 +242,22 @@ impl GamesPlatform for HeroicPlatform{
|
||||
(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")
|
||||
.show(ui, |ui| {
|
||||
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.");
|
||||
|
||||
egui::CollapsingHeader::new(safe_mode_header).id_source("Heroic_Launcher_safe_launch").show(ui, |ui| {
|
||||
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.");
|
||||
} 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.");
|
||||
|
||||
}
|
||||
|
||||
let manifests = self.heroic_games.get_or_insert_with(|| {
|
||||
let heroic_setting = self.settings.clone();
|
||||
|
||||
let heroic_platform = HeroicPlatform{
|
||||
settings:heroic_setting,
|
||||
heroic_games:None
|
||||
};
|
||||
let heroic_platform = HeroicPlatform{ settings:heroic_setting, heroic_games:None};
|
||||
heroic_platform.get_heroic_games().unwrap_or_default()
|
||||
});
|
||||
|
||||
let safe_open_games = &mut self.settings.launch_games_through_heroic;
|
||||
|
||||
for manifest in manifests{
|
||||
let key = manifest.app_name();
|
||||
let display_name = manifest.title();
|
||||
@@ -272,7 +271,6 @@ self.settings.default_launch_through_heroic{
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
fn get_settings_serilizable(&self) -> String {
|
||||
|
||||
@@ -38,8 +38,6 @@ impl From<ItchGame> for ShortcutOwned {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl NeedsPorton<ItchPlatform> for ItchGame {
|
||||
fn needs_proton(&self, _platform: &ItchPlatform) -> bool {
|
||||
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::receipt::Receipt;
|
||||
use super::ItchSettings;
|
||||
use super::{butler_db_parser::*};
|
||||
use crate::platforms::{
|
||||
load_settings, to_shortcuts, FromSettingsString, GamesPlatform, ShortcutToImport,
|
||||
};
|
||||
use flate2::read::GzDecoder;
|
||||
use is_executable::IsExecutable;
|
||||
use std::collections::HashSet;
|
||||
@@ -90,8 +92,6 @@ pub fn get_default_location() -> String {
|
||||
//C:\Users\phili\AppData\Local\itch
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl FromSettingsString for ItchPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
ItchPlatform {
|
||||
@@ -100,7 +100,6 @@ impl FromSettingsString for ItchPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl GamesPlatform for ItchPlatform {
|
||||
fn name(&self) -> &str {
|
||||
"Itch"
|
||||
@@ -120,11 +119,7 @@ impl GamesPlatform for ItchPlatform{
|
||||
if self.settings.enabled {
|
||||
ui.horizontal(|ui| {
|
||||
let mut empty_string = "".to_string();
|
||||
let itch_location = self
|
||||
.settings
|
||||
.location
|
||||
.as_mut()
|
||||
.unwrap_or(&mut empty_string);
|
||||
let itch_location = self.settings.location.as_mut().unwrap_or(&mut empty_string);
|
||||
ui.label("Itch.io Folder: ");
|
||||
if ui.text_edit_singleline(itch_location).changed() {
|
||||
self.settings.location = if itch_location.is_empty() {
|
||||
@@ -132,10 +127,12 @@ impl GamesPlatform for ItchPlatform{
|
||||
} else {
|
||||
Some(itch_location.to_string())
|
||||
};
|
||||
} else if !itch_location.is_empty() && ui
|
||||
} else if !itch_location.is_empty()
|
||||
&& ui
|
||||
.button("Reset")
|
||||
.on_hover_text("Reset the itch path, let BoilR guess again")
|
||||
.clicked() {
|
||||
.clicked()
|
||||
{
|
||||
self.settings.location = None;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use super::legendary_game::LegendaryGame;
|
||||
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 std::process::Command;
|
||||
|
||||
@@ -76,7 +78,7 @@ impl GamesPlatform for LegendaryPlatform {
|
||||
impl FromSettingsString for LegendaryPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
LegendaryPlatform {
|
||||
settings:load_settings(s)
|
||||
settings: load_settings(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,5 @@ mod legendary_game;
|
||||
mod legendary_platform;
|
||||
mod settings;
|
||||
|
||||
|
||||
pub use settings::LegendarySettings;
|
||||
pub use legendary_platform::LegendaryPlatform;
|
||||
pub use settings::LegendarySettings;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use super::game_list_parser::parse_lutris_games;
|
||||
use super::lutris_game::LutrisGame;
|
||||
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;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -59,7 +61,9 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result<String>
|
||||
|
||||
impl FromSettingsString for LutrisPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
LutrisPlatform { settings: load_settings(s) }
|
||||
LutrisPlatform {
|
||||
settings: load_settings(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,14 +72,12 @@ impl GamesPlatform for LutrisPlatform{
|
||||
"Lutris"
|
||||
}
|
||||
|
||||
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
|
||||
fn get_shortcut_info(&self) -> eyre::Result<Vec<ShortcutToImport>> {
|
||||
to_shortcuts_simple(self.get_shortcuts())
|
||||
|
||||
}
|
||||
|
||||
fn render_ui(&mut self, ui: &mut egui::Ui) {
|
||||
@@ -106,5 +108,4 @@ impl GamesPlatform for LutrisPlatform{
|
||||
fn code_name(&self) -> &str {
|
||||
"lutris"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
mod platform;
|
||||
mod egs;
|
||||
mod amazon;
|
||||
mod bottles;
|
||||
mod uplay;
|
||||
mod itch;
|
||||
mod egs;
|
||||
mod flatpak;
|
||||
mod origin;
|
||||
mod gog;
|
||||
mod heroic;
|
||||
mod lutris;
|
||||
mod itch;
|
||||
mod legendary;
|
||||
mod lutris;
|
||||
mod origin;
|
||||
mod platform;
|
||||
mod platforms_load;
|
||||
mod uplay;
|
||||
|
||||
pub(crate) use platform::*;
|
||||
|
||||
pub(crate) use gog::get_gog_shortcuts_from_game_folders;
|
||||
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(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 settings;
|
||||
|
||||
pub use settings::OriginSettings;
|
||||
pub(crate) use origin_platform::OriginPlatform;
|
||||
pub use settings::OriginSettings;
|
||||
|
||||
@@ -13,12 +13,10 @@ pub struct OriginGame {
|
||||
impl From<OriginGame> for ShortcutOwned {
|
||||
fn from(game: OriginGame) -> Self {
|
||||
let launch = match game.origin_compat_folder{
|
||||
Some(compat_folder) =>
|
||||
format!("STEAM_COMPAT_DATA_PATH=\"{}\" %command% \"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"", compat_folder.to_string_lossy(), game.id)
|
||||
,
|
||||
None => format!(
|
||||
"\"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",
|
||||
game.id)
|
||||
Some(compat_folder) => format!
|
||||
("STEAM_COMPAT_DATA_PATH=\"{}\" %command% \"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",
|
||||
compat_folder.to_string_lossy(), game.id),
|
||||
None => format!("\"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",game.id)
|
||||
};
|
||||
let origin_location = format!("\"{}\"", game.origin_location.to_string_lossy());
|
||||
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 std::{
|
||||
fs::DirEntry,
|
||||
@@ -205,13 +207,12 @@ impl GamesPlatform for OriginPlatform {
|
||||
fn code_name(&self) -> &str {
|
||||
"origin"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl FromSettingsString for OriginPlatform {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
|
||||
OriginPlatform { settings: load_settings(s) }
|
||||
OriginPlatform {
|
||||
settings: load_settings(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||
use dyn_clone::DynClone;
|
||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||
|
||||
pub trait GamesPlatform
|
||||
where
|
||||
@@ -29,7 +29,6 @@ pub struct ShortcutToImport {
|
||||
pub needs_symlinks: bool,
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn to_shortcuts<T, P>(
|
||||
platform: &P,
|
||||
into_shortcuts: Result<Vec<T>, eyre::ErrReport>,
|
||||
@@ -79,4 +78,3 @@ pub trait NeedsPorton<P> {
|
||||
|
||||
fn create_symlinks(&self, platform: &P) -> bool;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
use crate::settings::load_setting_sections;
|
||||
|
||||
use super::GamesPlatform;
|
||||
use super::amazon::AmazonPlatform;
|
||||
use super::bottles::BottlesPlatform;
|
||||
use super::egs::EpicPlatform;
|
||||
@@ -17,6 +15,7 @@ use super::legendary::LegendaryPlatform;
|
||||
use super::lutris::LutrisPlatform;
|
||||
use super::origin::OriginPlatform;
|
||||
use super::uplay::UplayPlatform;
|
||||
use super::GamesPlatform;
|
||||
|
||||
const PLATFORM_NAMES: [&str; 11] = [
|
||||
"amazon",
|
||||
@@ -56,7 +55,6 @@ pub fn load_platform<A: AsRef<str>, B: AsRef<str>>(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn get_platforms() -> Platforms {
|
||||
let sections = load_setting_sections();
|
||||
let sections = match sections {
|
||||
@@ -99,7 +97,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn load<T>(s: &str) -> eyre::Result<Box<dyn GamesPlatform>>
|
||||
where
|
||||
T: FromSettingsString,
|
||||
@@ -109,7 +106,6 @@ where
|
||||
Ok(Box::new(T::from_settings_string(s)))
|
||||
}
|
||||
|
||||
|
||||
pub trait FromSettingsString {
|
||||
fn from_settings_string<S: AsRef<str>>(s: S) -> Self;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ use std::path::Path;
|
||||
#[cfg(target_os = "windows")]
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::platforms::FromSettingsString;
|
||||
use crate::platforms::GamesPlatform;
|
||||
use crate::platforms::load_settings;
|
||||
use crate::platforms::to_shortcuts_simple;
|
||||
use crate::platforms::FromSettingsString;
|
||||
use crate::platforms::GamesPlatform;
|
||||
use crate::platforms::ShortcutToImport;
|
||||
|
||||
use super::{game::UplayGame, settings::UplaySettings};
|
||||
@@ -98,7 +98,6 @@ impl FromSettingsString for UplayPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl GamesPlatform for UplayPlatform {
|
||||
fn name(&self) -> &str {
|
||||
"Uplay"
|
||||
@@ -124,5 +123,4 @@ impl GamesPlatform for UplayPlatform{
|
||||
fn code_name(&self) -> &str {
|
||||
"uplay"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,5 +7,3 @@ pub use synchronization::download_images;
|
||||
pub use synchronization::IsBoilRShortcut;
|
||||
pub use synchronization::SyncProgress;
|
||||
pub use synchronization::*;
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,10 @@ impl MyEguiApp {
|
||||
ui.heading(&user.path.to_string_lossy().to_string());
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::sync;
|
||||
|
||||
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::{
|
||||
ui_colors::{BACKGROUND_COLOR, EXTRA_BACKGROUND_COLOR},
|
||||
MyEguiApp,
|
||||
@@ -106,7 +106,6 @@ impl MyEguiApp {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -114,7 +113,6 @@ impl MyEguiApp {
|
||||
ui.label("Failed finding games").on_hover_text(format!("Error message: {err}"));
|
||||
},
|
||||
};
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
@@ -125,7 +123,6 @@ impl MyEguiApp {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
pub fn run_sync(&mut self, wait: bool) {
|
||||
let (sender, reciever) = watch::channel(SyncProgress::NotStarted);
|
||||
let settings = self.settings.clone();
|
||||
@@ -142,7 +139,6 @@ impl MyEguiApp {
|
||||
if all_ready {
|
||||
let shortcuts_to_import = get_all_games(&self.games_to_sync);
|
||||
let handle = self.rt.spawn_blocking(move || {
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
setup_proton(shortcuts_to_import.iter());
|
||||
|
||||
@@ -150,7 +146,9 @@ impl MyEguiApp {
|
||||
|
||||
let mut some_sender = Some(sender);
|
||||
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);
|
||||
block_on(task);
|
||||
//Run a second time to fix up shortcuts after images are downloaded
|
||||
@@ -168,11 +166,11 @@ 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![];
|
||||
for (name, infos) in shortcuts_to_import {
|
||||
let mut shortcuts = vec![];
|
||||
@@ -184,11 +182,11 @@ fn to_shortcut_owned(shortcuts_to_import: Vec<(String, Vec<ShortcutToImport>)>)
|
||||
import_games
|
||||
}
|
||||
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
fn setup_proton<'a, I>(shortcut_infos: I)
|
||||
where
|
||||
I: IntoIterator<Item = &'a (String,Vec<ShortcutToImport>)>{
|
||||
I: IntoIterator<Item = &'a (String, Vec<ShortcutToImport>)>,
|
||||
{
|
||||
let mut shortcuts_to_proton = vec![];
|
||||
|
||||
for (name, shortcuts) in shortcut_infos {
|
||||
|
||||
@@ -38,7 +38,6 @@ impl MyEguiApp {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
fn render_steam_settings(&mut self, ui: &mut egui::Ui) {
|
||||
ui.heading("Steam");
|
||||
ui.horizontal(|ui| {
|
||||
@@ -56,7 +55,6 @@ impl MyEguiApp {
|
||||
} else {
|
||||
self.settings.steam.location = Some(steam_location.to_string());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
ui.checkbox(
|
||||
|
||||
Reference in New Issue
Block a user