Skip to content

Commit

Permalink
desktop v0.1.6 - add multimedia plugin, improve BtnConfig plugins list
Browse files Browse the repository at this point in the history
  • Loading branch information
b3nab committed Sep 24, 2021
1 parent 52fbea0 commit bc4ebb5
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 56 deletions.
3 changes: 3 additions & 0 deletions packages/desktop/main/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ if (isProd) {

(async () => {
await app.whenReady()
console.log('[DeckPad]')
console.log('platform: ', process.platform)
console.log('locale: ', app.getLocale())
// ---- Start Window ----
// ----------------------
const mainWin = await createMainWindow({
Expand Down
6 changes: 5 additions & 1 deletion packages/desktop/main/ipc/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import isDev from 'electron-is-dev'
import { PluginManager } from 'live-plugin-manager'
import PluginClerk from 'pluginclerk'
import pubsub from 'electron-pubsub'
import { companion } from '../plugins'
import {
companion,
multimedia,
} from '../plugins'

const manager = new PluginManager()
const clerk = new PluginClerk({
Expand Down Expand Up @@ -73,6 +76,7 @@ export const plugins = ({ store, toIO, sendMessageToRenderer }) => {
// -------------Main-------------
// ------------------------------
initPlugin("companion", companion)
initPlugin("multimedia", multimedia)
// initPlugin("mydeckBase", mydeckBase)
// ------------------------------
// ------------------------------
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop/main/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// export * from './mydeck'
import companion from './companion'
import multimedia from './multimedia'

export {
companion,
multimedia,
}
54 changes: 54 additions & 0 deletions packages/desktop/main/plugins/multimedia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ipcMain } from 'electron'
import loudness from 'loudness'

const multimedia = ({ store, toIO, sendMessageToRenderer, updateProps }) => {
// await loudness.setVolume(45)
// const vol = await loudness.getVolume()
// // vol = 45
// await loudness.setMuted(false)
// const mute = await loudness.getMuted()
// // mute = false
const start = () => {
ipcMain.on('update-board', (event, board) => {
console.log(`[multimedia] received update-board`)
updateProps()
})
}

const stop = () => {}

const actions = () => ({
'vol-up': {
label: 'Volume Up Button',
fire: async (data) => { loudness.setVolume(await loudness.getVolume() + 10) },
},
'vol-down': {
label: 'Volume Down Button',
fire: async (data) => { loudness.setVolume(await loudness.getVolume() - 10) },
},
'vol-to': {
label: 'Volume To Value Button',
fire: async (data) => { loudness.setVolume(data.volume) },
},
'mute': {
label: 'Mute Button',
fire: async (data) => { loudness.setMuted(true) },
},
'unmute': {
label: 'Unmute Button',
fire: async (data) => { loudness.setMuted(false) },
},
'mute-toggle': {
label: 'Mute Toggle Button',
fire: async (data) => { loudness.setMuted(!await loudness.getMuted()) },
},
})

return {
start,
stop,
actions,
}
}

export default multimedia
3 changes: 2 additions & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A powerful deck board app for your streaming needs! This is the desktop app, use it as a configurator for your companion mobile app (soon MyDeck on majors Stores).",
"author": "Benedetto Abbenanti b3nab <[email protected]>",
"homepage": "https://github.com/b3nab/mydeck",
"version": "0.1.5",
"version": "0.1.6",
"main": "app/background.js",
"scripts": {
"dev": "nextron",
Expand Down Expand Up @@ -34,6 +34,7 @@
"jsondiffpatch": "^0.4.1",
"jsum": "^2.0.0-alpha.3",
"live-plugin-manager": "^0.16.0",
"loudness": "^0.4.1",
"material-ui-popup-state": "^1.9.3",
"pluginclerk": "^4.13.0",
"react-colorful": "^5.4.0",
Expand Down
104 changes: 54 additions & 50 deletions packages/desktop/renderer/components/BtnConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,59 +136,63 @@ export const BtnConfig = ({ show, close, btn, saveBtn, plugins }) => {

<Grid container item direction="column" spacing={3} alignItems="center" justifyContent="space-evenly">
{plugins && (
<FormControl>
<InputLabel htmlFor="action.plugin">Plugin</InputLabel>
<Field
component={Select}
name="action.plugin"
inputProps={{
id: 'action.plugin',
}}
>
{Object.keys(plugins).map((plugin, i) => (
<MenuItem key={i} value={plugin}>{plugin.toUpperCase()}</MenuItem>
))}
</Field>
</FormControl>
<>
<FormControl>
<InputLabel htmlFor="action.plugin">Plugin</InputLabel>
<Field
component={Select}
name="action.plugin"
inputProps={{
id: 'action.plugin',
}}
>
{Object.keys(plugins).map((plugin, i) => (
<MenuItem key={i} value={plugin}>{plugin.toUpperCase()}</MenuItem>
))}
</Field>
</FormControl>
{values.action.plugin && Object.keys(plugins[values.action.plugin]) && (
<>
<FormControl>
<InputLabel htmlFor="action.type">Action</InputLabel>
<Field
component={Select}
name="action.type"
inputProps={{
id: 'action.type',
}}
>
{Object.keys(plugins[values.action.plugin]).map((action, i) => (
<MenuItem key={i} value={action}>
{plugins[values.action.plugin][action].label}
</MenuItem>
))}
</Field>
</FormControl>
{values.action.type && plugins[values.action.plugin][values.action.type] && plugins[values.action.plugin][values.action.type].options && (
<FormControl>
<InputLabel htmlFor="action.options">Options</InputLabel>
<Field
component={Select}
name="action.options"
inputProps={{
id: 'action.options',
}}
>
{plugins[values.action.plugin][values.action.type].options.map((option, i) => (
<MenuItem key={i} value={option.value}>
{option.name}
</MenuItem>
))}
</Field>
</FormControl>
)}
</>
)}
</>
)}

{plugins && values.action.plugin && (
<FormControl>
<InputLabel htmlFor="action.type">Action</InputLabel>
<Field
component={Select}
name="action.type"
inputProps={{
id: 'action.type',
}}
>
{Object.keys(plugins[values.action.plugin]).map((action, i) => (
<MenuItem key={i} value={action}>
{plugins[values.action.plugin][action].label}
</MenuItem>
))}
</Field>
</FormControl>
)}

{plugins && values.action.plugin && values.action.type && (
<FormControl>
<InputLabel htmlFor="action.options">Options</InputLabel>
<Field
component={Select}
name="action.options"
inputProps={{
id: 'action.options',
}}
>
{plugins[values.action.plugin][values.action.type].options.map((option, i) => (
<MenuItem key={i} value={option.value}>
{option.name}
</MenuItem>
))}
</Field>
</FormControl>
)}
</Grid>

</Box>
Expand Down
10 changes: 6 additions & 4 deletions packages/desktop/renderer/components/Side.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const Side = ({decks, actual, setActual, stats, plugins, serverStartStop,
</TabPanel>
<TabPanel value="2">
{Object.keys(plugins).map(plugin => (
<Accordion key="plugin">
<Accordion key={`plugin-${plugin}`}>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls={`panel${plugin}-content`}
Expand All @@ -143,9 +143,11 @@ export const Side = ({decks, actual, setActual, stats, plugins, serverStartStop,
<Typography className={classes.heading}>{plugin}</Typography>
</AccordionSummary>
<AccordionDetails>
{Object.keys(plugins[plugin]).map(action => (
<Typography>{action}</Typography>
))}
<Grid direction="column">
{Object.keys(plugins[plugin]).map((action, i) => (
<Typography key={i} paragraph>{action}</Typography>
))}
</Grid>
</AccordionDetails>
</Accordion>
))}
Expand Down

0 comments on commit bc4ebb5

Please sign in to comment.