diff options
author | Eugene Sandulenko | 2013-07-29 14:28:47 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2013-09-06 14:51:08 +0300 |
commit | 8cceaae590792b8a96b295530288437b17b21437 (patch) | |
tree | 2fa1eb2cf1fb8ca3a5ed581f66d34e8605480ad1 /engines/fullpipe | |
parent | 795a926744d4b39604fe8710a402bdb0cda5f79c (diff) | |
download | scummvm-rg350-8cceaae590792b8a96b295530288437b17b21437.tar.gz scummvm-rg350-8cceaae590792b8a96b295530288437b17b21437.tar.bz2 scummvm-rg350-8cceaae590792b8a96b295530288437b17b21437.zip |
FULLPIPE: Implement StaticANIObject::draw()
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/fullpipe.cpp | 2 | ||||
-rw-r--r-- | engines/fullpipe/gfx.cpp | 13 | ||||
-rw-r--r-- | engines/fullpipe/gfx.h | 20 | ||||
-rw-r--r-- | engines/fullpipe/scene.cpp | 6 | ||||
-rw-r--r-- | engines/fullpipe/scene.h | 1 | ||||
-rw-r--r-- | engines/fullpipe/statics.cpp | 180 | ||||
-rw-r--r-- | engines/fullpipe/statics.h | 15 |
7 files changed, 215 insertions, 22 deletions
diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index efecffa552..27ccb29dcc 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -126,7 +126,7 @@ Common::Error FullpipeEngine::run() { sceneSwitcher(&ent); -#if 1 +#if 0 loadAllScenes(); #endif diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 2b007bd2e4..88b86630b9 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -777,5 +777,18 @@ void Shadows::initMovement(Movement *mov) { warning("STUB: Shadows::initMovement()"); } +DynamicPhase *Shadows::findSize(int width, int height) { + int idx = 0; + int min = 1000; + + for (uint i = 0; i < _items.size(); i++) { + int w = abs(width - _items[i].width); + if (w < min) { + min = w; + idx = i; + } + } + return _items[idx].dynPhase; +} } // End of namespace Fullpipe diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index 81de8ec1c0..1dbdd28b44 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -30,10 +30,6 @@ namespace Fullpipe { class DynamicPhase; class Movement; -class ShadowsItemArray : public CObArray { - // empty -}; - struct Bitmap { int _x; int _y; @@ -62,6 +58,7 @@ class Picture : public MemoryObject { friend class DynamicPhase; friend class PictureObject; friend class CInputController; + friend class StaticANIObject; Common::Rect _rect; Bitmap *_convertedBitmap; @@ -168,6 +165,14 @@ class Background : public CObject { void addPictureObject(PictureObject *pct); }; +struct ShadowsItem { + int width; + int height; + DynamicPhase *dynPhase; +}; + +typedef Common::Array<ShadowsItem> ShadowsItemArray; + class Shadows : public CObject { int _sceneId; int _staticAniObjectId; @@ -180,12 +185,7 @@ class Shadows : public CObject { void init(); void initMovement(Movement *mov); -}; - -struct ShadowsItem { - int width; - int height; - DynamicPhase *dynPhase; + DynamicPhase *findSize(int width, int height); }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 1f6cb21ad7..5347d761d2 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -122,6 +122,7 @@ Scene::Scene() { _field_BC = 0; _shadows = 0; _soundList = 0; + _libHandle = 0; } bool Scene::load(MfcArchive &file) { @@ -236,7 +237,8 @@ bool Scene::load(MfcArchive &file) { } void Scene::initStaticANIObjects() { - warning("STUB: Scene::initStaticANIObjects"); + for (uint i = 0; i < _staticANIObjectList1.size(); i++) + ((StaticANIObject *)_staticANIObjectList1[i])->initMovements(); } void Scene::init() { @@ -249,7 +251,7 @@ void Scene::init() { ((PictureObject *)_picObjList[i])->clearFlags(); for (uint i = 0; i < _staticANIObjectList1.size(); i++) - ((PictureObject *)_staticANIObjectList1[i])->clearFlags(); + ((StaticANIObject *)_staticANIObjectList1[i])->clearFlags(); if (_staticANIObjectList2.size() != _staticANIObjectList1.size()) { _staticANIObjectList2.clear(); diff --git a/engines/fullpipe/scene.h b/engines/fullpipe/scene.h index d51d113b5e..95528d2e9e 100644 --- a/engines/fullpipe/scene.h +++ b/engines/fullpipe/scene.h @@ -30,6 +30,7 @@ namespace Fullpipe { class Scene : public Background { friend class FullpipeEngine; friend class SceneTag; + friend class StaticANIObject; CPtrList _staticANIObjectList1; CPtrList _staticANIObjectList2; diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index cca12cef65..2fa53e2d96 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -219,7 +219,64 @@ Statics *StaticANIObject::addReverseStatics(Statics *st) { } void StaticANIObject::draw() { - warning("STUB: StaticANIObject::draw()"); + if (_flags & 4 == 0) + return; + + Common::Point point; + Common::Rect rect; + + debug(0, "StaticANIObject::draw()"); + + if (_shadowsOn && g_fullpipe->_currentScene && g_fullpipe->_currentScene->_shadows + && (getCurrDimensions(point)->x != 1 || getCurrDimensions(point)->y != 1)) { + + DynamicPhase *dyn; + + if (!_movement || _flags & 0x20 ) + dyn = _statics; + else + dyn = _movement->_currDynamicPhase; + + if (dyn->getDynFlags() & 4) { + rect = *dyn->_rect; + + DynamicPhase *shd = g_fullpipe->_currentScene->_shadows->findSize(rect.width(), rect.height()); + if (shd) { + shd->getDimensions(&point); + int midx = _ox - shd->_x / 2 - dyn->_someX; + int midy = _oy - shd->_y / 2 - dyn->_someY + rect.bottom - 3; + int shdy = shd->_y; + + int px; + if (!_movement || _flags & 0x20 ) + px = _statics->getCenter(&point)->x; + else + px = _movement->getCenter(&point)->x; + + if (_shadowsOn != 1) + midy = _shadowsOn - shdy / 2; + + shd->draw(px + midx, midy, 0, 0); + } + } + } + + int angle = 0; + if (_field_30 & 0xC000) { + if (_field_30 & 0x8000) + angle = -(_field_30 ^ 0x8000); + else + angle = _field_30 ^ 0x4000; + } + + if (!_movement || _flags & 0x20) { + _statics->getSomeXY(point); + _statics->_x = _ox - point.x; + _statics->_y = _oy - point.y; + _statics->draw(_statics->_x, _statics->_y, 0, angle); + } else { + _movement->draw(0, angle); + } } void StaticANIObject::draw2() { @@ -268,6 +325,33 @@ void StaticANIObject::setSpeed(int speed) { warning("STUB: StaticANIObject::setSpeed(%d)", speed); } +void StaticANIObject::initMovements() { + for (uint i = 0; i < _movements.size(); i++) + ((Movement *)_movements[i])->removeFirstPhase(); +} + +Common::Point *StaticANIObject::getCurrDimensions(Common::Point &p) { + Picture *pic; + + if (_movement) + pic = _movement->_currDynamicPhase; + else + pic = _statics; + + if (pic) { + Common::Point point; + + pic->getDimensions(&point); + p.x = point.x; + p.y = point.y; + } else { + p.x = 0; + p.y = 0; + } + + return &p; +} + Statics::Statics() { _staticsId = 0; _picture = 0; @@ -317,6 +401,24 @@ Common::Point *Statics::getSomeXY(Common::Point &p) { return &p; } +Common::Point *Statics::getCenter(Common::Point *p) { + Common::Rect rect; + + rect = *_rect; + + if (_staticsId & 0x4000) { + Common::Point point; + + getDimensions(&point); + rect.moveTo(point.x - _rect->right, _rect->top); + } + + p->x = rect.left + _rect->width() / 2; + p->y = rect.top + _rect->height() / 2; + + return p; +} + Movement::Movement() { _lastFrameSpecialFlag = 0; _flipFlag = 0; @@ -335,7 +437,7 @@ Movement::Movement() { _field_8C = 0; _currDynamicPhaseIndex = 0; _field_94 = 0; - _currMovementObj = 0; + _currMovement = 0; _counter = 0; _counterMax = 83; } @@ -400,7 +502,7 @@ bool Movement::load(MfcArchive &file, StaticANIObject *ani) { } else { int movid = file.readUint16LE(); - _currMovementObj = ani->getMovementById(movid); + _currMovement = ani->getMovementById(movid); _staticsObj1 = 0; _staticsObj2 = 0; @@ -433,6 +535,28 @@ Common::Point *Movement::getCurrDynamicPhaseXY(Common::Point &p) { return &p; } +Common::Point *Movement::getDimensionsOfPhase(Common::Point *p, int phaseIndex) { + int idx = phaseIndex; + + if (idx == -1) + idx = _currDynamicPhaseIndex; + + DynamicPhase *dyn; + + if (_currMovement) + dyn = (DynamicPhase *)_currMovement->_dynamicPhases[idx]; + else + dyn = (DynamicPhase *)_dynamicPhases[idx]; + + Common::Point point; + + dyn->getDimensions(&point); + + *p = point; + + return p; +} + void Movement::initStatics(StaticANIObject *ani) { warning("STUB: Movement::initStatics"); } @@ -448,7 +572,7 @@ void Movement::updateCurrDynamicPhase() { void Movement::loadPixelData() { Movement *mov = this; - for (Movement *i = _currMovementObj; i; i = i->_currMovementObj) + for (Movement *i = _currMovement; i; i = i->_currMovement) mov = i; for (uint i = 0; i < _dynamicPhases.size(); i++) { @@ -460,6 +584,49 @@ void Movement::loadPixelData() { mov->_staticsObj1->getPixelData(); } +void Movement::removeFirstPhase() { + if (_updateFlag1) { + if (!_currDynamicPhaseIndex) + gotoNextFrame(0, 0); + + if (!_currMovement) { + _dynamicPhases.remove_at(0); + + for (uint i = 0; i < _dynamicPhases.size(); i++) { + _framePosOffsets[i - 1]->x = _framePosOffsets[i]->x; + _framePosOffsets[i - 1]->y = _framePosOffsets[i]->y; + } + } + _currDynamicPhaseIndex--; + } + + updateCurrDynamicPhase(); + _updateFlag1 = 0; +} + +void Movement::gotoNextFrame(int callback1, int callback2) { + warning("STUB: Movement::gotoNextFrame()"); +} + +Common::Point *Movement::getCenter(Common::Point *p) { + Common::Rect rect; + + rect = *_currDynamicPhase->_rect; + + if (_currMovement) { + Common::Point point; + + getDimensionsOfPhase(&point, _currDynamicPhaseIndex); + + rect.moveTo(point.x - _currDynamicPhase->_rect->right, _currDynamicPhase->_rect->top); + } + + p->x = rect.left + _currDynamicPhase->_rect->width() / 2; + p->y = rect.top + _currDynamicPhase->_rect->height() / 2; + + return p; +} + DynamicPhase::DynamicPhase() { _someX = 0; _rect = 0; @@ -508,10 +675,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { _someY = src->_someY; } - _rect->top = src->_rect->top; - _rect->bottom = src->_rect->bottom; - _rect->left = src->_rect->left; - _rect->right = src->_rect->right; + *_rect = *src->_rect; _width = src->_width; _height = src->_height; diff --git a/engines/fullpipe/statics.h b/engines/fullpipe/statics.h index 8a0f36aa6b..bfd7e70f99 100644 --- a/engines/fullpipe/statics.h +++ b/engines/fullpipe/statics.h @@ -64,6 +64,7 @@ class StaticPhase : public Picture { class DynamicPhase : public StaticPhase { friend class Movement; friend class Statics; + friend class StaticANIObject; int _someX; int _someY; @@ -77,6 +78,8 @@ class DynamicPhase : public StaticPhase { DynamicPhase(DynamicPhase *src, bool reverse); virtual bool load(MfcArchive &file); + + int getDynFlags() { return _dynFlags; } }; class Statics : public DynamicPhase { @@ -96,11 +99,14 @@ class Statics : public DynamicPhase { Statics *getStaticsById(int itemId); Common::Point *getSomeXY(Common::Point &p); + Common::Point *getCenter(Common::Point *p); }; class StaticANIObject; class Movement : public GameObject { + friend class StaticANIObject; + int _field_24; int _field_28; int _lastFrameSpecialFlag; @@ -118,7 +124,7 @@ class Movement : public GameObject { CPtrList _dynamicPhases; int _field_78; Common::Point **_framePosOffsets; - Movement *_currMovementObj; + Movement *_currMovement; int _field_84; DynamicPhase *_currDynamicPhase; int _field_8C; @@ -131,10 +137,15 @@ class Movement : public GameObject { bool load(MfcArchive &file, StaticANIObject *ani); Common::Point *getCurrDynamicPhaseXY(Common::Point &p); + Common::Point *getCenter(Common::Point *p); + Common::Point *getDimensionsOfPhase(Common::Point *p, int phaseIndex); void initStatics(StaticANIObject *ani); void updateCurrDynamicPhase(); + void removeFirstPhase(); + void gotoNextFrame(int callback1, int callback2); + void loadPixelData(); void draw(bool flipFlag, int angle); @@ -174,12 +185,14 @@ class StaticANIObject : public GameObject { Statics *getStaticsById(int id); Movement *getMovementById(int id); Movement *getMovementByName(char *name); + Common::Point *getCurrDimensions(Common::Point &p); void clearFlags(); bool isIdle(); void deleteFromGlobalMessageQueue(); + void initMovements(); void loadMovementsPixelData(); Statics *addReverseStatics(Statics *ani); |