From 5e0947d3431ecef54400c4deca79cde715b84320 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Thu, 18 Apr 2019 21:58:11 -0400 Subject: [PATCH] As much as I could do. Still doesn't work. Last commit. --- app/index.html | 4 +- app/js/app.js | 1 - app/lib/ui/cam.js | 80 ++++++++++++++++++ app/lib/ui/grid.js | 186 ++++++++++++++++++++++++++++++++++++++--- app/lib/ui/index.js | 44 +++++++++- app/lib/ui/proj.js | 81 +++++++++++++++++- app/main.js | 7 +- app/package-lock.json | 20 ++--- app/src/index.js | 1 - app/src/lib/ui/grid.ts | 171 ++++++++++++++++++++++++++++++++----- data/cfg.json | 3 +- 11 files changed, 546 insertions(+), 52 deletions(-) diff --git a/app/index.html b/app/index.html index cc2f72a..510f693 100644 --- a/app/index.html +++ b/app/index.html @@ -18,7 +18,7 @@
- +
@@ -26,7 +26,7 @@
- +
diff --git a/app/js/app.js b/app/js/app.js index 2f1faa1..b41fdfc 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -2496,7 +2496,6 @@ const mse = require('./lib/ui/mscript.js'); const Mscript = require('./lib/mscript'); let log; - /****** State shared by ALL interfaces *******/ diff --git a/app/lib/ui/cam.js b/app/lib/ui/cam.js index 43519a0..17ec671 100644 --- a/app/lib/ui/cam.js +++ b/app/lib/ui/cam.js @@ -98,6 +98,7 @@ cam.second.enable = function () { //ui actions $('.cam2').addClass('on'); $('#counters').addClass('cameras'); + cam.second.init(); } cam.second.disable = function () { @@ -107,4 +108,83 @@ cam.second.disable = function () { $('#counters').removeClass('cameras'); } +cam.second.init = function () { + 'use strict'; + cam.second.listen(); +}; +cam.second.set = function (dir, callback) { + 'use strict'; + var obj; + if (cam.second.lock) { + return false; + } + obj = { + dir : dir, + id : uuid.v4() + }; + ipcRenderer.sendSync(cam.second.id, obj); + + if (typeof callback !== 'undefined') { + obj.callback = callback; + } + cam.second.queue[obj.id] = obj; + cam.second.lock = true; +}; + +cam.second.setValue = function (val) { + 'use strict'; + var obj = { + val: val, + id : uuid.v4() + }; + ipcRenderer.sendSync(cam.second.id, obj); +}; +cam.second.move = function (callback) { + 'use strict'; + var obj; + if (cam.second.lock) { + return false; + } + obj = { + frame : true, + id : uuid.v4() + }; + ipcRenderer.sendSync(cam.second.id, obj); + + if (typeof callback !== 'undefined') { + obj.callback = callback; + } + cam.second.queue[obj.id] = obj; + cam.second.lock = true; +}; +cam.second.end = function (c, id, ms) { + 'use strict'; + if (c === cfg.arduino.cmd.camera_second_forward) { + cam.second.dir = true; + } else if (c === cfg.arduino.cmd.camera_second_backward) { + cam.second.dir = false; + } else if (c === cfg.arduino.cmd.camera_second) { + if (cam.dir) { + cam.second.pos += 1; + } else { + cam.second.pos -= 1; + } + } + gui.counterUpdate('cam', cam.second.pos) + if (typeof cam.second.queue[id] !== 'undefined') { + if (typeof cam.queue[id].callback !== 'undefined') { + cam.second.queue[id].callback(ms); + } + delete cam.second.queue[id]; + cam.second.lock = false; + } +}; +cam.listen = function () { + 'use strict'; + ipcRenderer.on(cam.second.id, function (event, arg) { + cam.second.end(arg.cmd, arg.id, arg.ms); + return event.returnValue = true; + }); +}; + module.exports = cam; \ No newline at end of file diff --git a/app/lib/ui/grid.js b/app/lib/ui/grid.js index e5ed943..c63a527 100644 --- a/app/lib/ui/grid.js +++ b/app/lib/ui/grid.js @@ -9,8 +9,8 @@ class Grid { } init() { this.refresh(); - seq.stats(); this.events(); + seq.stats(); } /** * Set a specific grid pad to the state stored in the sequence @@ -22,9 +22,49 @@ class Grid { const elem = $(`input[x=${x}]`); const lightElem = $(`.L[x=${x}]`); const step = seq.grid[x]; + let className; + let className2; if (typeof step !== 'undefined') { elem.prop('checked', false); - $(`.${step.cmd}[x=${x}]`).prop('checked', true); + if (step.cmd === cfg.cmd.cameras_forward) { + className = cfg.cmd.camera_forward; + className2 = cfg.cmd.camera_second_forward; + } + else if (step.cmd === cfg.cmd.cameras_backward) { + className = cfg.cmd.camera_backward; + className2 = cfg.cmd.camera_second_backward; + } + else if (step.cmd === cfg.cmd.camera_forward_camera_second_backward) { + className = cfg.cmd.camera_forward; + className2 = cfg.cmd.camera_second_backward; + } + else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) { + className = cfg.cmd.camera_backward; + className2 = cfg.cmd.camera_second_forward; + } + else if (step.cmd === cfg.cmd.projectors_forward) { + className = cfg.cmd.projector_forward; + className2 = cfg.cmd.projector_second_forward; + } + else if (step.cmd === cfg.cmd.projectors_backward) { + className = cfg.cmd.projector_backward; + className2 = cfg.cmd.projector_second_backward; + } + else if (step.cmd === cfg.cmd.camera_forward_camera_second_backward) { + className = cfg.cmd.projector_forward; + className2 = cfg.cmd.projector_second_backward; + } + else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) { + className = cfg.cmd.projector_backward; + className2 = cfg.cmd.projector_second_forward; + } + else { + className = step.cmd; + } + $(`.${className}[x=${x}]`).prop('checked', true); + if (className2) { + $(`.${className2}[x=${x}]`).prop('checked', true); + } if (step.cmd === 'CF' || step.cmd === 'CB') { lightElem.css('background', `rgb(${step.light})`) .addClass('a') @@ -42,6 +82,21 @@ class Grid { .prop('title', ''); } } + otherCmd(x, c) { + const step = $(`input[x=${x}]`); + let elem; + let selected = ''; + let cmdStr; + $.each(step, function (index, value) { + elem = $(this); + cmdStr = elem.attr('class').replace('.', ''); + if (elem.prop('checked') && cmdStr !== c) { + selected = cmdStr; + return false; + } + }); + return selected; + } /** * Clears the UI of the grid and restores it to the * state of the sequence. @@ -87,18 +142,127 @@ class Grid { /** * Function bound to click on grid pad elements * - * @param {object} t This, passed from clicked element + * @param {object} elem This, passed from clicked element **/ - click(t) { - const x = parseInt($(t).attr('x')); - let c; - if ($(t).prop('checked')) { - c = $(t).attr('class').replace('.', ''); + click(elem) { + const x = parseInt($(elem).attr('x')); + let checked = $(elem).prop('checked'); + let c = ''; + let other; + // if input was not checked, but now is + // event occurs after user action + if (checked) { + c = $(elem).attr('class').replace('.', ''); + if (cam.second.enabled) { + if (c === cfg.cmd.camera_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.camera_second_forward) { + c = cfg.cmd.cameras_forward; + } + else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.camera_forward_camera_second_backward; + } + } + else if (c === cfg.cmd.camera_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.camera_second_forward) { + c = cfg.cmd.camera_backward_camera_second_forward; + } + else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.cameras_backward; + } + } + else if (c === cfg.cmd.camera_second_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.camera_forward) { + c = cfg.cmd.cameras_forward; + } + else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.camera_forward_camera_second_backward; + } + } + else if (c === cfg.cmd.camera_second_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.camera_second_forward) { + c = cfg.cmd.camera_backward_camera_second_forward; + } + else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.cameras_backward; + } + } + } + if (proj.second.enabled) { + if (c === cfg.cmd.projector_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.projector_second_forward) { + c = cfg.cmd.projectorss_forward; + } + else if (other === cfg.cmd.projector_second_backward) { + c = cfg.cmd.projector_forward_projector_second_backward; + } + } + else if (c === cfg.cmd.projector_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.projector_second_forward) { + c = cfg.cmd.projector_backward_projector_second_forward; + } + else if (other === cfg.cmd.projector_second_backward) { + c = cfg.cmd.projectors_backward; + } + } + else if (c === cfg.cmd.projector_second_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.projector_forward) { + c = cfg.cmd.projectors_forward; + } + else if (other === cfg.cmd.projector_backward) { + c = cfg.cmd.projector_backward_projector_second_forward; + } + } + else if (c === cfg.cmd.projector_second_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } + else if (other === cfg.cmd.projector_forward) { + c = cfg.cmd.projectors_forward_projector_second_backward; + } + else if (other === cfg.cmd.projector_backward) { + c = cfg.cmd.projectors_backward; + } + } + } seq.set(x, c); } else { - seq.grid[x] = undefined; - delete seq.grid[x]; + if (seq.grid[x]) { + c = seq.grid[x].cmd + ''; // cast to string, bad hack + } + if (cam.second.enabled) { + } + if (proj.second.enabled) { + } seq.unset(x); } this.state(x); @@ -136,7 +300,7 @@ class Grid { if (typeof seq.grid[x].light === 'undefined') { return false; } - console.log(x); + //console.log(x) if (seq.grid[x].light === '0,0,0') { seq.setLight(x, light.color); } diff --git a/app/lib/ui/index.js b/app/lib/ui/index.js index 4ec9547..c13e260 100644 --- a/app/lib/ui/index.js +++ b/app/lib/ui/index.js @@ -65,11 +65,29 @@ gui.updateCam = function (t) { gui.counterFormat(t); } }; +gui.updateCam2 = function (t) { + 'use strict'; + const val = t.value; + let change; + + if (parseInt(val) === cam.pos) { + return false; + } + change = confirm(`Are you sure you want to set second camera counter to ${val}?`); + + if (change) { + cam.second.pos = parseInt(val); + gui.updateState(); + } else { + t.value = cam.second.pos; + gui.counterFormat(t); + } +}; gui.updateProj = function (t) { 'use strict'; const val = t.value; let change; - if (parseInt(val) === cam.pos) { + if (parseInt(val) === proj.pos) { return false; } change = confirm(`Are you sure you want to set projector counter to ${val}?`); @@ -82,16 +100,36 @@ gui.updateProj = function (t) { } proj.setValue(t.value); }; +gui.updateProj2 = function (t) { + 'use strict'; + const val = t.value; + let change; + if (parseInt(val) === proj.second.pos) { + return false; + } + change = confirm(`Are you sure you want to set second projector counter to ${val}?`); + if (change) { + proj.second.pos = parseInt(val); + gui.updateState(); + } else { + t.value = proj.second.pos; + gui.counterFormat(t); + } + proj.setValue(t.value); +}; + gui.updateState = function () { 'use strict'; const cpos = cam.pos; const ppos = proj.pos; + const p2pos = proj.second.pos; + const c2pos = cam.second.pos; $('#seq_cam_count').val(cpos).change(); $('#seq_proj_count').val(ppos).change(); - $('#seq_cam_count_2').val(cpos).change(); - $('#seq_proj_count_2').val(ppos).change(); + $('#seq_cam_count_2').val(c2pos).change(); + $('#seq_proj_count_2').val(p2pos).change(); }; gui.spinnerCfg = { lines: 11, // The number of lines to draw diff --git a/app/lib/ui/proj.js b/app/lib/ui/proj.js index d6b353b..ac10d6d 100644 --- a/app/lib/ui/proj.js +++ b/app/lib/ui/proj.js @@ -93,12 +93,12 @@ proj.second.id = 'projector_second'; proj.second.dir = true; proj.second.pos = 0; - proj.second.enable = function () { proj.second.enabled = true; //ui actions $('.proj2').addClass('on'); $('#counters').addClass('projectors'); + proj.second.init(); } proj.second.disable = function () { @@ -108,4 +108,83 @@ proj.second.disable = function () { $('#counters').removeClass('projectors'); } +proj.second.init = function () { + 'use strict'; + proj.second.listen(); +}; +proj.second.set = function (dir, callback) { + 'use strict'; + var obj; + if (proj.second.lock) { + return false; + } + obj = { + dir : dir, + id : uuid.v4() + }; + ipcRenderer.sendSync(proj.second.id, obj); + + if (typeof callback !== 'undefined') { + obj.callback = callback; + } + proj.second.queue[obj.id] = obj; + proj.second.lock = true; +}; +proj.second.move = function (callback) { + 'use strict'; + var obj; + if (proj.second.lock) { + return false; + } + obj = { + frame : true, + id : uuid.v4() + }; + ipcRenderer.sendSync(proj.second.id, obj); + + if (typeof callback !== 'undefined') { + obj.callback = callback; + } + proj.second.queue[obj.id] = obj; + proj.second.lock = true; +}; +proj.second.end = function (c, id, ms) { + 'use strict'; + if (c === cfg.arduino.cmd.projector_second_forward) { + proj.second.dir = true; + } else if (c === cfg.arduino.cmd.projector_second_backward) { + proj.second.dir = false; + } else if (c === cfg.arduino.cmd.projector_second) { + if (proj.dir) { + proj.second.pos += 1; + } else { + proj.second.pos -= 1; + } + } + gui.counterUpdate('proj2', proj.second.pos); + if (typeof proj.second.queue[id] !== 'undefined') { + if (typeof proj.second.queue[id].callback !== 'undefined') { + proj.second.queue[id].callback(ms); + } + delete proj.second.queue[id]; + proj.second.lock = false; + } +}; +proj.second.listen = function () { + 'use strict'; + ipcRenderer.on(proj.second.id, function (event, arg) { + proj.second.end(arg.cmd, arg.id, arg.ms); + return event.returnValue = true; + }); +}; + +proj.second.setValue = function (val) { + 'use strict'; + var obj = { + val: val, + id : uuid.v4() + }; + ipcRenderer.sendSync(proj.second.id, obj); +}; + module.exports = proj; \ No newline at end of file diff --git a/app/main.js b/app/main.js index 1035385..64fdf16 100644 --- a/app/main.js +++ b/app/main.js @@ -3,6 +3,8 @@ 'use strict' +process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'; + const electron = require('electron') const { Menu, MenuItem, ipcMain, BrowserWindow, app } = electron const fs = require('fs') @@ -58,7 +60,10 @@ var createWindow = function () { height: 600, minWidth : 800, minHeight : 600, - icon: path.join(__dirname, 'assets/icons/icon.png') + icon: path.join(__dirname, 'assets/icons/icon.png'), + webPreferences : { + nodeIntegration: true + } }) mainWindow.loadURL('file://' + __dirname + '/index.html') if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) { diff --git a/app/package-lock.json b/app/package-lock.json index e3d7cf1..b0a241a 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -619,7 +619,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -1648,7 +1648,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true } @@ -1689,7 +1689,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, @@ -2737,7 +2737,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -4712,7 +4712,7 @@ }, "tar": { "version": "2.2.1", - "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "dev": true, "requires": { @@ -5352,7 +5352,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } @@ -6323,7 +6323,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -6337,7 +6337,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" @@ -6975,7 +6975,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -7058,7 +7058,7 @@ }, "xmlbuilder": { "version": "9.0.7", - "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", "dev": true }, diff --git a/app/src/index.js b/app/src/index.js index 9032699..c6eb42f 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -22,7 +22,6 @@ const mse = require('./lib/ui/mscript.js'); const Mscript = require('./lib/mscript'); let log; - /****** State shared by ALL interfaces *******/ diff --git a/app/src/lib/ui/grid.ts b/app/src/lib/ui/grid.ts index 5716524..719dadf 100644 --- a/app/src/lib/ui/grid.ts +++ b/app/src/lib/ui/grid.ts @@ -8,6 +8,8 @@ declare var light : any; declare var cfg : any; declare var log : any; declare var w2popup : any; +declare var cam : any; +declare var proj : any; interface Step { cmd : string; @@ -27,8 +29,8 @@ class Grid { } public init () { this.refresh(); - seq.stats(); this.events(); + seq.stats(); } /** @@ -41,9 +43,43 @@ class Grid { const elem : any = $(`input[x=${x}]`); const lightElem : any = $(`.L[x=${x}]`); const step : Step = seq.grid[x]; + let className : string; + let className2 : string; if (typeof step !== 'undefined') { elem.prop('checked', false); - $(`.${step.cmd}[x=${x}]`).prop('checked', true); + if (step.cmd === cfg.cmd.cameras_forward) { + className = cfg.cmd.camera_forward; + className2 = cfg.cmd.camera_second_forward; + } else if (step.cmd === cfg.cmd.cameras_backward) { + className = cfg.cmd.camera_backward; + className2 = cfg.cmd.camera_second_backward; + } else if (step.cmd === cfg.cmd.camera_forward_camera_second_backward) { + className = cfg.cmd.camera_forward; + className2 = cfg.cmd.camera_second_backward; + } else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) { + className = cfg.cmd.camera_backward; + className2 = cfg.cmd.camera_second_forward; + } else if (step.cmd === cfg.cmd.projectors_forward) { + className = cfg.cmd.projector_forward; + className2 = cfg.cmd.projector_second_forward; + } else if (step.cmd === cfg.cmd.projectors_backward) { + className = cfg.cmd.projector_backward; + className2 = cfg.cmd.projector_second_backward; + } else if (step.cmd === cfg.cmd.camera_forward_camera_second_backward) { + className = cfg.cmd.projector_forward; + className2 = cfg.cmd.projector_second_backward; + } else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) { + className = cfg.cmd.projector_backward; + className2 = cfg.cmd.projector_second_forward; + } else { + className = step.cmd; + } + + $(`.${className}[x=${x}]`).prop('checked', true); + if (className2) { + $(`.${className2}[x=${x}]`).prop('checked', true); + } + if (step.cmd === 'CF' || step.cmd === 'CB') { lightElem.css('background', `rgb(${step.light})`) .addClass('a') @@ -60,6 +96,21 @@ class Grid { .prop('title', ''); } } + private otherCmd (x : number, c : string) { + const step : any = $(`input[x=${x}]`); + let elem : any; + let selected : string = ''; + let cmdStr : string; + $.each(step, function (index : number, value : any) { + elem = $(this); + cmdStr = elem.attr('class').replace('.', ''); + if (elem.prop('checked') && cmdStr !== c) { + selected = cmdStr; + return false; + } + }); + return selected; + } /** * Clears the UI of the grid and restores it to the * state of the sequence. @@ -86,7 +137,7 @@ class Grid { for (let i : number = 0; i < cmds.length; i++) { cmd = `#${cmds[i]}`; $(cmd).empty(); - for (let x = 0; x < seq.size; x++) { + for (let x : number = 0; x < seq.size; x++) { if (cmds[i] === 'numbers') { elem = `
${x}
` $(cmd).append($(elem)); @@ -104,36 +155,114 @@ class Grid { /** * Function bound to click on grid pad elements * - * @param {object} t This, passed from clicked element + * @param {object} elem This, passed from clicked element **/ - public click (t : any) { - const x : number = parseInt($(t).attr('x')); - let c : string; - let checked : boolean = $(t).prop('checked'); + public click (elem : any) { + const x : number = parseInt($(elem).attr('x')); + let checked : boolean = $(elem).prop('checked'); + let c : string = ''; + let other : string; // if input was not checked, but now is // event occurs after user action if (checked) { + c = $(elem).attr('class').replace('.', ''); + if (cam.second.enabled) { + if (c === cfg.cmd.camera_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.camera_second_forward) { + c = cfg.cmd.cameras_forward; + } else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.camera_forward_camera_second_backward; + } + } else if (c === cfg.cmd.camera_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.camera_second_forward) { + c = cfg.cmd.camera_backward_camera_second_forward; + } else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.cameras_backward; + } + } else if (c === cfg.cmd.camera_second_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.camera_forward) { + c = cfg.cmd.cameras_forward; + } else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.camera_forward_camera_second_backward; + } + } else if (c === cfg.cmd.camera_second_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.camera_second_forward) { + c = cfg.cmd.camera_backward_camera_second_forward; + } else if (other === cfg.cmd.camera_second_backward) { + c = cfg.cmd.cameras_backward; + } + } + } + if (proj.second.enabled) { + if (c === cfg.cmd.projector_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.projector_second_forward) { + c = cfg.cmd.projectorss_forward; + } else if (other === cfg.cmd.projector_second_backward) { + c = cfg.cmd.projector_forward_projector_second_backward; + } + } else if (c === cfg.cmd.projector_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.projector_second_forward) { + c = cfg.cmd.projector_backward_projector_second_forward; + } else if (other === cfg.cmd.projector_second_backward) { + c = cfg.cmd.projectors_backward; + } + } else if (c === cfg.cmd.projector_second_forward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.projector_forward) { + c = cfg.cmd.projectors_forward; + } else if (other === cfg.cmd.projector_backward) { + c = cfg.cmd.projector_backward_projector_second_forward; + } + } else if (c === cfg.cmd.projector_second_backward) { + other = this.otherCmd(x, c); + if (other === '') { + //skip modification + } else if (other === cfg.cmd.projector_forward) { + c = cfg.cmd.projectors_forward_projector_second_backward; + } else if (other === cfg.cmd.projector_backward) { + c = cfg.cmd.projectors_backward; + } + } + } - - - - - - c = $(t).attr('class').replace('.', ''); seq.set(x, c); + } else { + if (seq.grid[x]) { + c = seq.grid[x].cmd + '' // cast to string, bad hack + } + if (cam.second.enabled) { + } + if (proj.second.enabled) { + + } - - - - seq.grid[x] = undefined; - delete seq.grid[x]; seq.unset(x); } @@ -156,7 +285,7 @@ class Grid { /** * Add 24 frames to the sequence in the GUI **/ - plus_24 () { + public plus_24 () { seq.size += 24; this.refresh(); log.info(`Sequencer expanded to ${seq.size} steps`); @@ -172,7 +301,7 @@ class Grid { if (typeof seq.grid[x].light === 'undefined') { return false; } - console.log(x) + //console.log(x) if (seq.grid[x].light === '0,0,0') { seq.setLight(x, light.color); } else { diff --git a/data/cfg.json b/data/cfg.json index 79ae943..370b8bf 100644 --- a/data/cfg.json +++ b/data/cfg.json @@ -87,7 +87,8 @@ "black_backward": "BB", "camera_second_forward": "C2F", "camera_second_backward": "C2B", - "cameras_forward": "CCB", + "cameras_forward": "CCF", + "cameras_backward" : "CCB", "camera_forward_camera_second_backward": "CFCB", "camera_backward_camera_second_forward": "CBCF", "projector_second_forward": "P2F",