diff options
author | Strangerke | 2013-09-29 11:26:21 +0200 |
---|---|---|
committer | Strangerke | 2013-09-29 11:26:21 +0200 |
commit | 1af03774ccda57e153b3d3664613818645f5f4ff (patch) | |
tree | f1a230e5278a89a1c61cecac6943822035e4a860 | |
parent | ef8b661c3d80a498f0bacf0b954764084c95262b (diff) | |
download | scummvm-rg350-1af03774ccda57e153b3d3664613818645f5f4ff.tar.gz scummvm-rg350-1af03774ccda57e153b3d3664613818645f5f4ff.tar.bz2 scummvm-rg350-1af03774ccda57e153b3d3664613818645f5f4ff.zip |
AVALANCHE: Add some more graphic functions
-rw-r--r-- | engines/avalanche/animation.cpp | 12 | ||||
-rw-r--r-- | engines/avalanche/graphics.cpp | 34 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 6 | ||||
-rw-r--r-- | engines/avalanche/menu.cpp | 16 | ||||
-rw-r--r-- | engines/avalanche/parser.cpp | 2 |
5 files changed, 42 insertions, 28 deletions
diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp index 2a309f31a9..bf97328c5a 100644 --- a/engines/avalanche/animation.cpp +++ b/engines/avalanche/animation.cpp @@ -861,17 +861,9 @@ void Animation::callSpecial(uint16 which) { } void Animation::updateSpeed() { - // Given that you've just changed the speed in triptype._speedX, this adjusts _moveX. - + // Given that you've just changed the speed in _speedX, this adjusts _moveX. _sprites[0]._moveX = (_sprites[0]._moveX / 3) * _sprites[0]._speedX; - - if (_sprites[0]._speedX == _vm->kRun) { - _vm->_graphics->_surface.drawLine(336, 199, 338, 199, kColorLightblue); - _vm->_graphics->_surface.drawLine(371, 199, 373, 199, kColorYellow); - } else { - _vm->_graphics->_surface.drawLine(371, 199, 373, 199, kColorLightblue); - _vm->_graphics->_surface.drawLine(336, 199, 338, 199, kColorYellow); - } + _vm->_graphics->drawSpeedBar(_sprites[0]._speedX); } void Animation::setMoveSpeed(byte t, Direction dir) { diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 1961ce9a39..2d0a45eaa0 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -48,6 +48,7 @@ Graphics::~Graphics() { _background.free(); _screen.free(); _scrolls.free(); + _backup.free(); for (int i = 0; i < 10; i++) _digits[i].free(); @@ -363,6 +364,15 @@ void Graphics::drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::Str CursorMan.showMouse(true); } +void Graphics::drawSpeedBar(int speed) { + if (speed == _vm->kRun) { + _surface.drawLine(336, 199, 338, 199, kColorLightblue); + _surface.drawLine(371, 199, 373, 199, kColorYellow); + } else { + _surface.drawLine(371, 199, 373, 199, kColorLightblue); + _surface.drawLine(336, 199, 338, 199, kColorYellow); + } +} void Graphics::drawScroll(int mx, int lx, int my, int ly) { _scrolls.copyFrom(_surface); @@ -390,7 +400,6 @@ void Graphics::drawScroll(int mx, int lx, int my, int ly) { _scrolls.fillRect(Common::Rect(mx - lx - 30, my + ly + 6, mx + lx, my + ly + 7), kColorRed); _scrolls.fillRect(Common::Rect(mx - lx - 15, my - ly, mx - lx - 14, my + ly), kColorRed); _scrolls.fillRect(Common::Rect(mx + lx + 15, my - ly, mx + lx + 16, my + ly), kColorRed); - } ::Graphics::Surface Graphics::loadPictureGraphic(Common::File &file) { @@ -523,9 +532,7 @@ void Graphics::refreshBackground() { void Graphics::zoomOut(int16 x, int16 y) { //setlinestyle(dottedln, 0, 1); TODO: Implement it with a dotted line style!!! - ::Graphics::Surface backup; - backup.copyFrom(_surface); - + saveScreen(); for (byte i = 1; i <= 20; i ++) { int16 x1 = x - (x / 20) * i; int16 y1 = y - ((y - 10) / 20) * i; @@ -535,11 +542,10 @@ void Graphics::zoomOut(int16 x, int16 y) { _surface.frameRect(Common::Rect(x1, y1, x2, y2), kColorWhite); refreshScreen(); _vm->_system->delayMillis(17); - _surface.copyFrom(backup); - refreshScreen(); - } - backup.free(); + restoreScreen(); + } + removeBackup(); } // Original name background() @@ -547,4 +553,16 @@ void Graphics::setBackgroundColor(Color x) { warning("STUB: setBackgroundColor(%d)", x); } +void Graphics::saveScreen() { + _backup.copyFrom(_surface); +} + +void Graphics::removeBackup() { + _backup.free(); +} + +void Graphics::restoreScreen() { + _surface.copyFrom(_backup); + refreshScreen(); +} } // End of namespace Avalanche diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 8fdc39f34f..c6f1f6059e 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -82,6 +82,8 @@ 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 drawSpeedBar(int speed); + void clearAlso(); void clearTextBar(); void setAlsoLine(int x1, int y1, int x2, int y2, Color color); @@ -104,6 +106,9 @@ public: void zoomOut(int16 x, int16 y); // Only used when entering the map. + void saveScreen(); + void removeBackup(); + void restoreScreen(); private: static const uint16 kBackgroundWidth = kScreenWidth; static const byte kBackgroundHeight = 8 * 12080 / kScreenWidth; // With 640 width it's 151. @@ -114,6 +119,7 @@ private: ::Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in loadDigits() !!! ::Graphics::Surface _directions[9]; // Maybe it will be needed to move them to the class itself instead. ::Graphics::Surface _screen; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.) + ::Graphics::Surface _backup; byte _egaPalette[64][3]; AvalancheEngine *_vm; diff --git a/engines/avalanche/menu.cpp b/engines/avalanche/menu.cpp index 24183f8efc..8d9d105bef 100644 --- a/engines/avalanche/menu.cpp +++ b/engines/avalanche/menu.cpp @@ -683,10 +683,9 @@ void Menu::setup() { } void Menu::update() { // TODO: Optimize it ASAP!!! It really needs it... - Common::Point cursorPos = _vm->getMousePos(); - ::Graphics::Surface backup; - backup.copyFrom(_vm->_graphics->_surface); + _vm->_graphics->saveScreen(); + Common::Point cursorPos = _vm->getMousePos(); while (!_activeMenuItem._activeNow && (cursorPos.y <= 21) && _vm->_holdLeftMouse) { _menuBar.chooseMenuItem(cursorPos.x); do @@ -723,7 +722,7 @@ void Menu::update() { // TODO: Optimize it ASAP!!! It really needs it... if (_activeMenuItem._activeNow) { _activeMenuItem.wipe(); _vm->_holdLeftMouse = false; - backup.free(); + _vm->_graphics->removeBackup(); return; } // No "else"- clicking on menu has no effect (only releasing). } @@ -731,13 +730,12 @@ void Menu::update() { // TODO: Optimize it ASAP!!! It really needs it... // Clicked on menu bar. if (_activeMenuItem._activeNow) { _activeMenuItem.wipe(); - _vm->_graphics->_surface.copyFrom(backup); - _vm->_graphics->refreshScreen(); + _vm->_graphics->restoreScreen(); if (((_activeMenuItem._left * 8) <= cursorPos.x) && (cursorPos.x <= (_activeMenuItem._left * 8 + 80))) { // 80: the width of one menu item on the bar in pixels. // If we clicked on the same menu item (the one that is already active) on the bar... _vm->_holdLeftMouse = false; - backup.free(); + _vm->_graphics->removeBackup(); return; } else { _vm->_holdLeftMouse = true; @@ -764,7 +762,7 @@ void Menu::update() { // TODO: Optimize it ASAP!!! It really needs it... uint16 which = (cursorPos.y - 26) / 20; _activeMenuItem.select(which); if (_activeMenuItem._options[which]._valid) { // If the menu item wasn't active, we do nothing. - backup.free(); + _vm->_graphics->removeBackup(); return; } } @@ -772,7 +770,7 @@ void Menu::update() { // TODO: Optimize it ASAP!!! It really needs it... } } - backup.free(); + _vm->_graphics->removeBackup(); } bool Menu::isActive() { diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index b86cc636de..8d01996800 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -481,7 +481,7 @@ void Parser::wipeText() { CursorMan.showMouse(false); cursorOff(); - _vm->_graphics->_surface.fillRect(Common::Rect(24, 161, 640, 169), kColorBlack); // Black out the line of the text. + _vm->_graphics->clearTextBar(); _quote = true; _inputTextPos = 0; |