diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/gui/gui.cpp | 23 | ||||
-rw-r--r-- | engines/sci/gui/gui_palette.cpp | 2 | ||||
-rw-r--r-- | engines/sci/gui/gui_transitions.cpp | 62 | ||||
-rw-r--r-- | engines/sci/gui/gui_transitions.h | 9 |
4 files changed, 81 insertions, 15 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index f5cbf6b9ff..f31da098cb 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -254,7 +254,7 @@ void SciGui::display(const char *text, int argc, reg_t *argv) { if (bgcolor != -1) _gfx->FillRect(rect, SCI_SCREEN_MASK_VISUAL, bgcolor, 0, 0); _gfx->TextBox(text, 0, rect, align, -1); - if (!_screen->_picNotValid && bRedraw) + if (_screen->_picNotValid == 0 && bRedraw) _gfx->BitsShow(rect); // restoring port and cursor pos GuiPort *currport = _gfx->GetPort(); @@ -304,9 +304,9 @@ void SciGui::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirror GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind); if (_windowMgr->isFrontWindow(_windowMgr->_picWind)) { + _screen->_picNotValid = 1; _gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo); _transitions->setup(animationNr); - _screen->_picNotValid = 1; } else { _windowMgr->BeginUpdate(_windowMgr->_picWind); _gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo); @@ -332,7 +332,7 @@ void SciGui::drawControlButton(Common::Rect rect, reg_t obj, const char *text, i rect.grow(1); if (style & 8) // selected _gfx->FrameRect(rect); - if (!_screen->_picNotValid) { + if (_screen->_picNotValid == 0) { rect.grow(1); _gfx->BitsShow(rect); } @@ -352,7 +352,7 @@ void SciGui::drawControlText(Common::Rect rect, reg_t obj, const char *text, int _gfx->FrameRect(rect); } rect.grow(1); - if (!_screen->_picNotValid) + if (_screen->_picNotValid == 0) _gfx->BitsShow(rect); } else { _gfx->InvertRect(rect); @@ -377,7 +377,7 @@ void SciGui::drawControlTextEdit(Common::Rect rect, reg_t obj, const char *text, _gfx->SetFont(oldFontId); rect.grow(1); } - if (!_screen->_picNotValid) + if (_screen->_picNotValid == 0) _gfx->BitsShow(rect); } @@ -387,7 +387,7 @@ void SciGui::drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, if (style & 0x20) { _gfx->FrameRect(rect); } - if (!_screen->_picNotValid) + if (_screen->_picNotValid == 0) _gfx->BitsShow(rect); } else { _gfx->InvertRect(rect); @@ -402,7 +402,7 @@ void SciGui::drawControlList(Common::Rect rect, reg_t obj, int16 maxChars, int16 if (isAlias && (style & 8)) { _gfx->FrameRect(rect); } - if (!_screen->_picNotValid) + if (_screen->_picNotValid == 0) _gfx->BitsShow(rect); } } @@ -505,10 +505,13 @@ uint16 SciGui::onControl(byte screenMask, Common::Rect rect) { } void SciGui::animateShowPic() { - GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind); + GuiPort *picPort = _windowMgr->_picWind; + Common::Rect picRect = picPort->rect; - _transitions->doit(_gfx->GetPort()->rect); - _gfx->SetPort(oldPort); + // Adjust picRect to become relative to screen + picRect.top += picPort->top; picRect.bottom += picPort->top; + picRect.left += picPort->left; picRect.right += picPort->left; + _transitions->doit(picRect); } void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) { diff --git a/engines/sci/gui/gui_palette.cpp b/engines/sci/gui/gui_palette.cpp index 32c29f16ea..2e2ae650ae 100644 --- a/engines/sci/gui/gui_palette.cpp +++ b/engines/sci/gui/gui_palette.cpp @@ -191,7 +191,7 @@ void SciGuiPalette::set(GuiPalette *sciPal, int16 flag) { if (flag == 2 || sciPal->timestamp != systime) { merge(sciPal, &_sysPalette, flag); sciPal->timestamp = _sysPalette.timestamp; - if (!_screen->_picNotValid && systime != _sysPalette.timestamp) + if (_screen->_picNotValid == 0 && systime != _sysPalette.timestamp) setOnScreen(); } } diff --git a/engines/sci/gui/gui_transitions.cpp b/engines/sci/gui/gui_transitions.cpp index 9983982415..7ee269f9fa 100644 --- a/engines/sci/gui/gui_transitions.cpp +++ b/engines/sci/gui/gui_transitions.cpp @@ -30,6 +30,7 @@ #include "sci/sci.h" #include "sci/engine/state.h" #include "sci/tools.h" +#include "sci/gui/gui.h" #include "sci/gui/gui_screen.h" #include "sci/gui/gui_palette.h" #include "sci/gui/gui_transitions.h" @@ -52,11 +53,64 @@ void SciGuiTransitions::setup(int16 number) { } void SciGuiTransitions::doit(Common::Rect picRect) { - // TODO: Implement animations - warning("SciGuiTransitions: animation %d not implemented", _number); - _palette->setOnScreen(); - _screen->copyToScreen(); + _picRect = picRect; + + switch (_number) { + case SCI_TRANSITIONS_FADEPALETTE: + fadeOut(); + setNewScreen(); + fadeIn(); + break; + + default: + warning("SciGuiTransitions: %d not implemented", _number); + setNewPalette(); + setNewScreen(); + } _screen->_picNotValid = 0; } +void SciGuiTransitions::setNewPalette() { + _palette->setOnScreen(); +} + +void SciGuiTransitions::setNewScreen() { + _screen->copyRectToScreen(_picRect); + g_system->updateScreen(); +} + +void SciGuiTransitions::fadeOut() { + byte oldPalette[4 * 256], workPalette[4 * 256]; + int16 stepNr, colorNr; + + g_system->grabPalette(oldPalette, 0, 256); + + for (stepNr = 100; stepNr >= 0; stepNr -= 5) { + for (colorNr = 0; colorNr < 256; colorNr++){ + workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4] * stepNr / 100; + workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1] * stepNr / 100; + workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2] * stepNr / 100; + } + g_system->setPalette(workPalette, 0, 256); + _gui->wait(1); + } +} + +void SciGuiTransitions::fadeIn() { + byte workPalette[4 * 256]; + GuiPalette *newPalette = &_palette->_sysPalette; + int16 stepNr, colorNr; + + for (stepNr = 0; stepNr <= 100; stepNr += 5) { + for (colorNr = 0; colorNr < 256; colorNr++){ + workPalette[colorNr * 4 + 0] = newPalette->colors[colorNr].r * stepNr / 100; + workPalette[colorNr * 4 + 1] = newPalette->colors[colorNr].g * stepNr / 100; + workPalette[colorNr * 4 + 2] = newPalette->colors[colorNr].b * stepNr / 100; + workPalette[colorNr * 4 + 3] = 100; + } + g_system->setPalette(workPalette, 0, 256); + _gui->wait(1); + } +} + } // End of namespace Sci diff --git a/engines/sci/gui/gui_transitions.h b/engines/sci/gui/gui_transitions.h index b2b9d183ea..10090ada3c 100644 --- a/engines/sci/gui/gui_transitions.h +++ b/engines/sci/gui/gui_transitions.h @@ -30,6 +30,10 @@ namespace Sci { +enum { + SCI_TRANSITIONS_FADEPALETTE = 10 +}; + class SciGuiScreen; class SciGuiTransitions { public: @@ -41,12 +45,17 @@ public: private: void init(void); + void SciGuiTransitions::setNewPalette(); + void SciGuiTransitions::setNewScreen(); + void SciGuiTransitions::fadeOut(); + void SciGuiTransitions::fadeIn(); SciGui *_gui; SciGuiScreen *_screen; SciGuiPalette *_palette; int16 _number; + Common::Rect _picRect; }; } // End of namespace Sci |