mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
some bugs
This commit is contained in:
parent
8086d2b2b1
commit
31aba06d45
10 changed files with 314 additions and 144 deletions
273
build/bundle.js
273
build/bundle.js
|
@ -4745,7 +4745,7 @@ var Sandbox = Backbone.View.extend({
|
||||||
|
|
||||||
helpDialog: function(command, deferred) {
|
helpDialog: function(command, deferred) {
|
||||||
var helpDialog = new MultiView({
|
var helpDialog = new MultiView({
|
||||||
childViews: require('../dialogs/sandbox').helpDialog
|
childViews: require('../dialogs/sandbox').dialog
|
||||||
});
|
});
|
||||||
helpDialog.getPromise().then(_.bind(function() {
|
helpDialog.getPromise().then(_.bind(function() {
|
||||||
// the view has been closed, lets go ahead and resolve our command
|
// the view has been closed, lets go ahead and resolve our command
|
||||||
|
@ -6605,6 +6605,9 @@ var Level = Sandbox.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleOpen(deferred);
|
this.handleOpen(deferred);
|
||||||
|
deferred.promise.then(function() {
|
||||||
|
command.set('status', 'finished');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
initName: function() {
|
initName: function() {
|
||||||
|
@ -6876,7 +6879,7 @@ var Level = Sandbox.extend({
|
||||||
"Hmm, there doesn't seem to be a hint for this level :-/";
|
"Hmm, there doesn't seem to be a hint for this level :-/";
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[/^help$/, function() {
|
[/^help$|^\?$/, function() {
|
||||||
throw new Errors.CommandResult({
|
throw new Errors.CommandResult({
|
||||||
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
|
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
|
||||||
'"help level" or "help general"'
|
'"help level" or "help general"'
|
||||||
|
@ -6931,7 +6934,7 @@ var Level = Sandbox.extend({
|
||||||
'hide goal': this.hideGoal,
|
'hide goal': this.hideGoal,
|
||||||
'show solution': this.showSolution,
|
'show solution': this.showSolution,
|
||||||
'start dialog': this.startDialog,
|
'start dialog': this.startDialog,
|
||||||
'level help': this.startDialog
|
'help level': this.startDialog
|
||||||
};
|
};
|
||||||
var method = methodMap[command.get('method')];
|
var method = methodMap[command.get('method')];
|
||||||
if (!method) {
|
if (!method) {
|
||||||
|
@ -10035,12 +10038,8 @@ var ConfirmCancelTerminal = Backbone.View.extend({
|
||||||
// whenever they hit a button. make sure
|
// whenever they hit a button. make sure
|
||||||
// we close and pass that to our deferred
|
// we close and pass that to our deferred
|
||||||
buttonDefer.promise
|
buttonDefer.promise
|
||||||
.then(_.bind(function() {
|
.then(this.deferred.resolve)
|
||||||
this.deferred.resolve();
|
.fail(this.deferred.reject)
|
||||||
}, this))
|
|
||||||
.fail(_.bind(function() {
|
|
||||||
this.deferred.reject();
|
|
||||||
}, this))
|
|
||||||
.done(_.bind(function() {
|
.done(_.bind(function() {
|
||||||
this.close();
|
this.close();
|
||||||
}, this));
|
}, this));
|
||||||
|
@ -13047,7 +13046,6 @@ var instantCommands = [
|
||||||
}],
|
}],
|
||||||
[/^echo "(.*?)"$|^echo (.*?)$/, function(bits) {
|
[/^echo "(.*?)"$|^echo (.*?)$/, function(bits) {
|
||||||
var msg = bits[1] || bits[2];
|
var msg = bits[1] || bits[2];
|
||||||
console.log(bits, msg);
|
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: msg
|
msg: msg
|
||||||
});
|
});
|
||||||
|
@ -13056,7 +13054,7 @@ var instantCommands = [
|
||||||
|
|
||||||
var regexMap = {
|
var regexMap = {
|
||||||
'reset solved': /^reset solved($|\s)/,
|
'reset solved': /^reset solved($|\s)/,
|
||||||
'help': /^help ?(general)?($|\s)/,
|
'help': /^help( general)?$|^\?$/,
|
||||||
'reset': /^reset$/,
|
'reset': /^reset$/,
|
||||||
'delay': /^delay (\d+)$/,
|
'delay': /^delay (\d+)$/,
|
||||||
'clear': /^clear($|\s)/,
|
'clear': /^clear($|\s)/,
|
||||||
|
@ -15776,8 +15774,8 @@ LevelArbiter.prototype.validateLevel = function(level) {
|
||||||
var requiredFields = [
|
var requiredFields = [
|
||||||
'name',
|
'name',
|
||||||
'goalTreeString',
|
'goalTreeString',
|
||||||
'solutionCommand',
|
//'description',
|
||||||
'description'
|
'solutionCommand'
|
||||||
];
|
];
|
||||||
|
|
||||||
var optionalFields = [
|
var optionalFields = [
|
||||||
|
@ -16663,7 +16661,9 @@ var LevelToolbar = require('../views').LevelToolbar;
|
||||||
|
|
||||||
var regexMap = {
|
var regexMap = {
|
||||||
'define goal': /^define goal$/,
|
'define goal': /^define goal$/,
|
||||||
|
'help builder': /^help builder$/,
|
||||||
'define start': /^define start$/,
|
'define start': /^define start$/,
|
||||||
|
'edit dialog': /^edit dialog$/,
|
||||||
'show start': /^show start$/,
|
'show start': /^show start$/,
|
||||||
'hide start': /^hide start$/,
|
'hide start': /^hide start$/,
|
||||||
'define hint': /^define hint$/,
|
'define hint': /^define hint$/,
|
||||||
|
@ -16678,28 +16678,12 @@ var LevelBuilder = Level.extend({
|
||||||
options.level = options.level || {};
|
options.level = options.level || {};
|
||||||
|
|
||||||
options.level.startDialog = {
|
options.level.startDialog = {
|
||||||
childViews: [{
|
childViews: require('../dialogs/levelBuilder').dialog
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdowns: [
|
|
||||||
'## Welcome to the level builder!',
|
|
||||||
'',
|
|
||||||
'Here are the main steps:',
|
|
||||||
'',
|
|
||||||
' * Define the starting tree with ```define start```',
|
|
||||||
' * Enter the series of git commands that compose the (optimal) solution',
|
|
||||||
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
|
|
||||||
' * Optionally define a hint with ```define hint```',
|
|
||||||
' * Enter the command ```finish``` to output your level JSON!'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LevelBuilder.__super__.initialize.apply(this, [options]);
|
LevelBuilder.__super__.initialize.apply(this, [options]);
|
||||||
|
|
||||||
|
this.initStartVisualization();
|
||||||
this.startDialog = undefined;
|
this.startDialog = undefined;
|
||||||
this.initStartDialog();
|
|
||||||
|
|
||||||
// we wont be using this stuff, and its to delete to ensure we overwrite all functions that
|
// we wont be using this stuff, and its to delete to ensure we overwrite all functions that
|
||||||
// include that functionality
|
// include that functionality
|
||||||
|
@ -16722,7 +16706,8 @@ var LevelBuilder = Level.extend({
|
||||||
|
|
||||||
initStartVisualization: function() {
|
initStartVisualization: function() {
|
||||||
this.startCanvasHolder = new CanvasTerminalHolder({
|
this.startCanvasHolder = new CanvasTerminalHolder({
|
||||||
additionalClass: 'startTree'
|
additionalClass: 'startTree',
|
||||||
|
text: 'You can hide this window with "hide start"'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.startVis = new Visualization({
|
this.startVis = new Visualization({
|
||||||
|
@ -16768,7 +16753,15 @@ var LevelBuilder = Level.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInstantCommands: function() {
|
getInstantCommands: function() {
|
||||||
return [];
|
return [
|
||||||
|
[/^help$|^\?$/, function() {
|
||||||
|
throw new Errors.CommandResult({
|
||||||
|
msg: 'You are in a level builder, so multiple forms of ' +
|
||||||
|
'help are available. Please select either ' +
|
||||||
|
'"help general" or "help builder"'
|
||||||
|
});
|
||||||
|
}]
|
||||||
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
takeControl: function() {
|
takeControl: function() {
|
||||||
|
@ -16856,24 +16849,66 @@ var LevelBuilder = Level.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var masterDeferred = Q.defer();
|
||||||
|
var chain = masterDeferred.promise;
|
||||||
|
|
||||||
if (this.level.hint === undefined) {
|
if (this.level.hint === undefined) {
|
||||||
this.setHint();
|
var askForHintDeferred = Q.defer();
|
||||||
|
chain = chain.then(function() {
|
||||||
|
return askForHintDeferred.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
// ask for a hint if there is none
|
||||||
|
var askForHintView = new ConfirmCancelTerminal({
|
||||||
|
markdowns: [
|
||||||
|
'You have not specified a hint, would you like to add one?'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
askForHintView.getPromise()
|
||||||
|
.then(_.bind(this.setHint, this))
|
||||||
|
.fail(_.bind(function() {
|
||||||
|
this.level.hint = '';
|
||||||
|
}, this))
|
||||||
|
.done(function() {
|
||||||
|
askForHintDeferred.resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.startDialog === undefined) {
|
||||||
|
var askForStartDeferred = Q.defer();
|
||||||
|
chain = chain.then(function() {
|
||||||
|
return askForStartDeferred.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
var askForStartView = new ConfirmCancelTerminal({
|
||||||
|
markdowns: [
|
||||||
|
'You have not specified a start dialog, would you like to add one?'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
askForStartView.getPromise()
|
||||||
|
.then(function() {
|
||||||
|
alert(1);
|
||||||
|
})
|
||||||
|
.done(function() {
|
||||||
|
askForStartDeferred.resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
chain = chain.done(_.bind(function() {
|
||||||
var compiledLevel = _.extend(
|
var compiledLevel = _.extend(
|
||||||
{},
|
{},
|
||||||
this.level
|
this.level
|
||||||
);
|
);
|
||||||
|
|
||||||
// the start dialog now is just our help intro thing
|
// the start dialog now is just our help intro thing
|
||||||
delete compiledLevel.startDialog;
|
delete compiledLevel.startDialog;
|
||||||
if (this.startDialog) {
|
if (this.startDialog) {
|
||||||
compiledLevel.startDialog = this.startDialog;
|
compiledLevel.startDialog = this.startDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(compiledLevel);
|
console.log(compiledLevel);
|
||||||
|
|
||||||
command.finishWith(deferred);
|
command.finishWith(deferred);
|
||||||
|
}, this));
|
||||||
|
|
||||||
|
masterDeferred.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
processLevelBuilderCommand: function(command, deferred) {
|
processLevelBuilderCommand: function(command, deferred) {
|
||||||
|
@ -16883,7 +16918,8 @@ var LevelBuilder = Level.extend({
|
||||||
'show start': this.showStart,
|
'show start': this.showStart,
|
||||||
'hide start': this.hideStart,
|
'hide start': this.hideStart,
|
||||||
'finish': this.finish,
|
'finish': this.finish,
|
||||||
'define hint': this.defineHint
|
'define hint': this.defineHint,
|
||||||
|
'help builder': LevelBuilder.__super__.startDialog
|
||||||
};
|
};
|
||||||
|
|
||||||
methodMap[command.get('method')].apply(this, arguments);
|
methodMap[command.get('method')].apply(this, arguments);
|
||||||
|
@ -16908,7 +16944,28 @@ exports.LevelBuilder = LevelBuilder;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){exports.helpDialog = [{
|
require.define("/src/js/dialogs/levelBuilder.js",function(require,module,exports,__dirname,__filename,process,global){exports.dialog = [{
|
||||||
|
type: 'ModalAlert',
|
||||||
|
options: {
|
||||||
|
markdowns: [
|
||||||
|
'## Welcome to the level builder!',
|
||||||
|
'',
|
||||||
|
'Here are the main steps:',
|
||||||
|
'',
|
||||||
|
' * Set up the initial environment with git commands',
|
||||||
|
' * Define the starting tree with ```define start```',
|
||||||
|
' * Enter the series of git commands that compose the (optimal) solution',
|
||||||
|
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
|
||||||
|
' * Optionally define a hint with ```define hint```',
|
||||||
|
' * Optionally define a nice start dialog with ```edit dialog```',
|
||||||
|
' * Enter the command ```finish``` to output your level JSON!'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){exports.dialog = [{
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
markdowns: [
|
markdowns: [
|
||||||
|
@ -16937,6 +16994,7 @@ require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__di
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/js/util/mock.js",function(require,module,exports,__dirname,__filename,process,global){exports.mock = function(Constructor) {
|
require.define("/src/js/util/mock.js",function(require,module,exports,__dirname,__filename,process,global){exports.mock = function(Constructor) {
|
||||||
|
@ -17536,7 +17594,29 @@ exports.init = init;
|
||||||
});
|
});
|
||||||
require("/src/js/app/index.js");
|
require("/src/js/app/index.js");
|
||||||
|
|
||||||
require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){exports.helpDialog = [{
|
require.define("/src/js/dialogs/levelBuilder.js",function(require,module,exports,__dirname,__filename,process,global){exports.dialog = [{
|
||||||
|
type: 'ModalAlert',
|
||||||
|
options: {
|
||||||
|
markdowns: [
|
||||||
|
'## Welcome to the level builder!',
|
||||||
|
'',
|
||||||
|
'Here are the main steps:',
|
||||||
|
'',
|
||||||
|
' * Set up the initial environment with git commands',
|
||||||
|
' * Define the starting tree with ```define start```',
|
||||||
|
' * Enter the series of git commands that compose the (optimal) solution',
|
||||||
|
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
|
||||||
|
' * Optionally define a hint with ```define hint```',
|
||||||
|
' * Optionally define a nice start dialog with ```edit dialog```',
|
||||||
|
' * Enter the command ```finish``` to output your level JSON!'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
});
|
||||||
|
require("/src/js/dialogs/levelBuilder.js");
|
||||||
|
|
||||||
|
require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){exports.dialog = [{
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
markdowns: [
|
markdowns: [
|
||||||
|
@ -17565,6 +17645,7 @@ require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__di
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
require("/src/js/dialogs/sandbox.js");
|
require("/src/js/dialogs/sandbox.js");
|
||||||
|
|
||||||
|
@ -19826,8 +19907,8 @@ LevelArbiter.prototype.validateLevel = function(level) {
|
||||||
var requiredFields = [
|
var requiredFields = [
|
||||||
'name',
|
'name',
|
||||||
'goalTreeString',
|
'goalTreeString',
|
||||||
'solutionCommand',
|
//'description',
|
||||||
'description'
|
'solutionCommand'
|
||||||
];
|
];
|
||||||
|
|
||||||
var optionalFields = [
|
var optionalFields = [
|
||||||
|
@ -19924,7 +20005,9 @@ var LevelToolbar = require('../views').LevelToolbar;
|
||||||
|
|
||||||
var regexMap = {
|
var regexMap = {
|
||||||
'define goal': /^define goal$/,
|
'define goal': /^define goal$/,
|
||||||
|
'help builder': /^help builder$/,
|
||||||
'define start': /^define start$/,
|
'define start': /^define start$/,
|
||||||
|
'edit dialog': /^edit dialog$/,
|
||||||
'show start': /^show start$/,
|
'show start': /^show start$/,
|
||||||
'hide start': /^hide start$/,
|
'hide start': /^hide start$/,
|
||||||
'define hint': /^define hint$/,
|
'define hint': /^define hint$/,
|
||||||
|
@ -19939,28 +20022,12 @@ var LevelBuilder = Level.extend({
|
||||||
options.level = options.level || {};
|
options.level = options.level || {};
|
||||||
|
|
||||||
options.level.startDialog = {
|
options.level.startDialog = {
|
||||||
childViews: [{
|
childViews: require('../dialogs/levelBuilder').dialog
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdowns: [
|
|
||||||
'## Welcome to the level builder!',
|
|
||||||
'',
|
|
||||||
'Here are the main steps:',
|
|
||||||
'',
|
|
||||||
' * Define the starting tree with ```define start```',
|
|
||||||
' * Enter the series of git commands that compose the (optimal) solution',
|
|
||||||
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
|
|
||||||
' * Optionally define a hint with ```define hint```',
|
|
||||||
' * Enter the command ```finish``` to output your level JSON!'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LevelBuilder.__super__.initialize.apply(this, [options]);
|
LevelBuilder.__super__.initialize.apply(this, [options]);
|
||||||
|
|
||||||
|
this.initStartVisualization();
|
||||||
this.startDialog = undefined;
|
this.startDialog = undefined;
|
||||||
this.initStartDialog();
|
|
||||||
|
|
||||||
// we wont be using this stuff, and its to delete to ensure we overwrite all functions that
|
// we wont be using this stuff, and its to delete to ensure we overwrite all functions that
|
||||||
// include that functionality
|
// include that functionality
|
||||||
|
@ -19983,7 +20050,8 @@ var LevelBuilder = Level.extend({
|
||||||
|
|
||||||
initStartVisualization: function() {
|
initStartVisualization: function() {
|
||||||
this.startCanvasHolder = new CanvasTerminalHolder({
|
this.startCanvasHolder = new CanvasTerminalHolder({
|
||||||
additionalClass: 'startTree'
|
additionalClass: 'startTree',
|
||||||
|
text: 'You can hide this window with "hide start"'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.startVis = new Visualization({
|
this.startVis = new Visualization({
|
||||||
|
@ -20029,7 +20097,15 @@ var LevelBuilder = Level.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInstantCommands: function() {
|
getInstantCommands: function() {
|
||||||
return [];
|
return [
|
||||||
|
[/^help$|^\?$/, function() {
|
||||||
|
throw new Errors.CommandResult({
|
||||||
|
msg: 'You are in a level builder, so multiple forms of ' +
|
||||||
|
'help are available. Please select either ' +
|
||||||
|
'"help general" or "help builder"'
|
||||||
|
});
|
||||||
|
}]
|
||||||
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
takeControl: function() {
|
takeControl: function() {
|
||||||
|
@ -20117,24 +20193,66 @@ var LevelBuilder = Level.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var masterDeferred = Q.defer();
|
||||||
|
var chain = masterDeferred.promise;
|
||||||
|
|
||||||
if (this.level.hint === undefined) {
|
if (this.level.hint === undefined) {
|
||||||
this.setHint();
|
var askForHintDeferred = Q.defer();
|
||||||
|
chain = chain.then(function() {
|
||||||
|
return askForHintDeferred.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
// ask for a hint if there is none
|
||||||
|
var askForHintView = new ConfirmCancelTerminal({
|
||||||
|
markdowns: [
|
||||||
|
'You have not specified a hint, would you like to add one?'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
askForHintView.getPromise()
|
||||||
|
.then(_.bind(this.setHint, this))
|
||||||
|
.fail(_.bind(function() {
|
||||||
|
this.level.hint = '';
|
||||||
|
}, this))
|
||||||
|
.done(function() {
|
||||||
|
askForHintDeferred.resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.startDialog === undefined) {
|
||||||
|
var askForStartDeferred = Q.defer();
|
||||||
|
chain = chain.then(function() {
|
||||||
|
return askForStartDeferred.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
var askForStartView = new ConfirmCancelTerminal({
|
||||||
|
markdowns: [
|
||||||
|
'You have not specified a start dialog, would you like to add one?'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
askForStartView.getPromise()
|
||||||
|
.then(function() {
|
||||||
|
alert(1);
|
||||||
|
})
|
||||||
|
.done(function() {
|
||||||
|
askForStartDeferred.resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
chain = chain.done(_.bind(function() {
|
||||||
var compiledLevel = _.extend(
|
var compiledLevel = _.extend(
|
||||||
{},
|
{},
|
||||||
this.level
|
this.level
|
||||||
);
|
);
|
||||||
|
|
||||||
// the start dialog now is just our help intro thing
|
// the start dialog now is just our help intro thing
|
||||||
delete compiledLevel.startDialog;
|
delete compiledLevel.startDialog;
|
||||||
if (this.startDialog) {
|
if (this.startDialog) {
|
||||||
compiledLevel.startDialog = this.startDialog;
|
compiledLevel.startDialog = this.startDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(compiledLevel);
|
console.log(compiledLevel);
|
||||||
|
|
||||||
command.finishWith(deferred);
|
command.finishWith(deferred);
|
||||||
|
}, this));
|
||||||
|
|
||||||
|
masterDeferred.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
processLevelBuilderCommand: function(command, deferred) {
|
processLevelBuilderCommand: function(command, deferred) {
|
||||||
|
@ -20144,7 +20262,8 @@ var LevelBuilder = Level.extend({
|
||||||
'show start': this.showStart,
|
'show start': this.showStart,
|
||||||
'hide start': this.hideStart,
|
'hide start': this.hideStart,
|
||||||
'finish': this.finish,
|
'finish': this.finish,
|
||||||
'define hint': this.defineHint
|
'define hint': this.defineHint,
|
||||||
|
'help builder': LevelBuilder.__super__.startDialog
|
||||||
};
|
};
|
||||||
|
|
||||||
methodMap[command.get('method')].apply(this, arguments);
|
methodMap[command.get('method')].apply(this, arguments);
|
||||||
|
@ -20301,6 +20420,9 @@ var Level = Sandbox.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleOpen(deferred);
|
this.handleOpen(deferred);
|
||||||
|
deferred.promise.then(function() {
|
||||||
|
command.set('status', 'finished');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
initName: function() {
|
initName: function() {
|
||||||
|
@ -20572,7 +20694,7 @@ var Level = Sandbox.extend({
|
||||||
"Hmm, there doesn't seem to be a hint for this level :-/";
|
"Hmm, there doesn't seem to be a hint for this level :-/";
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[/^help$/, function() {
|
[/^help$|^\?$/, function() {
|
||||||
throw new Errors.CommandResult({
|
throw new Errors.CommandResult({
|
||||||
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
|
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
|
||||||
'"help level" or "help general"'
|
'"help level" or "help general"'
|
||||||
|
@ -20627,7 +20749,7 @@ var Level = Sandbox.extend({
|
||||||
'hide goal': this.hideGoal,
|
'hide goal': this.hideGoal,
|
||||||
'show solution': this.showSolution,
|
'show solution': this.showSolution,
|
||||||
'start dialog': this.startDialog,
|
'start dialog': this.startDialog,
|
||||||
'level help': this.startDialog
|
'help level': this.startDialog
|
||||||
};
|
};
|
||||||
var method = methodMap[command.get('method')];
|
var method = methodMap[command.get('method')];
|
||||||
if (!method) {
|
if (!method) {
|
||||||
|
@ -21000,7 +21122,7 @@ var Sandbox = Backbone.View.extend({
|
||||||
|
|
||||||
helpDialog: function(command, deferred) {
|
helpDialog: function(command, deferred) {
|
||||||
var helpDialog = new MultiView({
|
var helpDialog = new MultiView({
|
||||||
childViews: require('../dialogs/sandbox').helpDialog
|
childViews: require('../dialogs/sandbox').dialog
|
||||||
});
|
});
|
||||||
helpDialog.getPromise().then(_.bind(function() {
|
helpDialog.getPromise().then(_.bind(function() {
|
||||||
// the view has been closed, lets go ahead and resolve our command
|
// the view has been closed, lets go ahead and resolve our command
|
||||||
|
@ -21055,7 +21177,6 @@ var instantCommands = [
|
||||||
}],
|
}],
|
||||||
[/^echo "(.*?)"$|^echo (.*?)$/, function(bits) {
|
[/^echo "(.*?)"$|^echo (.*?)$/, function(bits) {
|
||||||
var msg = bits[1] || bits[2];
|
var msg = bits[1] || bits[2];
|
||||||
console.log(bits, msg);
|
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: msg
|
msg: msg
|
||||||
});
|
});
|
||||||
|
@ -21064,7 +21185,7 @@ var instantCommands = [
|
||||||
|
|
||||||
var regexMap = {
|
var regexMap = {
|
||||||
'reset solved': /^reset solved($|\s)/,
|
'reset solved': /^reset solved($|\s)/,
|
||||||
'help': /^help ?(general)?($|\s)/,
|
'help': /^help( general)?$|^\?$/,
|
||||||
'reset': /^reset$/,
|
'reset': /^reset$/,
|
||||||
'delay': /^delay (\d+)$/,
|
'delay': /^delay (\d+)$/,
|
||||||
'clear': /^clear($|\s)/,
|
'clear': /^clear($|\s)/,
|
||||||
|
@ -23193,12 +23314,8 @@ var ConfirmCancelTerminal = Backbone.View.extend({
|
||||||
// whenever they hit a button. make sure
|
// whenever they hit a button. make sure
|
||||||
// we close and pass that to our deferred
|
// we close and pass that to our deferred
|
||||||
buttonDefer.promise
|
buttonDefer.promise
|
||||||
.then(_.bind(function() {
|
.then(this.deferred.resolve)
|
||||||
this.deferred.resolve();
|
.fail(this.deferred.reject)
|
||||||
}, this))
|
|
||||||
.fail(_.bind(function() {
|
|
||||||
this.deferred.reject();
|
|
||||||
}, this))
|
|
||||||
.done(_.bind(function() {
|
.done(_.bind(function() {
|
||||||
this.close();
|
this.close();
|
||||||
}, this));
|
}, this));
|
||||||
|
|
18
src/js/dialogs/levelBuilder.js
Normal file
18
src/js/dialogs/levelBuilder.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
exports.dialog = [{
|
||||||
|
type: 'ModalAlert',
|
||||||
|
options: {
|
||||||
|
markdowns: [
|
||||||
|
'## Welcome to the level builder!',
|
||||||
|
'',
|
||||||
|
'Here are the main steps:',
|
||||||
|
'',
|
||||||
|
' * Set up the initial environment with git commands',
|
||||||
|
' * Define the starting tree with ```define start```',
|
||||||
|
' * Enter the series of git commands that compose the (optimal) solution',
|
||||||
|
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
|
||||||
|
' * Optionally define a hint with ```define hint```',
|
||||||
|
' * Optionally define a nice start dialog with ```edit dialog```',
|
||||||
|
' * Enter the command ```finish``` to output your level JSON!'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}];
|
|
@ -1,4 +1,4 @@
|
||||||
exports.helpDialog = [{
|
exports.dialog = [{
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
markdowns: [
|
markdowns: [
|
||||||
|
@ -26,3 +26,4 @@ exports.helpDialog = [{
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
|
@ -90,8 +90,8 @@ LevelArbiter.prototype.validateLevel = function(level) {
|
||||||
var requiredFields = [
|
var requiredFields = [
|
||||||
'name',
|
'name',
|
||||||
'goalTreeString',
|
'goalTreeString',
|
||||||
'solutionCommand',
|
//'description',
|
||||||
'description'
|
'solutionCommand'
|
||||||
];
|
];
|
||||||
|
|
||||||
var optionalFields = [
|
var optionalFields = [
|
||||||
|
|
|
@ -21,7 +21,9 @@ var LevelToolbar = require('../views').LevelToolbar;
|
||||||
|
|
||||||
var regexMap = {
|
var regexMap = {
|
||||||
'define goal': /^define goal$/,
|
'define goal': /^define goal$/,
|
||||||
|
'help builder': /^help builder$/,
|
||||||
'define start': /^define start$/,
|
'define start': /^define start$/,
|
||||||
|
'edit dialog': /^edit dialog$/,
|
||||||
'show start': /^show start$/,
|
'show start': /^show start$/,
|
||||||
'hide start': /^hide start$/,
|
'hide start': /^hide start$/,
|
||||||
'define hint': /^define hint$/,
|
'define hint': /^define hint$/,
|
||||||
|
@ -36,28 +38,12 @@ var LevelBuilder = Level.extend({
|
||||||
options.level = options.level || {};
|
options.level = options.level || {};
|
||||||
|
|
||||||
options.level.startDialog = {
|
options.level.startDialog = {
|
||||||
childViews: [{
|
childViews: require('../dialogs/levelBuilder').dialog
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdowns: [
|
|
||||||
'## Welcome to the level builder!',
|
|
||||||
'',
|
|
||||||
'Here are the main steps:',
|
|
||||||
'',
|
|
||||||
' * Define the starting tree with ```define start```',
|
|
||||||
' * Enter the series of git commands that compose the (optimal) solution',
|
|
||||||
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
|
|
||||||
' * Optionally define a hint with ```define hint```',
|
|
||||||
' * Enter the command ```finish``` to output your level JSON!'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LevelBuilder.__super__.initialize.apply(this, [options]);
|
LevelBuilder.__super__.initialize.apply(this, [options]);
|
||||||
|
|
||||||
|
this.initStartVisualization();
|
||||||
this.startDialog = undefined;
|
this.startDialog = undefined;
|
||||||
this.initStartDialog();
|
|
||||||
|
|
||||||
// we wont be using this stuff, and its to delete to ensure we overwrite all functions that
|
// we wont be using this stuff, and its to delete to ensure we overwrite all functions that
|
||||||
// include that functionality
|
// include that functionality
|
||||||
|
@ -80,7 +66,8 @@ var LevelBuilder = Level.extend({
|
||||||
|
|
||||||
initStartVisualization: function() {
|
initStartVisualization: function() {
|
||||||
this.startCanvasHolder = new CanvasTerminalHolder({
|
this.startCanvasHolder = new CanvasTerminalHolder({
|
||||||
additionalClass: 'startTree'
|
additionalClass: 'startTree',
|
||||||
|
text: 'You can hide this window with "hide start"'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.startVis = new Visualization({
|
this.startVis = new Visualization({
|
||||||
|
@ -126,7 +113,15 @@ var LevelBuilder = Level.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInstantCommands: function() {
|
getInstantCommands: function() {
|
||||||
return [];
|
return [
|
||||||
|
[/^help$|^\?$/, function() {
|
||||||
|
throw new Errors.CommandResult({
|
||||||
|
msg: 'You are in a level builder, so multiple forms of ' +
|
||||||
|
'help are available. Please select either ' +
|
||||||
|
'"help general" or "help builder"'
|
||||||
|
});
|
||||||
|
}]
|
||||||
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
takeControl: function() {
|
takeControl: function() {
|
||||||
|
@ -214,24 +209,66 @@ var LevelBuilder = Level.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var masterDeferred = Q.defer();
|
||||||
|
var chain = masterDeferred.promise;
|
||||||
|
|
||||||
if (this.level.hint === undefined) {
|
if (this.level.hint === undefined) {
|
||||||
this.setHint();
|
var askForHintDeferred = Q.defer();
|
||||||
|
chain = chain.then(function() {
|
||||||
|
return askForHintDeferred.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
// ask for a hint if there is none
|
||||||
|
var askForHintView = new ConfirmCancelTerminal({
|
||||||
|
markdowns: [
|
||||||
|
'You have not specified a hint, would you like to add one?'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
askForHintView.getPromise()
|
||||||
|
.then(_.bind(this.setHint, this))
|
||||||
|
.fail(_.bind(function() {
|
||||||
|
this.level.hint = '';
|
||||||
|
}, this))
|
||||||
|
.done(function() {
|
||||||
|
askForHintDeferred.resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.startDialog === undefined) {
|
||||||
|
var askForStartDeferred = Q.defer();
|
||||||
|
chain = chain.then(function() {
|
||||||
|
return askForStartDeferred.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
var askForStartView = new ConfirmCancelTerminal({
|
||||||
|
markdowns: [
|
||||||
|
'You have not specified a start dialog, would you like to add one?'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
askForStartView.getPromise()
|
||||||
|
.then(function() {
|
||||||
|
alert(1);
|
||||||
|
})
|
||||||
|
.done(function() {
|
||||||
|
askForStartDeferred.resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
chain = chain.done(_.bind(function() {
|
||||||
var compiledLevel = _.extend(
|
var compiledLevel = _.extend(
|
||||||
{},
|
{},
|
||||||
this.level
|
this.level
|
||||||
);
|
);
|
||||||
|
|
||||||
// the start dialog now is just our help intro thing
|
// the start dialog now is just our help intro thing
|
||||||
delete compiledLevel.startDialog;
|
delete compiledLevel.startDialog;
|
||||||
if (this.startDialog) {
|
if (this.startDialog) {
|
||||||
compiledLevel.startDialog = this.startDialog;
|
compiledLevel.startDialog = this.startDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(compiledLevel);
|
console.log(compiledLevel);
|
||||||
|
|
||||||
command.finishWith(deferred);
|
command.finishWith(deferred);
|
||||||
|
}, this));
|
||||||
|
|
||||||
|
masterDeferred.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
processLevelBuilderCommand: function(command, deferred) {
|
processLevelBuilderCommand: function(command, deferred) {
|
||||||
|
@ -241,7 +278,8 @@ var LevelBuilder = Level.extend({
|
||||||
'show start': this.showStart,
|
'show start': this.showStart,
|
||||||
'hide start': this.hideStart,
|
'hide start': this.hideStart,
|
||||||
'finish': this.finish,
|
'finish': this.finish,
|
||||||
'define hint': this.defineHint
|
'define hint': this.defineHint,
|
||||||
|
'help builder': LevelBuilder.__super__.startDialog
|
||||||
};
|
};
|
||||||
|
|
||||||
methodMap[command.get('method')].apply(this, arguments);
|
methodMap[command.get('method')].apply(this, arguments);
|
||||||
|
|
|
@ -86,6 +86,9 @@ var Level = Sandbox.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleOpen(deferred);
|
this.handleOpen(deferred);
|
||||||
|
deferred.promise.then(function() {
|
||||||
|
command.set('status', 'finished');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
initName: function() {
|
initName: function() {
|
||||||
|
@ -357,7 +360,7 @@ var Level = Sandbox.extend({
|
||||||
"Hmm, there doesn't seem to be a hint for this level :-/";
|
"Hmm, there doesn't seem to be a hint for this level :-/";
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[/^help$/, function() {
|
[/^help$|^\?$/, function() {
|
||||||
throw new Errors.CommandResult({
|
throw new Errors.CommandResult({
|
||||||
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
|
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
|
||||||
'"help level" or "help general"'
|
'"help level" or "help general"'
|
||||||
|
@ -412,7 +415,7 @@ var Level = Sandbox.extend({
|
||||||
'hide goal': this.hideGoal,
|
'hide goal': this.hideGoal,
|
||||||
'show solution': this.showSolution,
|
'show solution': this.showSolution,
|
||||||
'start dialog': this.startDialog,
|
'start dialog': this.startDialog,
|
||||||
'level help': this.startDialog
|
'help level': this.startDialog
|
||||||
};
|
};
|
||||||
var method = methodMap[command.get('method')];
|
var method = methodMap[command.get('method')];
|
||||||
if (!method) {
|
if (!method) {
|
||||||
|
|
|
@ -252,7 +252,7 @@ var Sandbox = Backbone.View.extend({
|
||||||
|
|
||||||
helpDialog: function(command, deferred) {
|
helpDialog: function(command, deferred) {
|
||||||
var helpDialog = new MultiView({
|
var helpDialog = new MultiView({
|
||||||
childViews: require('../dialogs/sandbox').helpDialog
|
childViews: require('../dialogs/sandbox').dialog
|
||||||
});
|
});
|
||||||
helpDialog.getPromise().then(_.bind(function() {
|
helpDialog.getPromise().then(_.bind(function() {
|
||||||
// the view has been closed, lets go ahead and resolve our command
|
// the view has been closed, lets go ahead and resolve our command
|
||||||
|
|
|
@ -37,7 +37,6 @@ var instantCommands = [
|
||||||
}],
|
}],
|
||||||
[/^echo "(.*?)"$|^echo (.*?)$/, function(bits) {
|
[/^echo "(.*?)"$|^echo (.*?)$/, function(bits) {
|
||||||
var msg = bits[1] || bits[2];
|
var msg = bits[1] || bits[2];
|
||||||
console.log(bits, msg);
|
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: msg
|
msg: msg
|
||||||
});
|
});
|
||||||
|
@ -46,7 +45,7 @@ var instantCommands = [
|
||||||
|
|
||||||
var regexMap = {
|
var regexMap = {
|
||||||
'reset solved': /^reset solved($|\s)/,
|
'reset solved': /^reset solved($|\s)/,
|
||||||
'help': /^help ?(general)?($|\s)/,
|
'help': /^help( general)?$|^\?$/,
|
||||||
'reset': /^reset$/,
|
'reset': /^reset$/,
|
||||||
'delay': /^delay (\d+)$/,
|
'delay': /^delay (\d+)$/,
|
||||||
'clear': /^clear($|\s)/,
|
'clear': /^clear($|\s)/,
|
||||||
|
|
|
@ -371,12 +371,8 @@ var ConfirmCancelTerminal = Backbone.View.extend({
|
||||||
// whenever they hit a button. make sure
|
// whenever they hit a button. make sure
|
||||||
// we close and pass that to our deferred
|
// we close and pass that to our deferred
|
||||||
buttonDefer.promise
|
buttonDefer.promise
|
||||||
.then(_.bind(function() {
|
.then(this.deferred.resolve)
|
||||||
this.deferred.resolve();
|
.fail(this.deferred.reject)
|
||||||
}, this))
|
|
||||||
.fail(_.bind(function() {
|
|
||||||
this.deferred.reject();
|
|
||||||
}, this))
|
|
||||||
.done(_.bind(function() {
|
.done(_.bind(function() {
|
||||||
this.close();
|
this.close();
|
||||||
}, this));
|
}, this));
|
||||||
|
|
10
todo.txt
10
todo.txt
|
@ -1,7 +1,7 @@
|
||||||
Big Things
|
Big Things
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
[ ] level builder dialog tester
|
[ ] edit dialog
|
||||||
[ ] level builder dialog builder
|
[ ] descriptions for levels?
|
||||||
|
|
||||||
Medium things:
|
Medium things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -25,13 +25,11 @@ Ideas for cleaning
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
- CSS... a ton. Switch to less
|
- CSS... a ton. Switch to less
|
||||||
|
|
||||||
/*************************************
|
|
||||||
** Publish Things **
|
|
||||||
************************************/
|
|
||||||
|
|
||||||
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] level builder dialog builder
|
||||||
|
[x] level builder dialog tester
|
||||||
[x] turn off button clicking for demonstration view :O
|
[x] turn off button clicking for demonstration view :O
|
||||||
[x] text grabber for commands
|
[x] text grabber for commands
|
||||||
[x] way to close testing view
|
[x] way to close testing view
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue