From db4db3076c43d92686e086906d45b8d0848610df Mon Sep 17 00:00:00 2001 From: nabeel Date: Sun, 9 Jun 2024 19:20:01 +1000 Subject: [PATCH] Added steamsapps to program selecotor --- src/main/index.js | 23 ++++++++++++++++++- src/renderer/src/App.vue | 16 +++++++++---- src/renderer/src/components/ProgramGroup.vue | 5 ++++ .../src/components/ProgramSelector.vue | 15 ++++++++---- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 1ea9cf5..8aecd4f 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -5,9 +5,11 @@ import icon from '../../resources/icon.png?asset' import fs from 'node:fs/promises' // import {getInstalledApps} from 'get-installed-apps' import getapps from 'get-startapps' +import * as steam from './Steam.js' import { SerialPort } from 'serialport' import * as logTimestamp from 'log-timestamp' +import { globSync } from 'glob' async function loadConfigurationYAML() { try { @@ -32,6 +34,25 @@ async function getApps() { return appCollection.filter((app) => filters.some((fn) => fn(app))) } +async function getSteamApps() { + let steamGames = [] + let steamLibraries = await steam.getLibraryFolders() + steamLibraries.forEach((libraryFolder) => { + let games = steam.getGames(libraryFolder) + games.forEach((game) => { + const dir = `${game.baseDirectory}\\steamapps\\common\\${game.installdir}\\` + const exeFiles = globSync(`${dir}/**/*.exe`) + exeFiles.forEach((file) => { + steamGames.push({ + name: game.name, + app: file.split('\\').pop() + }) + }) + }) + }) + return steamGames +} + function createWindow() { // Create the browser window. const mainWindow = new BrowserWindow({ @@ -83,9 +104,9 @@ app.whenReady().then(() => { ipcMain.handle('loadConfigurationYML', loadConfigurationYAML) ipcMain.handle('getSerialPorts', getSerialPorts) ipcMain.handle('getInstalledApps', getApps) + ipcMain.handle('getSteamApps', getSteamApps) createWindow() - app.on('activate', function () { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 2f0f6b6..6cf2576 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -8,12 +8,12 @@ import draggable from 'vuedraggable' import ProgramGroup from './components/ProgramGroup.vue' // import MovieCard from './components/MovieCard.vue' - // const movies = ref([]) // const apiKey = 'a0eb411ca9c81896004dce1d27a7245b' const configuration = ref('Loading....') const serialPorts = ref('Loading Serial ports.... ') const installedApps = ref([]) +const steamApps = ref([]) const steamPath = ref('') //model variables for user provided input @@ -49,11 +49,17 @@ async function getInstalledApps() { installedApps.value = await window.electron.ipcRenderer.invoke('getInstalledApps') // console.log(installedApps.value) installedApps.value.forEach((app) => { - if (app.appid.includes('Steam.exe')) { - steamPath.value = app.appid - } app.appid = app.appid.split('\\').pop() }) + + getSteamApps() +} + +async function getSteamApps() { + steamApps.value = await window.electron.ipcRenderer.invoke('getSteamApps') + steamApps.value.forEach((game) => { + console.log(`the game is ${Object.entries(game)}`) + }) } function deleteProgramRow(index) { @@ -103,6 +109,7 @@ onMounted(() => {
{ diff --git a/src/renderer/src/components/ProgramSelector.vue b/src/renderer/src/components/ProgramSelector.vue index 65eb2ef..c18862a 100644 --- a/src/renderer/src/components/ProgramSelector.vue +++ b/src/renderer/src/components/ProgramSelector.vue @@ -1,10 +1,8 @@