mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
UI image selection (#97)
This commit is contained in:
@@ -11,7 +11,9 @@ pub struct EpicPlatform {
|
||||
|
||||
impl EpicPlatform {
|
||||
pub fn new(settings: &EpicGamesLauncherSettings) -> Self {
|
||||
EpicPlatform { settings: settings.clone() }
|
||||
EpicPlatform {
|
||||
settings: settings.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,24 @@ pub(crate) fn get_egs_manifests(
|
||||
.filter_map(|dir| dir.ok())
|
||||
.filter_map(get_manifest_item)
|
||||
.filter(is_game_installed)
|
||||
.filter(is_game_launchable);
|
||||
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()){
|
||||
.filter(is_game_launchable);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +70,6 @@ pub(crate) fn get_egs_manifests(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn get_manifest_dir_path(
|
||||
settings: &EpicGamesLauncherSettings,
|
||||
) -> Result<String, EpicGamesManifestsError> {
|
||||
@@ -113,7 +124,7 @@ fn location_from_registry() -> Option<PathBuf> {
|
||||
if let Ok(path_string) = path_string {
|
||||
let path = Path::new(&path_string).join("Manifests");
|
||||
if path.exists() {
|
||||
return Some(path.to_path_buf());
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +143,7 @@ fn guess_default_location() -> PathBuf {
|
||||
.join("EpicGamesLauncher")
|
||||
.join("Data")
|
||||
.join("Manifests");
|
||||
path.to_path_buf()
|
||||
path
|
||||
}
|
||||
|
||||
fn is_game_installed(manifest: &ManifestItem) -> bool {
|
||||
|
||||
@@ -100,7 +100,7 @@ impl ManifestItem {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_key(&self) -> String{
|
||||
pub fn get_key(&self) -> String {
|
||||
format!(
|
||||
"{}-{}-{}",
|
||||
self.catalog_namespace, self.catalog_item_id, self.app_name
|
||||
@@ -108,7 +108,7 @@ impl ManifestItem {
|
||||
}
|
||||
|
||||
fn needs_launcher(&self) -> bool {
|
||||
if self.safe_launch{
|
||||
if self.safe_launch {
|
||||
return true;
|
||||
}
|
||||
match (&self.is_managed, &self.expected_dlc) {
|
||||
@@ -157,7 +157,7 @@ mod tests {
|
||||
let mut manifest: ManifestItem = serde_json::from_str(json).unwrap();
|
||||
manifest.is_managed = false;
|
||||
manifest.expected_dlc = None;
|
||||
let shortcut: ShortcutOwned = manifest.clone().into();
|
||||
let shortcut: ShortcutOwned = manifest.into();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
assert_eq!(shortcut.exe, "C:\\Games\\MarvelGOTG\\retail/gotg.exe");
|
||||
@@ -172,7 +172,7 @@ mod tests {
|
||||
let json = include_str!("example_item.json");
|
||||
let mut manifest: ManifestItem = serde_json::from_str(json).unwrap();
|
||||
manifest.is_managed = false;
|
||||
let shortcut: ShortcutOwned = manifest.clone().into();
|
||||
let shortcut: ShortcutOwned = manifest.into();
|
||||
|
||||
let expected ="com.epicgames.launcher://apps/2a09fb19b47f46dfb11ebd382f132a8f%3A88f4bb0bb06e4962a2042d5e20fb6ace%3A63a665088eb1480298f1e57943b225d8?action=launch&silent=true";
|
||||
let actual = shortcut.exe;
|
||||
|
||||
+1
-1
@@ -8,5 +8,5 @@ pub struct EpicGamesLauncherSettings {
|
||||
#[cfg(target_family = "unix")]
|
||||
pub create_symlinks: bool,
|
||||
|
||||
pub safe_launch : Vec<String>
|
||||
pub safe_launch: Vec<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user