Made changing of background more flexible, in that the engine can now configure its BackgroundInfo before passing it to Gfx.

svn-id: r33469
This commit is contained in:
Nicola Mettifogo 2008-07-31 12:50:43 +00:00
parent 591973c827
commit 6ed4beb1bf
7 changed files with 22 additions and 21 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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!!!!!!!

View File

@ -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() {

View File

@ -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);