diff options
author | Nicola Mettifogo | 2007-02-27 19:39:33 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-02-27 19:39:33 +0000 |
commit | b2927b69c653fa0c66dbf8e3de6f0c4ac06e237a (patch) | |
tree | 617ad3d9745daa116374bd315147823d63be94cd | |
parent | 75af37327893e9698e91a88801e9dd5289de10cf (diff) | |
download | scummvm-rg350-b2927b69c653fa0c66dbf8e3de6f0c4ac06e237a.tar.gz scummvm-rg350-b2927b69c653fa0c66dbf8e3de6f0c4ac06e237a.tar.bz2 scummvm-rg350-b2927b69c653fa0c66dbf8e3de6f0c4ac06e237a.zip |
changed font handling:
- engine doesn't see font as a low-level Cnv anymore
- the Graphics class takes care of freeing memory on font changes
svn-id: r25900
-rw-r--r-- | engines/parallaction/callables.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/dialogue.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/graphics.cpp | 14 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 5 | ||||
-rw-r--r-- | engines/parallaction/intro.cpp | 3 | ||||
-rw-r--r-- | engines/parallaction/location.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/menu.cpp | 7 | ||||
-rw-r--r-- | engines/parallaction/zone.cpp | 7 |
8 files changed, 29 insertions, 31 deletions
diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp index 52cdccaec6..7c3d2eebd3 100644 --- a/engines/parallaction/callables.cpp +++ b/engines/parallaction/callables.cpp @@ -285,7 +285,7 @@ void _c_finito(void *parm) { _vm->_graphics->palUnk0(_palette); if (gameCompleted) { - _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font); + _vm->_graphics->setFont("slidecnv"); _vm->_graphics->_proportionalFont = false; uint16 _ax = _vm->_graphics->getStringWidth(v4C[_language]); _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 70, v4C[_language]); @@ -303,9 +303,8 @@ void _c_finito(void *parm) { strcpy(_location, "estgrotta.drki"); _engineFlags |= kEngineChangeLocation; - _vm->_graphics->freeCnv(&Graphics::_font); } else { - _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font); + _vm->_graphics->setFont("slidecnv"); _vm->_graphics->_proportionalFont = false; uint16 _ax = _vm->_graphics->getStringWidth(v8C[_language]); _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 70, v8C[_language]); @@ -320,7 +319,6 @@ void _c_finito(void *parm) { _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2); waitUntilLeftClick(); - _vm->_graphics->freeCnv(&Graphics::_font); _vm->_menu->selectCharacter(); } @@ -357,7 +355,7 @@ void _c_testResult(void *parm) { _vm->parseLocation("common"); _vm->_archive.close(); - _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font); + _vm->_graphics->setFont("slidecnv"); _vm->_graphics->_proportionalFont = false; uint16 _ax = _vm->_graphics->getStringWidth(_slideText[0]); @@ -368,8 +366,6 @@ void _c_testResult(void *parm) { _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack); _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2); - _vm->_graphics->freeCnv(&Graphics::_font); - return; } diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 7fc936fa7a..5ba9a28a8d 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -245,7 +245,7 @@ void runDialogue(SpeakData *data) { _vm->_graphics->loadExternalCnv(v20, &_characterFace); debugC(1, kDebugDialogue, "runDialogue: 1st character head loaded"); - _vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font); + _vm->_graphics->setFont("comiccnv"); Cnv v6E; StaticCnv v5C, v48; @@ -519,8 +519,6 @@ void runDialogue(SpeakData *data) { debugC(1, kDebugDialogue, "runDialogue: 2nd character head free'd"); } - _vm->_graphics->freeCnv(&Graphics::_font); - exitDialogue(); debugC(1, kDebugDialogue, "runDialogue: exit dialogue ok"); diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index decb3a1e7a..a75c76f786 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -180,7 +180,6 @@ void Graphics::palUnk0(byte *palette) { return; } - void Graphics::buildBWPalette(byte *palette) { for (uint16 i = 0; i < PALETTE_COLORS; i++) { @@ -797,6 +796,14 @@ void Graphics::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* } +void Graphics::setFont(const char* name) { + if (_font._array != NULL) + freeCnv(&_font); + + loadExternalCnv(name, &_font); +} + + // backups background mask // // @@ -1106,6 +1113,7 @@ void Graphics::freeCnv(Cnv *cnv) { memFree(cnv->_array[_si]); } memFree(cnv->_array); + cnv->_array = NULL; return; } @@ -1366,6 +1374,8 @@ Graphics::Graphics(Parallaction* vm) : initMouse( 0 ); + _font._array = NULL; + return; } @@ -1379,6 +1389,8 @@ Graphics::~Graphics() { memFree(_buffers[kBit2]); memFree(_buffers[kBit3]); + freeCnv(&_font); + return; } diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 70eefa9271..7f51cd34c7 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -140,11 +140,11 @@ public: void setMousePointer(int16 index); + void setFont(const char* name); public: static Point _labelPosition[2]; static bool _proportionalFont; - static Cnv _font; protected: Parallaction* _vm; @@ -154,6 +154,9 @@ protected: static byte _mouseArrow[256]; static StaticCnv _mouseComposedArrow; + static Cnv _font; + + protected: // // decompress a graphics block (size is *target* size) diff --git a/engines/parallaction/intro.cpp b/engines/parallaction/intro.cpp index 2338ced7a0..c91cc3b08e 100644 --- a/engines/parallaction/intro.cpp +++ b/engines/parallaction/intro.cpp @@ -132,7 +132,7 @@ void _c_startIntro(void *parm) { void _c_endIntro(void *parm) { - _vm->_graphics->loadExternalCnv("slidecnv", &_vm->_graphics->_font); + _vm->_graphics->setFont("slidecnv"); _vm->_graphics->_proportionalFont = false; uint16 _di; @@ -153,7 +153,6 @@ void _c_endIntro(void *parm) { } waitUntilLeftClick(); - _vm->_graphics->freeCnv(&Graphics::_font); _engineFlags &= ~kEngineMouse; _vm->_menu->selectCharacter(); diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index a3bb95a6dd..32fbd14d64 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -46,7 +46,7 @@ void Parallaction::parseLocation(const char *filename) { uint16 _si = 1; _vm->_graphics->_proportionalFont = false; - _vm->_graphics->loadExternalCnv("topazcnv", &Graphics::_font); + _vm->_graphics->setFont("topazcnv"); char archivefile[PATH_LEN]; @@ -189,7 +189,6 @@ void Parallaction::parseLocation(const char *filename) { } resolveLocationForwards(); - _vm->_graphics->freeCnv(&Graphics::_font); delete _locationScript; _locationScript = NULL; @@ -404,14 +403,13 @@ void Parallaction::changeLocation(char *location) { debugC(1, kDebugLocation, "changeLocation: new background set"); _vm->_graphics->_proportionalFont = false; - _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font); + _vm->_graphics->setFont("slidecnv"); uint16 _ax = strlen(_slideText[0]); _ax <<= 3; // text width uint16 _dx = (SCREEN_WIDTH - _ax) >> 1; // center text _vm->_graphics->displayString(_dx, 14, _slideText[0]); // displays text on screen - _vm->_graphics->freeCnv(&Graphics::_font); waitUntilLeftClick(); debugC(2, kDebugLocation, "changeLocation: intro text shown"); @@ -511,7 +509,7 @@ void Parallaction::doLocationEnterTransition() { jobEraseAnimations(NULL, NULL); jobDisplayAnimations(NULL, NULL); - _vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font); + _vm->_graphics->setFont("comiccnv"); _vm->_graphics->swapBuffers(); _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack); @@ -521,8 +519,6 @@ void Parallaction::doLocationEnterTransition() { _vm->_graphics->floodFill(1, 6, 6, 9 + v7C, 4 + v7A, Graphics::kBitFront); _vm->_graphics->displayWrappedString(_locationComment, 3, 5, 130, 0); - _vm->_graphics->freeCnv( &Graphics::_font ); - // FIXME: ??? #if 0 do { diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp index 37024392bd..8ae0e098ab 100644 --- a/engines/parallaction/menu.cpp +++ b/engines/parallaction/menu.cpp @@ -104,7 +104,7 @@ void Menu::start() { _vm->_archive.open("disk1"); _vm->_graphics->_proportionalFont = false; - _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font); + _vm->_graphics->setFont("slidecnv"); _vm->_graphics->Graphics::loadBackground("intro.slide", Graphics::kBitBack); _vm->_graphics->palUnk0(_palette); @@ -196,7 +196,6 @@ void Menu::newGame() { if (_mouseButtons != kMouseRightUp) return; // show intro - _vm->_graphics->freeCnv(&Graphics::_font); _vm->_archive.close(); selectCharacter(); @@ -280,7 +279,6 @@ uint16 Menu::selectGame() { if (_si == 0) return 0; // new game // load game - _vm->_graphics->freeCnv(&Graphics::_font); strcpy(_location, "fogne"); strcpy(_engine->_characterName, "dough"); @@ -316,7 +314,7 @@ void Menu::selectCharacter() { _vm->_midiPlayer->stop(); _vm->_graphics->_proportionalFont = false; - _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font); + _vm->_graphics->setFont("slidecnv"); _vm->_archive.open("disk1"); _vm->_graphics->loadBackground("password.slide", Graphics::kBitBack); @@ -416,7 +414,6 @@ void Menu::selectCharacter() { _vm->_archive.close(); memFree(v14._data0); - _vm->_graphics->freeCnv(&Graphics::_font); refreshInventory(_vm->_characterName); diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index 4bbb177f67..c4765ba812 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -389,7 +389,7 @@ void displayCharacterComment(ExamineData *data) { v3C._data1 = NULL; //_characterFace.field_8[0]; v3C._data2 = NULL; - _vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font); + _vm->_graphics->setFont("comiccnv"); _vm->_graphics->flatBlitCnv(&v3C, 190, 80, Graphics::kBitFront, v3C._data1); int16 v26, v28; @@ -397,8 +397,6 @@ void displayCharacterComment(ExamineData *data) { _vm->_graphics->drawBalloon(140, 10, v28, v26, 0); _vm->_graphics->displayWrappedString(data->_description, 140, 10, 130, 0); - _vm->_graphics->freeCnv(&Graphics::_font); - // printf("wait left"); waitUntilLeftClick(); @@ -450,13 +448,12 @@ void displayItemComment(ExamineData *data) { int16 v6A = 0, v6C = 0; - _vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font); + _vm->_graphics->setFont("comiccnv"); _vm->_graphics->getStringExtent(data->_description, 130, &v6C, &v6A); _vm->_graphics->drawBalloon(0, 90, v6C, v6A, 0); _vm->_graphics->flatBlitCnv(&cnv, 100, 152, Graphics::kBitFront, cnv._data1); _vm->_graphics->freeStaticCnv(&cnv); _vm->_graphics->displayWrappedString(data->_description, 0, 90, 130, 0); - _vm->_graphics->freeCnv(&Graphics::_font); jobEraseAnimations((void*)1, NULL); |