mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 14:03:42 +02:00
Add tests for egs launcher shortcut
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"FormatVersion": 0,
|
||||||
|
"bIsIncompleteInstall": false,
|
||||||
|
"LaunchCommand": "",
|
||||||
|
"LaunchExecutable": "retail/gotg.exe",
|
||||||
|
"ManifestLocation": "C:\\Games\\MarvelGOTG/.egstore",
|
||||||
|
"bIsApplication": true,
|
||||||
|
"bIsExecutable": true,
|
||||||
|
"bIsManaged": false,
|
||||||
|
"bNeedsValidation": false,
|
||||||
|
"bRequiresAuth": true,
|
||||||
|
"bAllowMultipleInstances": false,
|
||||||
|
"bCanRunOffline": true,
|
||||||
|
"bAllowUriCmdArgs": false,
|
||||||
|
"BaseURLs": [
|
||||||
|
"http://download.epicgames.com/Builds/Org/o-7petn7mrlk8g86ktqm7uglcr7lfaja/fb40e48d8e454558a2e02ad7f9a991ff/default",
|
||||||
|
"http://download2.epicgames.com/Builds/Org/o-7petn7mrlk8g86ktqm7uglcr7lfaja/fb40e48d8e454558a2e02ad7f9a991ff/default",
|
||||||
|
"http://download3.epicgames.com/Builds/Org/o-7petn7mrlk8g86ktqm7uglcr7lfaja/fb40e48d8e454558a2e02ad7f9a991ff/default",
|
||||||
|
"http://download4.epicgames.com/Builds/Org/o-7petn7mrlk8g86ktqm7uglcr7lfaja/fb40e48d8e454558a2e02ad7f9a991ff/default",
|
||||||
|
"http://epicgames-download1.akamaized.net/Builds/Org/o-7petn7mrlk8g86ktqm7uglcr7lfaja/fb40e48d8e454558a2e02ad7f9a991ff/default",
|
||||||
|
"http://fastly-download.epicgames.com/Builds/Org/o-7petn7mrlk8g86ktqm7uglcr7lfaja/fb40e48d8e454558a2e02ad7f9a991ff/default"
|
||||||
|
],
|
||||||
|
"BuildLabel": "Live",
|
||||||
|
"AppCategories": [
|
||||||
|
"public",
|
||||||
|
"games",
|
||||||
|
"applications"
|
||||||
|
],
|
||||||
|
"ChunkDbs": [],
|
||||||
|
"CompatibleApps": [],
|
||||||
|
"DisplayName": "Marvel's Guardians of the Galaxy",
|
||||||
|
"InstallationGuid": "F222C4654922E0B5AD85FEAA13041D0C",
|
||||||
|
"InstallLocation": "C:\\Games\\MarvelGOTG",
|
||||||
|
"InstallSessionId": "5F9B61224533B88E5B286BAE553606FD",
|
||||||
|
"InstallTags": [],
|
||||||
|
"InstallComponents": [],
|
||||||
|
"HostInstallationGuid": "00000000000000000000000000000000",
|
||||||
|
"PrereqIds": [],
|
||||||
|
"StagingLocation": "C:\\Games\\MarvelGOTG/.egstore/bps",
|
||||||
|
"TechnicalType": "public,games,applications",
|
||||||
|
"VaultThumbnailUrl": "",
|
||||||
|
"VaultTitleText": "",
|
||||||
|
"InstallSize": 81199814148,
|
||||||
|
"MainWindowProcessName": "",
|
||||||
|
"ProcessNames": [],
|
||||||
|
"BackgroundProcessNames": [],
|
||||||
|
"ExpectingDLCInstalled":
|
||||||
|
{
|
||||||
|
"2a09fb19b47f46dfb11ebd382f132a8f:b2666e211d334d15a0c29188d0abb6c8:9596620d263b40c083ddf1f0c662c8ff": true
|
||||||
|
},
|
||||||
|
"MandatoryAppFolderName": "MarvelGOTG",
|
||||||
|
"OwnershipToken": "true",
|
||||||
|
"CatalogNamespace": "2a09fb19b47f46dfb11ebd382f132a8f",
|
||||||
|
"CatalogItemId": "88f4bb0bb06e4962a2042d5e20fb6ace",
|
||||||
|
"AppName": "63a665088eb1480298f1e57943b225d8",
|
||||||
|
"AppVersionString": "2982110",
|
||||||
|
"MainGameCatalogNamespace": "2a09fb19b47f46dfb11ebd382f132a8f",
|
||||||
|
"MainGameCatalogItemId": "88f4bb0bb06e4962a2042d5e20fb6ace",
|
||||||
|
"MainGameAppName": "63a665088eb1480298f1e57943b225d8",
|
||||||
|
"AllowedUriEnvVars": []
|
||||||
|
}
|
||||||
+81
-15
@@ -1,7 +1,7 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use steam_shortcuts_util::{Shortcut, shortcut::ShortcutOwned};
|
use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub(crate) struct ManifestItem {
|
pub(crate) struct ManifestItem {
|
||||||
@@ -20,35 +20,101 @@ pub(crate) struct ManifestItem {
|
|||||||
#[serde(alias = "AppName")]
|
#[serde(alias = "AppName")]
|
||||||
pub app_name: String,
|
pub app_name: String,
|
||||||
|
|
||||||
#[serde(alias = "LaunchCommand")]
|
#[serde(alias = "CatalogNamespace")]
|
||||||
pub launch_command: String,
|
pub catalog_namespace: String,
|
||||||
|
|
||||||
|
#[serde(alias = "CatalogItemId")]
|
||||||
|
pub catalog_item_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn exe_shortcut(manifest: ManifestItem) -> ShortcutOwned {
|
||||||
|
let exe = manifest.exe();
|
||||||
impl From<ManifestItem> for ShortcutOwned {
|
|
||||||
fn from(manifest: ManifestItem) -> Self {
|
|
||||||
|
|
||||||
let exe_path = Path::new(&manifest.install_location).join(manifest.launch_executable).to_string_lossy().to_string();
|
|
||||||
let exe = format!("\"{}\"",exe_path);
|
|
||||||
let mut start_dir = manifest.install_location.clone();
|
let mut start_dir = manifest.install_location.clone();
|
||||||
if !manifest.install_location.starts_with('"') {
|
if !manifest.install_location.starts_with('"') {
|
||||||
start_dir = format!("\"{}\"", manifest.install_location);
|
start_dir = format!("\"{}\"", manifest.install_location);
|
||||||
}
|
}
|
||||||
let shortcut = Shortcut::new(
|
Shortcut::new(
|
||||||
0,
|
0,
|
||||||
manifest.display_name.as_str(),
|
manifest.display_name.as_str(),
|
||||||
exe.as_str(),
|
exe.as_str(),
|
||||||
start_dir.as_str(),
|
start_dir.as_str(),
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
manifest.launch_command.as_str(),
|
"",
|
||||||
);
|
)
|
||||||
let mut owned_shortcut = shortcut.to_owned();
|
.to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn launcher_shortcut(manifest: ManifestItem) -> ShortcutOwned {
|
||||||
|
let icon = manifest.exe();
|
||||||
|
let options = manifest.get_launch_url();
|
||||||
|
Shortcut::new(
|
||||||
|
0,
|
||||||
|
manifest.display_name.as_str(),
|
||||||
|
"explorer.exe",
|
||||||
|
"",
|
||||||
|
icon.as_str(),
|
||||||
|
"",
|
||||||
|
options.as_str(),
|
||||||
|
)
|
||||||
|
.to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ManifestItem> for ShortcutOwned {
|
||||||
|
fn from(manifest: ManifestItem) -> Self {
|
||||||
|
let mut owned_shortcut = if manifest.needs_launcher() {
|
||||||
|
launcher_shortcut(manifest)
|
||||||
|
} else {
|
||||||
|
exe_shortcut(manifest)
|
||||||
|
};
|
||||||
owned_shortcut.tags.push("EGS".to_owned());
|
owned_shortcut.tags.push("EGS".to_owned());
|
||||||
owned_shortcut.tags.push("Ready TO Play".to_owned());
|
owned_shortcut.tags.push("Ready TO Play".to_owned());
|
||||||
owned_shortcut.tags.push("Installed".to_owned());
|
owned_shortcut.tags.push("Installed".to_owned());
|
||||||
|
|
||||||
owned_shortcut
|
owned_shortcut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ManifestItem {
|
||||||
|
fn exe(&self) -> String {
|
||||||
|
let manifest = self;
|
||||||
|
let exe_path = Path::new(&manifest.install_location)
|
||||||
|
.join(&manifest.launch_executable)
|
||||||
|
.to_string_lossy()
|
||||||
|
.to_string();
|
||||||
|
let exe = format!("\"{}\"", exe_path);
|
||||||
|
exe
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_launch_url(&self) -> String {
|
||||||
|
format!(
|
||||||
|
"com.epicgames.launcher://apps/{}%3A{}%3A{}?action=launch&silent=true",
|
||||||
|
self.catalog_namespace, self.catalog_item_id, self.app_name
|
||||||
|
)
|
||||||
|
}
|
||||||
|
fn needs_launcher(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_parse_item() {
|
||||||
|
let json = include_str!("example_item.json");
|
||||||
|
let _: ManifestItem = serde_json::from_str(json).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn generates_launch_string() {
|
||||||
|
let json = include_str!("example_item.json");
|
||||||
|
let expected ="com.epicgames.launcher://apps/2a09fb19b47f46dfb11ebd382f132a8f%3A88f4bb0bb06e4962a2042d5e20fb6ace%3A63a665088eb1480298f1e57943b225d8?action=launch&silent=true";
|
||||||
|
|
||||||
|
let manifest: ManifestItem = serde_json::from_str(json).unwrap();
|
||||||
|
let actual = manifest.get_launch_url();
|
||||||
|
|
||||||
|
assert_eq!(expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user