aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/gui.cpp4
-rw-r--r--engines/wage/gui.h1
-rw-r--r--engines/wage/menu.cpp32
-rw-r--r--engines/wage/menu.h4
-rw-r--r--engines/wage/wage.cpp7
5 files changed, 27 insertions, 21 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 6fcbbc3678..1feed364cd 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -470,10 +470,6 @@ void Gui::regenWeaponsMenu() {
_menu->regenWeaponsMenu();
}
-void Gui::processMenuShortCut(byte flags, uint16 ascii) {
- _menu->processMenuShortCut(flags, ascii);
-}
-
void Gui::pushArrowCursor() {
CursorMan.pushCursor(macCursorArrow, 11, 16, 1, 1, 3);
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index cfc7a09b76..d0af24c08b 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -96,7 +96,6 @@ public:
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
void regenCommandsMenu();
void regenWeaponsMenu();
- void processMenuShortCut(byte flags, uint16 ascii);
void pushArrowCursor();
void popCursor();
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 425f2d6cb0..18b1f04024 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -105,9 +105,6 @@ struct MenuData {
};
Menu::Menu(int id, Gui *gui) : BaseMacWindow(id), _gui(gui) {
- assert(_gui->_engine);
- assert(_gui->_engine->_world);
-
_font = getMenuFont();
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
@@ -447,12 +444,29 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
bool Menu::processEvent(Common::Event &event) {
- if (event.type == Common::EVENT_LBUTTONDOWN)
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ return keyEvent(event);
+ case Common::EVENT_LBUTTONDOWN:
return mouseClick(event.mouse.x, event.mouse.y);
- else if (event.type == Common::EVENT_LBUTTONUP)
+ case Common::EVENT_LBUTTONUP:
return mouseRelease(event.mouse.x, event.mouse.y);
- else if (event.type == Common::EVENT_MOUSEMOVE)
+ case Common::EVENT_MOUSEMOVE:
return mouseMove(event.mouse.x, event.mouse.y);
+ default:
+ return false;
+ }
+}
+
+bool Menu::keyEvent(Common::Event &event) {
+ if (event.type != Common::EVENT_KEYDOWN)
+ return false;
+
+ if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
+ if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
+ return processMenuShortCut(event.kbd.flags, event.kbd.ascii);
+ }
+ }
return false;
}
@@ -563,7 +577,7 @@ void Menu::executeCommand(MenuSubItem *subitem) {
}
}
-void Menu::processMenuShortCut(byte flags, uint16 ascii) {
+bool Menu::processMenuShortCut(byte flags, uint16 ascii) {
ascii = tolower(ascii);
if (flags & (Common::KBD_CTRL | Common::KBD_META)) {
@@ -571,9 +585,11 @@ void Menu::processMenuShortCut(byte flags, uint16 ascii) {
for (uint j = 0; j < _items[i]->subitems.size(); j++)
if (_items[i]->subitems[j]->enabled && tolower(_items[i]->subitems[j]->shortcut) == ascii) {
executeCommand(_items[i]->subitems[j]);
- break;
+ return true;
}
}
+
+ return false;
}
void Menu::enableCommand(int menunum, int action, bool state) {
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 511811265a..fba59bbc0a 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -100,7 +100,6 @@ public:
void regenCommandsMenu();
void regenWeaponsMenu();
- void processMenuShortCut(byte flags, uint16 ascii);
void enableCommand(int menunum, int action, bool state);
void disableAllMenus();
@@ -124,10 +123,13 @@ private:
void createWeaponsMenu(MenuItem *menu);
void executeCommand(MenuSubItem *subitem);
+ bool keyEvent(Common::Event &event);
bool mouseClick(int x, int y);
bool mouseRelease(int x, int y);
bool mouseMove(int x, int y);
+ bool processMenuShortCut(byte flags, uint16 ascii);
+
Common::Array<MenuItem *> _items;
MenuItem *_weapons;
MenuItem *_commands;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index be79b14b62..567e2768d8 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -180,13 +180,6 @@ void WageEngine::processEvents() {
break;
}
- if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
- if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
- _gui->processMenuShortCut(event.kbd.flags, event.kbd.ascii);
- }
- break;
- }
-
if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
_inputText += (char)event.kbd.ascii;
_gui->drawInput();