aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/menu.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-11 20:17:38 +0100
committerEugene Sandulenko2016-01-11 20:17:38 +0100
commit2d2c8ab340e873b1d4abdbd7573cca40ee3c49b5 (patch)
treea6b651299b9ec8f3564b22960964523e63c9c071 /engines/wage/menu.cpp
parentdb503e967dbd93458cf59837679c0f4a60d1420e (diff)
downloadscummvm-rg350-2d2c8ab340e873b1d4abdbd7573cca40ee3c49b5.tar.gz
scummvm-rg350-2d2c8ab340e873b1d4abdbd7573cca40ee3c49b5.tar.bz2
scummvm-rg350-2d2c8ab340e873b1d4abdbd7573cca40ee3c49b5.zip
WAGE: Highlight first level menus
Diffstat (limited to 'engines/wage/menu.cpp')
-rw-r--r--engines/wage/menu.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 1fc4028723..25bd3b9d8f 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -132,7 +132,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
for (int i = 0; menuSubItems[i].menunum; i++) {
MenuData *m = &menuSubItems[i];
- _items[i]->subitems.push_back(new MenuSubItem(m->title, m->action, m->shortcut));
+ _items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, m->shortcut));
}
MenuItem *commands = new MenuItem("Commands");
@@ -145,6 +145,15 @@ Menu::Menu(Gui *gui) : _gui(gui) {
MenuItem *weapons = new MenuItem("Weapons");
_items.push_back(weapons);
}
+
+ _bbox.left = 0;
+ _bbox.top = 0;
+ _bbox.right = _gui->_screen.w - 1;
+ _bbox.bottom = kMenuHeight - 1;
+
+ _menuActivated = false;
+ _activeItem = -1;
+ _activeSubItem = -1;
}
Menu::~Menu() {
@@ -160,7 +169,7 @@ const Graphics::Font *Menu::getMenuFont() {
}
void Menu::render() {
- Common::Rect r(0, 0, _gui->_screen.w - 1, kMenuHeight - 1);
+ Common::Rect r(_bbox);
Patterns p;
p.push_back(fillPattern);
@@ -176,7 +185,21 @@ void Menu::render() {
for (int i = 0; i < _items.size(); i++) {
int w = font->getStringWidth(_items[i]->name);
- font->drawString(&_gui->_screen, _items[i]->name, x, y, w, kColorBlack);
+ int color = kColorBlack;
+
+ if (_activeItem == i) {
+ Design::drawFilledRect(&_gui->_screen, _items[i]->bbox, kColorBlack, p, 1);
+ color = kColorWhite;
+ }
+
+ font->drawString(&_gui->_screen, _items[i]->name, x, y, w, color);
+
+ if (_items[i]->bbox.bottom == 0) {
+ _items[i]->bbox.left = x;
+ _items[i]->bbox.top = y;
+ _items[i]->bbox.right = x + w;
+ _items[i]->bbox.bottom = y + font->getFontHeight();
+ }
x += w + 13;
}
@@ -184,4 +207,17 @@ void Menu::render() {
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
}
+bool Menu::mouseClick(int x, int y) {
+ if (_bbox.contains(x, y)) {
+ for (int i = 0; i < _items.size(); i++)
+ if (_items[i]->bbox.contains(x, y)) {
+ _activeItem = i;
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
} // End of namespace Wage