From 6ed4beb1bfc1ffe7a2ca9f99dbd63eaf9c245bea Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Thu, 31 Jul 2008 12:50:43 +0000 Subject: Made changing of background more flexible, in that the engine can now configure its BackgroundInfo before passing it to Gfx. svn-id: r33469 --- engines/parallaction/graphics.cpp | 10 ++-------- engines/parallaction/graphics.h | 2 +- engines/parallaction/gui_br.cpp | 11 +++++------ engines/parallaction/parallaction.cpp | 5 ++++- engines/parallaction/parallaction.h | 2 +- engines/parallaction/parallaction_ns.cpp | 10 ++++++++-- engines/parallaction/parser_br.cpp | 3 +-- 7 files changed, 22 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 7aa284e82c..c19d6ae5e5 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -831,15 +831,11 @@ void Gfx::freeItems() { _numItems = 0; } - -void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) { - +void Gfx::setBackground(uint type, BackgroundInfo *info) { delete _backgroundInfo; - _backgroundInfo = new BackgroundInfo; + _backgroundInfo = info; if (type == kBackgroundLocation) { - _disk->loadScenery(*_backgroundInfo, name, mask, path); - // The PC version of BRA needs the entries 20-31 of the palette to be constant, but // the background resource files are screwed up. The right colors come from an unused // bitmap (pointer.bmp). Nothing is known about the Amiga version so far. @@ -854,12 +850,10 @@ void Gfx::setBackground(uint type, const char* name, const char* mask, const cha setPalette(_backgroundInfo->palette); _palette.clone(_backgroundInfo->palette); } else { - _disk->loadSlide(*_backgroundInfo, name); for (uint i = 0; i < 6; i++) _backgroundInfo->ranges[i]._flags = 0; // disable palette cycling for slides setPalette(_backgroundInfo->palette); } - } } // namespace Parallaction diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 71eaa3724f..23b4569c6a 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -512,7 +512,7 @@ public: // background surface BackgroundInfo *_backgroundInfo; - void setBackground(uint type, const char* name, const char* mask, const char* path); + void setBackground(uint type, BackgroundInfo *info); void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false); void grabBackground(const Common::Rect& r, Graphics::Surface &dst); void fillBackground(const Common::Rect& r, byte color); diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp index 89226bc9ac..3315433762 100644 --- a/engines/parallaction/gui_br.cpp +++ b/engines/parallaction/gui_br.cpp @@ -72,9 +72,7 @@ public: virtual void enter() { _vm->_gfx->clearScreen(); - _vm->_gfx->setBackground(kBackgroundSlide, _slideName.c_str(), 0, 0); - _vm->_gfx->_backgroundInfo->x = (_vm->_screenWidth - _vm->_gfx->_backgroundInfo->width) >> 1; - _vm->_gfx->_backgroundInfo->y = (_vm->_screenHeight - _vm->_gfx->_backgroundInfo->height) >> 1; + _vm->showSlide(_slideName.c_str(), CENTER_LABEL_HORIZONTAL, CENTER_LABEL_VERTICAL); _vm->_input->setMouseState(MOUSE_DISABLED); _startTime = g_system->getMillis(); @@ -215,11 +213,12 @@ public: virtual void enter() { _vm->_gfx->clearScreen(); - _vm->_gfx->setBackground(kBackgroundSlide, "tbra", 0, 0); + int x = 0, y = 0; if (_vm->getPlatform() == Common::kPlatformPC) { - _vm->_gfx->_backgroundInfo->x = 20; - _vm->_gfx->_backgroundInfo->y = 50; + x = 20; + y = 50; } + _vm->showSlide("tbra", x, y); // TODO: load progress from savefile int progress = 3; diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index e13d2f9aa4..e4a5f55894 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -289,7 +289,10 @@ void Parallaction::freeBackground() { void Parallaction::setBackground(const char* name, const char* mask, const char* path) { - _gfx->setBackground(kBackgroundLocation, name, mask, path); + BackgroundInfo *info = new BackgroundInfo; + _disk->loadScenery(*info, name, mask, path); + + _gfx->setBackground(kBackgroundLocation, info); _pathBuffer = &_gfx->_backgroundInfo->path; return; diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index d8e4da5baf..e5c5221414 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -487,7 +487,7 @@ public: bool saveGame(); void switchBackground(const char* background, const char* mask); - void showSlide(const char *name); + void showSlide(const char *name, int x = 0, int y = 0); void setArrowCursor(); // TODO: this should be private!!!!!!! diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 851fe38138..e81492e655 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -253,8 +253,14 @@ void Parallaction_ns::switchBackground(const char* background, const char* mask) } -void Parallaction_ns::showSlide(const char *name) { - _gfx->setBackground(kBackgroundSlide, name, 0, 0); +void Parallaction_ns::showSlide(const char *name, int x, int y) { + BackgroundInfo *info = new BackgroundInfo; + _disk->loadSlide(*info, name); + + info->x = (x == CENTER_LABEL_HORIZONTAL) ? ((_vm->_screenWidth - info->width) >> 1) : x; + info->y = (y == CENTER_LABEL_VERTICAL) ? ((_vm->_screenHeight - info->height) >> 1) : y; + + _gfx->setBackground(kBackgroundSlide, info); } void Parallaction_ns::runPendingZones() { diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index df992b9a20..ff7a34f95f 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -1178,8 +1178,7 @@ void LocationParser_br::parse(Script *script) { LocationParser_ns::parse(script); - _vm->_gfx->setBackground(kBackgroundLocation, ctxt.bgName, ctxt.maskName, ctxt.pathName); - _vm->_pathBuffer = &_vm->_gfx->_backgroundInfo->path; + _vm->setBackground(ctxt.bgName, ctxt.maskName, ctxt.pathName); if (ctxt.characterName) { _vm->changeCharacter(ctxt.characterName); -- cgit v1.2.3