Open urls with exe (#146)

* Launch Epic Games in safe mode through the exe

* Launch through exe for amazon games

* Remove unused comment

* Launch Uplay games through exe

* Fix epic tests

* Always launch origin games through the exe

* Fix that compat_folder is an option on unix
This commit is contained in:
Philip Kristoffersen
2022-05-22 14:53:23 +02:00
committed by GitHub
parent f2c83cb107
commit d1389fd757
12 changed files with 233 additions and 56 deletions
+23 -3
View File
@@ -30,7 +30,9 @@ impl Platform<AmazonGame, Box<dyn Error>> for AmazonPlatform {
fn get_shortcuts(&self) -> Result<Vec<AmazonGame>, Box<dyn Error>> {
let sqllite_path =
get_sqlite_path().expect("This should enver get called if settings are invalid");
get_sqlite_path().expect("This should never get called if settings are invalid");
let launcher_path =
get_launcher_path().expect("This should never get called if settings are invalid");
let mut result = vec![];
let connection = sqlite::open(sqllite_path)?;
let mut statement =
@@ -39,7 +41,7 @@ impl Platform<AmazonGame, Box<dyn Error>> for AmazonPlatform {
let id = statement.read::<String>(0);
let title = statement.read::<String>(1);
if let (Ok(id), Ok(title)) = (id, title) {
result.push(AmazonGame { title, id });
result.push(AmazonGame { title, id , launcher_path:launcher_path.clone()});
}
}
Ok(result)
@@ -47,7 +49,8 @@ impl Platform<AmazonGame, Box<dyn Error>> for AmazonPlatform {
fn settings_valid(&self) -> crate::platform::SettingsValidity {
let path = get_sqlite_path();
if path.is_some() {
let launcher = get_launcher_path();
if path.is_some() && launcher.is_some(){
crate::platform::SettingsValidity::Valid
} else {
crate::platform::SettingsValidity::Invalid {
@@ -84,3 +87,20 @@ fn get_sqlite_path() -> Option<PathBuf> {
Err(_e) => None,
}
}
fn get_launcher_path() -> Option<PathBuf> {
match std::env::var("LOCALAPPDATA") {
Ok(localdata) => {
let path = Path::new(&localdata)
.join("Amazon Games")
.join("App")
.join("Amazon Games.exe");
if path.exists() {
Some(path)
} else {
None
}
}
Err(_e) => None,
}
}