diff options
author | Eugene Sandulenko | 2016-04-28 15:25:14 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-28 15:25:14 +0200 |
commit | 72b8f3a1c7e47ec6fef962cd1aa7abebcf5d782f (patch) | |
tree | eb6304dbd84f20479d0bb886d79744369d32e982 /engines/wage/gui.cpp | |
parent | 3027433b669d00a5b16689a4de518639d7dff746 (diff) | |
download | scummvm-rg350-72b8f3a1c7e47ec6fef962cd1aa7abebcf5d782f.tar.gz scummvm-rg350-72b8f3a1c7e47ec6fef962cd1aa7abebcf5d782f.tar.bz2 scummvm-rg350-72b8f3a1c7e47ec6fef962cd1aa7abebcf5d782f.zip |
WAGE: Implemented menu commands as callback
Diffstat (limited to 'engines/wage/gui.cpp')
-rw-r--r-- | engines/wage/gui.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 9eca3a8fea..0ddae88f2d 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -112,6 +112,8 @@ static void cursorTimerHandler(void *refCon) { static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *gui); static bool consoleWindowCallback(WindowClick click, Common::Event &event, void *gui); +static void menuCommandsCallback(int action, Common::String &text, void *data); + Gui::Gui(WageEngine *engine) { _engine = engine; @@ -143,6 +145,8 @@ Gui::Gui(WageEngine *engine) { _menu = _wm.addMenu(this); + _menu->setCommandsCallback(menuCommandsCallback, this); + _menu->addStaticMenus(menuSubItems); _menu->addMenuSubItem(kMenuAbout, _engine->_world->getAboutMenuItemName(), kMenuActionAbout); @@ -267,6 +271,9 @@ static bool consoleWindowCallback(WindowClick click, Common::Event &event, void return gui->processConsoleEvents(click, event); } +//////////////// +// Menu stuff +//////////////// void Gui::regenCommandsMenu() { _menu->createSubMenuFromString(_commandsMenuId, _engine->_world->_commandsMenu.c_str()); } @@ -306,4 +313,47 @@ bool Gui::processEvent(Common::Event &event) { return _wm.processEvent(event); } +void menuCommandsCallback(int action, Common::String &text, void *data) { + Gui *g = (Gui *)data; + + g->executeMenuCommand(action, text); +} + +void Gui::executeMenuCommand(int action, Common::String &text) { + switch(action) { + case kMenuActionAbout: + case kMenuActionNew: + case kMenuActionOpen: + case kMenuActionClose: + case kMenuActionSave: + case kMenuActionSaveAs: + case kMenuActionRevert: + case kMenuActionQuit: + + case kMenuActionUndo: + actionUndo(); + break; + case kMenuActionCut: + actionCut(); + break; + case kMenuActionCopy: + actionCopy(); + break; + case kMenuActionPaste: + actionPaste(); + break; + case kMenuActionClear: + actionClear(); + break; + + case kMenuActionCommand: + _engine->processTurn(&text, NULL); + break; + + default: + warning("Unknown action: %d", action); + + } +} + } // End of namespace Wage |