diff options
author | Martin Kiewitz | 2010-01-31 15:07:36 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-01-31 15:07:36 +0000 |
commit | c991a5bcebd9c46070e41361855969bed9754e57 (patch) | |
tree | 98d6fb4b0647d2198267946b325b1e018bda1539 /engines/sci | |
parent | 6248362c38b97c40f0a71544381397657a2b041f (diff) | |
download | scummvm-rg350-c991a5bcebd9c46070e41361855969bed9754e57.tar.gz scummvm-rg350-c991a5bcebd9c46070e41361855969bed9754e57.tar.bz2 scummvm-rg350-c991a5bcebd9c46070e41361855969bed9754e57.zip |
SCI: renamed SciGuiAnimate to GfxAnimate, moved code from SciGui into this class, now getting called directly
svn-id: r47751
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/console.cpp | 3 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 6 | ||||
-rw-r--r-- | engines/sci/graphics/animate.cpp | 122 | ||||
-rw-r--r-- | engines/sci/graphics/animate.h | 15 | ||||
-rw-r--r-- | engines/sci/graphics/gui.cpp | 93 | ||||
-rw-r--r-- | engines/sci/graphics/gui.h | 7 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 2 |
8 files changed, 134 insertions, 120 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index ab4d13e630..ab6daa2847 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -45,6 +45,7 @@ #include "sci/graphics/gui.h" #include "sci/graphics/gui32.h" #include "sci/graphics/cursor.h" +#include "sci/graphics/screen.h" #include "sci/parser/vocabulary.h" @@ -1073,7 +1074,7 @@ bool Console::cmdDrawPic(int argc, const char **argv) { uint16 resourceId = atoi(argv[1]); _vm->_gamestate->_gui->drawPicture(resourceId, 100, false, false, false, 0); - _vm->_gamestate->_gui->animateShowPic(); + _vm->_gamestate->_screen->copyToScreen(); return true; } diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 782072a229..3b99a9b870 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -973,7 +973,7 @@ reg_t kAddToPic(EngineState *s, int argc, reg_t *argv) { case 1: if (argv[0].isNull()) return s->r_acc; - s->_gui->addToPicList(argv[0], argc, argv); + s->_gfxAnimate->kernelAddToPicList(argv[0], argc, argv); break; case 7: viewId = argv[0].toUint16(); @@ -983,7 +983,7 @@ reg_t kAddToPic(EngineState *s, int argc, reg_t *argv) { topPos = argv[4].toSint16(); priority = argv[5].toSint16(); control = argv[6].toSint16(); - s->_gui->addToPicView(viewId, loopNo, celNo, leftPos, topPos, priority, control); + s->_gfxAnimate->kernelAddToPicView(viewId, loopNo, celNo, leftPos, topPos, priority, control); break; default: error("kAddToPic with unsupported parameter count %d", argc); @@ -1102,7 +1102,7 @@ reg_t kAnimate(EngineState *s, int argc, reg_t *argv) { // Take care of incoming events (kAnimate is called semi-regularly) process_sound_events(s); #endif - s->_gui->animate(castListReference, cycle, argc, argv); + s->_gfxAnimate->kernelAnimate(castListReference, cycle, argc, argv); return s->r_acc; } diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index 31c46c4447..ad70669f7f 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -51,7 +51,9 @@ namespace Sci { class SciEvent; class Menubar; +class GfxAnimate; class GfxPorts; +class Screen; class SciGui; class Cursor; class MessageState; @@ -148,7 +150,9 @@ public: /* Non-VM information */ - GfxPorts *_gfxPorts; // Port managment for 16-bit gui + GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx + GfxPorts *_gfxPorts; // Port managment for 16-bit gfx + Screen *_screen; // gfx screen SciGui *_gui; /* Currently active Gui */ #ifdef ENABLE_SCI32 diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp index 55cccdc3a7..57b9226c02 100644 --- a/engines/sci/graphics/animate.cpp +++ b/engines/sci/graphics/animate.cpp @@ -32,6 +32,7 @@ #include "sci/engine/selector.h" #include "sci/engine/vm.h" #include "sci/graphics/cache.h" +#include "sci/graphics/cursor.h" #include "sci/graphics/ports.h" #include "sci/graphics/paint16.h" #include "sci/graphics/view.h" @@ -41,17 +42,17 @@ namespace Sci { -SciGuiAnimate::SciGuiAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette) - : _s(state), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen), _palette(palette) { +GfxAnimate::GfxAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette, Cursor *cursor, Transitions *transitions) + : _s(state), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen), _palette(palette), _cursor(cursor), _transitions(transitions) { init(); } -SciGuiAnimate::~SciGuiAnimate() { +GfxAnimate::~GfxAnimate() { free(_listData); free(_lastCastData); } -void SciGuiAnimate::init() { +void GfxAnimate::init() { _listData = NULL; _listCount = 0; _lastCastData = NULL; @@ -67,11 +68,11 @@ void SciGuiAnimate::init() { _ignoreFastCast = true; } -void SciGuiAnimate::disposeLastCast() { +void GfxAnimate::disposeLastCast() { _lastCastCount = 0; } -bool SciGuiAnimate::invoke(List *list, int argc, reg_t *argv) { +bool GfxAnimate::invoke(List *list, int argc, reg_t *argv) { reg_t curAddress = list->first; Node *curNode = _s->_segMan->lookupNode(curAddress); reg_t curObject; @@ -108,7 +109,7 @@ bool sortHelper(const AnimateEntry* entry1, const AnimateEntry* entry2) { return (entry1->y == entry2->y) ? (entry1->z < entry2->z) : (entry1->y < entry2->y); } -void SciGuiAnimate::makeSortedList(List *list) { +void GfxAnimate::makeSortedList(List *list) { reg_t curAddress = list->first; Node *curNode = _s->_segMan->lookupNode(curAddress); reg_t curObject; @@ -199,7 +200,7 @@ void SciGuiAnimate::makeSortedList(List *list) { Common::sort(_list.begin(), _list.end(), sortHelper); } -void SciGuiAnimate::fill(byte &old_picNotValid) { +void GfxAnimate::fill(byte &old_picNotValid) { reg_t curObject; AnimateEntry *listEntry; uint16 signal; @@ -262,7 +263,7 @@ void SciGuiAnimate::fill(byte &old_picNotValid) { } } -void SciGuiAnimate::update() { +void GfxAnimate::update() { reg_t curObject; AnimateEntry *listEntry; uint16 signal; @@ -367,7 +368,7 @@ void SciGuiAnimate::update() { } } -void SciGuiAnimate::drawCels() { +void GfxAnimate::drawCels() { reg_t curObject; AnimateEntry *listEntry; AnimateEntry *lastCastEntry = _lastCastData; @@ -405,7 +406,7 @@ void SciGuiAnimate::drawCels() { } } -void SciGuiAnimate::updateScreen(byte oldPicNotValid) { +void GfxAnimate::updateScreen(byte oldPicNotValid) { reg_t curObject; AnimateEntry *listEntry; uint16 signal; @@ -454,7 +455,7 @@ void SciGuiAnimate::updateScreen(byte oldPicNotValid) { // _screen->copyToScreen(); } -void SciGuiAnimate::restoreAndDelete(int argc, reg_t *argv) { +void GfxAnimate::restoreAndDelete(int argc, reg_t *argv) { reg_t curObject; AnimateEntry *listEntry; uint16 signal; @@ -495,7 +496,7 @@ void SciGuiAnimate::restoreAndDelete(int argc, reg_t *argv) { } } -void SciGuiAnimate::reAnimate(Common::Rect rect) { +void GfxAnimate::reAnimate(Common::Rect rect) { AnimateEntry *lastCastEntry; uint16 lastCastCount; @@ -542,7 +543,7 @@ void SciGuiAnimate::reAnimate(Common::Rect rect) { */ } -void SciGuiAnimate::addToPicDrawCels() { +void GfxAnimate::addToPicDrawCels() { reg_t curObject; AnimateEntry *listEntry; View *view = NULL; @@ -574,7 +575,7 @@ void SciGuiAnimate::addToPicDrawCels() { } } -void SciGuiAnimate::addToPicDrawView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) { +void GfxAnimate::addToPicDrawView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) { View *view = _cache->getView(viewId); Common::Rect celRect; @@ -583,4 +584,95 @@ void SciGuiAnimate::addToPicDrawView(GuiResourceId viewId, int16 loopNo, int16 c _paint16->drawCel(view, loopNo, celNo, celRect, priority, 0); } + +void GfxAnimate::animateShowPic() { + Port *picPort = _ports->_picWind; + Common::Rect picRect = picPort->rect; + bool previousCursorState = _cursor->isVisible(); + + if (previousCursorState) + _cursor->hide(); + // Adjust picRect to become relative to screen + picRect.translate(picPort->left, picPort->top); + _transitions->doit(picRect); + if (previousCursorState) + _cursor->show(); + + // We set SCI1.1 priority band information here + _ports->priorityBandsRecall(); +} + +void GfxAnimate::kernelAnimate(reg_t listReference, bool cycle, int argc, reg_t *argv) { + byte old_picNotValid = _screen->_picNotValid; + + if (listReference.isNull()) { + disposeLastCast(); + if (_screen->_picNotValid) + animateShowPic(); + return; + } + + List *list = _s->_segMan->lookupList(listReference); + if (!list) + error("kAnimate called with non-list as parameter"); + + if (cycle) { + if (!invoke(list, argc, argv)) + return; + } + + Port *oldPort = _ports->setPort((Port *)_ports->_picWind); + disposeLastCast(); + + makeSortedList(list); + fill(old_picNotValid); + + if (old_picNotValid) { + _ports->beginUpdate(_ports->_picWind); + update(); + _ports->endUpdate(_ports->_picWind); + } + + drawCels(); + + if (_screen->_picNotValid) + animateShowPic(); + + updateScreen(old_picNotValid); + restoreAndDelete(argc, argv); + + if (getLastCastCount() > 1) + _s->_throttleTrigger = true; + + _ports->setPort(oldPort); +} + +void GfxAnimate::addToPicSetPicNotValid() { + if (getSciVersion() <= SCI_VERSION_1_EARLY) + _screen->_picNotValid = 1; + else + _screen->_picNotValid = 2; +} + +void GfxAnimate::kernelAddToPicList(reg_t listReference, int argc, reg_t *argv) { + List *list; + + _ports->setPort((Port *)_ports->_picWind); + + list = _s->_segMan->lookupList(listReference); + if (!list) + error("kAddToPic called with non-list as parameter"); + + makeSortedList(list); + addToPicDrawCels(); + + addToPicSetPicNotValid(); +} + +void GfxAnimate::kernelAddToPicView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) { + _ports->setPort((Port *)_ports->_picWind); + addToPicDrawView(viewId, loopNo, celNo, leftPos, topPos, priority, control); + addToPicSetPicNotValid(); +} + } // End of namespace Sci diff --git a/engines/sci/graphics/animate.h b/engines/sci/graphics/animate.h index 8dae1a6d46..fccd96391c 100644 --- a/engines/sci/graphics/animate.h +++ b/engines/sci/graphics/animate.h @@ -62,10 +62,10 @@ class GfxPaint16; class Screen; class SciPalette; class Transitions; -class SciGuiAnimate { +class GfxAnimate { public: - SciGuiAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette); - ~SciGuiAnimate(); + GfxAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette, Cursor *cursor, Transitions *transitions); + ~GfxAnimate(); // FIXME: Don't store EngineState void resetEngineState(EngineState *newState) { _s = newState; } @@ -84,15 +84,24 @@ public: uint16 getLastCastCount() { return _lastCastCount; }; + virtual void kernelAnimate(reg_t listReference, bool cycle, int argc, reg_t *argv); + virtual void kernelAddToPicList(reg_t listReference, int argc, reg_t *argv); + virtual void kernelAddToPicView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control); + private: void init(); + void addToPicSetPicNotValid(); + void animateShowPic(); + EngineState *_s; GfxCache *_cache; GfxPorts *_ports; GfxPaint16 *_paint16; Screen *_screen; SciPalette *_palette; + Cursor *_cursor; + Transitions *_transitions; uint16 _listCount; AnimateEntry *_listData; diff --git a/engines/sci/graphics/gui.cpp b/engines/sci/graphics/gui.cpp index 633617eead..a122e2180a 100644 --- a/engines/sci/graphics/gui.cpp +++ b/engines/sci/graphics/gui.cpp @@ -57,7 +57,8 @@ SciGui::SciGui(EngineState *state, Screen *screen, SciPalette *palette, Cursor * _compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen); _paint16 = new GfxPaint16(_s->resMan, _s->_segMan, _s->_kernel, _cache, _ports, _screen, _palette); _transitions = new Transitions(this, _screen, _palette, _s->resMan->isVGA()); - _animate = new SciGuiAnimate(_s, _cache, _ports, _paint16, _screen, _palette); + _animate = new GfxAnimate(_s, _cache, _ports, _paint16, _screen, _palette, _cursor, _transitions); + _s->_gfxAnimate = _animate; _text = new Text(_s->resMan, _ports, _paint16, _screen); _controls = new Controls(_s->_segMan, _ports, _paint16, _text); _menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text, _screen, _cursor); @@ -572,96 +573,6 @@ uint16 SciGui::onControl(byte screenMask, Common::Rect rect) { return result; } -void SciGui::animateShowPic() { - Port *picPort = _ports->_picWind; - Common::Rect picRect = picPort->rect; - bool previousCursorState = _cursor->isVisible(); - - if (previousCursorState) - _cursor->hide(); - // Adjust picRect to become relative to screen - picRect.translate(picPort->left, picPort->top); - _transitions->doit(picRect); - if (previousCursorState) - _cursor->show(); - - // We set SCI1.1 priority band information here - _ports->priorityBandsRecall(); -} - -void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) { - byte old_picNotValid = _screen->_picNotValid; - - if (listReference.isNull()) { - _animate->disposeLastCast(); - if (_screen->_picNotValid) - animateShowPic(); - return; - } - - List *list = _s->_segMan->lookupList(listReference); - if (!list) - error("kAnimate called with non-list as parameter"); - - if (cycle) { - if (!_animate->invoke(list, argc, argv)) - return; - } - - Port *oldPort = _ports->setPort((Port *)_ports->_picWind); - _animate->disposeLastCast(); - - _animate->makeSortedList(list); - _animate->fill(old_picNotValid); - - if (old_picNotValid) { - _ports->beginUpdate(_ports->_picWind); - _animate->update(); - _ports->endUpdate(_ports->_picWind); - } - - _animate->drawCels(); - - if (_screen->_picNotValid) - animateShowPic(); - - _animate->updateScreen(old_picNotValid); - _animate->restoreAndDelete(argc, argv); - - if (_animate->getLastCastCount() > 1) - _s->_throttleTrigger = true; - - _ports->setPort(oldPort); -} - -void SciGui::addToPicSetPicNotValid() { - if (getSciVersion() <= SCI_VERSION_1_EARLY) - _screen->_picNotValid = 1; - else - _screen->_picNotValid = 2; -} - -void SciGui::addToPicList(reg_t listReference, int argc, reg_t *argv) { - List *list; - - _ports->setPort((Port *)_ports->_picWind); - - list = _s->_segMan->lookupList(listReference); - if (!list) - error("kAddToPic called with non-list as parameter"); - - _animate->makeSortedList(list); - _animate->addToPicDrawCels(); - - addToPicSetPicNotValid(); -} - -void SciGui::addToPicView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) { - _ports->setPort((Port *)_ports->_picWind); - _animate->addToPicDrawView(viewId, loopNo, celNo, leftPos, topPos, priority, control); - addToPicSetPicNotValid(); -} - void SciGui::setNowSeen(reg_t objectReference) { _compare->SetNowSeen(objectReference); } diff --git a/engines/sci/graphics/gui.h b/engines/sci/graphics/gui.h index a92af7a99b..184e2607d7 100644 --- a/engines/sci/graphics/gui.h +++ b/engines/sci/graphics/gui.h @@ -123,10 +123,6 @@ public: virtual void shakeScreen(uint16 shakeCount, uint16 directions); virtual uint16 onControl(byte screenMask, Common::Rect rect); - virtual void animateShowPic(); - virtual void animate(reg_t listReference, bool cycle, int argc, reg_t *argv); - virtual void addToPicList(reg_t listReference, int argc, reg_t *argv); - virtual void addToPicView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control); virtual void setNowSeen(reg_t objectReference); virtual bool canBeHere(reg_t curObject, reg_t listReference); virtual bool isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position); @@ -177,13 +173,12 @@ protected: private: virtual void initPriorityBands(); - virtual void addToPicSetPicNotValid(); virtual int getControlPicNotValid(); static void palVaryCallback(void *refCon); void doPalVary(); AudioPlayer *_audio; - SciGuiAnimate *_animate; + GfxAnimate *_animate; Controls *_controls; Menu *_menu; Text *_text; diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 81fc492ac5..4419ab6149 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -172,6 +172,7 @@ Common::Error SciEngine::run() { #ifdef ENABLE_SCI32 if (getSciVersion() >= SCI_VERSION_2) { _gamestate->_gfxPorts = 0; + _gamestate->_gfxAnimate = 0; _gamestate->_gui = 0; _gamestate->_gui32 = new SciGui32(_gamestate, screen, palette, cursor); } else { @@ -183,6 +184,7 @@ Common::Error SciEngine::run() { _gamestate->_ports = new GfxPorts(_segMan, _screen); _gamestate->_gui = new SciGui(_gamestate, screen, palette, cursor, _audio); #endif + _gamestate->_screen = screen; if (game_init(_gamestate)) { /* Initialize */ warning("Game initialization failed: Aborting..."); |