Added steamsapps to program selecotor
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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(() => {
|
||||
<div v-if="typeof element === 'string'">
|
||||
<ProgramSelector
|
||||
:installed-apps="installedApps"
|
||||
:steam-apps="steamApps"
|
||||
:selected-app="element"
|
||||
@update-app="programCounter[index] = $event"
|
||||
@delete-row="deleteProgramRow(index)"
|
||||
@@ -112,6 +119,7 @@ onMounted(() => {
|
||||
<ProgramGroup
|
||||
:installed-apps="installedApps"
|
||||
:program-counter="element"
|
||||
:steam-apps="steamApps"
|
||||
@delete-row="deleteProgramRow(index)"
|
||||
@update-app="(appName, childIndex) => updateCollectionApp(index, childIndex, appName)"
|
||||
@add-app="(childIndex) => addAppToCollection(index, childIndex)"
|
||||
|
||||
@@ -11,6 +11,10 @@ const props = defineProps({
|
||||
programCounter: {
|
||||
type: Array,
|
||||
required: false
|
||||
},
|
||||
steamApps: {
|
||||
type: Array,
|
||||
required: false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -42,6 +46,7 @@ const emit = defineEmits(['update-app', 'delete-row', 'add-app', 'delete-app'])
|
||||
<ProgramSelector
|
||||
:installed-apps="installedApps"
|
||||
:selected-app="element"
|
||||
:steam-apps="steamApps"
|
||||
@delete-row="$emit('delete-app', index)"
|
||||
@update-app="$emit('update-app', $event, index)"
|
||||
/>
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<script setup>
|
||||
defineEmits(['delete-row', 'update-app'])
|
||||
|
||||
const props = defineProps({ installedApps: Object, selectedApp: String })
|
||||
// const model = defineModel()
|
||||
const props = defineProps({ installedApps: Object, selectedApp: String, steamApps: Object })
|
||||
console.log(props.installedApps)
|
||||
// console.log(model)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -19,7 +17,16 @@ console.log(props.installedApps)
|
||||
<option value="mic">Mic</option>
|
||||
<option value="system">System</option>
|
||||
</optgroup>
|
||||
<optgroup label="Steam apps">
|
||||
<optgroup label="Steam Games">
|
||||
<option
|
||||
v-for="(app, i) in props.steamApps"
|
||||
:key="i"
|
||||
class="col-auto mt-3"
|
||||
:value="app.app"
|
||||
:selected="app.app == selectedApp"
|
||||
>
|
||||
<b>{{ app.name }}:</b> {{ app.app }}
|
||||
</option>
|
||||
</optgroup>
|
||||
<optgroup label="Installed apps">
|
||||
<option
|
||||
|
||||
Reference in New Issue
Block a user