mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-22 20:32:31 +08:00
Expand import dialog to a textarea
This commit is contained in:
+57
-42
@@ -204,44 +204,59 @@ var Engine = {
|
|||||||
|
|
||||||
exportImport: function() {
|
exportImport: function() {
|
||||||
Events.startEvent({
|
Events.startEvent({
|
||||||
title: 'Export / Import',
|
title: 'Export / Import',
|
||||||
scenes: {
|
scenes: {
|
||||||
start: {
|
start: {
|
||||||
text: ['export or import save data, for backing up',
|
text: ['export or import save data, for backing up',
|
||||||
'or migrating computers'],
|
'or migrating computers'],
|
||||||
buttons: {
|
buttons: {
|
||||||
'export': {
|
'export': {
|
||||||
text: 'export',
|
text: 'export',
|
||||||
onChoose: Engine.export64
|
onChoose: Engine.export64
|
||||||
},
|
},
|
||||||
'import': {
|
'import': {
|
||||||
text: 'import',
|
text: 'import',
|
||||||
nextScene: {1: 'confirm'},
|
nextScene: {1: 'confirm'},
|
||||||
},
|
},
|
||||||
'cancel': {
|
'cancel': {
|
||||||
text: 'cancel',
|
text: 'cancel',
|
||||||
nextScene: 'end'
|
nextScene: 'end'
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
'confirm': {
|
},
|
||||||
text: ['are you sure?',
|
'confirm': {
|
||||||
'if the code is invalid, all data will be lost.',
|
text: ['are you sure?',
|
||||||
'this is irreversible.'],
|
'if the code is invalid, all data will be lost.',
|
||||||
buttons: {
|
'this is irreversible.'],
|
||||||
'yes': {
|
buttons: {
|
||||||
text: 'yes',
|
'yes': {
|
||||||
nextScene: 'end',
|
text: 'yes',
|
||||||
onChoose: Engine.import64
|
nextScene: {1: 'inputImport'},
|
||||||
},
|
onChoose: Engine.enableSelection
|
||||||
'no': {
|
},
|
||||||
text: 'no',
|
'no': {
|
||||||
nextScene: 'end'
|
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() {
|
export64: function() {
|
||||||
@@ -269,14 +284,14 @@ var Engine = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
import64: function() {
|
import64: function(string64) {
|
||||||
var string64 = prompt("put the save code here.","");
|
Engine.disableSelection();
|
||||||
string64 = string64.replace(/\s/g, '');
|
string64 = string64.replace(/\s/g, '');
|
||||||
string64 = string64.replace(/\./g, '');
|
string64 = string64.replace(/\./g, '');
|
||||||
string64 = string64.replace(/\n/g, '');
|
string64 = string64.replace(/\n/g, '');
|
||||||
var decodedSave = Base64.decode(string64);
|
var decodedSave = Base64.decode(string64);
|
||||||
localStorage.gameState = decodedSave;
|
localStorage.gameState = decodedSave;
|
||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
|
|
||||||
event: function(cat, act) {
|
event: function(cat, act) {
|
||||||
|
|||||||
+3
-2
@@ -611,7 +611,7 @@ var Events = {
|
|||||||
$('<div>').text(scene.text[i]).appendTo(desc);
|
$('<div>').text(scene.text[i]).appendTo(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scene.textarea) {
|
if(scene.textarea != null) {
|
||||||
$('<textarea>').val(scene.textarea).appendTo(desc);
|
$('<textarea>').val(scene.textarea).appendTo(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,7 +690,8 @@ var Events = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(typeof info.onChoose == 'function') {
|
if(typeof info.onChoose == 'function') {
|
||||||
info.onChoose();
|
var textarea = Events.eventPanel().find('textarea');
|
||||||
|
info.onChoose(textarea.length > 0 ? textarea.val() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reward
|
// Reward
|
||||||
|
|||||||
Reference in New Issue
Block a user