diff --git a/src/js/level/builder.js b/src/js/level/builder.js index 4490462b..b25d968c 100644 --- a/src/js/level/builder.js +++ b/src/js/level/builder.js @@ -81,8 +81,9 @@ var LevelBuilder = Level.extend({ initGoalData: function() { // add some default behavior in the beginning if we are not editing if (!this.options.editLevel) { - this.level.goalTreeString = '{"branches":{"main":{"target":"C1","id":"main"},"makeLevel":{"target":"C2","id":"makeLevel"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"makeLevel","id":"HEAD"}}'; - this.level.solutionCommand = 'git checkout -b makeLevel; git commit'; + // Trivial tree: single C0 commit, HEAD=main + this.level.goalTreeString = '{"branches":{"main":{"target":"C0","id":"main"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true}},"HEAD":{"target":"main","id":"HEAD"}}'; + this.level.solutionCommand = ''; } LevelBuilder.__super__.initGoalData.apply(this, arguments); }, @@ -292,13 +293,25 @@ var LevelBuilder = Level.extend({ return; } - while (!this.level.name) { - this.defineName(); - } - var mainDeferred = Q.defer(); var chain = mainDeferred.promise; + // If noPrompts is set, skip hint/startDialog prompts + if (this.options.noPrompts) { + if (this.level.hint === undefined) { + this.level.hint = {'en_US': ''}; + } + if (this.startDialogObj === undefined) { + this.startDialogObj = null; + } + new MarkdownPresenter({ + fillerText: JSON.stringify(this.getExportObj(), null, 2), + previewText: intl.str('share-json') + }); + command.finishWith(deferred); + return; + } + if (this.level.hint === undefined) { var askForHintDeferred = Q.defer(); chain = chain.then(function() { diff --git a/src/js/sandbox/commands.js b/src/js/sandbox/commands.js index 6aad52b5..99346756 100644 --- a/src/js/sandbox/commands.js +++ b/src/js/sandbox/commands.js @@ -184,7 +184,7 @@ var regexMap = { 'level': /^level\s?([a-zA-Z0-9]*)/, 'levels': /^levels($|\s)/, 'mobileAlert': /^mobile alert($|\s)/, - 'build level': /^build +level\s?([a-zA-Z0-9]*)( +--skipIntro)?$/, + 'build level': /^build +level\s?([a-zA-Z0-9]*)( +--skipIntro)?( +--noPrompts)?$/, 'export tree': /^export +tree$/, 'importTreeNow': /^importTreeNow($|\s)/, 'importLevelNow': /^importLevelNow($|\s)/, diff --git a/src/js/sandbox/index.js b/src/js/sandbox/index.js index 540db4d5..6c02a3c4 100644 --- a/src/js/sandbox/index.js +++ b/src/js/sandbox/index.js @@ -208,10 +208,12 @@ var Sandbox = Backbone.View.extend({ var regexResults = command.get('regexResults') || []; var toEdit = regexResults[1] || false; + const rawStr = command.attributes.rawStr; this.levelBuilder = new LevelBuilder({ deferred: whenBuilderOpen, editLevel: toEdit, - skipIntro: command.attributes.rawStr.indexOf('skipIntro') !== -1, + skipIntro: rawStr.indexOf('skipIntro') !== -1, + noPrompts: rawStr.indexOf('noPrompts') !== -1, }); whenBuilderOpen.promise.then(function() { command.finishWith(deferred);