diff --git a/build/bundle.js b/build/bundle.js index 803d7f5b..1d6db50b 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -4770,6 +4770,12 @@ var Level = Sandbox.extend({ Sandbox.prototype.initialize.apply(this, [options]); }, + takeControl: function() { + Main.getEventBaton().stealBaton('processLevelCommand', this.processLevelCommand, this); + + Sandbox.prototype.takeControl.apply(this); + }, + initVisualization: function(options) { if (!options.level.startTree) { console.warn('No start tree specified for this level!!! using default...'); @@ -4798,26 +4804,31 @@ var Level = Sandbox.extend({ treeString: this.goalTreeString, noKeyboardInput: true }); - - this.goalVis.customEvents.on('paperReady', _.bind(function() { - // this is tricky. at this point we have a canvas that has 0 - // opacity but its floating in front of our command history. we need - // to move it out without an animation and then give it an opacity of 1 - this.goalVis.setTreeOpacity(1); - }, this)); }, - showGoal: function() { + showGoal: function(command, defer) { this.goalCanvasHolder.slideIn(); + setTimeout(function() { + command.finishWith(defer); + }, this.goalCanvasHolder.getAnimationTime()); }, - hideGoal: function() { + hideGoal: function(command, defer) { this.goalCanvasHolder.slideOut(); + setTimeout(function() { + command.finishWith(defer); + }, this.goalCanvasHolder.getAnimationTime()); }, initParseWaterfall: function(options) { this.parseWaterfall = new ParseWaterfall(); + // add our specific functionaity + this.parseWaterfall.addFirst( + 'parseWaterfall', + require('../level/commands').parse + ); + // if we want to disable certain commands... if (options.level.disabledMap) { // disable these other commands @@ -4905,8 +4916,19 @@ var Level = Sandbox.extend({ }, - parse: function() { + processLevelCommand: function(command, defer) { + console.log('processing command...'); + var methodMap = { + 'show goal': this.showGoal, + 'hide goal': this.hideGoal, + 'show solution': this.showSolution + }; + var method = methodMap[command.get('method')]; + if (!method) { + throw new Error('woah we dont support that method yet', method); + } + method.apply(this, [command, defer]); } }); @@ -9470,6 +9492,8 @@ var CanvasTerminalHolder = BaseView.extend({ this.render(); }, + getAnimationTime: function() { return 700; }, + slideOut: function() { this.slideToggle(true); }, @@ -14506,6 +14530,36 @@ exports.KeyboardListener = KeyboardListener; exports.mapKeycodeToKey = mapKeycodeToKey; +}); + +require.define("/src/js/level/commands.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); + +var regexMap = { + 'show goal': /^show goal$/, + 'hide goal': /^hide goal$/, + 'show solution': /^show solution$/ +}; + +var parse = function(str) { + var levelMethod; + + _.each(regexMap, function(regex, method) { + if (regex.test(str)) { + levelMethod = method; + } + }); + + return (!levelMethod) ? false : { + toSet: { + eventName: 'processLevelCommand', + method: levelMethod + } + }; +}; + +exports.parse = parse; + + }); require.define("/src/js/util/zoomLevel.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); @@ -17328,8 +17382,7 @@ require.define("/src/js/level/commands.js",function(require,module,exports,__dir var regexMap = { 'show goal': /^show goal$/, 'hide goal': /^hide goal$/, - 'show solution': /^show solution$/, - 'hint': /^hint$/ + 'show solution': /^show solution$/ }; var parse = function(str) { @@ -17440,6 +17493,12 @@ var Level = Sandbox.extend({ Sandbox.prototype.initialize.apply(this, [options]); }, + takeControl: function() { + Main.getEventBaton().stealBaton('processLevelCommand', this.processLevelCommand, this); + + Sandbox.prototype.takeControl.apply(this); + }, + initVisualization: function(options) { if (!options.level.startTree) { console.warn('No start tree specified for this level!!! using default...'); @@ -17468,26 +17527,31 @@ var Level = Sandbox.extend({ treeString: this.goalTreeString, noKeyboardInput: true }); - - this.goalVis.customEvents.on('paperReady', _.bind(function() { - // this is tricky. at this point we have a canvas that has 0 - // opacity but its floating in front of our command history. we need - // to move it out without an animation and then give it an opacity of 1 - this.goalVis.setTreeOpacity(1); - }, this)); }, - showGoal: function() { + showGoal: function(command, defer) { this.goalCanvasHolder.slideIn(); + setTimeout(function() { + command.finishWith(defer); + }, this.goalCanvasHolder.getAnimationTime()); }, - hideGoal: function() { + hideGoal: function(command, defer) { this.goalCanvasHolder.slideOut(); + setTimeout(function() { + command.finishWith(defer); + }, this.goalCanvasHolder.getAnimationTime()); }, initParseWaterfall: function(options) { this.parseWaterfall = new ParseWaterfall(); + // add our specific functionaity + this.parseWaterfall.addFirst( + 'parseWaterfall', + require('../level/commands').parse + ); + // if we want to disable certain commands... if (options.level.disabledMap) { // disable these other commands @@ -17575,8 +17639,19 @@ var Level = Sandbox.extend({ }, - parse: function() { + processLevelCommand: function(command, defer) { + console.log('processing command...'); + var methodMap = { + 'show goal': this.showGoal, + 'hide goal': this.hideGoal, + 'show solution': this.showSolution + }; + var method = methodMap[command.get('method')]; + if (!method) { + throw new Error('woah we dont support that method yet', method); + } + method.apply(this, [command, defer]); } }); @@ -19266,6 +19341,8 @@ var CanvasTerminalHolder = BaseView.extend({ this.render(); }, + getAnimationTime: function() { return 700; }, + slideOut: function() { this.slideToggle(true); }, diff --git a/src/js/level/commands.js b/src/js/level/commands.js index 64e43853..4a40c0da 100644 --- a/src/js/level/commands.js +++ b/src/js/level/commands.js @@ -3,8 +3,7 @@ var _ = require('underscore'); var regexMap = { 'show goal': /^show goal$/, 'hide goal': /^hide goal$/, - 'show solution': /^show solution$/, - 'hint': /^hint$/ + 'show solution': /^show solution$/ }; var parse = function(str) { diff --git a/src/js/level/index.js b/src/js/level/index.js index a5ad359a..9bcd2e28 100644 --- a/src/js/level/index.js +++ b/src/js/level/index.js @@ -40,6 +40,12 @@ var Level = Sandbox.extend({ Sandbox.prototype.initialize.apply(this, [options]); }, + takeControl: function() { + Main.getEventBaton().stealBaton('processLevelCommand', this.processLevelCommand, this); + + Sandbox.prototype.takeControl.apply(this); + }, + initVisualization: function(options) { if (!options.level.startTree) { console.warn('No start tree specified for this level!!! using default...'); @@ -68,26 +74,31 @@ var Level = Sandbox.extend({ treeString: this.goalTreeString, noKeyboardInput: true }); - - this.goalVis.customEvents.on('paperReady', _.bind(function() { - // this is tricky. at this point we have a canvas that has 0 - // opacity but its floating in front of our command history. we need - // to move it out without an animation and then give it an opacity of 1 - this.goalVis.setTreeOpacity(1); - }, this)); }, - showGoal: function() { + showGoal: function(command, defer) { this.goalCanvasHolder.slideIn(); + setTimeout(function() { + command.finishWith(defer); + }, this.goalCanvasHolder.getAnimationTime()); }, - hideGoal: function() { + hideGoal: function(command, defer) { this.goalCanvasHolder.slideOut(); + setTimeout(function() { + command.finishWith(defer); + }, this.goalCanvasHolder.getAnimationTime()); }, initParseWaterfall: function(options) { this.parseWaterfall = new ParseWaterfall(); + // add our specific functionaity + this.parseWaterfall.addFirst( + 'parseWaterfall', + require('../level/commands').parse + ); + // if we want to disable certain commands... if (options.level.disabledMap) { // disable these other commands @@ -175,8 +186,19 @@ var Level = Sandbox.extend({ }, - parse: function() { + processLevelCommand: function(command, defer) { + console.log('processing command...'); + var methodMap = { + 'show goal': this.showGoal, + 'hide goal': this.hideGoal, + 'show solution': this.showSolution + }; + var method = methodMap[command.get('method')]; + if (!method) { + throw new Error('woah we dont support that method yet', method); + } + method.apply(this, [command, defer]); } }); diff --git a/src/js/views/index.js b/src/js/views/index.js index e7c42fa7..3a414593 100644 --- a/src/js/views/index.js +++ b/src/js/views/index.js @@ -323,6 +323,8 @@ var CanvasTerminalHolder = BaseView.extend({ this.render(); }, + getAnimationTime: function() { return 700; }, + slideOut: function() { this.slideToggle(true); }, diff --git a/src/style/main.css b/src/style/main.css index 7056b9a2..344646f8 100644 --- a/src/style/main.css +++ b/src/style/main.css @@ -140,7 +140,7 @@ div.canvasTerminalHolder { } div.canvasTerminalHolder div.terminal-window-holder { - margin: 10% 0; + margin: 50px 0; height: 100%; -webkit-transform: translate3d(0,0,0); } diff --git a/todo.txt b/todo.txt index cc1b2835..b1f85533 100644 --- a/todo.txt +++ b/todo.txt @@ -23,6 +23,9 @@ Minor Bugs to fix: Big Bugs to fix: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +[ ] window zoom alert thing +[ ] better stuff for modals stealing input +[ ] click handlers on goal visualization /************************************* ** Publish Things **