add button to lunch steam when steam is not running

This commit is contained in:
MathieuG-P
2022-12-28 20:30:10 +01:00
parent a8ca0b26b3
commit 06622c4088
6 changed files with 63 additions and 1 deletions
+9
View File
@@ -274,9 +274,18 @@
"BS_ALREADY_RUNNING": "Close BeatSaber before launching it again.",
"EXE_NOT_FINDED": "Some files seem to be missing, try to verify the files.",
"EXIT": "BeatSaber stopped abruptly, tries to check the files."
},
"actions":{
"STEAM_NOT_RUNNING": "Launch Steam"
}
}
},
"steam":{
"steam-launching":{
"title": "Steam is launching!",
"description": "Steam may take some time to launch depending on your configuration."
}
},
"custom-version": {
"errors": {
"titles": {
+9
View File
@@ -274,9 +274,18 @@
"BS_ALREADY_RUNNING": "Cierra BeatSaber antes de volver a lanzarlo.",
"EXE_NOT_FINDED": "Parece que faltan algunos archivos, intente verificar los archivos.",
"EXIT": "BeatSaber se detuvo abruptamente, trata de revisar los archivos."
},
"actions":{
"STEAM_NOT_RUNNING": "Iniciar Steam"
}
}
},
"steam":{
"steam-launching":{
"title": "¡Steam se está iniciando!",
"description": "Steam puede tardar un poco en iniciarse dependiendo de tu configuración."
}
},
"custom-version": {
"errors": {
"titles": {
+9
View File
@@ -274,9 +274,18 @@
"BS_ALREADY_RUNNING": "Ferme BeatSaber avant de le lancer à nouveau.",
"EXE_NOT_FINDED": "Quelques fichiers semblent manquants. Essaye de vérifier les fichiers.",
"EXIT": "BeatSaber s'est arrêté brusquement, essaye de vérifier les fichiers."
},
"actions":{
"STEAM_NOT_RUNNING": "Lancer Steam"
}
}
},
"steam":{
"steam-launching":{
"title": "Steam se lance !",
"description": "Steam peut mettre quelque temps à se lancer selon votre configuration."
}
},
"custom-version": {
"errors": {
"titles": {
+11
View File
@@ -3,6 +3,7 @@ import { UtilsService } from '../services/utils.service';
import { IpcRequest } from 'shared/models/ipc';
import { SystemNotificationOptions } from 'shared/models/notification/system-notification.model';
import { NotificationService } from '../services/notification.service';
import { SteamService } from '../services/steam.service';
// TODO IMPROVE WINDOW CONTROL BY USING WINDOW SERVICE
@@ -60,4 +61,14 @@ ipcMain.on("open-logs", async (event, request: IpcRequest<void>) => {
ipcMain.on("notify-system", async (event, request: IpcRequest<SystemNotificationOptions>) => {
NotificationService.getInstance().notify(request.args)
});
ipcMain.on("open-steam", async (event, request: IpcRequest<void>) => {
const steam = SteamService.getInstance();
const utils = UtilsService.getInstance();
steam.openSteam().then(res => {
utils.ipcSend(request.responceChannel, {success: true, data: res});
}).catch((e) => {
utils.ipcSend(request.responceChannel, {success: false, error: e});
});
});
+10
View File
@@ -3,6 +3,7 @@ import regedit from 'regedit'
import path from "path";
import { parse } from "@node-steam/vdf";
import { readFile } from "fs/promises";
import { spawn } from "child_process";
export class SteamService{
@@ -62,4 +63,13 @@ export class SteamService{
return null;
}
public openSteam(): Promise<boolean>{
const process = spawn("start", ["steam://open/games"], {shell: true});
return new Promise(resolve => {
process.on("exit", () => resolve(true));
process.on("error", () => resolve(false));
});
}
}
+15 -1
View File
@@ -58,7 +58,21 @@ export class BSLauncherService{
return res;
});
}
if(res.data){ return this.notificationService.notifyError({title: `notifications.bs-launch.errors.titles.${res.data}`}); }
if(res.data){
// TODO : too much nesting here, need refactor
if(res.data === "STEAM_NOT_RUNNING"){
return new Promise(async resolve => {
const notif = await this.notificationService.notifyError({title: `notifications.bs-launch.errors.titles.${res.data}`, actions: [{id: "0", title: `notifications.bs-launch.errors.actions.${res.data}`}]});
if(notif === "0"){
await this.ipcService.send<boolean>("open-steam");
const lastNotif = await this.notificationService.notifySuccess({title: "notifications.steam.steam-launching.title", desc: "notifications.steam.steam-launching.description"});
resolve(lastNotif);
}
resolve(notif)
})
}
return this.notificationService.notifyError({title: `notifications.bs-launch.errors.titles.${res.data}`});
}
return this.notificationService.notifyError({title: res.data || res.error.title});
});
}