From 2ca0a7a948b29e1259c37e7be5aec6ab62a6ef88 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 May 2014 11:48:40 -0400 Subject: [PATCH] Expand import dialog to a textarea --- script/engine.js | 99 ++++++++++++++++++++++++++++-------------------- script/events.js | 5 ++- 2 files changed, 60 insertions(+), 44 deletions(-) diff --git a/script/engine.js b/script/engine.js index fbbfa06..966cd46 100644 --- a/script/engine.js +++ b/script/engine.js @@ -204,44 +204,59 @@ var Engine = { exportImport: function() { Events.startEvent({ - title: 'Export / Import', - scenes: { - start: { - text: ['export or import save data, for backing up', - 'or migrating computers'], - buttons: { - 'export': { - text: 'export', - onChoose: Engine.export64 - }, - 'import': { - text: 'import', - nextScene: {1: 'confirm'}, - }, - 'cancel': { - text: 'cancel', - nextScene: 'end' - } + title: 'Export / Import', + scenes: { + start: { + text: ['export or import save data, for backing up', + 'or migrating computers'], + buttons: { + 'export': { + text: 'export', + onChoose: Engine.export64 + }, + 'import': { + text: 'import', + nextScene: {1: 'confirm'}, + }, + 'cancel': { + text: 'cancel', + nextScene: 'end' } - }, - 'confirm': { - text: ['are you sure?', - 'if the code is invalid, all data will be lost.', - 'this is irreversible.'], - buttons: { - 'yes': { - text: 'yes', - nextScene: 'end', - onChoose: Engine.import64 - }, - 'no': { - text: 'no', - nextScene: 'end' - } + } + }, + 'confirm': { + text: ['are you sure?', + 'if the code is invalid, all data will be lost.', + 'this is irreversible.'], + buttons: { + 'yes': { + text: 'yes', + nextScene: {1: 'inputImport'}, + onChoose: Engine.enableSelection + }, + 'no': { + text: 'no', + nextScene: 'end' + } + } + }, + 'inputImport': { + text: ['put the save code here.'], + textarea: '', + buttons: { + 'okay': { + text: 'okay', + nextScene: 'end', + onChoose: Engine.import64 + }, + 'cancel': { + text: 'cancel', + nextScene: 'end' } } } - }); + } + }); }, export64: function() { @@ -269,14 +284,14 @@ var Engine = { }); }, - import64: function() { - var string64 = prompt("put the save code here.",""); - string64 = string64.replace(/\s/g, ''); - string64 = string64.replace(/\./g, ''); - string64 = string64.replace(/\n/g, ''); - var decodedSave = Base64.decode(string64); - localStorage.gameState = decodedSave; - location.reload(); + import64: function(string64) { + Engine.disableSelection(); + string64 = string64.replace(/\s/g, ''); + string64 = string64.replace(/\./g, ''); + string64 = string64.replace(/\n/g, ''); + var decodedSave = Base64.decode(string64); + localStorage.gameState = decodedSave; + location.reload(); }, event: function(cat, act) { diff --git a/script/events.js b/script/events.js index 239f406..10eff13 100644 --- a/script/events.js +++ b/script/events.js @@ -611,7 +611,7 @@ var Events = { $('
').text(scene.text[i]).appendTo(desc); } - if(scene.textarea) { + if(scene.textarea != null) { $('