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

@ -6494,7 +6494,8 @@ var Level = Sandbox.extend({
el: this.goalCanvasHolder.getCanvasLocation(), el: this.goalCanvasHolder.getCanvasLocation(),
containerElement: this.goalCanvasHolder.getCanvasLocation(), containerElement: this.goalCanvasHolder.getCanvasLocation(),
treeString: this.goalTreeString, treeString: this.goalTreeString,
noKeyboardInput: true noKeyboardInput: true,
noClick: true
}); });
}, },
@ -6607,7 +6608,6 @@ var Level = Sandbox.extend({
afterCB: _.bind(this.afterCommandCB, this), afterCB: _.bind(this.afterCommandCB, this),
afterDeferHandler: _.bind(this.afterCommandDefer, this) afterDeferHandler: _.bind(this.afterCommandDefer, this)
}); });
console.log('made my git shim');
}, },
getCommandsThatCount: function() { getCommandsThatCount: function() {
@ -6712,6 +6712,18 @@ var Level = Sandbox.extend({
return instants; 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) { exitLevel: function(command, deferred) {
this.die(); this.die();
setTimeout(function() { setTimeout(function() {
@ -6855,7 +6867,8 @@ var Visualization = Backbone.View.extend({
this.gitVisuals = new GitVisuals({ this.gitVisuals = new GitVisuals({
commitCollection: this.commitCollection, commitCollection: this.commitCollection,
branchCollection: this.branchCollection, branchCollection: this.branchCollection,
paper: this.paper paper: this.paper,
noClick: this.options.noClick
}); });
var GitEngine = require('../git').GitEngine; var GitEngine = require('../git').GitEngine;
@ -7363,6 +7376,7 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
}; };
GitEngine.prototype.tearDown = function() { GitEngine.prototype.tearDown = function() {
this.eventBaton.releaseBaton('processGitCommand', this.dispatch, this);
this.removeAll(); this.removeAll();
}; };
@ -12720,6 +12734,8 @@ var VisEdge = require('../visuals/visEdge').VisEdge;
var VisEdgeCollection = require('../visuals/visEdge').VisEdgeCollection; var VisEdgeCollection = require('../visuals/visEdge').VisEdgeCollection;
function GitVisuals(options) { function GitVisuals(options) {
options = options || {};
this.options = options;
this.commitCollection = options.commitCollection; this.commitCollection = options.commitCollection;
this.branchCollection = options.branchCollection; this.branchCollection = options.branchCollection;
this.visNodeMap = {}; this.visNodeMap = {};
@ -13800,6 +13816,9 @@ var VisNode = VisBase.extend({
}, },
attachClickHandlers: function() { attachClickHandlers: function() {
if (this.get('gitVisuals').options.noClick) {
return;
}
var commandStr = 'git checkout ' + this.get('commit').get('id'); var commandStr = 'git checkout ' + this.get('commit').get('id');
var Main = require('../app'); var Main = require('../app');
_.each([this.get('circle'), this.get('text')], function(rObj) { _.each([this.get('circle'), this.get('text')], function(rObj) {
@ -14282,6 +14301,9 @@ var VisBranch = VisBase.extend({
}, },
attachClickHandlers: function() { attachClickHandlers: function() {
if (this.get('gitVisuals').options.noClick) {
return;
}
var commandStr = 'git checkout ' + this.get('branch').get('id'); var commandStr = 'git checkout ' + this.get('branch').get('id');
var Main = require('../app'); var Main = require('../app');
var objs = [this.get('rect'), this.get('text'), this.get('arrow')]; var objs = [this.get('rect'), this.get('text'), this.get('arrow')];
@ -14705,8 +14727,7 @@ exports.GitShim = GitShim;
}); });
require.define("/src/js/views/multiView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError; require.define("/src/js/views/multiView.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var _ = require('underscore');
var Q = require('q'); var Q = require('q');
// horrible hack to get localStorage Backbone plugin // horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
@ -14718,6 +14739,8 @@ var LeftRightView = require('../views').LeftRightView;
var ModalAlert = require('../views').ModalAlert; var ModalAlert = require('../views').ModalAlert;
var KeyboardListener = require('../util/keyboard').KeyboardListener; var KeyboardListener = require('../util/keyboard').KeyboardListener;
var GitError = require('../util/errors').GitError;
var MultiView = Backbone.View.extend({ var MultiView = Backbone.View.extend({
tagName: 'div', tagName: 'div',
className: 'multiView', className: 'multiView',
@ -16258,6 +16281,7 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
}; };
GitEngine.prototype.tearDown = function() { GitEngine.prototype.tearDown = function() {
this.eventBaton.releaseBaton('processGitCommand', this.dispatch, this);
this.removeAll(); this.removeAll();
}; };
@ -17825,6 +17849,10 @@ exports.TreeCompare = TreeCompare;
}); });
require("/src/js/git/treeCompare.js"); require("/src/js/git/treeCompare.js");
require.define("/src/js/level/arbiter.js",function(require,module,exports,__dirname,__filename,process,global){
});
require("/src/js/level/arbiter.js");
require.define("/src/js/level/commands.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); require.define("/src/js/level/commands.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var regexMap = { var regexMap = {
@ -18015,7 +18043,8 @@ var Level = Sandbox.extend({
el: this.goalCanvasHolder.getCanvasLocation(), el: this.goalCanvasHolder.getCanvasLocation(),
containerElement: this.goalCanvasHolder.getCanvasLocation(), containerElement: this.goalCanvasHolder.getCanvasLocation(),
treeString: this.goalTreeString, treeString: this.goalTreeString,
noKeyboardInput: true noKeyboardInput: true,
noClick: true
}); });
}, },
@ -18128,7 +18157,6 @@ var Level = Sandbox.extend({
afterCB: _.bind(this.afterCommandCB, this), afterCB: _.bind(this.afterCommandCB, this),
afterDeferHandler: _.bind(this.afterCommandDefer, this) afterDeferHandler: _.bind(this.afterCommandDefer, this)
}); });
console.log('made my git shim');
}, },
getCommandsThatCount: function() { getCommandsThatCount: function() {
@ -18233,6 +18261,18 @@ var Level = Sandbox.extend({
return instants; 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) { exitLevel: function(command, deferred) {
this.die(); this.die();
setTimeout(function() { setTimeout(function() {
@ -19734,6 +19774,22 @@ exports.CommandLineHistoryView = CommandLineHistoryView;
}); });
require("/src/js/views/commandViews.js"); require("/src/js/views/commandViews.js");
require.define("/src/js/views/gitDemonstrationView.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var ModalTerminal = require('../views').ModalTerminal;
var ContainedBase = require('../views').ContainedBase;
var ConfirmCancelView = require('../views').ConfirmCancelView;
var LeftRightView = require('../views').LeftRightView;
var ModalAlert = require('../views').ModalAlert;
var KeyboardListener = require('../util/keyboard').KeyboardListener;
});
require("/src/js/views/gitDemonstrationView.js");
require.define("/src/js/views/index.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError; require.define("/src/js/views/index.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError;
var _ = require('underscore'); var _ = require('underscore');
var Q = require('q'); var Q = require('q');
@ -20187,8 +20243,7 @@ exports.LevelToolbar = LevelToolbar;
}); });
require("/src/js/views/index.js"); require("/src/js/views/index.js");
require.define("/src/js/views/multiView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError; require.define("/src/js/views/multiView.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var _ = require('underscore');
var Q = require('q'); var Q = require('q');
// horrible hack to get localStorage Backbone plugin // horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
@ -20200,6 +20255,8 @@ var LeftRightView = require('../views').LeftRightView;
var ModalAlert = require('../views').ModalAlert; var ModalAlert = require('../views').ModalAlert;
var KeyboardListener = require('../util/keyboard').KeyboardListener; var KeyboardListener = require('../util/keyboard').KeyboardListener;
var GitError = require('../util/errors').GitError;
var MultiView = Backbone.View.extend({ var MultiView = Backbone.View.extend({
tagName: 'div', tagName: 'div',
className: 'multiView', className: 'multiView',
@ -20895,6 +20952,8 @@ var VisEdge = require('../visuals/visEdge').VisEdge;
var VisEdgeCollection = require('../visuals/visEdge').VisEdgeCollection; var VisEdgeCollection = require('../visuals/visEdge').VisEdgeCollection;
function GitVisuals(options) { function GitVisuals(options) {
options = options || {};
this.options = options;
this.commitCollection = options.commitCollection; this.commitCollection = options.commitCollection;
this.branchCollection = options.branchCollection; this.branchCollection = options.branchCollection;
this.visNodeMap = {}; this.visNodeMap = {};
@ -22024,6 +22083,9 @@ var VisBranch = VisBase.extend({
}, },
attachClickHandlers: function() { attachClickHandlers: function() {
if (this.get('gitVisuals').options.noClick) {
return;
}
var commandStr = 'git checkout ' + this.get('branch').get('id'); var commandStr = 'git checkout ' + this.get('branch').get('id');
var Main = require('../app'); var Main = require('../app');
var objs = [this.get('rect'), this.get('text'), this.get('arrow')]; var objs = [this.get('rect'), this.get('text'), this.get('arrow')];
@ -22636,6 +22698,9 @@ var VisNode = VisBase.extend({
}, },
attachClickHandlers: function() { attachClickHandlers: function() {
if (this.get('gitVisuals').options.noClick) {
return;
}
var commandStr = 'git checkout ' + this.get('commit').get('id'); var commandStr = 'git checkout ' + this.get('commit').get('id');
var Main = require('../app'); var Main = require('../app');
_.each([this.get('circle'), this.get('text')], function(rObj) { _.each([this.get('circle'), this.get('text')], function(rObj) {
@ -22805,7 +22870,8 @@ var Visualization = Backbone.View.extend({
this.gitVisuals = new GitVisuals({ this.gitVisuals = new GitVisuals({
commitCollection: this.commitCollection, commitCollection: this.commitCollection,
branchCollection: this.branchCollection, branchCollection: this.branchCollection,
paper: this.paper paper: this.paper,
noClick: this.options.noClick
}); });
var GitEngine = require('../git').GitEngine; var GitEngine = require('../git').GitEngine;

View file

@ -258,6 +258,7 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
}; };
GitEngine.prototype.tearDown = function() { GitEngine.prototype.tearDown = function() {
this.eventBaton.releaseBaton('processGitCommand', this.dispatch, this);
this.removeAll(); 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(), el: this.goalCanvasHolder.getCanvasLocation(),
containerElement: this.goalCanvasHolder.getCanvasLocation(), containerElement: this.goalCanvasHolder.getCanvasLocation(),
treeString: this.goalTreeString, treeString: this.goalTreeString,
noKeyboardInput: true noKeyboardInput: true,
noClick: true
}); });
}, },
@ -227,7 +228,6 @@ var Level = Sandbox.extend({
afterCB: _.bind(this.afterCommandCB, this), afterCB: _.bind(this.afterCommandCB, this),
afterDeferHandler: _.bind(this.afterCommandDefer, this) afterDeferHandler: _.bind(this.afterCommandDefer, this)
}); });
console.log('made my git shim');
}, },
getCommandsThatCount: function() { getCommandsThatCount: function() {
@ -332,6 +332,18 @@ var Level = Sandbox.extend({
return instants; 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) { exitLevel: function(command, deferred) {
this.die(); this.die();
setTimeout(function() { setTimeout(function() {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,13 +5,10 @@ Big Graphic things:
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] levels dropdown selection? [ ] levels dropdown selection?
[ ] git demonstration view [ ] git demonstration view
[ ] sandbox can launch and takedown levels
Medium things: Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] level arbiter (has everything by ID)
Commands
========
Small things to implement: Small things to implement:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -21,7 +18,6 @@ Minor Bugs to fix:
Big Bugs to fix: Big Bugs to fix:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] click handlers on goal visualization for the actual canvas elements
/************************************* /*************************************
** Publish Things ** ** Publish Things **
@ -32,6 +28,11 @@ 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] click handlers on goal visualization for the actual canvas elements
[x] sandbox can launch and takedown levels
[x] TWO epic bugs squashed:
* Raphael process.nextTick needed
* _.debounce on prototype
[x] window zoom alert thing -- this just needs to be timeouted one more time [x] window zoom alert thing -- this just needs to be timeouted one more time
[x] level teardown [x] level teardown
[x] great die for levels [x] great die for levels