Epic safe launch (#85)

This feature lets users force some Epic Games to be launched through the Epic Launcher
This commit is contained in:
Philip Kristoffersen
2022-04-18 14:00:06 +02:00
committed by GitHub
parent 03aab2e088
commit e9d10499f2
7 changed files with 212 additions and 118 deletions
+2 -2
View File
@@ -10,8 +10,8 @@ pub struct EpicPlatform {
}
impl EpicPlatform {
pub fn new(settings: EpicGamesLauncherSettings) -> Self {
EpicPlatform { settings }
pub fn new(settings: &EpicGamesLauncherSettings) -> Self {
EpicPlatform { settings: settings.clone() }
}
}
+5
View File
@@ -44,6 +44,11 @@ pub(crate) fn get_egs_manifests(
let mut manifests : Vec<ManifestItem> = manifests.collect();
manifests.sort_by_key(|m| format!("{}-{}-{}",m.install_location,m.launch_executable,m.is_managed));
manifests.dedup_by_key(|m| format!("{}-{}-{}",m.install_location,m.launch_executable,m.is_managed));
for mut manifest in &mut manifests{
if settings.safe_launch.contains(&manifest.display_name) || settings.safe_launch.contains(&manifest.get_key()){
manifest.safe_launch = true;
}
}
Ok(manifests)
}
Err(err) => Err(ReadDirError {
+14
View File
@@ -31,6 +31,9 @@ pub(crate) struct ManifestItem {
#[serde(alias = "ExpectingDLCInstalled")]
pub expected_dlc: Option<HashMap<String, bool>>,
#[serde(default)]
pub safe_launch: bool,
}
fn exe_shortcut(manifest: ManifestItem) -> ShortcutOwned {
@@ -96,7 +99,18 @@ impl ManifestItem {
self.catalog_namespace, self.catalog_item_id, self.app_name
)
}
pub fn get_key(&self) -> String{
format!(
"{}-{}-{}",
self.catalog_namespace, self.catalog_item_id, self.app_name
)
}
fn needs_launcher(&self) -> bool {
if self.safe_launch{
return true;
}
match (&self.is_managed, &self.expected_dlc) {
(true, _) => true,
(false, Some(map)) => !map.is_empty(),
+2
View File
@@ -7,4 +7,6 @@ pub struct EpicGamesLauncherSettings {
#[cfg(target_family = "unix")]
pub create_symlinks: bool,
pub safe_launch : Vec<String>
}