From 79229cafabbf7f61c9a1043ffac8c5aee58a73d2 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 6 May 2007 09:31:45 +0000 Subject: [PATCH] Some cheap cleanup. svn-id: r26757 --- engines/parallaction/callables.cpp | 32 ++++++++++-------------------- engines/parallaction/graphics.cpp | 5 +++++ engines/parallaction/graphics.h | 1 + engines/parallaction/intro.cpp | 8 ++------ engines/parallaction/location.cpp | 5 +---- engines/parallaction/menu.cpp | 15 ++++---------- 6 files changed, 24 insertions(+), 42 deletions(-) diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp index 87264f4a984..a9aaef88eae 100644 --- a/engines/parallaction/callables.cpp +++ b/engines/parallaction/callables.cpp @@ -247,7 +247,7 @@ void _c_endComment(void *param) { _vm->_gfx->floodFill(Gfx::kBitFront, r, 0); r.setWidth(w+3); - r.setHeight(w+4); + r.setHeight(h+3); r.moveTo(7, 7); _vm->_gfx->floodFill(Gfx::kBitFront, r, 1); @@ -367,14 +367,10 @@ void _c_finito(void *parm) { if (gameCompleted) { _vm->_gfx->setFont(kFontMenu); - uint16 _ax = _vm->_gfx->getStringWidth(v4C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 70, v4C[_language]); - _ax = _vm->_gfx->getStringWidth(v3C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 100, v3C[_language]); - _ax = _vm->_gfx->getStringWidth(v2C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 130, v2C[_language]); - _ax = _vm->_gfx->getStringWidth(v1C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 160, v1C[_language]); + _vm->_gfx->displayCenteredString(70, v4C[_language]); + _vm->_gfx->displayCenteredString(100, v3C[_language]); + _vm->_gfx->displayCenteredString(130, v2C[_language]); + _vm->_gfx->displayCenteredString(160, v1C[_language]); _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2); @@ -385,14 +381,10 @@ void _c_finito(void *parm) { _engineFlags |= kEngineChangeLocation; } else { _vm->_gfx->setFont(kFontMenu); - uint16 _ax = _vm->_gfx->getStringWidth(v8C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 70, v8C[_language]); - _ax = _vm->_gfx->getStringWidth(v7C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 100, v7C[_language]); - _ax = _vm->_gfx->getStringWidth(v6C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 130, v6C[_language]); - _ax = _vm->_gfx->getStringWidth(v5C[_language]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 160, v5C[_language]); + _vm->_gfx->displayCenteredString(70, v8C[_language]); + _vm->_gfx->displayCenteredString(100, v7C[_language]); + _vm->_gfx->displayCenteredString(130, v6C[_language]); + _vm->_gfx->displayCenteredString(160, v5C[_language]); _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2); @@ -437,10 +429,8 @@ void _c_testResult(void *parm) { _vm->_gfx->setFont(kFontMenu); - uint16 _ax = _vm->_gfx->getStringWidth(_slideText[0]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 38, _slideText[0]); - _ax = _vm->_gfx->getStringWidth(_slideText[1]); - _vm->_gfx->displayString((SCREEN_WIDTH - _ax)/2, 58, _slideText[1]); + _vm->_gfx->displayCenteredString(38, _slideText[0]); + _vm->_gfx->displayCenteredString(58, _slideText[1]); _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2); diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 073e05dbcd1..aa90403fcdf 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -598,6 +598,11 @@ void Gfx::displayString(uint16 x, uint16 y, const char *text) { _font->drawString(dst, SCREEN_WIDTH, text); } +void Gfx::displayCenteredString(uint16 y, const char *text) { + uint16 x = (SCREEN_WIDTH - getStringWidth(text)) / 2; + displayString(x, y, text); +} + void Gfx::displayBalloonString(uint16 x, uint16 y, const char *text, byte color) { assert(_font == _fonts[kFontDialogue]); diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 424a6d98dc1..c815f60d279 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -164,6 +164,7 @@ public: void drawBalloon(const Common::Rect& r, uint16 arg_8); void displayBalloonString(uint16 x, uint16 y, const char *text, byte color); void displayString(uint16 x, uint16 y, const char *text); + void displayCenteredString(uint16 y, const char *text); bool displayWrappedString(char *text, uint16 x, uint16 y, uint16 maxwidth, byte color); uint16 getStringWidth(const char *text); void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height); diff --git a/engines/parallaction/intro.cpp b/engines/parallaction/intro.cpp index 39d869aa16c..e782e174c8c 100644 --- a/engines/parallaction/intro.cpp +++ b/engines/parallaction/intro.cpp @@ -141,13 +141,9 @@ void _c_endIntro(void *parm) { _vm->_gfx->setFont(kFontMenu); - uint16 _di; for (uint16 _si = 0; _si < 7; _si++) { - _di = _vm->_gfx->getStringWidth(_credits[_si]._role); - _vm->_gfx->displayString((SCREEN_WIDTH - _di)/2, 80, _credits[_si]._role); - - _di = _vm->_gfx->getStringWidth(_credits[_si]._name); - _vm->_gfx->displayString((SCREEN_WIDTH - _di)/2, 100, _credits[_si]._name); + _vm->_gfx->displayCenteredString(80, _credits[_si]._role); + _vm->_gfx->displayCenteredString(100, _credits[_si]._name); _vm->_gfx->updateScreen(); diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index 3f65863a626..d2daeaaddf0 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -286,10 +286,7 @@ void Parallaction::showSlide(const char *name) { _gfx->setFont(kFontMenu); - uint16 _ax = strlen(_slideText[0]); - _ax <<= 3; // text width - uint16 _dx = (SCREEN_WIDTH - _ax) >> 1; // center text - _gfx->displayString(_dx, 14, _slideText[0]); // displays text on screen + _gfx->displayCenteredString(14, _slideText[0]); // displays text on screen _gfx->updateScreen(); waitUntilLeftClick(); diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp index 84f7570b947..5f804d59f41 100644 --- a/engines/parallaction/menu.cpp +++ b/engines/parallaction/menu.cpp @@ -148,17 +148,10 @@ void Menu::newGame() { _vm->_gfx->setPalette(_vm->_gfx->_palette); _vm->_gfx->swapBuffers(); - uint16 _ax = (SCREEN_WIDTH - _vm->_gfx->getStringWidth(v14[0])) / 2; - _vm->_gfx->displayString(_ax, 50, v14[0]); - - _ax = (SCREEN_WIDTH - _vm->_gfx->getStringWidth(v14[1])) / 2; - _vm->_gfx->displayString(_ax, 70, v14[1]); - - _ax = (SCREEN_WIDTH - _vm->_gfx->getStringWidth(v14[2])) / 2; - _vm->_gfx->displayString(_ax, 100, v14[2]); - - _ax = (SCREEN_WIDTH - _vm->_gfx->getStringWidth(v14[3])) / 2; - _vm->_gfx->displayString(_ax, 120, v14[3]); + _vm->_gfx->displayCenteredString(50, v14[0]); + _vm->_gfx->displayCenteredString(70, v14[1]); + _vm->_gfx->displayCenteredString(100, v14[2]); + _vm->_gfx->displayCenteredString(120, v14[3]); _vm->_gfx->updateScreen(); _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);