Example using menusThis example shows a menu, and demonstrates the new menu update ability.
#include "door.h"
int main(int argc, char *argv[]) {
menu.
setTitle(std::make_unique<door::Line>(
"Menu Example"), 1);
int arrows = 15;
std::string text = "Arrows (";
text += std::to_string(arrows);
text += " in stock)";
return text;
};
menu.
addSelection(
'A',
"Arrows (0 in stock)", arrowsUpdate);
menu.addSelection('C', "Color selection");
menu.addSelection('P', "Pants");
menu.addSelection('Q', "Quit");
int r = 0;
while (r >= 0) {
if (r > 0) {
char c = menu.
which(r - 1);
if (c == 'A') {
if (arrows > 0)
--arrows;
else {
<< "Sorry, we're out of stock.";
continue;
}
}
if (c == 'Q')
break;
}
}
}