diff --git a/lib/engine.js b/lib/engine.js index f45fb6e..7b1200d 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -7,6 +7,8 @@ (function() { 'use strict'; + var toTranscript = require('./ui/content/transcript'); + // To avoid the need to include any utility libraries when this is // used in a browser, define some helper functions we'd normally // rely on libraries for. @@ -235,12 +237,13 @@ return this; }; + DendryEngine.prototype.displayChoices = function() { var choices = this.getCurrentChoices(); assert(choices); this.ui.displayChoices(choices); if (this.state.enableTranscript) { - this.transcript.push(choices); + toTranscript.logChoices(choices, this.transcript); } return this; }; @@ -269,7 +272,7 @@ if (scene.content !== undefined && !restorePage) { var displayContent = this._makeDisplayContent(scene.content, true); if (this.state.enableTranscript) { - this.transcript = this.transcript.concat(displayContent); + toTranscript.log(displayContent, this.transcript); } this.state.currentContent = this.state.currentContent.concat(displayContent); this.ui.displayContent(displayContent); @@ -358,7 +361,7 @@ // Should the transcription feature be part of the UI or the engine? // Should the transcript-enabling flag be part of the game state, or be part of the UI options? // let's just say that it's part of the game state. But the actual transcript-writing process is done in the UIs? Because different UIs might want to save states... - enableTranscript: false, + enableTranscript: false }; // TODO: transcript this.transcript = []; diff --git a/lib/templates/html/default/+game.js b/lib/templates/html/default/+game.js index 7f18a50..e67ab32 100644 --- a/lib/templates/html/default/+game.js +++ b/lib/templates/html/default/+game.js @@ -46,6 +46,22 @@ save_element.style.display = "none"; }; + window.enableTranscript = function() { + var checkbox = document.getElementById('transcript_checkbox'); + // Update the engine's transcripting state + window.dendryUI.dendryEngine.state.enableTranscript = checkbox.checked; + // Show or hide the Save Transcript links + var save_links = document.querySelectorAll('.save-transcript'); + for (var i = 0; i < save_links.length; ++i) { + var link = save_links[i]; + if (checkbox.checked) { + link.style.display = ''; + } else { + link.style.display = 'none'; + } + } + } + window.disableBg = function() { window.dendryUI.disable_bg = true; document.body.style.backgroundImage = 'none'; @@ -80,9 +96,11 @@ // populates the checkboxes in the options view window.populateOptions = function() { + var enable_transcript = window.dendryUI.dendryEngine.state.enableTranscript; var disable_bg = window.dendryUI.disable_bg; var animate = window.dendryUI.animate; var animate_bg = window.dendryUI.animate_bg; + $('#transcript_checkbox')[0].checked = enable_transcript; if (disable_bg) { $('#backgrounds_no')[0].checked = true; } else { diff --git a/lib/templates/html/default/+index.html b/lib/templates/html/default/+index.html index edb5ad6..d08a4a3 100644 --- a/lib/templates/html/default/+index.html +++ b/lib/templates/html/default/+index.html @@ -26,6 +26,7 @@