SCI/newgui: SciGuiTransitions now also supports scrolling up (lsl6 intro)

svn-id: r45084
This commit is contained in:
Martin Kiewitz 2009-10-14 15:43:58 +00:00
parent 1b3a5eaff6
commit e074792616
5 changed files with 69 additions and 5 deletions

View File

@ -509,8 +509,9 @@ void SciGui::animateShowPic() {
Common::Rect picRect = picPort->rect;
// Adjust picRect to become relative to screen
picRect.top += picPort->top; picRect.bottom += picPort->top;
picRect.left += picPort->left; picRect.right += picPort->left;
picRect.translate(picPort->left, picPort->top);
//picRect.top += picPort->top; picRect.bottom += picPort->top;
//picRect.left += picPort->left; picRect.right += picPort->left;
_transitions->doit(picRect);
}

View File

@ -25,6 +25,7 @@
#include "common/timer.h"
#include "common/util.h"
#include "graphics/surface.h"
#include "sci/sci.h"
#include "sci/engine/state.h"
@ -66,10 +67,21 @@ void SciGuiScreen::copyToScreen() {
g_system->copyRectToScreen(_activeScreen, _displayWidth, 0, 0, _displayWidth, _displayHeight);
}
void SciGuiScreen::copyFromScreen(byte *buffer) {
Graphics::Surface *screen;
screen = g_system->lockScreen();
memcpy(buffer, screen->pixels, _displayWidth * _displayHeight);
g_system->unlockScreen();
}
void SciGuiScreen::copyRectToScreen(const Common::Rect &rect) {
g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, rect.left, rect.top, rect.width(), rect.height());
}
void SciGuiScreen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) {
g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, x, y, rect.width(), rect.height());
}
byte SciGuiScreen::getDrawingMask(byte color, byte prio, byte control) {
byte flag = 0;
if (color != 255)

View File

@ -46,7 +46,9 @@ public:
~SciGuiScreen();
void copyToScreen();
void copyFromScreen(byte *buffer);
void copyRectToScreen(const Common::Rect &rect);
void copyRectToScreen(const Common::Rect &rect, int16 x, int16 y);
byte getDrawingMask(byte color, byte prio, byte control);
void putPixel(int x, int y, byte drawMask, byte color, byte prio, byte control);

View File

@ -43,9 +43,11 @@ SciGuiTransitions::SciGuiTransitions(SciGui *gui, SciGuiScreen *screen, SciGuiPa
}
SciGuiTransitions::~SciGuiTransitions() {
delete[] _oldScreen;
}
void SciGuiTransitions::init() {
_oldScreen = new byte[_screen->_displayHeight * _screen->_displayWidth];
}
void SciGuiTransitions::setup(int16 number) {
@ -70,6 +72,10 @@ void SciGuiTransitions::doit(Common::Rect picRect) {
fadeOut(); setNewScreen(); fadeIn();
break;
case SCI_TRANSITIONS_VGA_SCROLLUP:
scroll(SCI_TRANSITIONS_SCROLL_UP);
break;
default:
warning("SciGuiTransitions: VGA-%d not implemented", _number);
setNewPalette(); setNewScreen();
@ -142,7 +148,7 @@ void SciGuiTransitions::fadeIn() {
}
}
// pixelates the new picture over the old one
// pixelates the new picture over the old one - works against the whole screen
void SciGuiTransitions::pixelation () {
uint16 mask = 0x40, stepNr = 0;
Common::Rect pixelRect;
@ -162,7 +168,7 @@ void SciGuiTransitions::pixelation () {
} while (mask != 0x40);
}
// like pixelation but uses 8x8 blocks
// like pixelation but uses 8x8 blocks - works against the whole screen
void SciGuiTransitions::blocks() {
uint16 mask = 0x40, stepNr = 0;
Common::Rect blockRect;
@ -182,4 +188,39 @@ void SciGuiTransitions::blocks() {
} while (mask != 0x40);
}
// scroll old screen (up/down/left/right) and insert new screen that way - works on _picRect area
void SciGuiTransitions::scroll(int16 direction) {
int16 screenWidth, screenHeight;
int16 oldWidth, oldHeight;
int16 newWidth, newHeight;
byte *oldScreenPtr;
int16 x, y;
Common::Rect newScreenRect = _picRect;
_screen->copyFromScreen(_oldScreen);
screenWidth = _screen->_displayWidth; screenHeight = _screen->_displayHeight;
x = _picRect.left; y = _picRect.top;
oldWidth = _picRect.width(); oldHeight = _picRect.height();
newWidth = 0; newHeight = 0;
oldScreenPtr = _oldScreen + _picRect.left + _picRect.top * screenWidth;
switch (direction) {
case SCI_TRANSITIONS_SCROLL_UP:
newScreenRect.bottom = newScreenRect.top;
y += oldHeight;
while (oldHeight > 0) {
oldScreenPtr += screenWidth; oldHeight--;
if (oldHeight)
g_system->copyRectToScreen(oldScreenPtr, _screen->_displayWidth, _picRect.left, _picRect.top, oldWidth, oldHeight);
newScreenRect.bottom++; y--;
_screen->copyRectToScreen(newScreenRect, x, y);
g_system->updateScreen();
g_system->delayMillis(3);
}
break;
}
}
} // End of namespace Sci

View File

@ -39,7 +39,13 @@ enum {
enum {
SCI_TRANSITIONS_VGA_BLOCKS = 8,
SCI_TRANSITIONS_VGA_PIXELATION = 9,
SCI_TRANSITIONS_VGA_FADEPALETTE = 10
SCI_TRANSITIONS_VGA_FADEPALETTE = 10,
SCI_TRANSITIONS_VGA_SCROLLUP = 13,
SCI_TRANSITIONS_VGA_SCROLLDOWN = 14
};
enum {
SCI_TRANSITIONS_SCROLL_UP = 1
};
class SciGuiScreen;
@ -59,6 +65,7 @@ private:
void fadeIn();
void pixelation();
void blocks();
void scroll(int16 direction);
SciGui *_gui;
SciGuiScreen *_screen;
@ -67,6 +74,7 @@ private:
bool _isVGA;
int16 _number;
Common::Rect _picRect;
byte *_oldScreen; // buffer for saving current active screen data to, has dimenions of _screen->_displayScreen
};
} // End of namespace Sci