mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 14:03:42 +02:00
UI image selection (#97)
This commit is contained in:
@@ -13,23 +13,23 @@ pub struct HeroicGame {
|
||||
pub launch_parameters: String,
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl HeroicGame{
|
||||
pub fn is_installed(&self) -> bool{
|
||||
Path::new(&self.install_path).join(&self.executable).exists()
|
||||
impl HeroicGame {
|
||||
pub fn is_installed(&self) -> bool {
|
||||
Path::new(&self.install_path)
|
||||
.join(&self.executable)
|
||||
.exists()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HeroicGame> for ShortcutOwned {
|
||||
fn from(game: HeroicGame) -> Self {
|
||||
let target_path = Path::new(&game.install_path).join(game.executable);
|
||||
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
let mut target = target_path.to_string_lossy().to_string();
|
||||
#[cfg(target_family = "unix")]
|
||||
{
|
||||
if !target.starts_with("\"") && !target.ends_with("\"") {
|
||||
if !target.starts_with('\"') && !target.ends_with('\"') {
|
||||
target = format!("\"{}\"", target);
|
||||
}
|
||||
}
|
||||
@@ -38,12 +38,12 @@ impl From<HeroicGame> for ShortcutOwned {
|
||||
let mut install_path = game.install_path.to_string();
|
||||
#[cfg(target_family = "unix")]
|
||||
{
|
||||
if !install_path.starts_with("\"") && !install_path.ends_with("\"") {
|
||||
if !install_path.starts_with('\"') && !install_path.ends_with('\"') {
|
||||
install_path = format!("\"{}\"", install_path);
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
let install_path = game.install_path.to_string();
|
||||
let install_path = game.install_path.to_string();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
let target = target_path.to_string_lossy().to_string();
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||
|
||||
use crate::gog::GogShortcut;
|
||||
use super::HeroicGame;
|
||||
|
||||
use crate::gog::GogShortcut;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum HeroicGameType{
|
||||
pub enum HeroicGameType {
|
||||
Epic(HeroicGame),
|
||||
//The bool is if it is windows (true) or not (false)
|
||||
Gog(GogShortcut,bool)
|
||||
Gog(GogShortcut, bool),
|
||||
}
|
||||
|
||||
|
||||
impl From<HeroicGameType> for ShortcutOwned {
|
||||
fn from(heroic_game_type: HeroicGameType) -> Self {
|
||||
match heroic_game_type{
|
||||
match heroic_game_type {
|
||||
HeroicGameType::Epic(epic) => epic.into(),
|
||||
HeroicGameType::Gog(gog,_) => gog.into(),
|
||||
HeroicGameType::Gog(gog, _) => gog.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize};
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::{HeroicGame, HeroicGameType, HeroicSettings};
|
||||
use crate::gog::{ get_shortcuts_from_game_folders};
|
||||
use crate::gog::get_shortcuts_from_game_folders;
|
||||
use crate::platform::{Platform, SettingsValidity};
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
@@ -48,7 +48,7 @@ fn get_gog_installed_location(install_mode: &InstallationMode) -> PathBuf {
|
||||
InstallationMode::UserBin => {
|
||||
Path::new(&home_dir).join(".config/heroic/gog_store/installed.json")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_shortcuts_from_install_mode(
|
||||
@@ -68,7 +68,7 @@ fn get_shortcuts_from_location<P: AsRef<Path>>(path: P) -> Result<Vec<HeroicGame
|
||||
games.push(game.clone());
|
||||
}
|
||||
Ok(games)
|
||||
}else{
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ impl Platform<HeroicGameType, Box<dyn Error>> for HeroicPlatform {
|
||||
}
|
||||
|
||||
fn needs_proton(&self, input: &HeroicGameType) -> bool {
|
||||
match input{
|
||||
match input {
|
||||
HeroicGameType::Epic(_) => true,
|
||||
HeroicGameType::Gog(_, is_windows) => *is_windows,
|
||||
}
|
||||
@@ -150,7 +150,7 @@ fn get_gog_games(
|
||||
})
|
||||
.filter_map(|config_path| std::fs::read_to_string(config_path).ok())
|
||||
.filter_map(|config_string| serde_json::from_str::<HeroicGogConfig>(&config_string).ok())
|
||||
.flat_map(|config| config.installed)
|
||||
.flat_map(|config| config.installed)
|
||||
.collect();
|
||||
|
||||
let mut is_windows_map = HashMap::new();
|
||||
@@ -170,9 +170,9 @@ fn get_gog_games(
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let shortcuts = get_shortcuts_from_game_folders(game_folders);
|
||||
let shortcuts = get_shortcuts_from_game_folders(game_folders);
|
||||
let mut gog_shortcuts = vec![];
|
||||
for shortcut in shortcuts {
|
||||
for shortcut in shortcuts {
|
||||
let is_windows = is_windows_map.get(&shortcut.game_id).unwrap_or(&false);
|
||||
gog_shortcuts.push(HeroicGameType::Gog(shortcut, *is_windows));
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
mod heroic_game;
|
||||
mod heroic_game_type;
|
||||
mod heroic_platform;
|
||||
mod settings;
|
||||
mod heroic_game_type;
|
||||
|
||||
pub use heroic_game::*;
|
||||
pub use heroic_game_type::*;
|
||||
pub use heroic_platform::*;
|
||||
pub use settings::*;
|
||||
pub use heroic_game_type::*;
|
||||
|
||||
Reference in New Issue
Block a user