aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-19 09:58:00 -0400
committerPaul Gilbert2016-07-15 19:23:38 -0400
commit68f13646e185416bb74812ea489764b9b28b8e22 (patch)
tree99bae897378a78f89fe72a12c528c0a10e4b43c8 /engines/titanic
parent758fb87f0ead14545ea7bbea85ae5355230ff113 (diff)
downloadscummvm-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')
-rw-r--r--engines/titanic/core/game_object.cpp57
-rw-r--r--engines/titanic/core/game_object.h20
-rw-r--r--engines/titanic/support/screen_manager.cpp16
-rw-r--r--engines/titanic/support/screen_manager.h16
4 files changed, 84 insertions, 25 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
diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp
index b0e249d7b3..27c0d9886e 100644
--- a/engines/titanic/support/screen_manager.cpp
+++ b/engines/titanic/support/screen_manager.cpp
@@ -163,7 +163,7 @@ void OSScreenManager::fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g
}
void OSScreenManager::blitFrom(SurfaceNum surfaceNum, CVideoSurface *src,
- const Point *destPos, const Rect *srcRect) {
+ const Point *destPos, const Rect *srcRect) {
// Get the dest surface
CVideoSurface *destSurface = _frontRenderSurface;
if (surfaceNum < -1)
@@ -200,7 +200,19 @@ void OSScreenManager::blitFrom(SurfaceNum surfaceNum, CVideoSurface *src,
destSurface->blitFrom(destPoint, src, bounds);
}
-void OSScreenManager::proc12() {}
+void OSScreenManager::blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v) {
+ // Get the dest surface
+ CVideoSurface *destSurface = _frontRenderSurface;
+ if (surfaceNum < -1)
+ return;
+ if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size())
+ destSurface = _backSurfaces[surfaceNum]._surface;
+ if (!destSurface->hasSurface())
+ return;
+
+ if (!rect->isEmpty())
+ destSurface->blitFrom(Point(rect->left, rect->top), src, rect);
+}
int OSScreenManager::writeString(int surfaceNum, const Rect &destRect,
int yOffset, const CString &str, CTextCursor *textCursor) {
diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h
index 2e80869085..21b40cad37 100644
--- a/engines/titanic/support/screen_manager.h
+++ b/engines/titanic/support/screen_manager.h
@@ -41,8 +41,8 @@ namespace Titanic {
* remapped to the primary surface
*/
enum SurfaceNum {
- SURFACE_PRIMARY = -1,
- SURFACE_BACKBUFFER = -1
+ SURFACE_PRIMARY = -1, // Surface 0
+ SURFACE_BACKBUFFER = -1 // Surface -1
};
class TitanicEngine;
@@ -109,8 +109,11 @@ public:
virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos = nullptr,
const Rect *srcRect = nullptr) = 0;
- virtual void proc12() = 0;
-
+ /**
+ * Blits a surface onto one of the screen surfaces
+ */
+ virtual void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0) = 0;
+
/**
* Write a string
* @param surfaceNum Destination surface
@@ -248,7 +251,10 @@ public:
virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos,
const Rect *srcRect = nullptr);
- virtual void proc12();
+ /**
+ * Blits a surface onto one of the screen surfaces
+ */
+ virtual void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0);
/**
* Write a string