mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 17:27:22 +02:00
Objective and Assignment commands Issue #76 works even in level builder
This commit is contained in:
parent
63a8d385bf
commit
e081c47e31
8 changed files with 154 additions and 28 deletions
|
@ -51,7 +51,7 @@ var LevelBuilder = Level.extend({
|
|||
};
|
||||
LevelBuilder.__super__.initialize.apply(this, [options]);
|
||||
|
||||
this.startDialog = undefined;
|
||||
this.startDialogObj = undefined;
|
||||
this.definedGoal = false;
|
||||
|
||||
// we wont be using this stuff, and its to delete to ensure we overwrite all functions that
|
||||
|
@ -96,6 +96,21 @@ var LevelBuilder = Level.extend({
|
|||
);
|
||||
},
|
||||
|
||||
objectiveDialog: function(command, deferred) {
|
||||
var args = [
|
||||
command,
|
||||
deferred,
|
||||
(this.startDialogObj === undefined) ?
|
||||
null :
|
||||
{
|
||||
startDialog: {
|
||||
'en_US': this.startDialogObj
|
||||
}
|
||||
}
|
||||
];
|
||||
LevelBuilder.__super__.objectiveDialog.apply(this, args);
|
||||
},
|
||||
|
||||
initParseWaterfall: function(options) {
|
||||
LevelBuilder.__super__.initParseWaterfall.apply(this, [options]);
|
||||
|
||||
|
@ -207,12 +222,12 @@ var LevelBuilder = Level.extend({
|
|||
editDialog: function(command, deferred) {
|
||||
var whenDoneEditing = Q.defer();
|
||||
this.currentBuilder = new MultiViewBuilder({
|
||||
multiViewJSON: this.startDialog,
|
||||
multiViewJSON: this.startDialogObj,
|
||||
deferred: whenDoneEditing
|
||||
});
|
||||
whenDoneEditing.promise
|
||||
.then(_.bind(function(levelObj) {
|
||||
this.startDialog = levelObj;
|
||||
this.startDialogObj = levelObj;
|
||||
}, this))
|
||||
.fail(function() {
|
||||
// nothing to do, they dont want to edit it apparently
|
||||
|
@ -264,7 +279,7 @@ var LevelBuilder = Level.extend({
|
|||
});
|
||||
}
|
||||
|
||||
if (this.startDialog === undefined) {
|
||||
if (this.startDialogObj === undefined) {
|
||||
var askForStartDeferred = Q.defer();
|
||||
chain = chain.then(function() {
|
||||
return askForStartDeferred.promise;
|
||||
|
@ -310,8 +325,8 @@ var LevelBuilder = Level.extend({
|
|||
);
|
||||
// the start dialog now is just our help intro thing
|
||||
delete compiledLevel.startDialog;
|
||||
if (this.startDialog) {
|
||||
compiledLevel.startDialog = {'en_US': this.startDialog};
|
||||
if (this.startDialogObj) {
|
||||
compiledLevel.startDialog = {'en_US': this.startDialogObj};
|
||||
}
|
||||
return compiledLevel;
|
||||
},
|
||||
|
|
|
@ -29,7 +29,8 @@ var regexMap = {
|
|||
'start dialog': /^start dialog$/,
|
||||
'show goal': /^(show goal|goal|help goal)$/,
|
||||
'hide goal': /^hide goal$/,
|
||||
'show solution': /^show solution($|\s)/
|
||||
'show solution': /^show solution($|\s)/,
|
||||
'objective': /^(objective|assignment)$/
|
||||
};
|
||||
|
||||
var parse = util.genParseCommand(regexMap, 'processLevelCommand');
|
||||
|
@ -77,6 +78,31 @@ var Level = Sandbox.extend({
|
|||
}, this.getAnimationTime() * 1.2);
|
||||
},
|
||||
|
||||
objectiveDialog: function(command, deferred, levelObj) {
|
||||
levelObj = (levelObj === undefined) ? this.level : levelObj;
|
||||
|
||||
if (!levelObj || !levelObj.startDialog) {
|
||||
command.set('error', new Errors.GitError({
|
||||
msg: intl.str('no-start-dialog')
|
||||
}));
|
||||
deferred.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
var dialog = _.clone(intl.getStartDialog(levelObj));
|
||||
// grab the last slide only
|
||||
dialog.childViews = dialog.childViews.splice(-1);
|
||||
new MultiView(_.extend(
|
||||
dialog,
|
||||
{ deferred: deferred }
|
||||
));
|
||||
|
||||
// when its closed we are done
|
||||
deferred.promise.then(function() {
|
||||
command.set('status', 'finished');
|
||||
});
|
||||
},
|
||||
|
||||
startDialog: function(command, deferred) {
|
||||
if (!this.level.startDialog) {
|
||||
command.set('error', new Errors.GitError({
|
||||
|
@ -494,7 +520,8 @@ var Level = Sandbox.extend({
|
|||
'hide goal': this.hideGoal,
|
||||
'show solution': this.showSolution,
|
||||
'start dialog': this.startDialog,
|
||||
'help level': this.startDialog
|
||||
'help level': this.startDialog,
|
||||
'objective': this.objectiveDialog
|
||||
};
|
||||
var method = methodMap[command.get('method')];
|
||||
if (!method) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue