settings: add "--state" (#349)

This commit is contained in:
jean-emmanuel 2018-08-04 17:05:04 +02:00
parent 5a2ec0ea84
commit 9cd107fd5c
5 changed files with 35 additions and 0 deletions

View file

@ -2,6 +2,8 @@
## 0.35.0
- main
- added `--state` option for loading a state file with a session file
- state
- loading a state file doesn't replace the quick save slot anymore
- widgets

View file

@ -133,7 +133,24 @@ module.exports = {
},
sessionOpened: function(data, clientId) {
if (settings.read('stateFile')) {
var send = true
for (var id in ipc.clients) {
// only make the client send its osc state if there are no other active clients
if (id !== clientId && ipc.clients[id].connected()) {
send = false
}
}
var state = {
state: settings.read('stateFile'),
send: send
}
ipc.send('stateLoad', state, clientId)
}
ipc.send('stateSend', null, null, clientId)
},
savingSession: function(data, clientId) {

View file

@ -21,6 +21,7 @@ var options = {
}
},
'l':{alias:'load',type:'string',file:{name:'OSC Session (.json)', extensions: ['json', 'js']},describe:'session file to load'},
'state':{type:'string',file:{name:'OSC State (.state)', extensions: ['state']},describe:'state file to load'},
'b':{alias:'blank',type:'boolean',describe:'load a blank session and start the editor'},
'c':{alias:'custom-module',type:'string',file:{name:'OSC Custom module (.js)', extensions: ['js']},describe:'custom module file to load'},
'p':{alias:'port',type:'number',describe:'http port of the server (default to 8080)',
@ -145,6 +146,14 @@ var makeDefaultConfig = function(argv){
noGpu: argv['disable-gpu'] || false,
readOnly: argv['read-only'] || false,
midi: argv['midi'],
stateFile: (function(){
if (!argv['state']) return false
try {
return JSON.parse(fs.readFileSync(argv['state'], 'utf8'))
} catch(err) {
return false
}
})(),
appAddresses:function(){
var appAddresses = []

View file

@ -15,6 +15,7 @@ Below are the available command-line options. Note that when running without any
|---||---|
| `-s` | `--send` | default targets for all widgets (ip:port pairs)|
| `-l` | `--load` | session file to load |
| | `--state` | state file to load (osc messages will be sent, unless there are other clients connected) |
| `-b` | `--blank` | load a blank session and start the editor |
| `-c` | `--custom-module` | custom module file to load |
| `-p` | `--port` | http port of the server (default to 8080) |

View file

@ -39,6 +39,12 @@ module.exports = {
},
stateLoad: function(data){
state.set(data.state, data.send)
},
stateSend:function(){
var p = utils.loading('New client connecting...')