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 fs from 'node:fs/promises'
|
||||||
// import {getInstalledApps} from 'get-installed-apps'
|
// import {getInstalledApps} from 'get-installed-apps'
|
||||||
import getapps from 'get-startapps'
|
import getapps from 'get-startapps'
|
||||||
|
import * as steam from './Steam.js'
|
||||||
|
|
||||||
import { SerialPort } from 'serialport'
|
import { SerialPort } from 'serialport'
|
||||||
import * as logTimestamp from 'log-timestamp'
|
import * as logTimestamp from 'log-timestamp'
|
||||||
|
import { globSync } from 'glob'
|
||||||
|
|
||||||
async function loadConfigurationYAML() {
|
async function loadConfigurationYAML() {
|
||||||
try {
|
try {
|
||||||
@@ -32,6 +34,25 @@ async function getApps() {
|
|||||||
return appCollection.filter((app) => filters.some((fn) => fn(app)))
|
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() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
@@ -83,9 +104,9 @@ app.whenReady().then(() => {
|
|||||||
ipcMain.handle('loadConfigurationYML', loadConfigurationYAML)
|
ipcMain.handle('loadConfigurationYML', loadConfigurationYAML)
|
||||||
ipcMain.handle('getSerialPorts', getSerialPorts)
|
ipcMain.handle('getSerialPorts', getSerialPorts)
|
||||||
ipcMain.handle('getInstalledApps', getApps)
|
ipcMain.handle('getInstalledApps', getApps)
|
||||||
|
ipcMain.handle('getSteamApps', getSteamApps)
|
||||||
|
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it's common to re-create a window in the app when the
|
// 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.
|
// 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 ProgramGroup from './components/ProgramGroup.vue'
|
||||||
// import MovieCard from './components/MovieCard.vue'
|
// import MovieCard from './components/MovieCard.vue'
|
||||||
|
|
||||||
|
|
||||||
// const movies = ref([])
|
// const movies = ref([])
|
||||||
// const apiKey = 'a0eb411ca9c81896004dce1d27a7245b'
|
// const apiKey = 'a0eb411ca9c81896004dce1d27a7245b'
|
||||||
const configuration = ref('Loading....')
|
const configuration = ref('Loading....')
|
||||||
const serialPorts = ref('Loading Serial ports.... ')
|
const serialPorts = ref('Loading Serial ports.... ')
|
||||||
const installedApps = ref([])
|
const installedApps = ref([])
|
||||||
|
const steamApps = ref([])
|
||||||
const steamPath = ref('')
|
const steamPath = ref('')
|
||||||
|
|
||||||
//model variables for user provided input
|
//model variables for user provided input
|
||||||
@@ -49,11 +49,17 @@ async function getInstalledApps() {
|
|||||||
installedApps.value = await window.electron.ipcRenderer.invoke('getInstalledApps')
|
installedApps.value = await window.electron.ipcRenderer.invoke('getInstalledApps')
|
||||||
// console.log(installedApps.value)
|
// console.log(installedApps.value)
|
||||||
installedApps.value.forEach((app) => {
|
installedApps.value.forEach((app) => {
|
||||||
if (app.appid.includes('Steam.exe')) {
|
|
||||||
steamPath.value = app.appid
|
|
||||||
}
|
|
||||||
app.appid = app.appid.split('\\').pop()
|
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) {
|
function deleteProgramRow(index) {
|
||||||
@@ -103,6 +109,7 @@ onMounted(() => {
|
|||||||
<div v-if="typeof element === 'string'">
|
<div v-if="typeof element === 'string'">
|
||||||
<ProgramSelector
|
<ProgramSelector
|
||||||
:installed-apps="installedApps"
|
:installed-apps="installedApps"
|
||||||
|
:steam-apps="steamApps"
|
||||||
:selected-app="element"
|
:selected-app="element"
|
||||||
@update-app="programCounter[index] = $event"
|
@update-app="programCounter[index] = $event"
|
||||||
@delete-row="deleteProgramRow(index)"
|
@delete-row="deleteProgramRow(index)"
|
||||||
@@ -112,6 +119,7 @@ onMounted(() => {
|
|||||||
<ProgramGroup
|
<ProgramGroup
|
||||||
:installed-apps="installedApps"
|
:installed-apps="installedApps"
|
||||||
:program-counter="element"
|
:program-counter="element"
|
||||||
|
:steam-apps="steamApps"
|
||||||
@delete-row="deleteProgramRow(index)"
|
@delete-row="deleteProgramRow(index)"
|
||||||
@update-app="(appName, childIndex) => updateCollectionApp(index, childIndex, appName)"
|
@update-app="(appName, childIndex) => updateCollectionApp(index, childIndex, appName)"
|
||||||
@add-app="(childIndex) => addAppToCollection(index, childIndex)"
|
@add-app="(childIndex) => addAppToCollection(index, childIndex)"
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ const props = defineProps({
|
|||||||
programCounter: {
|
programCounter: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: false
|
required: false
|
||||||
|
},
|
||||||
|
steamApps: {
|
||||||
|
type: Array,
|
||||||
|
required: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -42,6 +46,7 @@ const emit = defineEmits(['update-app', 'delete-row', 'add-app', 'delete-app'])
|
|||||||
<ProgramSelector
|
<ProgramSelector
|
||||||
:installed-apps="installedApps"
|
:installed-apps="installedApps"
|
||||||
:selected-app="element"
|
:selected-app="element"
|
||||||
|
:steam-apps="steamApps"
|
||||||
@delete-row="$emit('delete-app', index)"
|
@delete-row="$emit('delete-app', index)"
|
||||||
@update-app="$emit('update-app', $event, index)"
|
@update-app="$emit('update-app', $event, index)"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
defineEmits(['delete-row', 'update-app'])
|
defineEmits(['delete-row', 'update-app'])
|
||||||
|
|
||||||
const props = defineProps({ installedApps: Object, selectedApp: String })
|
const props = defineProps({ installedApps: Object, selectedApp: String, steamApps: Object })
|
||||||
// const model = defineModel()
|
|
||||||
console.log(props.installedApps)
|
console.log(props.installedApps)
|
||||||
// console.log(model)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -19,7 +17,16 @@ console.log(props.installedApps)
|
|||||||
<option value="mic">Mic</option>
|
<option value="mic">Mic</option>
|
||||||
<option value="system">System</option>
|
<option value="system">System</option>
|
||||||
</optgroup>
|
</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>
|
||||||
<optgroup label="Installed apps">
|
<optgroup label="Installed apps">
|
||||||
<option
|
<option
|
||||||
|
|||||||
Reference in New Issue
Block a user