aboutsummaryrefslogtreecommitdiff
path: root/engines
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
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')
-rw-r--r--engines/wage/gui.cpp5
-rw-r--r--engines/wage/gui.h1
-rw-r--r--engines/wage/menu.cpp42
-rw-r--r--engines/wage/menu.h8
-rw-r--r--engines/wage/wage.cpp1
5 files changed, 54 insertions, 3 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e38d0249bf..e40b7af01c 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -613,4 +613,9 @@ Designed *Gui::getClickTarget(int x, int y) {
return NULL;
}
+void Gui::mouseClick(int x, int y) {
+ if (_menu->mouseClick(x, y))
+ _menuDirty = true;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 8ba9ce904d..8dea4f85e5 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -82,6 +82,7 @@ public:
void appendText(Common::String &str);
void clearOutput();
void mouseMove(int x, int y);
+ void mouseClick(int x, int y);
Designed *getClickTarget(int x, int y);
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
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
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 6034ee494d..255f2e8294 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -58,6 +58,9 @@ public:
~Menu();
void render();
+ bool mouseClick(int x, int y);
+
+ Common::Rect _bbox;
private:
Gui *_gui;
@@ -65,6 +68,11 @@ private:
private:
const Graphics::Font *getMenuFont();
Common::Array<MenuItem *> _items;
+
+ bool _menuActivated;
+
+ int _activeItem;
+ int _activeSubItem;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 73499d27a9..ff92a6935b 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -145,6 +145,7 @@ void WageEngine::processEvents() {
_gui->mouseMove(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONDOWN:
+ _gui->mouseClick(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONUP:
{