hide and show goal

This commit is contained in:
Peter Cottle 2013-01-04 15:38:41 -08:00
parent 9bb6b5c2d9
commit a12bc276ae
6 changed files with 138 additions and 35 deletions

View file

@ -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);
},

View file

@ -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) {

View file

@ -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]);
}
});

View file

@ -323,6 +323,8 @@ var CanvasTerminalHolder = BaseView.extend({
this.render();
},
getAnimationTime: function() { return 700; },
slideOut: function() {
this.slideToggle(true);
},

View file

@ -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);
}

View file

@ -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 **