From 973087d19ac0efe1522e23067049d927975f9742 Mon Sep 17 00:00:00 2001 From: Blue Fox Date: Mon, 18 Jul 2022 20:13:08 +0200 Subject: [PATCH] Created an setup wizard on first startup. --- memorytrainer.app.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/memorytrainer.app.js b/memorytrainer.app.js index 20aaccc..b78333d 100644 --- a/memorytrainer.app.js +++ b/memorytrainer.app.js @@ -12,7 +12,7 @@ function wait(s) { while(getTime() - c_time <= s) {} } function getSettings() { - return Object.assign({"firstrun": true}, storage.readJSON(settingsfile, true) || {}); + return Object.assign({"firstrun": true, "fullscreen": true}, storage.readJSON(settingsfile, true) || {}); } @@ -34,6 +34,29 @@ function animate100x100img_big2small(img, minscale, maxscale) { } } +function homescreen() { + g.clear(); +} + +function setupWizard() { + E.showPrompt( + "Do you want the app to stay full screen (default)?", + { "title": "FULLSCREEN", "buttons": {"Yes!": true, "No, I love Widgets!": false} } + ).then(function(v) { + if(settings.fullscreen != v) { + settings.fullscreen = v; + storage.writeJSON(settingsfile, settings); + E.showMessage("Changes will be visible after a restart of the application.", "INFO"); + wait(2); + } + // always do start homescreen + g.clear(); + E.showMessage("You can now use your fully configured MemoryTrainer app.", "CONGRATULATIONS!"); + wait(2); + homescreen(); + }); +} + function welcome(new_user) { var brain_trainer_text = storage.readJSON("memorytrainer.icons.json", true).brain_trainer_text; var img_brain_trainer_text = brain_trainer_text.data; @@ -46,10 +69,12 @@ function welcome(new_user) { wait(1); g.clear(); wait(0.2); + setupWizard(); + return; } g.drawImage(img_brain_trainer_text, g.getWidth()/2, g.getHeight()/2, {rotate: 0.04, scale: 1.2}); wait(1); - g.clear(); + homescreen(); }