Skip to content

Commit

Permalink
Only load platforms for OS (#288)
Browse files Browse the repository at this point in the history
* Only load platforms for OS

* Update to version 1.7.10
  • Loading branch information
PhilipK committed Dec 28, 2022
1 parent ffb9b65 commit 32c6540
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "boilr"
version = "1.7.9"
version = "1.7.10"

[dependencies]
base64 = "^0.20.0"
Expand All @@ -21,9 +21,6 @@ eyre = "^0.6.8"
color-eyre = "^0.6.2"
dyn-clone = "^1.0.10"

[dependencies.sqlite]
version = "^0.30.3"

[dependencies.dashmap]
features = ["serde"]
version = "^5.4.0"
Expand Down Expand Up @@ -65,6 +62,7 @@ winres = "^0.1.12"

[target."cfg(windows)".dependencies]
winreg = "^0.10.1"
sqlite = "^0.30.3"

[features]
# This feature is enabled when building for a flatpak environment
Expand Down
11 changes: 10 additions & 1 deletion flatpak/io.github.philipk.boilr.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ https://hughsie.github.io/oars/index.html
-->
<content_rating type="oars-1.1" />
<releases>
<release version="1.7.9" date="2022-12-28">
<release version="1.7.10" date="2022-12-28">
<description>
<ul>
<li>Only load platforms that are available for OS</li>
</ul>
</description>
</release>


<release version="1.7.9" date="2022-12-28">
<description>
<ul>
<li>Fix import button hidden on steam deck in game mode</li>
Expand Down
20 changes: 15 additions & 5 deletions src/platforms/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
mod amazon;
#[cfg(target_family = "unix")]
mod bottles;
mod egs;
#[cfg(target_family = "unix")]
mod flatpak;
mod gog;
#[cfg(target_family = "unix")]
mod heroic;
mod itch;
#[cfg(target_family = "unix")]
mod legendary;
#[cfg(target_family = "unix")]
mod lutris;
#[cfg(target_family = "unix")]
mod minigalaxy;

#[cfg(not(target_family = "unix"))]
mod amazon;


mod gog;
mod itch;
mod origin;
mod platform;
mod platforms_load;
mod uplay;
mod minigalaxy;

mod egs;
pub(crate) use platform::*;

pub(crate) use gog::get_gog_shortcuts_from_game_folders;
Expand Down
65 changes: 41 additions & 24 deletions src/platforms/platforms_load.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
use std::collections::HashMap;

use serde::de::DeserializeOwned;
use std::collections::HashMap;

use crate::settings::load_setting_sections;

use super::amazon::AmazonPlatform;
use super::bottles::BottlesPlatform;
use super::egs::EpicPlatform;
use super::flatpak::FlatpakPlatform;
use super::gog::GogPlatform;
use super::heroic::HeroicPlatform;
use super::itch::ItchPlatform;
use super::legendary::LegendaryPlatform;
use super::lutris::LutrisPlatform;
use super::minigalaxy::MiniGalaxyPlatform;
use super::origin::OriginPlatform;
use super::uplay::UplayPlatform;
use super::GamesPlatform;

use crate::settings::load_setting_sections;
const PLATFORM_NAMES: [&str; 12] = [
"amazon",
"bottles",
Expand All @@ -30,7 +16,7 @@ const PLATFORM_NAMES: [&str; 12] = [
"lutris",
"origin",
"uplay",
"minigalaxy"
"minigalaxy",
];

pub type Platforms = Vec<Box<dyn GamesPlatform>>;
Expand All @@ -41,19 +27,50 @@ pub fn load_platform<A: AsRef<str>, B: AsRef<str>>(
) -> eyre::Result<Box<dyn GamesPlatform>> {
let name = name.as_ref();
let s = settings_string.as_ref();

#[cfg(not(target_family = "unix"))]
{
//Windows only platforms
use super::amazon::AmazonPlatform;
match name {
"amazon" => return load::<AmazonPlatform>(s),
_ => {}
}
}

#[cfg(target_family = "unix")]
{
use super::bottles::BottlesPlatform;
use super::flatpak::FlatpakPlatform;
use super::heroic::HeroicPlatform;
use super::legendary::LegendaryPlatform;
use super::lutris::LutrisPlatform;
use super::minigalaxy::MiniGalaxyPlatform;
//Linux only platforms
match name {
"bottles" => return load::<BottlesPlatform>(s),
"flatpak" => return load::<FlatpakPlatform>(s),
"minigalaxy" => return load::<MiniGalaxyPlatform>(s),
"legendary" => return load::<LegendaryPlatform>(s),
"lutris" => return load::<LutrisPlatform>(s),
"heroic" => return load::<HeroicPlatform>(s),
_ => {}
}
}

//Common platforms
use super::egs::EpicPlatform;
use super::gog::GogPlatform;
use super::itch::ItchPlatform;
use super::origin::OriginPlatform;
use super::uplay::UplayPlatform;

match name {
"amazon" => load::<AmazonPlatform>(s),
"bottles" => load::<BottlesPlatform>(s),
"epic_games" => load::<EpicPlatform>(s),
"uplay" => load::<UplayPlatform>(s),
"itch" => load::<ItchPlatform>(s),
"flatpak" => load::<FlatpakPlatform>(s),
"gog" => load::<GogPlatform>(s),
"heroic" => load::<HeroicPlatform>(s),
"legendary" => load::<LegendaryPlatform>(s),
"lutris" => load::<LutrisPlatform>(s),
"origin" => load::<OriginPlatform>(s),
"minigalaxy" => load::<MiniGalaxyPlatform>(s),
_ => Err(eyre::format_err!("Unknown platform named {name}")),
}
}
Expand Down

0 comments on commit 32c6540

Please sign in to comment.