diff options
author | Paul Gilbert | 2016-06-19 09:58:00 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:23:38 -0400 |
commit | 68f13646e185416bb74812ea489764b9b28b8e22 (patch) | |
tree | 99bae897378a78f89fe72a12c528c0a10e4b43c8 /engines/titanic/core | |
parent | 758fb87f0ead14545ea7bbea85ae5355230ff113 (diff) | |
download | scummvm-rg350-68f13646e185416bb74812ea489764b9b28b8e22.tar.gz scummvm-rg350-68f13646e185416bb74812ea489764b9b28b8e22.tar.bz2 scummvm-rg350-68f13646e185416bb74812ea489764b9b28b8e22.zip |
TITANIC: Implementing more CGameObject/OSScreenManager draw methods
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 57 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 20 |
2 files changed, 59 insertions, 18 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 624a4b0e67..5f68037f22 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -161,6 +161,47 @@ bool CGameObject::checkPoint(const Point &pt, bool ignore40, bool visibleOnly) { return pixel != transColor; } +bool CGameObject::clipRect(const Rect &rect1, Rect &rect2) const { + if (!rect2.intersects(rect1)) + return false; + + rect2.clip(rect1); + return true; +} + +void CGameObject::draw(CScreenManager *screenManager, const Rect &destRect, const Rect &srcRect) { + Rect tempRect = destRect; + if (clipRect(srcRect, tempRect)) { + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface) + screenManager->blitFrom(SURFACE_PRIMARY, &tempRect, _surface); + } +} + +void CGameObject::draw(CScreenManager *screenManager, const Point &destPos) { + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface) { + int xSize = _surface->getWidth(); + int ySize = _surface->getHeight(); + + if (xSize > 0 && ySize > 0) { + screenManager->blitFrom(SURFACE_BACKBUFFER, _surface, &destPos); + } + } +} + +void CGameObject::draw(CScreenManager *screenManager, const Point &destPos, const Rect &srcRect) { + draw(screenManager, Rect(destPos.x, destPos.y, destPos.x + 52, destPos.y + 52), srcRect); +} + void CGameObject::draw(CScreenManager *screenManager) { if (!_visible) return; @@ -209,22 +250,6 @@ void CGameObject::draw(CScreenManager *screenManager) { } } -void CGameObject::draw(CScreenManager *screenManager, const Common::Point &destPos) { - if (!_surface && !_resource.empty()) { - loadResource(_resource); - _resource.clear(); - } - - if (_surface) { - int xSize = _surface->getWidth(); - int ySize = _surface->getHeight(); - - if (xSize > 0 && ySize > 0) { - screenManager->blitFrom(SURFACE_BACKBUFFER, _surface, &destPos); - } - } -} - bool CGameObject::isPet() const { return isInstanceOf(CPetControl::_type); } diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 24a8ac2f81..a30c348312 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -66,6 +66,12 @@ private: void loadImage(const CString &name, bool pendingFlag = true); void processClipList2(); + + /** + * Merges one rect into another, and returns true if there was + * a common intersection + */ + bool clipRect(const Rect &rect1, Rect &rect2) const; protected: Rect _bounds; double _field34; @@ -367,12 +373,22 @@ public: /** * Allows the item to draw itself */ - virtual void draw(CScreenManager *screenManager); + void draw(CScreenManager *screenManager, const Rect &destRect, const Rect &srcRect); /** * Allows the item to draw itself */ - virtual void draw(CScreenManager *screenManager, const Common::Point &destPos); + void draw(CScreenManager *screenManager, const Point &destPos); + + /** + * Allows the item to draw itself + */ + void draw(CScreenManager *screenManager, const Point &destPos, const Rect &srcRect); + + /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager); /** * Returns true if the item is the PET control |