aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/game_object.cpp129
-rw-r--r--engines/titanic/core/game_object.h42
-rw-r--r--engines/titanic/core/resource_key.h2
-rw-r--r--engines/titanic/files_manager.cpp4
-rw-r--r--engines/titanic/files_manager.h2
-rw-r--r--engines/titanic/game_manager.cpp7
-rw-r--r--engines/titanic/game_manager.h6
7 files changed, 182 insertions, 10 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index db1e9ef3d6..acd34decfc 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -20,11 +20,18 @@
*
*/
+#include "titanic/files_manager.h"
+#include "titanic/game_manager.h"
+#include "titanic/screen_manager.h"
+#include "titanic/titanic.h"
+#include "titanic/video_surface.h"
#include "titanic/core/game_object.h"
#include "titanic/core/resource_key.h"
namespace Titanic {
+void *CGameObject::_v1 = nullptr;
+
CGameObject::CGameObject(): CNamedItem() {
_bounds = Rect(0, 0, 15, 15);
_field34 = 0;
@@ -41,14 +48,14 @@ CGameObject::CGameObject(): CNamedItem() {
_field60 = 0;
_cursorId = 1;
_field78 = 0;
- _field8C = -1;
+ _frameNumber = -1;
_field90 = 0;
_field94 = 0;
_field98 = 0;
_field9C = 0;
_fieldA0 = 0;
_fieldA4 = 0;
- _fieldA8 = nullptr;
+ _surface = nullptr;
_fieldB8 = 0;
}
@@ -66,7 +73,7 @@ void CGameObject::load(SimpleFile *file) {
switch (val) {
case 7:
_clipList2.load(file);
- _field8C = file->readNumber();
+ _frameNumber = file->readNumber();
// Deliberate fall-through
case 6:
@@ -86,7 +93,7 @@ void CGameObject::load(SimpleFile *file) {
// Deliberate fall-through
case 2:
- _string = file->readString();
+ _resource = file->readString();
// Deliberate fall-through
case 1:
@@ -104,10 +111,10 @@ void CGameObject::load(SimpleFile *file) {
_field58 = file->readNumber();
resourceKey.load(file);
- _fieldA8 = nullptr;
+ _surface = nullptr;
val = file->readNumber();
if (val) {
- _string = resourceKey.getString();
+ _resource = resourceKey.getString();
}
break;
@@ -128,7 +135,115 @@ bool CGameObject::checkPoint(const Point &pt, int v0, int v1) {
}
void CGameObject::draw(CScreenManager *screenManager) {
- warning("TODO: CGameObject::draw");
+ if (!_field5C)
+ return;
+ if (_v1) {
+ error("TODO: Block in CGameObject::draw");
+ }
+
+ if (_field40) {
+ if (_field90) {
+ if (_bounds.intersects(getGameManager()->_bounds))
+ warning("TODO: _field90(screenManager);");
+ }
+ } else {
+ if (!_surface) {
+ if (!_resource.empty()) {
+ loadResource(_resource);
+ _resource = "";
+ }
+ }
+
+ if (_surface) {
+ _bounds.right = _surface->getWidth();
+ _bounds.bottom = _surface->getHeight();
+
+ if (!_bounds.right || !_bounds.bottom)
+ return;
+
+ if (_frameNumber >= 0) {
+ loadFrame(_frameNumber);
+ _frameNumber = -1;
+ }
+
+ if (!_clipList2.empty())
+ processClipList2();
+
+ if (_bounds.intersects(getGameManager()->_bounds)) {
+ if (_surface) {
+ Point destPos(_bounds.left, _bounds.top);
+ screenManager->blitFrom(0, _surface, &destPos);
+ }
+
+ if (_field90)
+ warning("TODO: sub_415f80(screenManager);");
+ }
+ }
+ }
+}
+
+void CGameObject::loadResource(const CString &name) {
+ switch (name.imageTypeSuffix()) {
+ case FILETYPE_IMAGE:
+ loadImage(name);
+ break;
+ case FILETYPE_MOVIE:
+ loadMovie(name);
+ break;
+ }
+}
+
+void CGameObject::loadMovie(const CString &name, bool pendingFlag) {
+ warning("TODO: CGameObject::loadMovie");
+}
+
+void CGameObject::loadImage(const CString &name, bool pendingFlag) {
+ // Get a refernce to the game and screen managers
+ CGameManager *gameManager = getGameManager();
+ CScreenManager *screenManager;
+
+ if (gameManager && (screenManager = CScreenManager::setCurrent()) != nullptr) {
+ // Destroy the object's surface if it already had one
+ if (_surface) {
+ delete _surface;
+ _surface = nullptr;
+ }
+
+ g_vm->_filesManager.fn5(name);
+
+ if (!name.empty()) {
+ _surface = new OSVideoSurface(screenManager, CResourceKey(name), pendingFlag);
+ }
+
+ if (_surface && !pendingFlag) {
+ _bounds.right = _surface->getWidth();
+ _bounds.bottom = _surface->getHeight();
+ }
+
+ // Mark the object's area as dirty, so that on the next frame rendering
+ // this object will be redrawn
+ makeDirty();
+ }
+
+ _field78 = 0;
+}
+
+void CGameObject::loadFrame(int frameNumber) {
+ warning("CGameObject::loadFrame");
+}
+
+void CGameObject::processClipList2() {
+ warning("CGameObject::processClipList2");
+}
+
+void CGameObject::makeDirty(const Rect &r) {
+ CGameManager *gameManager = getGameManager();
+ if (gameManager)
+ gameManager->extendBounds(r);
+}
+
+void CGameObject::makeDirty() {
+ makeDirty(_bounds);
}
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 675339e926..b327671b6b 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -29,7 +29,43 @@
namespace Titanic {
+class CVideoSurface;
+
class CGameObject : public CNamedItem {
+public:
+ static void *_v1;
+private:
+ /**
+ * Load a visual resource for the object
+ */
+ void loadResource(const CString &name);
+
+ /**
+ * Loads a movie
+ */
+ void loadMovie(const CString &name, bool pendingFlag = true);
+
+ /**
+ * Loads an image
+ */
+ void loadImage(const CString &name, bool pendingFlag = true);
+
+ /**
+ * Loads a frame
+ */
+ void loadFrame(int frameNumber);
+
+ void processClipList2();
+
+ /**
+ * Marks the area in the passed rect as dirty, and requiring re-rendering
+ */
+ void makeDirty(const Rect &r);
+
+ /**
+ * Marks the area occupied by the object as dirty, requiring re-rendering
+ */
+ void makeDirty();
protected:
Rect _bounds;
double _field34;
@@ -46,15 +82,15 @@ protected:
CMovieClipList _clipList1;
int _field78;
CMovieClipList _clipList2;
- int _field8C;
+ int _frameNumber;
int _field90;
int _field94;
int _field98;
int _field9C;
int _fieldA0;
int _fieldA4;
- void *_fieldA8;
- CString _string;
+ CVideoSurface *_surface;
+ CString _resource;
int _fieldB8;
public:
int _field60;
diff --git a/engines/titanic/core/resource_key.h b/engines/titanic/core/resource_key.h
index dc4c791cea..ab49cb8b12 100644
--- a/engines/titanic/core/resource_key.h
+++ b/engines/titanic/core/resource_key.h
@@ -36,6 +36,8 @@ private:
void setValue(const CString &name);
public:
CLASSDEF
+ CResourceKey() {}
+ CResourceKey(const CString &name) { setValue(name); }
/**
* Save the data for the class to file
diff --git a/engines/titanic/files_manager.cpp b/engines/titanic/files_manager.cpp
index 7ff0b51af8..f56c9c5e45 100644
--- a/engines/titanic/files_manager.cpp
+++ b/engines/titanic/files_manager.cpp
@@ -81,4 +81,8 @@ void CFilesManager::resetView() {
}
}
+void CFilesManager::fn5(const CString &name) {
+ warning("TODO: CFilesManager::fn5");
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/files_manager.h b/engines/titanic/files_manager.h
index ab92151055..0785bfc3c0 100644
--- a/engines/titanic/files_manager.h
+++ b/engines/titanic/files_manager.h
@@ -76,6 +76,8 @@ public:
* Resets the view being displayed
*/
void resetView();
+
+ void fn5(const CString &name);
};
} // End of namespace Titanic
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index a80e871e49..a3c241c1dc 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -235,4 +235,11 @@ void CGameManager::frameMessage(CRoomItem *room) {
}
}
+void CGameManager::extendBounds(const Rect &r) {
+ if (_bounds.isEmpty())
+ _bounds = r;
+ else
+ _bounds.combine1(r);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 51e1c3dd8f..610c438cfa 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -192,6 +192,12 @@ public:
void inc54() { ++_field54; }
void dec54() { --_field54; }
+
+ /**
+ * Extends the bounds of the currently affected game display area
+ * to include the passed rect
+ */
+ void extendBounds(const Rect &r);
};
} // End of namespace Titanic