From 2297d01966063f0d410245b8e2582fc2deccfd6f Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 25 Feb 2025 15:25:14 +0100 Subject: [PATCH] main loop --- src/ui/mainmenu.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ui/mainmenu.js b/src/ui/mainmenu.js index 710f458..3fcf0fd 100644 --- a/src/ui/mainmenu.js +++ b/src/ui/mainmenu.js @@ -1,12 +1,21 @@ export class MainMenu { constructor(uiService) { this.ui = uiService; + this.running = true; } show = async () => { this.ui.showLogo(); this.ui.showInfoMessage("hello"); + while (this.running) { + await this.promptMainMenu(); + } + + this.ui.showInfoMessage("K-THX-BYE"); + }; + + promptMainMenu = async() => { await this.ui.askMultipleChoice("Select an option",[ { label: "optionOne", @@ -15,10 +24,13 @@ export class MainMenu { } },{ label: "optionTwo", - action: async function() { - console.log("B!") - } + action: this.closeMainMenu }, ]) }; + + closeMainMenu = async() => { + console.log("B!") + this.running = false; + }; }