()
| 217 | } |
| 218 | |
| 219 | updatePathNamesGUI(){ |
| 220 | //this.ghosts = { folder: backdrop, settings: {}, ctrls: {} }; |
| 221 | const pathNames = this.store.getPathNames(); |
| 222 | |
| 223 | //Remove settings and ctrls that are no longer in the pathNames array |
| 224 | for( const [ key, value ] of Object.entries(this.ghosts.settings) ){ |
| 225 | const index = pathNames.indexOf( key ); |
| 226 | if (index == -1){ |
| 227 | delete this.ghosts.settings[ key ]; |
| 228 | this.ghosts.ctrls[ key ].destroy(); |
| 229 | delete this.ghosts.ctrls[ key ]; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | //Add new settings and ctrls |
| 234 | pathNames.forEach( name => { |
| 235 | if ( this.ghosts.settings[name] == undefined ){ |
| 236 | this.ghosts.settings[name] = false; |
| 237 | const ctrl = this.ghosts.folder.add( this.ghosts.settings, name ).onChange( value => { |
| 238 | if ( value ){ |
| 239 | try{ |
| 240 | const path = this.store.read( name ).nodes; |
| 241 | this.ghosts.paths[name] = path; |
| 242 | }catch(e){ |
| 243 | console.warn( e.message ); |
| 244 | } |
| 245 | }else{ |
| 246 | delete this.ghosts.paths[name]; |
| 247 | } |
| 248 | |
| 249 | this.render(); |
| 250 | |
| 251 | } ); |
| 252 | this.ghosts.ctrls[name] = ctrl; |
| 253 | } |
| 254 | }); |
| 255 | } |
| 256 | |
| 257 | loadPath( name ){ |
| 258 | const data = this.store.read( name ); |
no test coverage detected