level arbiter beginning

This commit is contained in:
Peter Cottle 2013-01-05 21:47:05 -08:00
parent d5bddcc6b4
commit 27498419c9
10 changed files with 109 additions and 19 deletions

View file

@ -258,6 +258,7 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
};
GitEngine.prototype.tearDown = function() {
this.eventBaton.releaseBaton('processGitCommand', this.dispatch, this);
this.removeAll();
};

0
src/js/level/arbiter.js Normal file
View file

View file

@ -114,7 +114,8 @@ var Level = Sandbox.extend({
el: this.goalCanvasHolder.getCanvasLocation(),
containerElement: this.goalCanvasHolder.getCanvasLocation(),
treeString: this.goalTreeString,
noKeyboardInput: true
noKeyboardInput: true,
noClick: true
});
},
@ -227,7 +228,6 @@ var Level = Sandbox.extend({
afterCB: _.bind(this.afterCommandCB, this),
afterDeferHandler: _.bind(this.afterCommandDefer, this)
});
console.log('made my git shim');
},
getCommandsThatCount: function() {
@ -332,6 +332,18 @@ var Level = Sandbox.extend({
return instants;
},
startLevel: function(command, deferred) {
command.addWarning(
"You are in a level! You can't start a new one before exiting. I'll add the command for you..."
);
command.set('status', 'error');
Main.getEventBaton().trigger('commandSubmitted',
'delay 3000; exit level; delay 500;' + command.get('rawStr')
);
deferred.resolve();
},
exitLevel: function(command, deferred) {
this.die();
setTimeout(function() {

View file

@ -1,4 +1,3 @@
var GitError = require('../util/errors').GitError;
var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
@ -11,6 +10,8 @@ var LeftRightView = require('../views').LeftRightView;
var ModalAlert = require('../views').ModalAlert;
var KeyboardListener = require('../util/keyboard').KeyboardListener;
var GitError = require('../util/errors').GitError;
var MultiView = Backbone.View.extend({
tagName: 'div',
className: 'multiView',

View file

@ -16,6 +16,8 @@ var VisEdge = require('../visuals/visEdge').VisEdge;
var VisEdgeCollection = require('../visuals/visEdge').VisEdgeCollection;
function GitVisuals(options) {
options = options || {};
this.options = options;
this.commitCollection = options.commitCollection;
this.branchCollection = options.branchCollection;
this.visNodeMap = {};

View file

@ -313,6 +313,9 @@ var VisBranch = VisBase.extend({
},
attachClickHandlers: function() {
if (this.get('gitVisuals').options.noClick) {
return;
}
var commandStr = 'git checkout ' + this.get('branch').get('id');
var Main = require('../app');
var objs = [this.get('rect'), this.get('text'), this.get('arrow')];

View file

@ -314,6 +314,9 @@ var VisNode = VisBase.extend({
},
attachClickHandlers: function() {
if (this.get('gitVisuals').options.noClick) {
return;
}
var commandStr = 'git checkout ' + this.get('commit').get('id');
var Main = require('../app');
_.each([this.get('circle'), this.get('text')], function(rObj) {

View file

@ -47,7 +47,8 @@ var Visualization = Backbone.View.extend({
this.gitVisuals = new GitVisuals({
commitCollection: this.commitCollection,
branchCollection: this.branchCollection,
paper: this.paper
paper: this.paper,
noClick: this.options.noClick
});
var GitEngine = require('../git').GitEngine;