aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-19 20:58:37 -0400
committerPaul Gilbert2016-07-15 19:23:44 -0400
commitf0889c17a46019b8b294a74d054d0c60e445190b (patch)
treed9ddfcb512eefb3bcca3307228464d27ce0c4027
parent2267c5eb4c5addecbf0012495f84ece6d6df835d (diff)
downloadscummvm-rg350-f0889c17a46019b8b294a74d054d0c60e445190b.tar.gz
scummvm-rg350-f0889c17a46019b8b294a74d054d0c60e445190b.tar.bz2
scummvm-rg350-f0889c17a46019b8b294a74d054d0c60e445190b.zip
TITANIC: Implementing lots of cGameObject methods
-rw-r--r--engines/titanic/core/game_object.cpp91
-rw-r--r--engines/titanic/core/game_object.h41
-rw-r--r--engines/titanic/core/mail_man.cpp17
-rw-r--r--engines/titanic/core/mail_man.h9
-rw-r--r--engines/titanic/game_state.cpp2
-rw-r--r--engines/titanic/game_state.h2
-rw-r--r--engines/titanic/pet_control/pet_control.cpp4
-rw-r--r--engines/titanic/pet_control/pet_control.h6
-rw-r--r--engines/titanic/support/movie.cpp8
-rw-r--r--engines/titanic/support/movie.h2
-rw-r--r--engines/titanic/support/video_surface.cpp4
-rw-r--r--engines/titanic/support/video_surface.h4
12 files changed, 178 insertions, 12 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 2da7d79949..4a5dd9b065 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -343,7 +343,10 @@ void CGameObject::loadFrame(int frameNumber) {
}
void CGameObject::processClipList2() {
- warning("CGameObject::processClipList2");
+ for (CMovieClipList::iterator i = _clipList2.begin(); i != _clipList2.end(); ++i)
+ (*i)->process(this);
+
+ _clipList2.destroyContents();
}
void CGameObject::makeDirty(const Rect &r) {
@@ -429,6 +432,17 @@ void CGameObject::playClip(uint startFrame, uint endFrame) {
gameManager->playClip(clip, room, room);
}
+void CGameObject::playRandomClip(const char **names, uint flags) {
+ // Count size of array
+ int count = 0;
+ for (const char **p = names; *p; ++p)
+ ++count;
+
+ // Play clip
+ const char *name = names[g_vm->getRandomNumber(count - 1)];
+ playClip(name, flags);
+}
+
void CGameObject::playMovie(uint flags) {
_frameNumber = -1;
if (!_surface && !_resource.empty()) {
@@ -844,6 +858,11 @@ void CGameObject::dragMove(const Point &pt) {
setPosition(Point(pt.x - _bounds.width() / 2, pt.y - _bounds.height() / 2));
}
+Point CGameObject::getControid() const {
+ return Point(_bounds.left + _bounds.width() / 2,
+ _bounds.top + _bounds.height() / 2);
+}
+
bool CGameObject::clipExistsByStart(const CString &name, int startFrame) const {
return _clipList1.existsByStart(name, startFrame);
}
@@ -943,7 +962,75 @@ void CGameObject::createCredits() {
_credits = new CCreditText();
CScreenManager *screenManager = getGameManager()->setScreenManager();
_credits->load(this, screenManager, _bounds);
-
+}
+
+void CGameObject::fn10(int v1, int v2, int v3) {
+ makeDirty();
+ _field44 = v1;
+ _field48 = v2;
+ _field4C = v3;
+}
+
+void CGameObject::setMovie14(int v) {
+ if (!_surface && !_resource.empty()) {
+ loadResource(_resource);
+ _resource.clear();
+ }
+
+ if (_surface && _surface->_movie)
+ _surface->_movie->_field14 = v;
+}
+
+void CGameObject::movie38(int v1, int v2) {
+ if (_surface)
+ _surface->proc38(v1, v2);
+}
+
+void CGameObject::movie38(int v1) {
+ if (_surface)
+ _surface->proc38(-1, v1);
+}
+
+int CGameObject::getClipDuration(const CString &name, int frameRate) const {
+ CMovieClip *clip = _clipList1.findByName(name);
+ return clip ? (clip->_endFrame - clip->_startFrame) * 1000 / frameRate : 0;
+}
+
+void CGameObject::petIncC0() {
+ getPetControl()->incC0();
+}
+
+void CGameObject::petDecC0() {
+ getPetControl()->decC0();
+}
+
+void CGameObject::setState1C(bool flag) {
+ getGameManager()->_gameState._field1C = flag;
+}
+
+void CGameObject::mailFn10(int v) {
+ CMailMan *mailMan = getMailMan();
+ if (mailMan) {
+ makeDirty();
+ mailMan->fn10(this, v);
+ }
+}
+
+void CGameObject::mailFn11(int v) {
+ CMailMan *mailMan = getMailMan();
+ if (mailMan) {
+ makeDirty();
+ mailMan->fn11(this, v);
+ }
+}
+
+bool CGameObject::mailExists(int id) const {
+ return findMail(id) != nullptr;
+}
+
+CGameObject *CGameObject::findMail(int id) const {
+ CMailMan *mailMan = getMailMan();
+ return mailMan ? mailMan->findMail(id) : nullptr;
}
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 44e12319e4..01f15ceb85 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -276,6 +276,11 @@ protected:
void dragMove(const Point &pt);
/**
+ * Get the centre of the game object's bounds
+ */
+ Point getControid() const;
+
+ /**
* Set the position of the object
*/
void setPosition(const Point &newPos);
@@ -293,6 +298,11 @@ protected:
void playClip(uint startFrame, uint endFrame);
/**
+ * Play a clip randomly from a passed list of names
+ */
+ void playRandomClip(const char **names, uint flags);
+
+ /**
* Return the current view/node/room as a single string
*/
CString getViewFullName() const;
@@ -353,6 +363,37 @@ protected:
* Set's the player's passenger class
*/
void setPassengerClass(int newClass);
+
+ void setMovie14(int v);
+
+ void movie38(int v1, int v2);
+
+ void movie38(int v1);
+
+ void fn10(int v1, int v2, int v3);
+
+ /**
+ * Gets the duration of a specified clip in milliseconds
+ */
+ int getClipDuration(const CString &name, int frameRate = 14) const;
+
+ void petIncC0();
+ void petDecC0();
+
+ void setState1C(bool flag);
+
+ void mailFn10(int v);
+ void mailFn11(int v);
+
+ /**
+ * Returns true if a mail with a specified Id exists
+ */
+ bool mailExists(int id) const;
+
+ /**
+ * Returns a specified mail, if one exists
+ */
+ CGameObject *findMail(int id) const;
public:
int _field60;
CursorId _cursorId;
diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp
index cb959245b5..e96b697dff 100644
--- a/engines/titanic/core/mail_man.cpp
+++ b/engines/titanic/core/mail_man.cpp
@@ -47,4 +47,21 @@ CGameObject *CMailMan::getNextObject(CGameObject *prior) const {
return static_cast<CGameObject *>(prior->getNextSibling());
}
+void CMailMan::fn10(CGameObject *obj, int v) {
+ warning("TODO: CMailMan::fn10");
+}
+
+void CMailMan::fn11(CGameObject *obj, int v) {
+ warning("TODO: CMailMan::fn11");
+}
+
+CGameObject *CMailMan::findMail(int id) const {
+ for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) {
+ if (_field50 && _field54 == id)
+ return obj;
+ }
+
+ return nullptr;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/mail_man.h b/engines/titanic/core/mail_man.h
index d1c84e2264..1a95729ff1 100644
--- a/engines/titanic/core/mail_man.h
+++ b/engines/titanic/core/mail_man.h
@@ -54,8 +54,17 @@ public:
* the passed game object
*/
CGameObject *getNextObject(CGameObject *prior) const;
+
+ void fn10(CGameObject *obj, int v);
+ void fn11(CGameObject *obj, int v);
+
+ /**
+ * Scan the mail list for a specified item
+ */
+ CGameObject *findMail(int id) const;
};
+
} // End of namespace Titanic
#endif /* TITANIC_MAIL_MAN_H */
diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp
index c552c69831..d129767e10 100644
--- a/engines/titanic/game_state.cpp
+++ b/engines/titanic/game_state.cpp
@@ -46,7 +46,7 @@ bool CGameStateMovieList::clear() {
CGameState::CGameState(CGameManager *gameManager) :
_gameManager(gameManager), _gameLocation(this),
_passengerClass(0), _priorClass(0), _mode(GSMODE_UNSELECTED),
- _field14(0), _petActive(false), _field1C(0), _quitGame(false),
+ _field14(0), _petActive(false), _field1C(false), _quitGame(false),
_field24(0), _nodeChangeCtr(0), _nodeEnterTicks(0), _field38(0) {
}
diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h
index 65126120be..327459278d 100644
--- a/engines/titanic/game_state.h
+++ b/engines/titanic/game_state.h
@@ -59,7 +59,7 @@ public:
GameStateMode _mode;
int _field14;
bool _petActive;
- int _field1C;
+ bool _field1C;
bool _quitGame;
int _field24;
uint _nodeChangeCtr;
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 51631a3e1b..37af6f7d0a 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -239,10 +239,6 @@ bool CPetControl::containsPt(const Common::Point &pt) const {
return _drawBounds.contains(pt);
}
-bool CPetControl::getC0() const {
- return _fieldC0 > 0;
-}
-
bool CPetControl::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (!containsPt(msg->_mousePos) || getC0())
return false;
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index cf1589ca62..71785cedb6 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -92,8 +92,6 @@ private:
*/
bool containsPt(const Common::Point &pt) const;
- bool getC0() const;
-
/**
* Checks whether a designated NPC in present in the current view
*/
@@ -304,6 +302,10 @@ public:
* Resets the dial display to reflect new values
*/
void resetDials(int flag = 1);
+
+ bool getC0() const { return _fieldC0 > 0; }
+ void incC0() { ++_fieldC0; }
+ void decC0() { --_fieldC0; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp
index 1c94cab250..26620de3a6 100644
--- a/engines/titanic/support/movie.cpp
+++ b/engines/titanic/support/movie.cpp
@@ -26,7 +26,8 @@
namespace Titanic {
-CMovie::CMovie() : ListItem(), _state(MOVIE_STOPPED), _field10(0) {
+CMovie::CMovie() : ListItem(), _state(MOVIE_STOPPED), _field10(0),
+ _field14(0) {
}
CMovie::~CMovie() {
@@ -50,7 +51,10 @@ bool CMovie::get10() {
OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) :
_videoSurface(surface), _gameObject(nullptr), _endFrame(-1) {
- _video = new Video::AVIDecoder();
+ Video::AVIDecoder *decoder = new Video::AVIDecoder();
+ _video = decoder;
+ _field14 = 1;
+
if (!_video->loadFile(name.getString()))
error("Could not open video - %s", name.getString().c_str());
}
diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h
index 20de84afa5..01f107ec5b 100644
--- a/engines/titanic/support/movie.h
+++ b/engines/titanic/support/movie.h
@@ -46,6 +46,8 @@ protected:
MovieState _state;
int _field10;
public:
+ int _field14;
+public:
CMovie();
virtual ~CMovie();
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 813138da4a..3b026c546c 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -418,6 +418,10 @@ void OSVideoSurface::setMovieFrame(uint frameNumber) {
_movie->setFrame(frameNumber);
}
+void OSVideoSurface::proc38(int v1, int v2) {
+ warning("OSVideoSurface::proc38");
+}
+
bool OSVideoSurface::loadIfReady() {
_videoSurfaceNum = _videoSurfaceCounter;
diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h
index aee28be730..8d0dd2ffac 100644
--- a/engines/titanic/support/video_surface.h
+++ b/engines/titanic/support/video_surface.h
@@ -178,6 +178,8 @@ public:
*/
virtual void setMovieFrame(uint frameNumber) = 0;
+ virtual void proc38(int v1, int v2) = 0;
+
/**
* Loads the surface's resource if there's one pending
*/
@@ -343,6 +345,8 @@ public:
*/
virtual void setMovieFrame(uint frameNumber);
+ virtual void proc38(int v1, int v2);
+
/**
* Loads the surface's resource if there's one pending
*/