diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 63d36e1..d7243f3 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -676,6 +676,17 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "dbus" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" +dependencies = [ + "libc", + "libdbus-sys", + "winapi", +] + [[package]] name = "deranged" version = "0.3.9" @@ -1773,6 +1784,16 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +[[package]] +name = "libdbus-sys" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "libredox" version = "0.0.1" @@ -2193,7 +2214,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c62dcb6174f9cb326eac248f07e955d5d559c272730b6c03e396b443b562788" dependencies = [ "bstr", + "dbus", "normpath", + "url", "winapi", ] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 5e6373e..a7c935e 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -25,7 +25,7 @@ directories = "5.0.1" sevenz-rust = { version = "0.4.3", features = ["aes256"] } window-shadows = "0.2.1" minisign = "0.7.5" -opener = "0.6.1" +opener = { version = "0.6.1", features = ["reveal"] } async-trait = "0.1.74" [features] diff --git a/src-tauri/src/app_profile/mod.rs b/src-tauri/src/app_profile/mod.rs index 8dc9a2f..ce0ff97 100644 --- a/src-tauri/src/app_profile/mod.rs +++ b/src-tauri/src/app_profile/mod.rs @@ -39,4 +39,8 @@ pub trait AppProfile { fn launch( &self ) -> Result<(), String>; + + fn reveal_folder( + &self + ) -> Result<(), String>; } \ No newline at end of file diff --git a/src-tauri/src/app_profile/official_setlist.rs b/src-tauri/src/app_profile/official_setlist.rs index e05213e..487b821 100644 --- a/src-tauri/src/app_profile/official_setlist.rs +++ b/src-tauri/src/app_profile/official_setlist.rs @@ -97,4 +97,10 @@ impl AppProfile for OfficialSetlistProfile { ) -> Result<(), String> { Err("Cannot launch the setlist!".to_string()) } + + fn reveal_folder( + &self + ) -> Result<(), String> { + Err("Cannot reveal the setlist folder!".to_string()) + } } \ No newline at end of file diff --git a/src-tauri/src/app_profile/yarg.rs b/src-tauri/src/app_profile/yarg.rs index 7a364b6..8386a35 100644 --- a/src-tauri/src/app_profile/yarg.rs +++ b/src-tauri/src/app_profile/yarg.rs @@ -15,10 +15,16 @@ pub struct YARGAppProfile { } impl YARGAppProfile { + fn get_folder( + &self + ) -> PathBuf { + self.root_folder.join(&self.profile).join(&self.version) + } + fn get_exec( &self ) -> Result { - let mut path = self.root_folder.join(&self.profile).join(&self.version); + let mut path = self.get_folder(); // Each OS has a different executable path = match std::env::consts::OS.to_string().as_str() { @@ -136,7 +142,7 @@ impl AppProfile for YARGAppProfile { fn exists( &self ) -> bool { - Path::new(&self.root_folder.join(&self.profile).join(&self.version)).exists() + Path::new(&self.get_folder()).exists() } fn launch( @@ -148,4 +154,17 @@ impl AppProfile for YARGAppProfile { .map_err(|e| format!("Failed to start YARG. Is it installed?\n{:?}", e))?; Ok(()) } + + fn reveal_folder( + &self + ) -> Result<(), String> { + if !self.exists() { + return Err("Cannot reveal something that doesn't exist!".to_string()); + } + + opener::reveal(self.get_folder()) + .map_err(|e| format!("Failed to reveal folder. Is it installed?\n{:?}", e))?; + + Ok(()) + } } \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b5d2924..ba5dcb7 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -246,6 +246,23 @@ fn launch( app_profile.launch() } +#[tauri::command(async)] +fn reveal_folder( + state: tauri::State<'_, State>, + app_name: String, + version: String, + profile: String +) -> Result<(), String> { + let app_profile = create_app_profile( + app_name, + &state, + version, + profile + )?; + + app_profile.reveal_folder() +} + #[tauri::command] fn get_os() -> String { std::env::consts::OS.to_string() @@ -304,6 +321,7 @@ fn main() { uninstall, exists, launch, + reveal_folder, get_os, is_dir_empty, diff --git a/src/components/Launch/LaunchButton/index.tsx b/src/components/Launch/LaunchButton/index.tsx index d063433..0ab5f3b 100644 --- a/src/components/Launch/LaunchButton/index.tsx +++ b/src/components/Launch/LaunchButton/index.tsx @@ -53,6 +53,9 @@ export function LaunchButton(props: LaunchButtonProps) { version.uninstall()}> Uninstall + version.revealFolder()}> + Open Install Folder + ; return Promise, download: () => Promise, uninstall: () => Promise, + revealFolder: () => Promise, payload?: TaskPayload } @@ -54,6 +55,7 @@ export const useYARGVersion = (releaseData: ExtendedReleaseData | undefined, pro play: async () => {}, download: async () => {}, uninstall: async () => {}, + revealFolder: async () => {}, }; } @@ -142,5 +144,20 @@ export const useYARGVersion = (releaseData: ExtendedReleaseData | undefined, pro } }; - return { state, play, download, uninstall, payload }; + const revealFolder = async () => { + if (!releaseData) return; + + try { + await invoke("reveal_folder", { + appName: "yarg", + version: releaseData.tag_name, + profile: profileName + }); + } catch (e) { + showErrorDialog(e as string); + console.error(e); + } + }; + + return { state, play, download, uninstall, revealFolder, payload }; }; \ No newline at end of file