diff options
author | Strangerke | 2013-09-29 19:03:52 +0200 |
---|---|---|
committer | Strangerke | 2013-09-29 19:03:52 +0200 |
commit | 6b41b38049d4a7450f0b4a2c6e71c1ba22f8cb70 (patch) | |
tree | 6b5066fd46c4929b0f99c59d0c0b894d7f61f601 /engines | |
parent | de12f46db5d636c005118db2743bbb7b8a8e6287 (diff) | |
download | scummvm-rg350-6b41b38049d4a7450f0b4a2c6e71c1ba22f8cb70.tar.gz scummvm-rg350-6b41b38049d4a7450f0b4a2c6e71c1ba22f8cb70.tar.bz2 scummvm-rg350-6b41b38049d4a7450f0b4a2c6e71c1ba22f8cb70.zip |
AVALANCHE: Move code from Menu to Graphics
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/graphics.cpp | 22 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 4 | ||||
-rw-r--r-- | engines/avalanche/menu.cpp | 28 | ||||
-rw-r--r-- | engines/avalanche/menu.h | 5 |
4 files changed, 39 insertions, 20 deletions
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 61cb40a11a..77113ee54b 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -364,6 +364,14 @@ void GraphicManager::drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Commo CursorMan.showMouse(true); } +void GraphicManager::drawMenuBar(Color color) { + _surface.fillRect(Common::Rect(0, 0, 640, 10), color); +} + +void GraphicManager::drawMenuBlock(int x1, int y1, int x2, int y2, Color color) { + _surface.fillRect(Common::Rect(x1, y1, x2, y2), color); +} + void GraphicManager::drawSpeedBar(int speed) { if (speed == _vm->kRun) { _surface.drawLine(336, 199, 338, 199, kColorLightblue); @@ -544,6 +552,20 @@ void GraphicManager::prepareBubble(int xc, int xw, int my, Common::Point points[ drawTriangle(points, _vm->_talkBackgroundColor); } +// And set the background of the text to the desired color. +void GraphicManager::wipeChar(int x, int y, Color color) { + for (int k = 0; k < 8; k++) + *(byte *)_surface.getBasePtr(x + k, y) = color; +} + +void GraphicManager::drawChar(byte ander, int x, int y, Color color) { + byte pixel = ander; + for (int bit = 0; bit < 8; bit++) { + byte pixelBit = (pixel >> bit) & 1; + if (pixelBit) + *(byte *)_surface.getBasePtr(x + 7 - bit, y) = color; + } +} void GraphicManager::refreshScreen() { // These cycles are for doubling the screen height. for (uint16 y = 0; y < _screen.h / 2; y++) { diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 5c5f91d7f5..383370d87b 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -81,8 +81,12 @@ public: void drawScrollShadow(int16 x1, int16 y1, int16 x2, int16 y2); void drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String text); void drawScroll(int mx, int lx, int my, int ly); + void drawMenuBar(Color color); void drawSpeedBar(int speed); void drawBackgroundSprite(int16 x, int16 y, SpriteType &sprite); + void drawMenuBlock(int x1, int y1, int x2, int y2, Color color); + void wipeChar(int x, int y, Color color); + void drawChar(byte ander, int x, int y, Color color); void clearAlso(); void clearTextBar(); diff --git a/engines/avalanche/menu.cpp b/engines/avalanche/menu.cpp index 8d9d105bef..21ed2d5813 100644 --- a/engines/avalanche/menu.cpp +++ b/engines/avalanche/menu.cpp @@ -103,18 +103,18 @@ void MenuItem::setupOption(Common::String title, char trigger, Common::String sh } void MenuItem::displayOption(byte y, bool highlit) { + Common::String text = _options[y]._title; + while (text.size() + _options[y]._shortcut.size() < _width) + text += ' '; // Pad _options[y] with spaces. + text += _options[y]._shortcut; + Color backgroundColor; if (highlit) backgroundColor = kColorBlack; else backgroundColor = kColorLightgray; - _dr->_vm->_graphics->_surface.fillRect(Common::Rect((_flx1 + 1) * 8, 3 + (y + 1) * 10, (_flx2 + 1) * 8, 13 + (y + 1) * 10), backgroundColor); - - Common::String text = _options[y]._title; - while (text.size() + _options[y]._shortcut.size() < _width) - text += ' '; // Pad _options[y] with spaces. - text += _options[y]._shortcut; + _dr->_vm->_graphics->drawMenuBlock((_flx1 + 1) * 8, 3 + (y + 1) * 10, (_flx2 + 1) * 8, 13 + (y + 1) * 10, backgroundColor); _dr->drawMenuText(_left, 4 + (y + 1) * 10, _options[y]._trigger, text, _options[y]._valid, highlit); } @@ -128,8 +128,8 @@ void MenuItem::display() { _activeNow = true; _dr->_menuActive = true; - _dr->_vm->_graphics->_surface.fillRect(Common::Rect((_flx1 + 1) * 8, 12, (_flx2 + 1) * 8, _fly), _dr->kMenuBackgroundColor); - _dr->_vm->_graphics->_surface.frameRect(Common::Rect((_flx1 + 1) * 8 - 1, 11, (_flx2 + 1) * 8 + 1, _fly + 1), _dr->kMenuBorderColor); + _dr->_vm->_graphics->_surface.fillRect(Common::Rect((_flx1 + 1) * 8, 12, (_flx2 + 1) * 8, _fly), kMenuBackgroundColor); + _dr->_vm->_graphics->_surface.frameRect(Common::Rect((_flx1 + 1) * 8 - 1, 11, (_flx2 + 1) * 8 + 1, _fly + 1), kMenuBorderColor); displayOption(0, true); for (int y = 1; y < _optionNum; y++) @@ -216,7 +216,7 @@ void MenuBar::createMenuItem(char trig, Common::String title, char altTrig, Menu } void MenuBar::draw() { - _dr->_vm->_graphics->_surface.fillRect(Common::Rect(0, 0, 640, 10), _dr->kMenuBackgroundColor); + _dr->_vm->_graphics->drawMenuBar(kMenuBackgroundColor); byte savecp = _dr->_vm->_cp; _dr->_vm->_cp = 3; @@ -312,8 +312,7 @@ void Menu::drawMenuText(int16 x, int16 y, char trigger, Common::String text, boo byte idx = text[i]; font[idx][j] = _vm->_font[idx][j] & ander; // Set the font. // And set the background of the text to the desired color. - for (int k = 0; k < 8; k++) - *(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + i * 8 + k, y + j) = backgroundColor; + _vm->_graphics->wipeChar(x * 8 + i * 8, y + j, backgroundColor); } } @@ -327,12 +326,7 @@ void Menu::drawMenuText(int16 x, int16 y, char trigger, Common::String text, boo for (i = 0; text[i] != trigger; i++) ; // Search for the character in the string. - byte pixel = ander; - for (int bit = 0; bit < 8; bit++) { - byte pixelBit = (pixel >> bit) & 1; - if (pixelBit) - *(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + i * 8 + 7 - bit, y + 8) = fontColor; - } + _vm->_graphics->drawChar(ander, x * 8 + i * 8, y + 8, fontColor); } _vm->_graphics->refreshScreen(); diff --git a/engines/avalanche/menu.h b/engines/avalanche/menu.h index 815ff230e9..eb357f597d 100644 --- a/engines/avalanche/menu.h +++ b/engines/avalanche/menu.h @@ -39,6 +39,8 @@ class AvalancheEngine; class Menu; typedef void (Menu::*MenuFunc)(); +static const Color kMenuBackgroundColor = kColorLightgray; +static const Color kMenuBorderColor = kColorBlack; class HeadType { public: @@ -131,9 +133,6 @@ private: static const byte kIndent = 5; static const byte kSpacing = 10; - static const Color kMenuBackgroundColor = kColorLightgray; - static const Color kMenuBorderColor = kColorBlack; - // Checkme: Useless constants? // static const Color kMenuFontColor = kColorBlack; // static const Color kHighlightBackgroundColor = kColorBlack; |