[Scummvm-cvs-logs] SF.net SVN: scummvm:[45072] scummvm/trunk/engines/sci/gui

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed Oct 14 14:39:39 CEST 2009


Revision: 45072
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45072&view=rev
Author:   m_kiewitz
Date:     2009-10-14 12:39:39 +0000 (Wed, 14 Oct 2009)

Log Message:
-----------
SCI/newgui: SciGuiTransitions now at least supports fadeIn/out

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui_palette.cpp
    scummvm/trunk/engines/sci/gui/gui_transitions.cpp
    scummvm/trunk/engines/sci/gui/gui_transitions.h

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-14 11:34:02 UTC (rev 45071)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-14 12:39:39 UTC (rev 45072)
@@ -254,7 +254,7 @@
 	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 @@
 	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 @@
 		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 @@
 			_gfx->FrameRect(rect);
 		}
 		rect.grow(1);
-		if (!_screen->_picNotValid)
+		if (_screen->_picNotValid == 0)
 			_gfx->BitsShow(rect);
 	} else {
 		_gfx->InvertRect(rect);
@@ -377,7 +377,7 @@
 		_gfx->SetFont(oldFontId);
 		rect.grow(1);
 	}
-	if (!_screen->_picNotValid)
+	if (_screen->_picNotValid == 0)
 		_gfx->BitsShow(rect);
 }
 
@@ -387,7 +387,7 @@
 		if (style & 0x20) {
 			_gfx->FrameRect(rect);
 		}
-		if (!_screen->_picNotValid)
+		if (_screen->_picNotValid == 0)
 			_gfx->BitsShow(rect);
 	} else {
 		_gfx->InvertRect(rect);
@@ -402,7 +402,7 @@
 		if (isAlias && (style & 8)) {
 			_gfx->FrameRect(rect);
 		}
-		if (!_screen->_picNotValid)
+		if (_screen->_picNotValid == 0)
 			_gfx->BitsShow(rect);
 	}
 }
@@ -505,10 +505,13 @@
 }
 
 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) {

Modified: scummvm/trunk/engines/sci/gui/gui_palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-14 11:34:02 UTC (rev 45071)
+++ scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-14 12:39:39 UTC (rev 45072)
@@ -191,7 +191,7 @@
 	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();
 	}
 }

Modified: scummvm/trunk/engines/sci/gui/gui_transitions.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_transitions.cpp	2009-10-14 11:34:02 UTC (rev 45071)
+++ scummvm/trunk/engines/sci/gui/gui_transitions.cpp	2009-10-14 12:39:39 UTC (rev 45072)
@@ -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::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

Modified: scummvm/trunk/engines/sci/gui/gui_transitions.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_transitions.h	2009-10-14 11:34:02 UTC (rev 45071)
+++ scummvm/trunk/engines/sci/gui/gui_transitions.h	2009-10-14 12:39:39 UTC (rev 45072)
@@ -30,6 +30,10 @@
 
 namespace Sci {
 
+enum {
+	SCI_TRANSITIONS_FADEPALETTE		= 10
+};
+
 class SciGuiScreen;
 class SciGuiTransitions {
 public:
@@ -41,12 +45,17 @@
 
 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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list