mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Validate settings before run
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use crate::platform::Platform;
|
use crate::platform::{Platform, SettingsValidity};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
get_egs_manifests, get_manifests::EpicGamesManifestsError, EpicGamesLauncherSettings,
|
get_egs_manifests, get_manifests::EpicGamesManifestsError, EpicGamesLauncherSettings,
|
||||||
@@ -32,4 +32,13 @@ impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform {
|
|||||||
fn create_symlinks(&self) -> bool {
|
fn create_symlinks(&self) -> bool {
|
||||||
self.settings.create_symlinks
|
self.settings.create_symlinks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn settings_valid(&self) -> SettingsValidity {
|
||||||
|
let shortcuts_res = self.get_shortcuts();
|
||||||
|
match shortcuts_res {
|
||||||
|
Ok(_) => SettingsValidity::Valid,
|
||||||
|
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,15 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
|||||||
|
|
||||||
Ok(shortcuts)
|
Ok(shortcuts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn settings_valid(&self) -> crate::platform::SettingsValidity {
|
||||||
|
use crate::platform::*;
|
||||||
|
let shortcuts_res = self.get_shortcuts();
|
||||||
|
match shortcuts_res {
|
||||||
|
Ok(_) => SettingsValidity::Valid,
|
||||||
|
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use super::butler_db_parser::*;
|
use super::butler_db_parser::*;
|
||||||
use super::receipt::Receipt;
|
use super::receipt::Receipt;
|
||||||
use super::{ItchGame, ItchSettings};
|
use super::{ItchGame, ItchSettings};
|
||||||
use crate::platform::Platform;
|
use crate::platform::{Platform, SettingsValidity};
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@@ -59,6 +59,15 @@ impl Platform<ItchGame, ItchErrors> for ItchPlatform {
|
|||||||
fn create_symlinks(&self) -> bool {
|
fn create_symlinks(&self) -> bool {
|
||||||
self.settings.create_symlinks
|
self.settings.create_symlinks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn settings_valid(&self) -> crate::platform::SettingsValidity {
|
||||||
|
let shortcuts_res = self.get_shortcuts();
|
||||||
|
match shortcuts_res {
|
||||||
|
Ok(_) => SettingsValidity::Valid,
|
||||||
|
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dbpath_to_game(paths: &DbPaths<'_>) -> Option<ItchGame> {
|
fn dbpath_to_game(paths: &DbPaths<'_>) -> Option<ItchGame> {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use super::{LegendaryGame, LegendarySettings};
|
use super::{LegendaryGame, LegendarySettings};
|
||||||
use crate::platform::Platform;
|
use crate::platform::{Platform, SettingsValidity};
|
||||||
use serde_json::from_str;
|
use serde_json::from_str;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
@@ -37,4 +37,12 @@ impl Platform<LegendaryGame, Box<dyn Error>> for LegendaryPlatform {
|
|||||||
fn create_symlinks(&self) -> bool {
|
fn create_symlinks(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn settings_valid(&self) -> crate::platform::SettingsValidity {
|
||||||
|
let shortcuts_res = self.get_shortcuts();
|
||||||
|
match shortcuts_res {
|
||||||
|
Ok(_) => SettingsValidity::Valid,
|
||||||
|
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::platform::Platform;
|
use crate::platform::{Platform, SettingsValidity};
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use nom::bytes::complete::take_until;
|
use nom::bytes::complete::take_until;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -65,6 +65,16 @@ impl Platform<OriginGame, OriginErrors> for OriginPlatform {
|
|||||||
});
|
});
|
||||||
Ok(games.collect())
|
Ok(games.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn settings_valid(&self) -> crate::platform::SettingsValidity {
|
||||||
|
let shortcuts_res = self.get_shortcuts();
|
||||||
|
match shortcuts_res {
|
||||||
|
Ok(_) => SettingsValidity::Valid,
|
||||||
|
Err(err) => SettingsValidity::Invalid{reason:format!("{}",err)}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_folder_mfst_file_content(game_folder_path: &Path) -> Option<String> {
|
fn get_folder_mfst_file_content(game_folder_path: &Path) -> Option<String> {
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ where
|
|||||||
|
|
||||||
fn get_shortcuts(&self) -> Result<Vec<T>, E>;
|
fn get_shortcuts(&self) -> Result<Vec<T>, E>;
|
||||||
|
|
||||||
|
fn settings_valid(&self) -> SettingsValidity;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn create_symlinks(&self) -> bool;
|
fn create_symlinks(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub enum SettingsValidity{
|
||||||
|
Valid,
|
||||||
|
Invalid{reason:String},
|
||||||
|
}
|
||||||
|
|||||||
@@ -126,6 +126,11 @@ where
|
|||||||
T: Into<ShortcutOwned>,
|
T: Into<ShortcutOwned>,
|
||||||
{
|
{
|
||||||
if platform.enabled() {
|
if platform.enabled() {
|
||||||
|
if let crate::platform::SettingsValidity::Invalid { reason } = platform.settings_valid() {
|
||||||
|
eprintln!("Setting for platform {} are invalid, reason: {}",platform.name(),reason);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
if platform.create_symlinks() {
|
if platform.create_symlinks() {
|
||||||
let name = platform.name();
|
let name = platform.name();
|
||||||
|
|||||||
Reference in New Issue
Block a user