AWESOME origin compare within trees and levels, visualizations down, finish animation chain fixed, everything is awesome here. ready fororigin levels

This commit is contained in:
Peter Cottle 2013-07-24 21:41:53 -07:00
parent 7a00bd09f6
commit c4ae821cef
12 changed files with 203 additions and 60 deletions

View file

@ -69,6 +69,31 @@ var regexMap = {
'git clone': /^git +clone *?$/
};
/**
* Maintain this list to keep track of which commands we track
* for the "git golf" minigame
*/
var commandsThatCount = (function() {
var toCount = [
'git commit',
'git checkout',
'git rebase',
'git reset',
'git branch',
'git revert',
'git merge',
'git clone',
'git cherry-pick'
];
var whichCountMap = {};
_.each(toCount, function(method) {
if (!regexMap[method]) { throw new Error('wut no regex'); }
whichCountMap[method] = regexMap[method];
});
return whichCountMap;
})();
var parse = function(str) {
var method;
var options;
@ -200,6 +225,7 @@ GitOptionParser.prototype.explodeAndSet = function() {
};
exports.shortcutMap = shortcutMap;
exports.commandsThatCount = commandsThatCount;
exports.instantCommands = instantCommands;
exports.parse = parse;
exports.regexMap = regexMap;

View file

@ -230,6 +230,11 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
if (tree.originTree) {
var treeString = JSON.stringify(tree.originTree);
// if we dont have an animation queue (like when loading
// right away), just go ahead and make an empty one
this.animationQueue = this.animationQueue || new AnimationQueue({
callback: function() {}
});
this.makeOrigin(treeString);
}
};

View file

@ -299,23 +299,7 @@ var Level = Sandbox.extend({
getCommandsThatCount: function() {
var GitCommands = require('../git/commands');
var toCount = [
'git commit',
'git checkout',
'git rebase',
'git reset',
'git branch',
'git revert',
'git merge',
'git cherry-pick'
];
var myRegexMap = {};
_.each(toCount, function(method) {
if (!GitCommands.regexMap[method]) { throw new Error('wut no regex'); }
myRegexMap[method] = GitCommands.regexMap[method];
});
return myRegexMap;
return GitCommands.commandsThatCount;
},
undo: function() {
@ -387,9 +371,13 @@ var Level = Sandbox.extend({
Constants.GLOBAL.isAnimating = true;
var skipFinishDialog = this.testOption('noFinishDialog');
var finishAnimationChain = this.mainVis.gitVisuals.finishAnimation();
if (this.mainVis.originVis) {
finishAnimationChain = finishAnimationChain.then(
this.mainVis.originVis.gitVisuals.finishAnimation()
);
}
if (!skipFinishDialog) {
finishAnimationChain = finishAnimationChain
.then(function() {
finishAnimationChain = finishAnimationChain.then(function() {
// we want to ask if they will move onto the next level
// while giving them their results...
var nextDialog = new NextLevelConfirm({

View file

@ -250,6 +250,11 @@ var Visualization = Backbone.View.extend({
left: left + 'px',
top: top + 'px'
});
} else {
// set position to absolute so we all stack nicely
$(this.paper.canvas).css({
position: 'absolute'
});
}
this.paper.setSize(width, height);