added MenuActionWrapper to call callbacks /classes
This commit is contained in:
+16
-3
@@ -20,19 +20,32 @@ MenuAction::MenuAction(const char* name, MenuControl* menu) {
|
||||
this->name = name;
|
||||
this->menu = menu;
|
||||
this->isMenu = true;
|
||||
this->callback = nullptr;
|
||||
}
|
||||
|
||||
MenuAction::MenuAction(const char* name, MenuActionWrapper* action) {
|
||||
this->name = name;
|
||||
this->action = action;
|
||||
}
|
||||
|
||||
MenuAction::~MenuAction() {
|
||||
if (this->menu)
|
||||
delete this->menu;
|
||||
|
||||
if (this->action)
|
||||
delete this->action;
|
||||
}
|
||||
|
||||
void MenuAction::runAction() {
|
||||
if (isMenu)
|
||||
this->menu->printMenu();
|
||||
else
|
||||
this->function();
|
||||
else {
|
||||
if (this->function)
|
||||
this->function();
|
||||
else if (this->action)
|
||||
this->action->action();
|
||||
else
|
||||
std::cout << "Error in MenuAction::runAction" << std::endl;
|
||||
}
|
||||
|
||||
if (this->callback)
|
||||
this->callback();
|
||||
|
||||
Reference in New Issue
Block a user