mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Fix finding more game pass games (#353)
This commit is contained in:
Generated
+17
-1
@@ -399,7 +399,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "boilr"
|
name = "boilr"
|
||||||
version = "1.9.0"
|
version = "1.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.0",
|
"base64 0.21.0",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
@@ -417,6 +417,7 @@ dependencies = [
|
|||||||
"nom",
|
"nom",
|
||||||
"openssl",
|
"openssl",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"roxmltree",
|
||||||
"rusty-leveldb",
|
"rusty-leveldb",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -2613,6 +2614,15 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "roxmltree"
|
||||||
|
version = "0.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d8f595a457b6b8c6cda66a48503e92ee8d19342f905948f29c383200ec9eb1d8"
|
||||||
|
dependencies = [
|
||||||
|
"xmlparser",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-ini"
|
name = "rust-ini"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
@@ -3970,6 +3980,12 @@ version = "0.8.14"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52839dc911083a8ef63efa4d039d1f58b5e409f923e44c80828f206f66e5541c"
|
checksum = "52839dc911083a8ef63efa4d039d1f58b5e409f923e44c80828f206f66e5541c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xmlparser"
|
||||||
|
version = "0.13.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yaml-rust"
|
name = "yaml-rust"
|
||||||
version = "0.4.5"
|
version = "0.4.5"
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
name = "boilr"
|
name = "boilr"
|
||||||
version = "1.9.0"
|
version = "1.9.1"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "^0.21.0"
|
base64 = "^0.21.0"
|
||||||
@@ -64,6 +64,7 @@ winres = "^0.1.12"
|
|||||||
[target."cfg(windows)".dependencies]
|
[target."cfg(windows)".dependencies]
|
||||||
winreg = "^0.50.0"
|
winreg = "^0.50.0"
|
||||||
sqlite = "^0.30.3"
|
sqlite = "^0.30.3"
|
||||||
|
roxmltree = "^0.18.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# This feature is enabled when building for a flatpak environment
|
# This feature is enabled when building for a flatpak environment
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ pub struct GamePassSettings {
|
|||||||
enabled: bool,
|
enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl GamesPlatform for GamePassPlatForm {
|
impl GamesPlatform for GamePassPlatForm {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"Game Pass"
|
"Game Pass"
|
||||||
@@ -37,27 +36,30 @@ impl GamesPlatform for GamePassPlatForm {
|
|||||||
let command = include_str!("./game_pass_games.ps1");
|
let command = include_str!("./game_pass_games.ps1");
|
||||||
let res = run_powershell_command(command)?;
|
let res = run_powershell_command(command)?;
|
||||||
let apps: Vec<AppInfo> = serde_json::from_str(&res)?;
|
let apps: Vec<AppInfo> = serde_json::from_str(&res)?;
|
||||||
let expanded_search = false;
|
|
||||||
|
|
||||||
let windows_dir = std::env::var("WinDir").unwrap_or("C:\\Windows".to_string());
|
let windows_dir = std::env::var("WinDir").unwrap_or("C:\\Windows".to_string());
|
||||||
let explorer = Path::new(&windows_dir)
|
let explorer = Path::new(&windows_dir)
|
||||||
.join("explorer.exe")
|
.join("explorer.exe")
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
|
let name_getters: [fn(&AppInfo) -> eyre::Result<String>; 3] =
|
||||||
|
[get_name_from_game, get_name_from_config, get_name_from_xml];
|
||||||
|
|
||||||
let games_iter = apps
|
let games_iter = apps
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|app| {
|
.filter(|app| {
|
||||||
app.kind.is_game()
|
!(app.display_name.contains("DisplayName")
|
||||||
|| (expanded_search
|
|| app.display_name.contains("ms-resource"))
|
||||||
&& (app.display_name.contains("DisplayName")
|
|
||||||
|| app.display_name.contains("ms-resource")))
|
|
||||||
})
|
})
|
||||||
.filter(|game| game.microsoft_game_path().exists() || game.appx_manifest().exists())
|
.filter_map(|game| {
|
||||||
.map(|game| {
|
|
||||||
let launch_url = format!("shell:AppsFolder\\{}", game.aum_id());
|
let launch_url = format!("shell:AppsFolder\\{}", game.aum_id());
|
||||||
|
name_getters
|
||||||
|
.iter()
|
||||||
|
.find_map(|&f| f(game).ok())
|
||||||
|
.map(|game_name| {
|
||||||
let shortcut = Shortcut::new(
|
let shortcut = Shortcut::new(
|
||||||
"0",
|
"0",
|
||||||
&game.display_name,
|
&game_name,
|
||||||
&explorer,
|
&explorer,
|
||||||
&windows_dir,
|
&windows_dir,
|
||||||
"",
|
"",
|
||||||
@@ -69,7 +71,9 @@ impl GamesPlatform for GamePassPlatForm {
|
|||||||
needs_proton: false,
|
needs_proton: false,
|
||||||
needs_symlinks: false,
|
needs_symlinks: false,
|
||||||
}
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(games_iter.collect())
|
Ok(games_iter.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +87,38 @@ impl GamesPlatform for GamePassPlatForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_name_from_xml(app_info: &AppInfo) -> eyre::Result<String> {
|
||||||
|
use roxmltree::Document;
|
||||||
|
let path_to_config = app_info.appx_manifest();
|
||||||
|
let xml = std::fs::read_to_string(path_to_config)?;
|
||||||
|
let doc = Document::parse(&xml)?;
|
||||||
|
doc.descendants()
|
||||||
|
.find(|n| n.has_tag_name("uap::VisualElements"))
|
||||||
|
.and_then(|n| n.attribute("DisplayName"))
|
||||||
|
.map(|n| n.to_string())
|
||||||
|
.ok_or(eyre::format_err!("Name not found"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_name_from_game(app_info: &AppInfo) -> eyre::Result<String> {
|
||||||
|
if !app_info.kind.is_game() {
|
||||||
|
Err(eyre::format_err!("Not a game type"))
|
||||||
|
} else {
|
||||||
|
Ok(app_info.display_name.to_owned())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_name_from_config(app_info: &AppInfo) -> eyre::Result<String> {
|
||||||
|
use roxmltree::Document;
|
||||||
|
let path_to_config = app_info.microsoft_game_path();
|
||||||
|
let xml = std::fs::read_to_string(path_to_config)?;
|
||||||
|
let doc = Document::parse(&xml)?;
|
||||||
|
doc.descendants()
|
||||||
|
.find(|n| n.has_tag_name("ShellVisuals"))
|
||||||
|
.and_then(|n| n.attribute("DefaultDisplayName"))
|
||||||
|
.map(|n| n.to_string())
|
||||||
|
.ok_or(eyre::format_err!("Name not found"))
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct AppInfo {
|
struct AppInfo {
|
||||||
kind: Kind,
|
kind: Kind,
|
||||||
@@ -105,7 +141,7 @@ impl AppInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn microsoft_game_path(&self) -> PathBuf {
|
fn microsoft_game_path(&self) -> PathBuf {
|
||||||
Path::new(&self.install_location).join("MicrosoftGames.config")
|
Path::new(&self.install_location).join("MicrosoftGame.config")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn appx_manifest(&self) -> PathBuf {
|
fn appx_manifest(&self) -> PathBuf {
|
||||||
|
|||||||
Reference in New Issue
Block a user