Website Summary Files Commits Branches @commit @diff @stats
path: root / src / ConsoleInterface
diff options
context:
space:
mode:
Commit110fdbde950490a1911c6033a602519f609b3192 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 14:58:54 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 14:58:54 +0300
Files3f869671f8675fa0a79dfd6bd5192fa98a2d8bd6 /src/ConsoleInterface
FMI-OOP-P1_TicketSystem-110fdbde950490a1911c6033a602519f609b3192.tar
FMI-OOP-P1_TicketSystem-110fdbde950490a1911c6033a602519f609b3192.tar.gz
FMI-OOP-P1_TicketSystem-110fdbde950490a1911c6033a602519f609b3192.zip
Parent1ad57c16e2532cc7db63b3b2c0277d0c9f6762c3 (diff)
Autocommit at 05.05.2022 @ 14:58
2 files changed, 12 insertions, 11 deletions
-rw-r--r--src/ConsoleInterface/Menu.cpp21
-rw-r--r--src/ConsoleInterface/Menu.h2
diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp
index cfed9fa..9c24d41 100644
--- a/src/ConsoleInterface/Menu.cpp
+++ b/src/ConsoleInterface/Menu.cpp
@@ -17,23 +17,22 @@ void Menu::navigate() const {
return;
}
- resetOrderedList(0);
- printOrderedListElem("Go Back");
- for (unsigned i = 0; i < menuOptions.get_count(); i++)
- printOrderedListElem(menuOptions[i].get_nameInMenu());
+ unsigned buffer = 1; // We immedeately read the value of buffer, so this is fine
- unsigned buffer = 0; // 0 is optionless continue, 1 is exit, others are options
+ while (buffer != 0) {
+ resetOrderedList(0);
+ printOrderedListElem("Go Back");
+ for (unsigned i = 0; i < menuOptions.get_count(); i++)
+ printOrderedListElem(menuOptions[i].get_nameInMenu());
- while (buffer != 1) {
- print("Execute No [0-");
+ _printInputBoxLabel("Execute No [0-");
print(menuOptions.get_count());
print("]: ");
read(buffer);
- buffer++;
- if (buffer - 2 > menuOptions.get_count())
+ if (buffer > menuOptions.get_count())
printError("Invalid menu option!");
- else
- menuOptions[buffer - 2].run();
+ else if (buffer > 0)
+ menuOptions[buffer - 1].run();
}
}
diff --git a/src/ConsoleInterface/Menu.h b/src/ConsoleInterface/Menu.h
index ba0a413..5298b4b 100644
--- a/src/ConsoleInterface/Menu.h
+++ b/src/ConsoleInterface/Menu.h
@@ -5,8 +5,10 @@
#include "../List/List.hpp"
class Menu {
+ char title[256];
List<Command> menuOptions;
+
public:
Menu();
Menu(const Command* commands, unsigned commandCount);