fix setting screen

pull/2660/head
Kevin Whitaker 2023-03-25 17:46:41 -04:00
parent 7e095a67f5
commit cc0ac4e3f5
1 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,5 @@
(function(back) {
var FILE = "nesclock.json";
// Load settings
var settings = Object.assign({
currentFace: "Mario 3",
}, require('Storage').readJSON(FILE, true) || {});
@ -8,7 +7,8 @@
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}
// Helper method which uses int-based menu item for set of string values
function stringItems(startvalue, writer, values) {
return {
value: (startvalue === undefined ? 0 : values.indexOf(startvalue)),
@ -22,16 +22,21 @@
writeSettings();
}
};
}
}
// Helper method which breaks string set settings down to local settings object
function stringInSettings(name, values) {
return stringItems(settings[name], v => settings[name] = v, values);
}
// Show the menu
E.showMenu({
"" : { "title" : "NES Clock" },
"< Back" : () => back(),
'Game Theme': stringInSettings("currentFace", ["Mario 3", "Mario 2", "Mario 1", "Kirby", "Zelda"]),
});
})(load);
var mainmenu = {
"": {
"title": "NES Clock"
},
"< Back": () => back(),
"Game Theme": stringInSettings("currentFace", ["Mario 3", "Mario 2", "Mario 1", "Kirby", "Zelda"]),
};
E.showMenu(mainmenu);
});