Load state menu
This commit is contained in:
parent
5e920f760d
commit
d5ceb0afec
@ -12,6 +12,7 @@ function run(data) {
|
||||
|
||||
$(document).ready(function() {
|
||||
if ( (typeof rpyscript === 'undefined') || TextUtils.isEmpty(rpyscript)) {
|
||||
rpyscript = "undefined";
|
||||
run('play music music_list["everlasting_summer"]\n' +
|
||||
'scene bg ext_square_day\n' +
|
||||
'show mz smile pioneer far at fright\n' +
|
||||
|
@ -387,6 +387,13 @@ Views.prototype.showMainMenu = function () {
|
||||
$('#menu').hide();
|
||||
views.saveState();
|
||||
});
|
||||
var saves = JSON.parse(localStorage.saves || null) || {};
|
||||
saves[rpyscript] = saves[rpyscript] || [];
|
||||
if (saves[rpyscript].length > 0) {
|
||||
this.addMainMenuItem("Загрузить…", function() {
|
||||
views.showLoadStateMenu();
|
||||
});
|
||||
}
|
||||
this.addMainMenuItem("Закрыть", function() {
|
||||
$('#menu').hide();
|
||||
});
|
||||
@ -572,4 +579,33 @@ Views.prototype.createSave = function () {
|
||||
save.backgroundType = this.backgroundType;
|
||||
save.backgroundName = this.backgroundName;
|
||||
return save;
|
||||
};
|
||||
|
||||
Views.prototype.showLoadStateMenu = function () {
|
||||
var saves = JSON.parse(localStorage.saves || null) || {};
|
||||
var items = saves[rpyscript] || [];
|
||||
|
||||
$('#menuTitle').text('Загрузить');
|
||||
$('#menuChoose').empty();
|
||||
this.addMainMenuItem("Закрыть", function() {
|
||||
$('#menu').hide();
|
||||
});
|
||||
for(var i = items.length - 1; i >= 0; i--) {
|
||||
var li = $('<li>', {text: items[i].time});
|
||||
li.click(this.createLoadStateClickFunction(i, items[i]));
|
||||
li.appendTo($('#menuChoose'));
|
||||
}
|
||||
$('#menu').show();
|
||||
};
|
||||
Views.prototype.createLoadStateClickFunction = function (index, save) {
|
||||
var views = this;
|
||||
return function () {
|
||||
Variables.variables = save.variables;
|
||||
views.characters.names = save.characterNames;
|
||||
if (!TextUtils.isEmpty(save.backgroundName)) {
|
||||
views.background(save.backgroundType, save.backgroundName, "");
|
||||
}
|
||||
views.parser.setPosition(save.position);
|
||||
$('#menu').hide();
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user