From cd07f3c013b8cbf467cd1ebca9da19f2bcdfa50b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 5 May 2022 18:03:38 +0300 Subject: Autocommit at 05.05.2022 @ 18:03 --- src/ConsoleInterface/Menu.cpp | 11 +++++++++-- src/ConsoleInterface/Menu.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ConsoleInterface') diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp index 4112ed2..07be42e 100644 --- a/src/ConsoleInterface/Menu.cpp +++ b/src/ConsoleInterface/Menu.cpp @@ -17,6 +17,14 @@ void Menu::addCommand(const Command& command) { menuOptions.add(command); } +bool error = false; +String errMessage; + +void Menu::registerError(const char* message) { + error = true; + errMessage = message; +} + void Menu::navigate() const { if (menuOptions.get_count() == 0) { printLine("Menu is empty!"); @@ -24,7 +32,6 @@ void Menu::navigate() const { } unsigned buffer = 1; // We immedeately read the value of buffer, so this is fine - bool error = false; while (buffer != 0) { printTitle(title); @@ -35,7 +42,7 @@ void Menu::navigate() const { printOrderedListElem(menuOptions[i].get_nameInMenu()); if (error) { - printError("Invalid menu option!"); + printError(errMessage.get_cstr()); error = false; } diff --git a/src/ConsoleInterface/Menu.h b/src/ConsoleInterface/Menu.h index 3ee4b0b..a4ee3c6 100644 --- a/src/ConsoleInterface/Menu.h +++ b/src/ConsoleInterface/Menu.h @@ -14,6 +14,7 @@ public: Menu(const char* title, const Command* commands, unsigned commandCount); void addCommand(const Command& command); + void registerError(const char* message); void navigate() const; }; -- cgit v1.3.1-23-gd82d