From 5eb6112aaabebe5338e65f16cf4f18acc38ddf4d Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 5 May 2022 21:29:12 +0300 Subject: Autocommit at 05.05.2022 @ 21:29 --- src/ConsoleInterface/Menu.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/ConsoleInterface/Menu.cpp') diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp index beb69c2..caba7e8 100644 --- a/src/ConsoleInterface/Menu.cpp +++ b/src/ConsoleInterface/Menu.cpp @@ -2,13 +2,17 @@ #include "Toolbox.hpp" #include -Menu::Menu() : Menu("Menu") {} +Menu::Menu() : Menu("Menu", false, false) {} -Menu::Menu(const char* title) : menuOptions() { +Menu::Menu(const char* title, bool backExistsApp, bool isSubMenu) : menuOptions() { + this->backExistsApp = backExistsApp; + this->isSubMenu = isSubMenu; strcpy(this->title, title); } -Menu::Menu(const char* title, const Command* commands, unsigned commandCount) { +Menu::Menu(const char* title, bool backExistsApp, bool isSubMenu, const Command* commands, unsigned commandCount) { + this->backExistsApp = backExistsApp; + this->isSubMenu = isSubMenu; menuOptions = List(commands, commandCount); strcpy(this->title, title); } @@ -51,17 +55,25 @@ void Menu::navigate() const { while (buffer != 0) { clear(); - title(title); + if (isSubMenu) + subTitleBox(title); + else + titleBox(title); + switch(msgType) { - case Error: error(msg.get_cstr()); msgType = NoPrint; break; - case Warning: warning(msg.get_cstr()); msgType = NoPrint; break; - case Success: success(msg.get_cstr()); msgType = NoPrint; break; + case Error: errorBox(msg.get_cstr()); msgType = NoPrint; break; + case Warning: warningBox(msg.get_cstr()); msgType = NoPrint; break; + case Success: successBox(msg.get_cstr()); msgType = NoPrint; break; case NoPrint: printLine(""); break; } printLine(""); resetOrderedList(0); - printOrderedListElem("Go Back"); + if (backExistsApp) + printOrderedListElem("Exit"); + else + printOrderedListElem("Go Back"); + for (unsigned i = 0; i < menuOptions.get_count(); i++) printOrderedListElem(menuOptions[i].get_nameInMenu()); -- cgit v1.3.1-23-gd82d