diff options
author | Strangerke | 2013-09-28 09:43:28 +0200 |
---|---|---|
committer | Strangerke | 2013-09-28 09:43:28 +0200 |
commit | 7a8d252ddb9115d4cfea0bdc5e94b38ac3ddad23 (patch) | |
tree | fc6ad103ac331fe4c4e3ded1d83c33888637264a | |
parent | 00e5a4830bda004f5b4193c9d0d97a21f3e253ba (diff) | |
download | scummvm-rg350-7a8d252ddb9115d4cfea0bdc5e94b38ac3ddad23.tar.gz scummvm-rg350-7a8d252ddb9115d4cfea0bdc5e94b38ac3ddad23.tar.bz2 scummvm-rg350-7a8d252ddb9115d4cfea0bdc5e94b38ac3ddad23.zip |
AVALANCHE: Move Digits and Directions to Graphics
-rw-r--r-- | engines/avalanche/avalanche.cpp | 6 | ||||
-rw-r--r-- | engines/avalanche/avalanche.h | 3 | ||||
-rw-r--r-- | engines/avalanche/avalot.cpp | 29 | ||||
-rw-r--r-- | engines/avalanche/graphics.cpp | 33 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 14 |
5 files changed, 48 insertions, 37 deletions
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index cd943513ba..729bb8bdc5 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -88,12 +88,6 @@ AvalancheEngine::~AvalancheEngine() { } } } - - for (int i = 0; i < 9; i++) { - _digits[i].free(); - _directions[i].free(); - } - _digits[9].free(); } Common::ErrorCode AvalancheEngine::initialize() { diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index 024b484eb0..2e2724f864 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -283,8 +283,6 @@ public: byte _scrollBells; // no. of times to ring the bell bool _onToolbar, _seeScroll; // TODO: maybe this means we're interacting with the toolbar / a scroll? char _objectList[10]; - ::Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in Lucerna::load_digits() !!! - ::Graphics::Surface _directions[9]; // Maybe it will be needed to move them to the class itself instead. // Called .free() for them in ~Gyro(). int8 _scoreToDisplay[3]; byte _currentMouse; // current mouse-void @@ -327,7 +325,6 @@ public: void exitRoom(byte x); void enterRoom(Room room, byte ped); void thinkAbout(byte object, bool type); // Hey!!! Get it and put it!!! - void loadDigits(); // Load the scoring digits & rwlites void drawToolbar(); void drawScore(); void incScore(byte num); // Add on no. of points diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index 0e71f600e0..096a5d7dd0 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -318,7 +318,7 @@ void AvalancheEngine::setup() { _dialogs->reset(); dusk(); - loadDigits(); + _graphics->loadDigits(file); _parser->_inputTextPos = 0; _parser->_quote = true; @@ -1111,26 +1111,6 @@ void AvalancheEngine::thinkAbout(byte object, bool type) { _thinkThing = type; } -void AvalancheEngine::loadDigits() { // Load the scoring digits & rwlites - const byte digitsize = 134; - const byte rwlitesize = 126; - - if (!file.open("digit.avd")) - error("AVALANCHE: Lucerna: File not found: digit.avd"); - - for (int i = 0; i < 10; i++) { - file.seek(i * digitsize); - _digits[i] = _graphics->loadPictureGraphic(file); - } - - for (int i = 0; i < 9; i++) { - file.seek(10 * digitsize + i * rwlitesize); - _directions[i] = _graphics->loadPictureGraphic(file); - } - - file.close(); -} - void AvalancheEngine::drawToolbar() { if (!file.open("useful.avd")) error("AVALANCHE: Lucerna: File not found: useful.avd"); @@ -1138,10 +1118,11 @@ void AvalancheEngine::drawToolbar() { file.seek(40); CursorMan.showMouse(false); + ::Graphics::Surface picture = _graphics->loadPictureGraphic(file); _graphics->drawPicture(_graphics->_surface, picture, 5, 169); - picture.free(); + file.close(); CursorMan.showMouse(true); @@ -1165,7 +1146,7 @@ void AvalancheEngine::drawScore() { for (int i = 0; i < 3; i++) { if (_scoreToDisplay[i] != numbers[i]) - _graphics->drawPicture(_graphics->_surface, _digits[numbers[i]], 250 + (i + 1) * 15, 177); + _graphics->drawDigit(numbers[i], 250 + (i + 1) * 15, 177); } CursorMan.showMouse(true); @@ -1401,7 +1382,7 @@ void AvalancheEngine::drawDirection() { // It's data is loaded in load_digits(). _animation->setOldDirection(_animation->getDirection()); CursorMan.showMouse(false); - _graphics->drawPicture(_graphics->_surface, _directions[_animation->getDirection()], 0, 161); + _graphics->drawDirection(_animation->getDirection(), 0, 161); CursorMan.showMouse(true); } diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 79df06b8c0..efed0fa97f 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -48,6 +48,11 @@ Graphics::~Graphics() { _background.free(); _screen.free(); _scrolls.free(); + + for (int i = 0; i < 10; i++) + _digits[i].free(); + for (int i = 0; i < 9; i++) + _directions[i].free(); } void Graphics::init() { @@ -68,6 +73,26 @@ void Graphics::init() { _scrolls.create(kScreenWidth, kScreenHeight, ::Graphics::PixelFormat::createFormatCLUT8()); } +void Graphics::loadDigits(Common::File &file) { // Load the scoring digits & rwlites + const byte digitsize = 134; + const byte rwlitesize = 126; + + if (!file.open("digit.avd")) + error("AVALANCHE: Lucerna: File not found: digit.avd"); + + for (int i = 0; i < 10; i++) { + file.seek(i * digitsize); + _digits[i] = loadPictureGraphic(file); + } + + for (int i = 0; i < 9; i++) { + file.seek(10 * digitsize + i * rwlitesize); + _directions[i] = loadPictureGraphic(file); + } + + file.close(); +} + void Graphics::fleshColors() { g_system->getPaletteManager()->setPalette(_egaPalette[39], 13, 1); g_system->getPaletteManager()->setPalette(_egaPalette[28], 5, 1); @@ -214,6 +239,14 @@ void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text } } +void Graphics::drawDigit(int index, int x, int y) { + drawPicture(_surface, _digits[index], x, y); +} + +void Graphics::drawDirection(int index, int x, int y) { + drawPicture(_surface, _directions[index], x, y); +} + ::Graphics::Surface Graphics::loadPictureGraphic(Common::File &file) { // This function mimics Pascal's getimage(). // The height and the width are stored in 2-2 bytes. We have to add 1 to each because Pascal stores the value of them -1. diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index b1b186af41..ea05ef13ef 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -70,6 +70,8 @@ public: Graphics(AvalancheEngine *vm); ~Graphics(); void init(); + void loadDigits(Common::File &file); // Load the scoring digits & rwlites + void fleshColors(); // Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc. @@ -80,6 +82,8 @@ public: void drawPieSlice(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color); void drawTriangle(::Graphics::Surface &surface, Common::Point *p, Color color); void drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color); + void drawDigit(int index, int x, int y); + void drawDirection(int index, int x, int y); // The caller has to .free() the returned Surfaces!!! // Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data @@ -94,12 +98,14 @@ public: void zoomOut(int16 x, int16 y); // Only used when entering the map. private: - AvalancheEngine *_vm; - static const byte kEgaPaletteIndex[16]; - - byte _egaPalette[64][3]; + ::Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in Lucerna::load_digits() !!! + ::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.) + byte _egaPalette[64][3]; + + AvalancheEngine *_vm; + }; } // End of namespace Avalanche |