mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-26 05:34:50 +02:00
a bunch of keys from level directory
This commit is contained in:
parent
3adec8d88a
commit
9048f09d9f
7 changed files with 665 additions and 349 deletions
|
@ -4,6 +4,7 @@ var Q = require('q');
|
|||
|
||||
var util = require('../util');
|
||||
var Main = require('../app');
|
||||
var intl = require('../intl');
|
||||
var Errors = require('../util/errors');
|
||||
|
||||
var Visualization = require('../visuals/visualization').Visualization;
|
||||
|
@ -59,7 +60,7 @@ var LevelBuilder = Level.extend({
|
|||
|
||||
initName: function() {
|
||||
this.levelToolbar = new LevelToolbar({
|
||||
name: 'Level Builder'
|
||||
name: intl.str('level-builder')
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -73,7 +74,7 @@ var LevelBuilder = Level.extend({
|
|||
initStartVisualization: function() {
|
||||
this.startCanvasHolder = new CanvasTerminalHolder({
|
||||
additionalClass: 'startTree',
|
||||
text: 'You can hide this window with "hide start"'
|
||||
text: intl.str('hide-start')
|
||||
});
|
||||
|
||||
this.startVis = new Visualization({
|
||||
|
@ -89,7 +90,7 @@ var LevelBuilder = Level.extend({
|
|||
startOffCommand: function() {
|
||||
Main.getEventBaton().trigger(
|
||||
'commandSubmitted',
|
||||
'echo "Get Building!!"'
|
||||
'echo :D'
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -118,9 +119,7 @@ var LevelBuilder = Level.extend({
|
|||
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"'
|
||||
msg: intl.str('help-vague-builder')
|
||||
});
|
||||
}]
|
||||
];
|
||||
|
@ -160,9 +159,7 @@ var LevelBuilder = Level.extend({
|
|||
defineStart: function(command, deferred) {
|
||||
this.hideStart();
|
||||
|
||||
command.addWarning(
|
||||
'Defining start point... solution and goal will be overwritten if they were defined earlier'
|
||||
);
|
||||
command.addWarning(intl.str('define-start-warning'));
|
||||
this.resetSolution();
|
||||
|
||||
this.level.startTree = this.mainVis.gitEngine.printTree();
|
||||
|
@ -176,7 +173,7 @@ var LevelBuilder = Level.extend({
|
|||
|
||||
if (!this.gitCommandsIssued.length) {
|
||||
command.set('error', new Errors.GitError({
|
||||
msg: 'Your solution is empty!! something is amiss'
|
||||
msg: intl.str('solution-empty')
|
||||
}));
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
@ -191,12 +188,12 @@ var LevelBuilder = Level.extend({
|
|||
},
|
||||
|
||||
defineName: function(command, deferred) {
|
||||
this.level.name = prompt('Enter the name for the level');
|
||||
this.level.name = prompt(intl.str('prompt-name'));
|
||||
if (command) { command.finishWith(deferred); }
|
||||
},
|
||||
|
||||
defineHint: function(command, deferred) {
|
||||
this.level.hint = prompt('Enter a hint! Or blank if you dont want one');
|
||||
this.level.hint = prompt(intl.str('prompt-hint'));
|
||||
if (command) { command.finishWith(deferred); }
|
||||
},
|
||||
|
||||
|
@ -225,7 +222,7 @@ var LevelBuilder = Level.extend({
|
|||
finish: function(command, deferred) {
|
||||
if (!this.gitCommandsIssued.length || !this.definedGoal) {
|
||||
command.set('error', new Errors.GitError({
|
||||
msg: 'Your solution is empty or goal is undefined!'
|
||||
msg: intl.str('solution-empty')
|
||||
}));
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
@ -247,7 +244,7 @@ var LevelBuilder = Level.extend({
|
|||
// 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?'
|
||||
intl.str('want-hint')
|
||||
]
|
||||
});
|
||||
askForHintView.getPromise()
|
||||
|
@ -268,7 +265,7 @@ var LevelBuilder = Level.extend({
|
|||
|
||||
var askForStartView = new ConfirmCancelTerminal({
|
||||
markdowns: [
|
||||
'You have not specified a start dialog, would you like to add one?'
|
||||
intl.str('want-start-dialog')
|
||||
]
|
||||
});
|
||||
askForStartView.getPromise()
|
||||
|
@ -291,7 +288,7 @@ var LevelBuilder = Level.extend({
|
|||
// ok great! lets just give them the goods
|
||||
new MarkdownPresenter({
|
||||
fillerText: JSON.stringify(this.getExportObj(), null, 2),
|
||||
previewText: 'Here is the JSON for this level! Share it with someone or send it to me on Github!'
|
||||
previewText: intl.str('share-json')
|
||||
});
|
||||
command.finishWith(deferred);
|
||||
}, this));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var _ = require('underscore');
|
||||
var intl = require('../intl');
|
||||
|
||||
var GitCommands = require('../git/commands');
|
||||
|
||||
|
@ -20,7 +21,7 @@ DisabledMap.prototype.getInstantCommands = function() {
|
|||
var instants = [];
|
||||
var onMatch = function() {
|
||||
throw new GitError({
|
||||
msg: 'That git command is disabled for this level!'
|
||||
msg: intl.str('command-disabled')
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ var Level = Sandbox.extend({
|
|||
startDialog: function(command, deferred) {
|
||||
if (!this.level.startDialog) {
|
||||
command.set('error', new Errors.GitError({
|
||||
msg: 'There is no start dialog to show for this level!'
|
||||
msg: intl.str('no-start-dialog')
|
||||
}));
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
@ -171,6 +171,7 @@ var Level = Sandbox.extend({
|
|||
|
||||
// allow them for force the solution
|
||||
var confirmDefer = Q.defer();
|
||||
// TODO intl
|
||||
var confirmView = new ConfirmCancelTerminal({
|
||||
markdowns: [
|
||||
'## Are you sure you want to see the solution?',
|
||||
|
@ -183,7 +184,7 @@ var Level = Sandbox.extend({
|
|||
confirmDefer.promise
|
||||
.then(issueFunc)
|
||||
.fail(function() {
|
||||
command.setResult("Great! I'll let you get back to it");
|
||||
command.setResult("");
|
||||
})
|
||||
.done(function() {
|
||||
// either way we animate, so both options can share this logic
|
||||
|
@ -299,10 +300,7 @@ var Level = Sandbox.extend({
|
|||
|
||||
afterCommandDefer: function(defer, command) {
|
||||
if (this.solved) {
|
||||
command.addWarning(
|
||||
"You've already solved this level, try other levels with 'show levels'" +
|
||||
"or go back to the sandbox with 'sandbox'"
|
||||
);
|
||||
command.addWarning(intl.str('already-solved'));
|
||||
defer.resolve();
|
||||
return;
|
||||
}
|
||||
|
@ -415,15 +413,10 @@ var Level = Sandbox.extend({
|
|||
return hint;
|
||||
}, this);
|
||||
|
||||
var hintMsg = (this.level.hint) ?
|
||||
this.level.hint :
|
||||
"Hmm, there doesn't seem to be a hint for this level :-/";
|
||||
|
||||
return [
|
||||
[/^help$|^\?$/, function() {
|
||||
throw new Errors.CommandResult({
|
||||
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
|
||||
'"help level" or "help general"'
|
||||
msg: intl.str('help-vague-level')
|
||||
});
|
||||
}],
|
||||
[/^hint$/, function() {
|
||||
|
|
|
@ -4,6 +4,7 @@ var Q = require('q');
|
|||
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
|
||||
|
||||
var util = require('../util');
|
||||
var intl = require('../intl');
|
||||
var Main = require('../app');
|
||||
var Errors = require('../util/errors');
|
||||
|
||||
|
@ -124,7 +125,7 @@ var Sandbox = Backbone.View.extend({
|
|||
var toRestore = this.undoStack.pop();
|
||||
if (!toRestore) {
|
||||
command.set('error', new Errors.GitError({
|
||||
msg: 'The undo stack is empty!'
|
||||
msg: intl.str('undo-stack-empty')
|
||||
}));
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
@ -156,7 +157,10 @@ var Sandbox = Backbone.View.extend({
|
|||
// handle the case where that level is not found...
|
||||
if (!levelJSON) {
|
||||
command.addWarning(
|
||||
'A level for that id "' + desiredID + '" was not found!! Opening up level selection view...'
|
||||
intl.str(
|
||||
'level-no-id',
|
||||
{ id: desiredID }
|
||||
)
|
||||
);
|
||||
Main.getEventBaton().trigger('commandSubmitted', 'levels');
|
||||
|
||||
|
@ -203,7 +207,7 @@ var Sandbox = Backbone.View.extend({
|
|||
|
||||
exitLevel: function(command, deferred) {
|
||||
command.addWarning(
|
||||
"You aren't in a level! You are in a sandbox, start a level with `level [id]`"
|
||||
intl.str('level-cant-exit')
|
||||
);
|
||||
command.set('status', 'error');
|
||||
deferred.resolve();
|
||||
|
@ -220,7 +224,7 @@ var Sandbox = Backbone.View.extend({
|
|||
resetSolved: function(command, deferred) {
|
||||
Main.getLevelArbiter().resetSolvedMap();
|
||||
command.addWarning(
|
||||
"Solved map was reset, you are starting from a clean slate!"
|
||||
intl.str('solved-map-reset')
|
||||
);
|
||||
command.finishWith(deferred);
|
||||
},
|
||||
|
@ -267,7 +271,7 @@ var Sandbox = Backbone.View.extend({
|
|||
|
||||
importTree: function(command, deferred) {
|
||||
var jsonGrabber = new BuilderViews.MarkdownPresenter({
|
||||
previewText: "Paste a tree JSON blob below!",
|
||||
previewText: intl.str('paste-json'),
|
||||
fillerText: ' '
|
||||
});
|
||||
jsonGrabber.deferred.promise
|
||||
|
@ -300,7 +304,7 @@ var Sandbox = Backbone.View.extend({
|
|||
|
||||
importLevel: function(command, deferred) {
|
||||
var jsonGrabber = new BuilderViews.MarkdownPresenter({
|
||||
previewText: 'Paste a level JSON blob in here!',
|
||||
previewText: intl.str('paste-json'),
|
||||
fillerText: ' '
|
||||
});
|
||||
|
||||
|
@ -350,7 +354,7 @@ var Sandbox = Backbone.View.extend({
|
|||
childViews: [{
|
||||
type: 'MarkdownPresenter',
|
||||
options: {
|
||||
previewText: 'Share this tree with friends! They can load it with "import tree"',
|
||||
previewText: intl.str('share-tree'),
|
||||
fillerText: treeJSON,
|
||||
noConfirmCancel: true
|
||||
}
|
||||
|
@ -371,7 +375,7 @@ var Sandbox = Backbone.View.extend({
|
|||
},
|
||||
|
||||
mobileAlert: function(command, deferred) {
|
||||
alert("Can't bring up the keyboard on mobile / tablet :( try visiting on desktop! :D");
|
||||
alert(intl.str('mobile-alert'));
|
||||
command.finishWith(deferred);
|
||||
},
|
||||
|
||||
|
|
|
@ -13,25 +13,31 @@ var CommandResult = Errors.CommandResult;
|
|||
var instantCommands = [
|
||||
[/^ls/, function() {
|
||||
throw new CommandResult({
|
||||
msg: "DontWorryAboutFilesInThisDemo.txt"
|
||||
msg: intl.str('ls-command')
|
||||
});
|
||||
}],
|
||||
[/^cd/, function() {
|
||||
throw new CommandResult({
|
||||
msg: "Directory Changed to '/directories/dont/matter/in/this/demo'"
|
||||
msg: intl.str('cd-command')
|
||||
});
|
||||
}],
|
||||
[/^(locale|locale reset)$/, function(bits) {
|
||||
constants.GLOBAL.locale = intl.getDefaultLocale();
|
||||
throw new CommandResult({
|
||||
msg: 'Locale reset to default, which is ' + intl.getDefaultLocale()
|
||||
msg: intl.str(
|
||||
'locale-reset-command',
|
||||
{ locale: intl.getDefaultLocale() }
|
||||
)
|
||||
});
|
||||
}],
|
||||
[/^locale (\w+)$/, function(bits) {
|
||||
constants.GLOBAL.locale = bits[1];
|
||||
|
||||
throw new CommandResult({
|
||||
msg: "Locale set to " + bits[1]
|
||||
msg: intl.str(
|
||||
'locale-command',
|
||||
{ locale: bits[1] }
|
||||
)
|
||||
});
|
||||
}],
|
||||
[/^refresh$/, function() {
|
||||
|
@ -39,7 +45,7 @@ var instantCommands = [
|
|||
|
||||
events.trigger('refreshTree');
|
||||
throw new CommandResult({
|
||||
msg: "Refreshing tree..."
|
||||
msg: intl.str('refresh-tree-command')
|
||||
});
|
||||
}],
|
||||
[/^rollup (\d+)$/, function(bits) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue