die for levels

This commit is contained in:
Peter Cottle 2013-01-05 13:53:00 -08:00
parent 5d981a1268
commit 953bd49ee2
11 changed files with 270 additions and 14 deletions

View file

@ -18,6 +18,7 @@ var ModalAlert = require('../views').ModalAlert;
var MultiView = require('../views/multiView').MultiView;
var CanvasTerminalHolder = require('../views').CanvasTerminalHolder;
var ConfirmCancelTerminal = require('../views').ConfirmCancelTerminal;
var LevelToolbar = require('../views').LevelToolbar;
var TreeCompare = require('../git/treeCompare').TreeCompare;
@ -35,10 +36,25 @@ var Level = Sandbox.extend({
this.treeCompare = new TreeCompare();
this.initGoalData(options);
this.initName(options);
Sandbox.prototype.initialize.apply(this, [options]);
this.startOffCommand();
},
initName: function(options) {
this.levelName = options.levelName;
this.levelID = options.levelID;
if (!this.levelName || !this.levelID) {
this.levelName = 'Rebase Classic';
console.warn('REALLY BAD FORM need ids and names');
}
this.levelToolbar = new LevelToolbar({
levelName: this.levelName
});
},
initGoalData: function(options) {
this.goalTreeString = options.level.goalTree;
this.solutionCommand = options.level.solutionCommand;
@ -59,6 +75,12 @@ var Level = Sandbox.extend({
Sandbox.prototype.takeControl.apply(this);
},
releaseControl: function() {
Main.getEventBaton().releaseBaton('processLevelCommand', this.processLevelCommand, this);
Sandbox.prototype.releaseControl.apply(this);
},
startOffCommand: function() {
Main.getEventBaton().trigger(
'commandSubmitted',
@ -270,6 +292,22 @@ var Level = Sandbox.extend({
});
},
die: function() {
this.levelToolbar.die();
this.goalCanvasHolder.die();
this.mainVis.die();
this.goalVis.die();
this.releaseControl();
this.clear();
delete this.commandCollection;
delete this.mainVis;
delete this.goalVis;
delete this.goalCanvasHolder;
},
getInstantCommands: function() {
var hintMsg = (this.level.hint) ?
this.level.hint :