Skip to content

Commit

Permalink
Misc but important fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
p0ryae committed Apr 1, 2024
1 parent 6a15065 commit f89ea53
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 23 deletions.
6 changes: 6 additions & 0 deletions src-tauri/src/launchers/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ pub async fn get_installed_games() -> Vec<GameObject> {
}

async fn get_minecraft_launcher() -> Option<GameObject> {
// TO-DO: FINISH MACOS
#[cfg(target_os = "macos")]
{
return None
}

#[cfg(target_os = "windows")]
{
let output = Command::new("cmd")
Expand Down
36 changes: 27 additions & 9 deletions src-tauri/src/launchers/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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};

Expand Down Expand Up @@ -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;
Expand All @@ -86,7 +105,6 @@ fn is_installed(native_name: &str, flatpak_name: &str) -> bool {
#[tauri::command]
pub async fn fetch_installed_games() -> Vec<GameObject> {
let mut installed_games: Vec<GameObject> = 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);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ input[type="color"] {
.switch {
--line: #505162;
--dot: #f7f8ff;
--dot: rgb(var(--accent-color));
--circle: #9ea0be;
--duration: 0.3s;
--text: #9ea0be;
Expand Down
20 changes: 14 additions & 6 deletions src/components/find-games.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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", {
Expand Down
13 changes: 6 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit f89ea53

Please sign in to comment.