aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-11 20:58:37 +0100
committerEugene Sandulenko2016-01-11 20:58:37 +0100
commitdb9a9665a47a16852613fd0a15799cdaeaa4bb97 (patch)
tree84c928f3baaa5a968c5dfe48e1f4cf89241dd4cb /engines
parenta65fdcf7567e4a8a1ce1d5ee4ec7e483781befd9 (diff)
downloadscummvm-rg350-db9a9665a47a16852613fd0a15799cdaeaa4bb97.tar.gz
scummvm-rg350-db9a9665a47a16852613fd0a15799cdaeaa4bb97.tar.bz2
scummvm-rg350-db9a9665a47a16852613fd0a15799cdaeaa4bb97.zip
WAGE: Precalculate menu dimensions
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/gui.h2
-rw-r--r--engines/wage/menu.cpp34
-rw-r--r--engines/wage/menu.h2
3 files changed, 23 insertions, 15 deletions
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 8dea4f85e5..c5c1aada0b 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -65,6 +65,8 @@ enum WindowType {
enum {
kMenuHeight = 20,
+ kMenuLeftMargin = 7,
+ kMenuSpacing = 13,
kMenuPadding = 6,
kMenuItemHeight = 20,
kBorderWidth = 17,
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index bb58398326..f7ab7e9998 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -146,6 +146,24 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items.push_back(weapons);
}
+ // Calculate menu dimensions
+ _font = getMenuFont();
+ int y = _gui->_builtInFonts ? 3 : 2;
+ int x = 18;
+
+ for (int i = 0; i < _items.size(); i++) {
+ int w = _font->getStringWidth(_items[i]->name);
+
+ if (_items[i]->bbox.bottom == 0) {
+ _items[i]->bbox.left = x - kMenuLeftMargin;
+ _items[i]->bbox.top = y;
+ _items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
+ _items[i]->bbox.bottom = y + _font->getFontHeight();
+ }
+
+ x += w + kMenuSpacing;
+ }
+
_bbox.left = 0;
_bbox.top = 0;
_bbox.right = _gui->_screen.w - 1;
@@ -179,12 +197,7 @@ void Menu::render() {
r.top = kMenuHeight - 1;
Design::drawFilledRect(&_gui->_screen, r, kColorBlack, p, 1);
- const Graphics::Font *font = getMenuFont();
- int y = _gui->_builtInFonts ? 3 : 2;
- int x = 18;
-
for (int i = 0; i < _items.size(); i++) {
- int w = font->getStringWidth(_items[i]->name);
int color = kColorBlack;
if (_activeItem == i) {
@@ -192,16 +205,7 @@ void Menu::render() {
color = kColorWhite;
}
- font->drawString(&_gui->_screen, _items[i]->name, x, y, w, color);
-
- if (_items[i]->bbox.bottom == 0) {
- _items[i]->bbox.left = x - 7;
- _items[i]->bbox.top = y;
- _items[i]->bbox.right = x + w + 6;
- _items[i]->bbox.bottom = y + font->getFontHeight();
- }
-
- x += w + 13;
+ _font->drawString(&_gui->_screen, _items[i]->name, _items[i]->bbox.left + kMenuLeftMargin, _items[i]->bbox.top, _items[i]->bbox.width(), color);
}
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index e444c1a161..0a8c498be9 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -72,6 +72,8 @@ private:
const Graphics::Font *getMenuFont();
Common::Array<MenuItem *> _items;
+ const Graphics::Font *_font;
+
int _activeItem;
int _activeSubItem;
};