diff options
Autocommit at 05.05.2022 @ 14:48
2 files changed, 6 insertions, 5 deletions
| -rw-r--r-- | src/ConsoleInterface/Menu.cpp | 9 | ||||
| -rw-r--r-- | src/ConsoleInterface/Toolbox.cpp | 2 |
diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp index 58477df..bf746e4 100644 --- a/src/ConsoleInterface/Menu.cpp +++ b/src/ConsoleInterface/Menu.cpp @@ -22,14 +22,15 @@ void Menu::navigate() const { for (unsigned i = 0; i < menuOptions.get_count(); i++) printOrderedListElem(menuOptions[i].get_nameInMenu()); - int buffer = -1; - while (buffer < 0 || buffer >= menuOptions.get_count()) { + unsigned buffer = 0; // 0 is optionless continue, 1 is exit, others are options + + while (buffer != 1) { print("Execute No [0-"); print(menuOptions.get_count()); print("]: "); read(buffer); - if (buffer == 0) return; - menuOptions[buffer].run(); + if (++buffer > 0) + menuOptions[buffer - 1].run(); } } diff --git a/src/ConsoleInterface/Toolbox.cpp b/src/ConsoleInterface/Toolbox.cpp index 81f4525..84842e4 100644 --- a/src/ConsoleInterface/Toolbox.cpp +++ b/src/ConsoleInterface/Toolbox.cpp @@ -7,7 +7,7 @@ void resetOrderedList(int starter) { } void _printOrderedListBeginning() { - std::cout << orderedListIndex << ". "; + std::cout << orderedListIndex++ << ". "; } void inputBoxLabel(const char* label) { |
