use match instead of if for LaunchVersion checks

This commit is contained in:
2025-10-25 09:35:31 +01:00
parent d15b8070ec
commit 1363f5b125
+11 -10
View File
@@ -22,19 +22,17 @@ pub struct Launch {
pub fn launch(platform: &Platform, version: &LaunchVersion) { pub fn launch(platform: &Platform, version: &LaunchVersion) {
match platform { match platform {
Platform::Steam => { Platform::Steam => {
let steam_url = if *version == LaunchVersion::Enhanced { let steam_url = match version {
"steam://run/3240220" LaunchVersion::Enhanced => "steam://run/3240220",
} else { LaunchVersion::Legacy => "steam://run/271590",
"steam://run/271590"
}; };
let _ = open::that_detached(steam_url); let _ = open::that_detached(steam_url);
} }
Platform::Rockstar => { Platform::Rockstar => {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE); let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let rockstar_url = if *version == LaunchVersion::Enhanced { let rockstar_url = match version {
r"SOFTWARE\WOW6432Node\Rockstar Games\GTAV Enhanced" LaunchVersion::Enhanced => r"SOFTWARE\WOW6432Node\Rockstar Games\GTAV Enhanced",
} else { LaunchVersion::Legacy => r"SOFTWARE\WOW6432Node\Rockstar Games\Grand Theft Auto V",
r"SOFTWARE\WOW6432Node\Rockstar Games\Grand Theft Auto V"
}; };
let Ok(gta_v_enhanced) = hklm.open_subkey(rockstar_url) else { let Ok(gta_v_enhanced) = hklm.open_subkey(rockstar_url) else {
return; return;
@@ -49,10 +47,13 @@ pub fn launch(platform: &Platform, version: &LaunchVersion) {
let _ = Command::new(play_gtav_path).spawn(); let _ = Command::new(play_gtav_path).spawn();
} }
Platform::Epic => { Platform::Epic => {
let epic_url = if *version == LaunchVersion::Enhanced { let epic_url = match version {
LaunchVersion::Enhanced => {
"com.epicgames.launcher://apps/8769e24080ea413b8ebca3f1b8c50951?action=launch&silent=true" "com.epicgames.launcher://apps/8769e24080ea413b8ebca3f1b8c50951?action=launch&silent=true"
} else { }
LaunchVersion::Legacy => {
"com.epicgames.launcher://apps/9d2d0eb64d5c44529cece33fe2a46482?action=launch&silent=true" "com.epicgames.launcher://apps/9d2d0eb64d5c44529cece33fe2a46482?action=launch&silent=true"
}
}; };
let _ = open::that_detached(epic_url); let _ = open::that_detached(epic_url);
} }