From f89ea5323b73166f349a174f44587774bb56c2bb Mon Sep 17 00:00:00 2001 From: p0ryae Date: Mon, 1 Apr 2024 13:10:38 -0700 Subject: [PATCH] Misc but important fixes --- src-tauri/src/launchers/minecraft.rs | 6 +++++ src-tauri/src/launchers/mod.rs | 36 +++++++++++++++++++++------- src/components/Settings.vue | 2 +- src/components/find-games.vue | 20 +++++++++++----- yarn.lock | 13 +++++----- 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/src-tauri/src/launchers/minecraft.rs b/src-tauri/src/launchers/minecraft.rs index 5d2421c0..507a9e26 100644 --- a/src-tauri/src/launchers/minecraft.rs +++ b/src-tauri/src/launchers/minecraft.rs @@ -25,6 +25,12 @@ pub async fn get_installed_games() -> Vec { } async fn get_minecraft_launcher() -> Option { + // TO-DO: FINISH MACOS + #[cfg(target_os = "macos")] + { + return None + } + #[cfg(target_os = "windows")] { let output = Command::new("cmd") diff --git a/src-tauri/src/launchers/mod.rs b/src-tauri/src/launchers/mod.rs index 351d9012..58f673e4 100644 --- a/src-tauri/src/launchers/mod.rs +++ b/src-tauri/src/launchers/mod.rs @@ -1,5 +1,7 @@ #[cfg(target_os = "windows")] mod epic_games; +#[cfg(target_os = "windows")] +mod gog; mod minecraft; #[cfg(target_os = "windows")] mod riot_games; @@ -10,8 +12,6 @@ mod steam; mod uplay; #[cfg(target_os = "linux")] mod wine_managers; -#[cfg(target_os = "windows")] -mod gog; use serde::{Deserialize, Serialize}; @@ -62,15 +62,34 @@ impl GameObject { #[cfg(target_os = "linux")] fn is_installed(native_name: &str, flatpak_name: &str) -> bool { - let flatpak = String::from_utf8(std::process::Command::new("flatpak") - .arg("list") - .output() - .expect("Failed to execute command").stdout).unwrap_or_default(); + let flatpak = match std::process::Command::new("flatpak").arg("list").output() { + Ok(output) => { + if output.status.success() { + String::from_utf8(output.stdout).unwrap_or_default() + } else { + String::default() + } + } + Err(_e) => { + String::default() + } + }; - let native = String::from_utf8(std::process::Command::new("which") + let native = match std::process::Command::new("which") .arg(native_name) .output() - .expect("Failed to execute command").stdout).unwrap_or_default(); + { + Ok(output) => { + if output.status.success() { + String::from_utf8(output.stdout).unwrap_or_default() + } else { + String::default() + } + } + Err(_e) => { + String::default() + } + }; if native.starts_with("/") { return true; @@ -86,7 +105,6 @@ fn is_installed(native_name: &str, flatpak_name: &str) -> bool { #[tauri::command] pub async fn fetch_installed_games() -> Vec { let mut installed_games: Vec = Vec::new(); - installed_games.extend(steam::get_installed_games().await); installed_games.extend(minecraft::get_installed_games().await); #[cfg(target_os = "linux")] installed_games.extend(wine_managers::get_installed_games().await); diff --git a/src/components/Settings.vue b/src/components/Settings.vue index 0339f407..a589e6c2 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -690,7 +690,7 @@ input[type="color"] { .switch { --line: #505162; - --dot: #f7f8ff; + --dot: rgb(var(--accent-color)); --circle: #9ea0be; --duration: 0.3s; --text: #9ea0be; diff --git a/src/components/find-games.vue b/src/components/find-games.vue index c556f29d..c4cdffbc 100644 --- a/src/components/find-games.vue +++ b/src/components/find-games.vue @@ -220,9 +220,7 @@ class GameElement { break; } case "GOG": { - res = this.createProcess( - `/C start "" ${this.data.launch_id}` - ); + res = this.createProcess(`/C start "" ${this.data.launch_id}`); break; } default: { @@ -353,10 +351,20 @@ class Storage { if (source === "getInstalledGames") { if (data.length > 0) { if (data.length != games.length) { - await invoke("write_file", { - filePath: this.gamesDataJSON, - fileContent: JSON.stringify(games), + const newData = games.filter((game) => { + return !data.some( + (existingGame) => + existingGame.LauncherName === game.LauncherName && + existingGame.GameID === game.GameID + ); }); + + if (newData.length > 0) { + await invoke("write_file", { + filePath: this.gamesDataJSON, + fileContent: JSON.stringify(newData), + }); + } } } else { await invoke("write_file", { diff --git a/yarn.lock b/yarn.lock index d45d0338..a3ad36b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1246,6 +1246,11 @@ resolved "https://registry.yarnpkg.com/@soda/get-current-script/-/get-current-script-1.0.2.tgz#a53515db25d8038374381b73af20bb4f2e508d87" integrity sha512-T7VNNlYVM1SgQ+VsMYhnDkcGmWhQdL0bDyGm5TlQ3GBXnJscEClUUOKduWTmm2zCnvNLC1hc3JpuXjs/nFOc5w== +"@tauri-apps/api@1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.4.0.tgz#b4013ca3d17b853f7df29fe14079ebb4d52dbffa" + integrity sha512-Jd6HPoTM1PZSFIzq7FB8VmMu3qSSyo/3lSwLpoapW+lQ41CL5Dow2KryLg+gyazA/58DRWI9vu/XpEeHK4uMdw== + "@tauri-apps/api@1.5.3", "@tauri-apps/api@^1.4.0": version "1.5.3" resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.5.3.tgz#f7b362b1f30aadb0a8bbeb7ae111755c0ed33d73" @@ -6088,13 +6093,7 @@ tapable@^2.0.0, tapable@^2.1.1, tapable@^2.2.0, tapable@^2.2.1: version "0.0.0" resolved "https://codeload.github.com/tauri-apps/tauri-plugin-fs-extra/tar.gz/b0a4a479cabb00bb7a689756f742ef89da4f2601" dependencies: - "@tauri-apps/api" "1.4.0" - -"tauri-plugin-sql-api@github:tauri-apps/tauri-plugin-sql": - version "0.0.0" - resolved "https://codeload.github.com/tauri-apps/tauri-plugin-sql/tar.gz/fe26880383d97d28ab0cc339773e75ce80730ced" - dependencies: - "@tauri-apps/api" "1.4.0" + "@tauri-apps/api" "1.5.3" terser-webpack-plugin@^5.1.1, terser-webpack-plugin@^5.3.10: version "5.3.10"