aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-13 15:28:27 +0000
committerMartin Kiewitz2009-10-13 15:28:27 +0000
commit050f3626544f3c8217a0cec701fd6fb68940ada3 (patch)
treefd0a8b484ddeb50016200db63d4d961dae700399 /engines/sci
parent099c073605952c7c530d009a6c7cb4f988616f73 (diff)
downloadscummvm-rg350-050f3626544f3c8217a0cec701fd6fb68940ada3.tar.gz
scummvm-rg350-050f3626544f3c8217a0cec701fd6fb68940ada3.tar.bz2
scummvm-rg350-050f3626544f3c8217a0cec701fd6fb68940ada3.zip
SCI/newgui: SciGuiAnimate class created
svn-id: r45019
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/gui/gui.cpp30
-rw-r--r--engines/sci/gui/gui.h2
-rw-r--r--engines/sci/gui/gui_animate.cpp482
-rw-r--r--engines/sci/gui/gui_animate.h84
-rw-r--r--engines/sci/gui/gui_gfx.cpp436
-rw-r--r--engines/sci/gui/gui_gfx.h17
-rw-r--r--engines/sci/gui/gui_windowmgr.cpp7
-rw-r--r--engines/sci/gui/gui_windowmgr.h3
8 files changed, 592 insertions, 469 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index 2097fe0e2c..17caa8b89c 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -36,6 +36,7 @@
#include "sci/gui/gui_cursor.h"
#include "sci/gui/gui_gfx.h"
#include "sci/gui/gui_windowmgr.h"
+#include "sci/gui/gui_animate.h"
#include "sci/gui/gui_view.h"
#include "sci/gfx/operations.h"
@@ -53,7 +54,8 @@ SciGui::SciGui(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette,
: _s(state), _screen(screen), _palette(palette), _cursor(cursor) {
_gfx = new SciGuiGfx(_s, _screen, _palette);
- _windowMgr = new SciGuiWindowMgr(_screen, _gfx);
+ _animate = new SciGuiAnimate(_s, _gfx, _screen, _palette);
+ _windowMgr = new SciGuiWindowMgr(_screen, _gfx, _animate);
// _gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes
}
@@ -437,7 +439,7 @@ void SciGui::graphUpdateBox(Common::Rect rect) {
}
void SciGui::graphRedrawBox(Common::Rect rect) {
- _gfx->ReAnimate(rect);
+ _animate->reAnimate(rect);
}
int16 SciGui::picNotValid(int16 newPicNotValid) {
@@ -496,7 +498,7 @@ void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
byte old_picNotValid = _screen->_picNotValid;
if (listReference.isNull()) {
- _gfx->AnimateDisposeLastCast();
+ _animate->disposeLastCast();
if (_screen->_picNotValid)
_gfx->ShowPic();
return;
@@ -507,28 +509,28 @@ void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
error("kAnimate called with non-list as parameter");
if (cycle)
- _gfx->AnimateInvoke(list, argc, argv);
+ _animate->invoke(list, argc, argv);
GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind);
- _gfx->AnimateDisposeLastCast();
+ _animate->disposeLastCast();
- _gfx->AnimateMakeSortedList(list);
- _gfx->AnimateFill(old_picNotValid);
+ _animate->makeSortedList(list);
+ _animate->fill(old_picNotValid);
if (old_picNotValid) {
_windowMgr->BeginUpdate(_windowMgr->_picWind);
- _gfx->AnimateUpdate();
+ _animate->update();
_windowMgr->EndUpdate(_windowMgr->_picWind);
}
- _gfx->AnimateDrawCels();
+ _animate->drawCels();
if (_screen->_picNotValid) {
_gfx->ShowPic();
}
- _gfx->AnimateUpdateScreen(old_picNotValid);
- _gfx->AnimateRestoreAndDelete(argc, argv);
+ _animate->updateScreen(old_picNotValid);
+ _animate->restoreAndDelete(argc, argv);
_gfx->SetPort(oldPort);
}
@@ -542,15 +544,15 @@ void SciGui::addToPicList(reg_t listReference, int argc, reg_t *argv) {
if (!list)
error("kAddToPic called with non-list as parameter");
- _gfx->AnimateMakeSortedList(list);
- _gfx->AddToPicDrawCels(list);
+ _animate->makeSortedList(list);
+ _animate->addToPicDrawCels(list);
_screen->_picNotValid = 2;
}
void SciGui::addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
_gfx->SetPort((GuiPort *)_windowMgr->_picWind);
- _gfx->AddToPicDrawView(viewId, loopNo, celNo, leftPos, topPos, priority, control);
+ _animate->addToPicDrawView(viewId, loopNo, celNo, leftPos, topPos, priority, control);
}
void SciGui::setNowSeen(reg_t objectReference) {
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index 59c19fcc4c..b2b0ea0cbb 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -36,6 +36,7 @@ class SciGuiCursor;
class SciGuiGfx;
class SciGuiresources;
class SciGuiWindowMgr;
+class SciGuiAnimate;
class SciGui32; // for debug purposes
class SciGui {
@@ -121,6 +122,7 @@ private:
SciGuiGfx *_gfx;
SciGuiresources *_resources;
SciGuiWindowMgr *_windowMgr;
+ SciGuiAnimate *_animate;
// SciGui32 *_gui32; // for debug purposes
};
diff --git a/engines/sci/gui/gui_animate.cpp b/engines/sci/gui/gui_animate.cpp
new file mode 100644
index 0000000000..77d06c0372
--- /dev/null
+++ b/engines/sci/gui/gui_animate.cpp
@@ -0,0 +1,482 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/util.h"
+#include "common/stack.h"
+#include "graphics/primitives.h"
+
+#include "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/tools.h"
+#include "sci/gui/gui_gfx.h"
+#include "sci/gui/gui_view.h"
+#include "sci/gui/gui_screen.h"
+#include "sci/gui/gui_animate.h"
+
+namespace Sci {
+
+SciGuiAnimate::SciGuiAnimate(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *screen, SciGuiPalette *palette)
+ : _s(state), _gfx(gfx), _screen(screen), _palette(palette) {
+ init();
+}
+
+SciGuiAnimate::~SciGuiAnimate() {
+}
+
+void SciGuiAnimate::init() {
+ _listData = NULL;
+ _listSize = 0;
+}
+
+void SciGuiAnimate::disposeLastCast() {
+ // FIXME
+ //if (!_lastCast->first.isNull())
+ //_lastCast->DeleteList();
+}
+
+void SciGuiAnimate::invoke(List *list, int argc, reg_t *argv) {
+ SegManager *segMan = _s->_segMan;
+ reg_t curAddress = list->first;
+ Node *curNode = _s->_segMan->lookupNode(curAddress);
+ reg_t curObject;
+ uint16 signal;
+
+ while (curNode) {
+ curObject = curNode->value;
+ signal = GET_SEL32V(curObject, signal);
+ if (!(signal & SCI_ANIMATE_SIGNAL_FROZEN)) {
+ // Call .doit method of that object
+ invoke_selector(_s, curObject, _s->_kernel->_selectorCache.doit, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
+ // Lookup node again, since the nodetable it was in may have been reallocated
+ curNode = _s->_segMan->lookupNode(curAddress);
+ }
+ curAddress = curNode->succ;
+ curNode = _s->_segMan->lookupNode(curAddress);
+ }
+}
+
+bool sortHelper(const GuiAnimateEntry* entry1, const GuiAnimateEntry* entry2) {
+ return (entry1->y == entry2->y) ? (entry1->z < entry2->z) : (entry1->y < entry2->y);
+}
+
+void SciGuiAnimate::makeSortedList(List *list) {
+ SegManager *segMan = _s->_segMan;
+ reg_t curAddress = list->first;
+ Node *curNode = _s->_segMan->lookupNode(curAddress);
+ reg_t curObject;
+ GuiAnimateEntry *listEntry;
+ int16 listNr, listCount = 0;
+
+ // Count the list entries
+ while (curNode) {
+ listCount++;
+ curAddress = curNode->succ;
+ curNode = _s->_segMan->lookupNode(curAddress);
+ }
+
+ _list.clear();
+
+ // No entries -> exit immediately
+ if (listCount == 0)
+ return;
+
+ // Adjust list size, if needed
+ if ((_listData == NULL) || (_listSize < listCount)) {
+ if (_listData)
+ free(_listData);
+ _listData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
+ if (!_listData)
+ error("Could not allocate memory for _animateList");
+ _listSize = listCount;
+ }
+
+ // Fill the list
+ curAddress = list->first;
+ curNode = _s->_segMan->lookupNode(curAddress);
+ listEntry = _listData;
+ for (listNr = 0; listNr < listCount; listNr++) {
+ curObject = curNode->value;
+ listEntry->object = curObject;
+
+ // Get data from current object
+ listEntry->viewId = GET_SEL32V(curObject, view);
+ listEntry->loopNo = GET_SEL32V(curObject, loop);
+ listEntry->celNo = GET_SEL32V(curObject, cel);
+ listEntry->paletteNo = GET_SEL32V(curObject, palette);
+ listEntry->x = GET_SEL32V(curObject, x);
+ listEntry->y = GET_SEL32V(curObject, y);
+ listEntry->z = GET_SEL32V(curObject, z);
+ listEntry->priority = GET_SEL32V(curObject, priority);
+ listEntry->signal = GET_SEL32V(curObject, signal);
+ // listEntry->celRect is filled in AnimateFill()
+ listEntry->showBitsFlag = false;
+
+ _list.push_back(listEntry);
+
+ listEntry++;
+ curAddress = curNode->succ;
+ curNode = _s->_segMan->lookupNode(curAddress);
+ }
+
+ // Now sort the list according y and z (descending)
+ GuiAnimateList::iterator listBegin = _list.begin();
+ GuiAnimateList::iterator listEnd = _list.end();
+
+ Common::sort(_list.begin(), _list.end(), sortHelper);
+}
+
+void SciGuiAnimate::fill(byte &old_picNotValid) {
+ SegManager *segMan = _s->_segMan;
+ reg_t curObject;
+ GuiAnimateEntry *listEntry;
+ uint16 signal;
+ SciGuiView *view = NULL;
+ GuiAnimateList::iterator listIterator;
+ GuiAnimateList::iterator listEnd = _list.end();
+
+ listIterator = _list.begin();
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+
+ // Get the corresponding view
+ view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
+
+ // adjust loop and cel, if any of those is invalid
+ if (listEntry->loopNo >= view->getLoopCount()) {
+ listEntry->loopNo = 0;
+ PUT_SEL32V(curObject, loop, listEntry->loopNo);
+ }
+ if (listEntry->celNo >= view->getCelCount(listEntry->loopNo)) {
+ listEntry->celNo = 0;
+ PUT_SEL32V(curObject, cel, listEntry->celNo);
+ }
+
+ // Create rect according to coordinates and given cel
+ view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
+ PUT_SEL32V(curObject, nsLeft, listEntry->celRect.left);
+ PUT_SEL32V(curObject, nsTop, listEntry->celRect.top);
+ PUT_SEL32V(curObject, nsRight, listEntry->celRect.right);
+ PUT_SEL32V(curObject, nsBottom, listEntry->celRect.bottom);
+
+ signal = listEntry->signal;
+
+ // Calculate current priority according to y-coordinate
+ if (!(signal & SCI_ANIMATE_SIGNAL_FIXEDPRIORITY)) {
+ listEntry->priority = _gfx->CoordinateToPriority(listEntry->y);
+ PUT_SEL32V(curObject, priority, listEntry->priority);
+ }
+
+ if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
+ if (signal & (SCI_ANIMATE_SIGNAL_FORCEUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED)
+ || (signal & SCI_ANIMATE_SIGNAL_HIDDEN && !(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW))
+ || (!(signal & SCI_ANIMATE_SIGNAL_HIDDEN) && signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)
+ || (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))
+ old_picNotValid++;
+ signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE;
+ } else {
+ if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE || signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE)
+ old_picNotValid++;
+ signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
+ }
+ listEntry->signal = signal;
+
+ listIterator++;
+ }
+}
+
+void SciGuiAnimate::update() {
+ SegManager *segMan = _s->_segMan;
+ reg_t curObject;
+ GuiAnimateEntry *listEntry;
+ uint16 signal;
+ reg_t bitsHandle;
+ Common::Rect rect;
+ GuiAnimateList::iterator listIterator;
+ GuiAnimateList::iterator listBegin = _list.begin();
+ GuiAnimateList::iterator listEnd = _list.end();
+
+ // Remove all no-update cels, if requested
+ listIterator = _list.reverse_begin();
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+ signal = listEntry->signal;
+
+ if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
+ if (!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)) {
+ bitsHandle = GET_SEL32(curObject, underBits);
+ if (_screen->_picNotValid != 1) {
+ _gfx->BitsRestore(bitsHandle);
+ listEntry->showBitsFlag = true;
+ } else {
+ _gfx->BitsFree(bitsHandle);
+ }
+ PUT_SEL32V(curObject, underBits, 0);
+ }
+ signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
+ signal &= signal & SCI_ANIMATE_SIGNAL_VIEWUPDATED ? 0xFFFF ^ (SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE) : 0xFFFF;
+ } else if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE) {
+ signal = (signal & (0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE)) | SCI_ANIMATE_SIGNAL_NOUPDATE;
+ }
+ listEntry->signal = signal;
+ listIterator--;
+ }
+
+ // Draw always-update cels
+ listIterator = listBegin;
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+ signal = listEntry->signal;
+
+ if (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE) {
+ // draw corresponding cel
+ _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+ listEntry->showBitsFlag = true;
+
+ signal &= 0xFFFF ^ (SCI_ANIMATE_SIGNAL_STOPUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_FORCEUPDATE);
+ if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+ rect = listEntry->celRect;
+ rect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
+ _gfx->FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+ }
+ listEntry->signal = signal;
+ }
+ listIterator++;
+ }
+
+ // Saving background for all NoUpdate-cels
+ listIterator = listBegin;
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+ signal = listEntry->signal;
+
+ if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
+ if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
+ signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+ } else {
+ signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+ if (signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR)
+ bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
+ else
+ bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
+ PUT_SEL32(curObject, underBits, bitsHandle);
+ }
+ listEntry->signal = signal;
+ }
+ listIterator++;
+ }
+
+ // Draw NoUpdate cels
+ listIterator = listBegin;
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+ signal = listEntry->signal;
+
+ if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE && !(signal & SCI_ANIMATE_SIGNAL_HIDDEN)) {
+ // draw corresponding cel
+ _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+ listEntry->showBitsFlag = true;
+
+ if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+ rect = listEntry->celRect;
+ rect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
+ _gfx->FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+ }
+ }
+ listIterator++;
+ }
+}
+
+void SciGuiAnimate::drawCels() {
+ SegManager *segMan = _s->_segMan;
+ reg_t curObject;
+ GuiAnimateEntry *listEntry;
+ uint16 signal;
+ reg_t bitsHandle;
+ GuiAnimateList::iterator listIterator;
+ GuiAnimateList::iterator listEnd = _list.end();
+
+ listIterator = _list.begin();
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+ signal = listEntry->signal;
+
+ if (!(signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_HIDDEN | SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))) {
+ // Save background
+ bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
+ PUT_SEL32(curObject, underBits, bitsHandle);
+
+ // draw corresponding cel
+ _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+ listEntry->showBitsFlag = true;
+
+ if (signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) {
+ signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+ }
+ listEntry->signal = signal;
+
+// HEAPHANDLE hNewCast = heapNewPtr(sizeof(sciCast), kDataCast);
+// sciCast *pNewCast = (sciCast *)heap2Ptr(hNewCast);
+// pNewCast->view = view;
+// pNewCast->loop = loop;
+// pNewCast->cel = cel;
+// pNewCast->z = z;
+// pNewCast->pal = pal;
+// pNewCast->hSaved = 0;
+// pNewCast->rect = *rect;
+// _lastCast->AddToEnd(hNewCast);
+ }
+ listIterator++;
+ }
+}
+
+void SciGuiAnimate::updateScreen(byte oldPicNotValid) {
+ GuiAnimateEntry *listEntry;
+ uint16 signal;
+ GuiAnimateList::iterator listIterator;
+ GuiAnimateList::iterator listEnd = _list.end();
+
+ listIterator = _list.begin();
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ signal = listEntry->signal;
+
+ if (listEntry->showBitsFlag || !(signal & (SCI_ANIMATE_SIGNAL_REMOVEVIEW | SCI_ANIMATE_SIGNAL_NOUPDATE) ||
+ (!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) && (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) && oldPicNotValid))) {
+// TODO: code finish
+// rect = (Common::Rect *)&cobj[_objOfs[7]];
+// rect1 = (Common::Rect *)&cobj[_objOfs[8]];
+//
+// Common::Rect ro(rect->left, rect->top, rect->right, rect->bottom);
+// ro.clip(*rect1);
+//
+// if (!ro.isEmpty()) {
+// ro = *rect;
+// ro.extend(*rect1);
+// } else {
+// _gfx->ShowBits(*rect, _showMap);
+// // ro = *rect1;
+// //}
+// //*rect = *rect1;
+// _gfx->ShowBits(ro, _showMap);
+ if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
+ listEntry->signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+ }
+ }
+
+ listIterator++;
+ }
+ _screen->copyToScreen();
+}
+
+void SciGuiAnimate::restoreAndDelete(int argc, reg_t *argv) {
+ SegManager *segMan = _s->_segMan;
+ reg_t curObject;
+ GuiAnimateEntry *listEntry;
+ uint16 signal;
+ GuiAnimateList::iterator listIterator;
+ GuiAnimateList::iterator listEnd = _list.end();
+
+ listIterator = _list.reverse_begin();
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+ signal = listEntry->signal;
+
+ // FIXME: this is supposed to go into the loop above (same method)
+ if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
+ signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+ }
+
+ if ((signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_REMOVEVIEW)) == 0) {
+ _gfx->BitsRestore(GET_SEL32(curObject, underBits));
+ PUT_SEL32V(curObject, underBits, 0);
+ }
+
+ // Finally update signal
+ PUT_SEL32V(curObject, signal, signal);
+
+ if (signal & SCI_ANIMATE_SIGNAL_DISPOSEME) {
+ // Call .delete_ method of that object
+ invoke_selector(_s, curObject, _s->_kernel->_selectorCache.delete_, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
+ }
+ listIterator--;
+ }
+}
+
+void SciGuiAnimate::reAnimate(Common::Rect rect) {
+ // TODO: implement ReAnimate
+ _gfx->BitsShow(rect);
+}
+
+void SciGuiAnimate::addToPicDrawCels(List *list) {
+ reg_t curObject;
+ GuiAnimateEntry *listEntry;
+ SciGuiView *view = NULL;
+ GuiAnimateList::iterator listIterator;
+ GuiAnimateList::iterator listEnd = _list.end();
+
+ listIterator = _list.begin();
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ curObject = listEntry->object;
+
+ if (listEntry->priority == -1)
+ listEntry->priority = _gfx->CoordinateToPriority(listEntry->y);
+
+ // Get the corresponding view
+ view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
+
+ // Create rect according to coordinates and given cel
+ view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
+
+ // draw corresponding cel
+ _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+ if ((listEntry->signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+ listEntry->celRect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, listEntry->celRect.top, listEntry->celRect.bottom - 1);
+ _gfx->FillRect(listEntry->celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+ }
+
+ listIterator++;
+ }
+}
+
+void SciGuiAnimate::addToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
+ SciGuiView *view = NULL;
+ Common::Rect celRect;
+
+ view = new SciGuiView(_s->resMan, _screen, _palette, viewId);
+
+ // Create rect according to coordinates and given cel
+ view->getCelRect(loopNo, celNo, leftPos, topPos, priority, &celRect);
+ _gfx->drawCel(view, loopNo, celNo, celRect, priority, 0);
+}
+
+} // End of namespace Sci
diff --git a/engines/sci/gui/gui_animate.h b/engines/sci/gui/gui_animate.h
new file mode 100644
index 0000000000..b312027665
--- /dev/null
+++ b/engines/sci/gui/gui_animate.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_GUI_ANIMATE_H
+#define SCI_GUI_ANIMATE_H
+
+#include "sci/gui/gui_helpers.h"
+
+namespace Sci {
+
+#if 0
+enum {
+ SCI_ANIMATE_SIGNAL_STOPUPDATE = 0x0001,
+ SCI_ANIMATE_SIGNAL_VIEWUPDATED = 0x0002,
+ SCI_ANIMATE_SIGNAL_NOUPDATE = 0x0004,
+ SCI_ANIMATE_SIGNAL_HIDDEN = 0x0008,
+ SCI_ANIMATE_SIGNAL_FIXEDPRIORITY = 0x0010,
+ SCI_ANIMATE_SIGNAL_ALWAYSUPDATE = 0x0020,
+ SCI_ANIMATE_SIGNAL_FORCEUPDATE = 0x0040,
+ SCI_ANIMATE_SIGNAL_REMOVEVIEW = 0x0080,
+ SCI_ANIMATE_SIGNAL_FROZEN = 0x0100,
+ SCI_ANIMATE_SIGNAL_IGNOREACTOR = 0x4000,
+ SCI_ANIMATE_SIGNAL_DISPOSEME = 0x8000
+};
+#endif
+
+class SciGuiScreen;
+class SciGuiView;
+class SciGuiAnimate {
+public:
+ SciGuiAnimate(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *screen, SciGuiPalette *palette);
+ ~SciGuiAnimate();
+
+ void disposeLastCast();
+ void invoke(List *list, int argc, reg_t *argv);
+ void makeSortedList(List *list);
+ void fill(byte &oldPicNotValid);
+ void update();
+ void drawCels();
+ void updateScreen(byte oldPicNotValid);
+ void restoreAndDelete(int argc, reg_t *argv);
+ void reAnimate(Common::Rect rect);
+ void addToPicDrawCels(List *list);
+ void addToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
+
+private:
+ void init(void);
+
+ EngineState *_s;
+ SciGuiGfx *_gfx;
+ SciGuiScreen *_screen;
+ SciGuiPalette *_palette;
+
+ uint16 _listSize;
+ GuiAnimateEntry *_listData;
+ GuiAnimateList _list;
+ //List *_lastCast;
+};
+
+} // End of namespace Sci
+
+#endif
diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp
index 9490a471f0..d7e15dcb14 100644
--- a/engines/sci/gui/gui_gfx.cpp
+++ b/engines/sci/gui/gui_gfx.cpp
@@ -56,9 +56,6 @@ void SciGuiGfx::init() {
_texteditCursorVisible = false;
- _animateListData = NULL;
- _animateListSize = 0;
-
// _mainPort is not known to windowmanager, that's okay according to sierra sci
// its not even used currently in our engine
_mainPort = new GuiPort(0);
@@ -165,11 +162,11 @@ void SciGuiGfx::InvertRect(const Common::Rect &rect) {
FillRect(rect, 1, _curPort->penClr, _curPort->backClr);
_curPort->penMode = oldpenmode;
}
-//-----------------------------
+
void SciGuiGfx::EraseRect(const Common::Rect &rect) {
FillRect(rect, 1, _curPort->backClr);
}
-//-----------------------------
+
void SciGuiGfx::PaintRect(const Common::Rect &rect) {
FillRect(rect, 1, _curPort->penClr);
}
@@ -982,435 +979,6 @@ void SciGuiGfx::ShowPic() {
_screen->_picNotValid = 0;
}
-void SciGuiGfx::AnimateDisposeLastCast() {
- // FIXME
- //if (!_lastCast->first.isNull())
- //_lastCast->DeleteList();
-}
-
-void SciGuiGfx::AnimateInvoke(List *list, int argc, reg_t *argv) {
- SegManager *segMan = _s->_segMan;
- reg_t curAddress = list->first;
- Node *curNode = _s->_segMan->lookupNode(curAddress);
- reg_t curObject;
- uint16 signal;
-
- while (curNode) {
- curObject = curNode->value;
- signal = GET_SEL32V(curObject, signal);
- if (!(signal & SCI_ANIMATE_SIGNAL_FROZEN)) {
- // Call .doit method of that object
- invoke_selector(_s, curObject, _s->_kernel->_selectorCache.doit, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
- // Lookup node again, since the nodetable it was in may have been reallocated
- curNode = _s->_segMan->lookupNode(curAddress);
- }
- curAddress = curNode->succ;
- curNode = _s->_segMan->lookupNode(curAddress);
- }
-}
-
-bool AnimateSortHelper(const GuiAnimateEntry* entry1, const GuiAnimateEntry* entry2) {
- return (entry1->y == entry2->y) ? (entry1->z < entry2->z) : (entry1->y < entry2->y);
-}
-
-void SciGuiGfx::AnimateMakeSortedList(List *list) {
- SegManager *segMan = _s->_segMan;
- reg_t curAddress = list->first;
- Node *curNode = _s->_segMan->lookupNode(curAddress);
- reg_t curObject;
- GuiAnimateEntry *listEntry;
- int16 listNr, listCount = 0;
-
- // Count the list entries
- while (curNode) {
- listCount++;
- curAddress = curNode->succ;
- curNode = _s->_segMan->lookupNode(curAddress);
- }
-
- _animateList.clear();
-
- // No entries -> exit immediately
- if (listCount == 0)
- return;
-
- // Adjust list size, if needed
- if ((_animateListData == NULL) || (_animateListSize < listCount)) {
- if (_animateListData)
- free(_animateListData);
- _animateListData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
- if (!_animateListData)
- error("Could not allocate memory for _animateList");
- _animateListSize = listCount;
- }
-
- // Fill the list
- curAddress = list->first;
- curNode = _s->_segMan->lookupNode(curAddress);
- listEntry = _animateListData;
- for (listNr = 0; listNr < listCount; listNr++) {
- curObject = curNode->value;
- listEntry->object = curObject;
-
- // Get data from current object
- listEntry->viewId = GET_SEL32V(curObject, view);
- listEntry->loopNo = GET_SEL32V(curObject, loop);
- listEntry->celNo = GET_SEL32V(curObject, cel);
- listEntry->paletteNo = GET_SEL32V(curObject, palette);
- listEntry->x = GET_SEL32V(curObject, x);
- listEntry->y = GET_SEL32V(curObject, y);
- listEntry->z = GET_SEL32V(curObject, z);
- listEntry->priority = GET_SEL32V(curObject, priority);
- listEntry->signal = GET_SEL32V(curObject, signal);
- // listEntry->celRect is filled in AnimateFill()
- listEntry->showBitsFlag = false;
-
- _animateList.push_back(listEntry);
-
- listEntry++;
- curAddress = curNode->succ;
- curNode = _s->_segMan->lookupNode(curAddress);
- }
-
- // Now sort the list according y and z (descending)
- GuiAnimateList::iterator listBegin = _animateList.begin();
- GuiAnimateList::iterator listEnd = _animateList.end();
-
- Common::sort(_animateList.begin(), _animateList.end(), AnimateSortHelper);
-}
-
-void SciGuiGfx::AnimateFill(byte &old_picNotValid) {
- SegManager *segMan = _s->_segMan;
- reg_t curObject;
- GuiAnimateEntry *listEntry;
- uint16 signal;
- SciGuiView *view = NULL;
- GuiAnimateList::iterator listIterator;
- GuiAnimateList::iterator listEnd = _animateList.end();
-
- listIterator = _animateList.begin();
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
-
- // Get the corresponding view
- view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
-
- // adjust loop and cel, if any of those is invalid
- if (listEntry->loopNo >= view->getLoopCount()) {
- listEntry->loopNo = 0;
- PUT_SEL32V(curObject, loop, listEntry->loopNo);
- }
- if (listEntry->celNo >= view->getCelCount(listEntry->loopNo)) {
- listEntry->celNo = 0;
- PUT_SEL32V(curObject, cel, listEntry->celNo);
- }
-
- // Create rect according to coordinates and given cel
- view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
- PUT_SEL32V(curObject, nsLeft, listEntry->celRect.left);
- PUT_SEL32V(curObject, nsTop, listEntry->celRect.top);
- PUT_SEL32V(curObject, nsRight, listEntry->celRect.right);
- PUT_SEL32V(curObject, nsBottom, listEntry->celRect.bottom);
-
- signal = listEntry->signal;
-
- // Calculate current priority according to y-coordinate
- if (!(signal & SCI_ANIMATE_SIGNAL_FIXEDPRIORITY)) {
- listEntry->priority = CoordinateToPriority(listEntry->y);
- PUT_SEL32V(curObject, priority, listEntry->priority);
- }
-
- if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
- if (signal & (SCI_ANIMATE_SIGNAL_FORCEUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED)
- || (signal & SCI_ANIMATE_SIGNAL_HIDDEN && !(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW))
- || (!(signal & SCI_ANIMATE_SIGNAL_HIDDEN) && signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)
- || (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))
- old_picNotValid++;
- signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE;
- } else {
- if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE || signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE)
- old_picNotValid++;
- signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
- }
- listEntry->signal = signal;
-
- listIterator++;
- }
-}
-
-void SciGuiGfx::AnimateUpdate() {
- SegManager *segMan = _s->_segMan;
- reg_t curObject;
- GuiAnimateEntry *listEntry;
- uint16 signal;
- reg_t bitsHandle;
- Common::Rect rect;
- GuiAnimateList::iterator listIterator;
- GuiAnimateList::iterator listBegin = _animateList.begin();
- GuiAnimateList::iterator listEnd = _animateList.end();
-
- // Remove all no-update cels, if requested
- listIterator = _animateList.reverse_begin();
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
- signal = listEntry->signal;
-
- if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
- if (!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)) {
- bitsHandle = GET_SEL32(curObject, underBits);
- if (_screen->_picNotValid != 1) {
- BitsRestore(bitsHandle);
- listEntry->showBitsFlag = true;
- } else {
- BitsFree(bitsHandle);
- }
- PUT_SEL32V(curObject, underBits, 0);
- }
- signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
- signal &= signal & SCI_ANIMATE_SIGNAL_VIEWUPDATED ? 0xFFFF ^ (SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE) : 0xFFFF;
- } else if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE) {
- signal = (signal & (0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE)) | SCI_ANIMATE_SIGNAL_NOUPDATE;
- }
- listEntry->signal = signal;
- listIterator--;
- }
-
- // Draw always-update cels
- listIterator = listBegin;
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
- signal = listEntry->signal;
-
- if (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE) {
- // draw corresponding cel
- drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
- listEntry->showBitsFlag = true;
-
- signal &= 0xFFFF ^ (SCI_ANIMATE_SIGNAL_STOPUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_FORCEUPDATE);
- if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
- rect = listEntry->celRect;
- rect.top = CLIP<int16>(PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
- FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
- }
- listEntry->signal = signal;
- }
- listIterator++;
- }
-
- // Saving background for all NoUpdate-cels
- listIterator = listBegin;
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
- signal = listEntry->signal;
-
- if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
- if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
- signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
- } else {
- signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
- if (signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR)
- bitsHandle = BitsSave(listEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
- else
- bitsHandle = BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
- PUT_SEL32(curObject, underBits, bitsHandle);
- }
- listEntry->signal = signal;
- }
- listIterator++;
- }
-
- // Draw NoUpdate cels
- listIterator = listBegin;
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
- signal = listEntry->signal;
-
- if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE && !(signal & SCI_ANIMATE_SIGNAL_HIDDEN)) {
- // draw corresponding cel
- drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
- listEntry->showBitsFlag = true;
-
- if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
- rect = listEntry->celRect;
- rect.top = CLIP<int16>(PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
- FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
- }
- }
- listIterator++;
- }
-}
-
-void SciGuiGfx::AnimateDrawCels() {
- SegManager *segMan = _s->_segMan;
- reg_t curObject;
- GuiAnimateEntry *listEntry;
- uint16 signal;
- reg_t bitsHandle;
- GuiAnimateList::iterator listIterator;
- GuiAnimateList::iterator listEnd = _animateList.end();
-
- listIterator = _animateList.begin();
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
- signal = listEntry->signal;
-
- if (!(signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_HIDDEN | SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))) {
- // Save background
- bitsHandle = BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
- PUT_SEL32(curObject, underBits, bitsHandle);
-
- // draw corresponding cel
- drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
- listEntry->showBitsFlag = true;
-
- if (signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) {
- signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
- }
- listEntry->signal = signal;
-
-// HEAPHANDLE hNewCast = heapNewPtr(sizeof(sciCast), kDataCast);
-// sciCast *pNewCast = (sciCast *)heap2Ptr(hNewCast);
-// pNewCast->view = view;
-// pNewCast->loop = loop;
-// pNewCast->cel = cel;
-// pNewCast->z = z;
-// pNewCast->pal = pal;
-// pNewCast->hSaved = 0;
-// pNewCast->rect = *rect;
-// _lastCast->AddToEnd(hNewCast);
- }
- listIterator++;
- }
-}
-
-void SciGuiGfx::AnimateUpdateScreen(byte oldPicNotValid) {
- GuiAnimateEntry *listEntry;
- uint16 signal;
- GuiAnimateList::iterator listIterator;
- GuiAnimateList::iterator listEnd = _animateList.end();
-
- listIterator = _animateList.begin();
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- signal = listEntry->signal;
-
- if (listEntry->showBitsFlag || !(signal & (SCI_ANIMATE_SIGNAL_REMOVEVIEW | SCI_ANIMATE_SIGNAL_NOUPDATE) ||
- (!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) && (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) && oldPicNotValid))) {
-// TODO: code finish
-// rect = (Common::Rect *)&cobj[_objOfs[7]];
-// rect1 = (Common::Rect *)&cobj[_objOfs[8]];
-//
-// Common::Rect ro(rect->left, rect->top, rect->right, rect->bottom);
-// ro.clip(*rect1);
-//
-// if (!ro.isEmpty()) {
-// ro = *rect;
-// ro.extend(*rect1);
-// } else {
-// _gfx->ShowBits(*rect, _showMap);
-// // ro = *rect1;
-// //}
-// //*rect = *rect1;
-// _gfx->ShowBits(ro, _showMap);
- if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
- listEntry->signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
- }
- }
-
- listIterator++;
- }
- _screen->copyToScreen();
-}
-
-void SciGuiGfx::AnimateRestoreAndDelete(int argc, reg_t *argv) {
- SegManager *segMan = _s->_segMan;
- reg_t curObject;
- GuiAnimateEntry *listEntry;
- uint16 signal;
- GuiAnimateList::iterator listIterator;
- GuiAnimateList::iterator listEnd = _animateList.end();
-
- listIterator = _animateList.reverse_begin();
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
- signal = listEntry->signal;
-
- // FIXME: this is supposed to go into the loop above (same method)
- if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
- signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
- }
-
- if ((signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_REMOVEVIEW)) == 0) {
- BitsRestore(GET_SEL32(curObject, underBits));
- PUT_SEL32V(curObject, underBits, 0);
- }
-
- // Finally update signal
- PUT_SEL32V(curObject, signal, signal);
-
- if (signal & SCI_ANIMATE_SIGNAL_DISPOSEME) {
- // Call .delete_ method of that object
- invoke_selector(_s, curObject, _s->_kernel->_selectorCache.delete_, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
- }
- listIterator--;
- }
-}
-
-void SciGuiGfx::ReAnimate(Common::Rect rect) {
- // TODO: implement ReAnimate
- BitsShow(rect);
-}
-
-void SciGuiGfx::AddToPicDrawCels(List *list) {
- reg_t curObject;
- GuiAnimateEntry *listEntry;
- SciGuiView *view = NULL;
- GuiAnimateList::iterator listIterator;
- GuiAnimateList::iterator listEnd = _animateList.end();
-
- listIterator = _animateList.begin();
- while (listIterator != listEnd) {
- listEntry = *listIterator;
- curObject = listEntry->object;
-
- if (listEntry->priority == -1)
- listEntry->priority = CoordinateToPriority(listEntry->y);
-
- // Get the corresponding view
- view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
-
- // Create rect according to coordinates and given cel
- view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
-
- // draw corresponding cel
- drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
- if ((listEntry->signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
- listEntry->celRect.top = CLIP<int16>(PriorityToCoordinate(listEntry->priority) - 1, listEntry->celRect.top, listEntry->celRect.bottom - 1);
- FillRect(listEntry->celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
- }
-
- listIterator++;
- }
-}
-
-void SciGuiGfx::AddToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
- SciGuiView *view = NULL;
- Common::Rect celRect;
-
- view = new SciGuiView(_s->resMan, _screen, _palette, viewId);
-
- // Create rect according to coordinates and given cel
- view->getCelRect(loopNo, celNo, leftPos, topPos, priority, &celRect);
- drawCel(view, loopNo, celNo, celRect, priority, 0);
-}
-
bool SciGuiGfx::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list) {
SegManager *segMan = _s->_segMan;
reg_t curAddress = list->first;
diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h
index bf5041fb24..280b1adf6e 100644
--- a/engines/sci/gui/gui_gfx.h
+++ b/engines/sci/gui/gui_gfx.h
@@ -127,17 +127,6 @@ public:
void ShowPic();
- void AnimateDisposeLastCast();
- void AnimateInvoke(List *list, int argc, reg_t *argv);
- void AnimateMakeSortedList(List *list);
- void AnimateFill(byte &oldPicNotValid);
- void AnimateUpdate();
- void AnimateDrawCels();
- void AnimateUpdateScreen(byte oldPicNotValid);
- void AnimateRestoreAndDelete(int argc, reg_t *argv);
- void ReAnimate(Common::Rect rect);
- void AddToPicDrawCels(List *list);
- void AddToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
bool CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list);
void SetNowSeen(reg_t objectReference);
@@ -177,12 +166,6 @@ private:
bool _texteditCursorVisible;
uint32 _texteditBlinkTime;
- // Animate* related variables
- uint16 _animateListSize;
- GuiAnimateEntry *_animateListData;
- GuiAnimateList _animateList;
- //List *_lastCast;
-
SciGuiFont *_font;
};
diff --git a/engines/sci/gui/gui_windowmgr.cpp b/engines/sci/gui/gui_windowmgr.cpp
index b27fd31d14..bb510b5775 100644
--- a/engines/sci/gui/gui_windowmgr.cpp
+++ b/engines/sci/gui/gui_windowmgr.cpp
@@ -30,6 +30,7 @@
#include "sci/tools.h"
#include "sci/gui/gui_screen.h"
#include "sci/gui/gui_gfx.h"
+#include "sci/gui/gui_animate.h"
#include "sci/gui/gui_windowmgr.h"
namespace Sci {
@@ -43,8 +44,8 @@ enum {
SCI_WINDOWMGR_STYLE_USER = (1 << 7)
};
-SciGuiWindowMgr::SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx)
- : _screen(screen), _gfx(gfx) {
+SciGuiWindowMgr::SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate)
+ : _screen(screen), _gfx(gfx), _animate(animate) {
_wmgrPort = new GuiPort(1);
_windowsById.resize(2);
@@ -250,7 +251,7 @@ void SciGuiWindowMgr::DisposeWindow(GuiWindow *pWnd, int16 arg2) {
if (arg2)
_gfx->BitsShow(pWnd->restoreRect);
else
- _gfx->ReAnimate(pWnd->restoreRect);
+ _animate->reAnimate(pWnd->restoreRect);
_windowList.remove(pWnd);
_gfx->SetPort(_windowList.back());
_windowsById[pWnd->id] = 0;
diff --git a/engines/sci/gui/gui_windowmgr.h b/engines/sci/gui/gui_windowmgr.h
index da0576f2e2..8ec95720e2 100644
--- a/engines/sci/gui/gui_windowmgr.h
+++ b/engines/sci/gui/gui_windowmgr.h
@@ -33,7 +33,7 @@ namespace Sci {
class SciGuiWindowMgr {
public:
- SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx);
+ SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate);
~SciGuiWindowMgr();
int16 isFrontWindow(GuiWindow *wnd);
@@ -54,6 +54,7 @@ private:
SciGuiScreen *_screen;
SciGuiGfx *_gfx;
+ SciGuiAnimate *_animate;
/** The list of open 'windows' (and ports), in visual order. */
PortList _windowList;