mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
first level :DDDDDD
This commit is contained in:
parent
d400158781
commit
984f139245
6 changed files with 5023 additions and 4758 deletions
9643
build/bundle.js
9643
build/bundle.js
File diff suppressed because it is too large
Load diff
|
@ -25,11 +25,12 @@ var init = function() {
|
||||||
* - handling window.focus and zoom events
|
* - handling window.focus and zoom events
|
||||||
**/
|
**/
|
||||||
var Sandbox = require('../level/sandbox').Sandbox;
|
var Sandbox = require('../level/sandbox').Sandbox;
|
||||||
|
var Level = require('../level').Level;
|
||||||
var EventBaton = require('../util/eventBaton').EventBaton;
|
var EventBaton = require('../util/eventBaton').EventBaton;
|
||||||
|
|
||||||
eventBaton = new EventBaton();
|
eventBaton = new EventBaton();
|
||||||
commandUI = new CommandUI();
|
commandUI = new CommandUI();
|
||||||
sandbox = new Sandbox();
|
sandbox = new Level();
|
||||||
|
|
||||||
// we always want to focus the text area to collect input
|
// we always want to focus the text area to collect input
|
||||||
var focusTextArea = function() {
|
var focusTextArea = function() {
|
||||||
|
|
|
@ -5,6 +5,8 @@ var Q = require('q');
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
|
|
||||||
|
var Sandbox = require('../level/sandbox').Sandbox;
|
||||||
|
|
||||||
var Visualization = require('../visuals/visualization').Visualization;
|
var Visualization = require('../visuals/visualization').Visualization;
|
||||||
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
|
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
|
||||||
var DisabledMap = require('../level/disabledMap').DisabledMap;
|
var DisabledMap = require('../level/disabledMap').DisabledMap;
|
||||||
|
@ -13,20 +15,88 @@ var GitShim = require('../git/gitShim').GitShim;
|
||||||
|
|
||||||
var ModalTerminal = require('../views').ModalTerminal;
|
var ModalTerminal = require('../views').ModalTerminal;
|
||||||
var ModalAlert = require('../views').ModalAlert;
|
var ModalAlert = require('../views').ModalAlert;
|
||||||
|
|
||||||
var MultiView = require('../views/multiView').MultiView;
|
var MultiView = require('../views/multiView').MultiView;
|
||||||
|
|
||||||
/*
|
var TreeCompare = require('../git/treeCompare').TreeCompare;
|
||||||
this.beforeDeferHandler = function(deferred) {
|
|
||||||
var view = new MultiView({
|
var Level = Sandbox.extend({
|
||||||
});
|
initialize: function(options) {
|
||||||
view.getPromise()
|
options = options || {};
|
||||||
.then(function() {
|
options.level = options.level || {};
|
||||||
return Q.delay(700);
|
|
||||||
})
|
this.gitCommandsIssued = 0;
|
||||||
.then(function() {
|
this.solved = false;
|
||||||
deferred.resolve();
|
// possible options on how stringent to be go here
|
||||||
})
|
this.treeCompare = new TreeCompare();
|
||||||
.done();
|
|
||||||
};*/
|
this.goalTreeString = options.level.goalTree;
|
||||||
|
if (!this.goalTreeString) {
|
||||||
|
console.warn('woah no goal, using random other one');
|
||||||
|
this.goalTreeString = '{"branches":{"master":{"target":"C2","id":"master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}';
|
||||||
|
}
|
||||||
|
|
||||||
|
Sandbox.prototype.initialize.apply(this, [options]);
|
||||||
|
},
|
||||||
|
|
||||||
|
initVisualization: function(options) {
|
||||||
|
if (!options.level.startTree) {
|
||||||
|
console.warn('No start tree specified for this level!!! using default...');
|
||||||
|
}
|
||||||
|
this.mainVis = new Visualization({
|
||||||
|
el: options.el || this.getDefaultVisEl(),
|
||||||
|
treeString: options.level.startTree
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
initParseWaterfall: function(options) {
|
||||||
|
this.parseWaterfall = new ParseWaterfall();
|
||||||
|
|
||||||
|
// if we want to disable certain commands...
|
||||||
|
if (options.level.disabledMap) {
|
||||||
|
// disable these other commands
|
||||||
|
this.parseWaterfall.addFirst(
|
||||||
|
new DisabledMap({
|
||||||
|
disabledMap: options.level.disabledMap
|
||||||
|
}).getInstantCommands()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
initGitShim: function(options) {
|
||||||
|
// ok we definitely want a shim here
|
||||||
|
this.gitShim = new GitShim({
|
||||||
|
afterCB: _.bind(this.afterCommandCB, this),
|
||||||
|
afterDeferHandler: _.bind(this.afterCommandDefer, this)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
afterCommandCB: function(command) {
|
||||||
|
// TODO check if error, but not warning
|
||||||
|
this.gitCommandsIssued++;
|
||||||
|
},
|
||||||
|
|
||||||
|
afterCommandDefer: function(defer) {
|
||||||
|
if (this.solved) { return; }
|
||||||
|
// ok so lets see if they solved it...
|
||||||
|
var current = this.mainVis.gitEngine.exportTree();
|
||||||
|
var solved = this.treeCompare.compareTrees(current, this.goalTreeString);
|
||||||
|
|
||||||
|
if (!solved) {
|
||||||
|
defer.resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// woohoo!!! they solved the level, lets animate and such
|
||||||
|
this.levelSolved(defer);
|
||||||
|
},
|
||||||
|
|
||||||
|
levelSolved: function(defer) {
|
||||||
|
this.mainVis.gitVisuals.finishAnimation()
|
||||||
|
.then(function() {
|
||||||
|
defer.resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.Level = Level;
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,13 @@ var Sandbox = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDefaultVisEl: function() {
|
||||||
|
return $('#canvasWrapper')[0];
|
||||||
|
},
|
||||||
|
|
||||||
initVisualization: function(options) {
|
initVisualization: function(options) {
|
||||||
this.mainVis = new Visualization({
|
this.mainVis = new Visualization({
|
||||||
el: options.el || $('#canvasWrapper')[0]
|
el: options.el || this.getDefaultVisEl()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -47,11 +51,6 @@ var Sandbox = Backbone.View.extend({
|
||||||
|
|
||||||
initParseWaterfall: function(options) {
|
initParseWaterfall: function(options) {
|
||||||
this.parseWaterfall = new ParseWaterfall();
|
this.parseWaterfall = new ParseWaterfall();
|
||||||
/* DISBALED MAP example!!!
|
|
||||||
this.parseWaterfall.addFirst(
|
|
||||||
'instantWaterfall',
|
|
||||||
new DisabledMap().getInstantCommands()
|
|
||||||
);*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initGitShim: function(options) {
|
initGitShim: function(options) {
|
||||||
|
|
|
@ -138,6 +138,7 @@ GitVisuals.prototype.animateAllAttrKeys = function(keys, attr, speed, easing) {
|
||||||
GitVisuals.prototype.finishAnimation = function() {
|
GitVisuals.prototype.finishAnimation = function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
|
var animationDone = Q.defer();
|
||||||
var defaultTime = GRAPHICS.defaultAnimationTime;
|
var defaultTime = GRAPHICS.defaultAnimationTime;
|
||||||
var nodeRadius = GRAPHICS.nodeRadius;
|
var nodeRadius = GRAPHICS.nodeRadius;
|
||||||
|
|
||||||
|
@ -218,13 +219,17 @@ GitVisuals.prototype.finishAnimation = function() {
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
}, this))
|
}, this))
|
||||||
|
.then(function() {
|
||||||
|
animationDone.resolve();
|
||||||
|
})
|
||||||
.fail(function(reason) {
|
.fail(function(reason) {
|
||||||
console.warn('Finish animation failed due to ', reason);
|
console.warn('animation error' + reason);
|
||||||
throw reason;
|
})
|
||||||
});
|
.done();
|
||||||
|
|
||||||
deferred.resolve(); // start right away
|
// start our animation chain right away
|
||||||
return deferred.promise;
|
deferred.resolve();
|
||||||
|
return animationDone.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.explodeNodes = function() {
|
GitVisuals.prototype.explodeNodes = function() {
|
||||||
|
|
11
todo.txt
11
todo.txt
|
@ -1,14 +1,16 @@
|
||||||
Big things:
|
Big things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
[ ] promise-based levels
|
|
||||||
|
|
||||||
Big Graphic things:
|
Big Graphic things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
[ ] show goal
|
||||||
|
[ ] show solution
|
||||||
|
[ ] show which level you are in! with a little thing on the top
|
||||||
|
[ ] levels dropdown selection?
|
||||||
|
|
||||||
Medium things:
|
Medium things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
[ ] do an after-paper-initialize type thing so we can insert git shim once
|
[ ] move command history into sandbox / visualization?
|
||||||
git engine is done.
|
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
========
|
========
|
||||||
|
@ -31,6 +33,9 @@ Big Bugs to fix:
|
||||||
Done things:
|
Done things:
|
||||||
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
[x] do an after-paper-initialize type thing so we can insert git shim once
|
||||||
|
git engine is done.
|
||||||
|
[x] promise-based levels
|
||||||
[x] fixed that to-do entry with the toggle Z thing. now its much more consistent
|
[x] fixed that to-do entry with the toggle Z thing. now its much more consistent
|
||||||
[x] sandbox a real view now
|
[x] sandbox a real view now
|
||||||
[x] awesome before and after shims with event baton stealing and passing back
|
[x] awesome before and after shims with event baton stealing and passing back
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue