aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-25 00:01:15 -0400
committerPaul Gilbert2016-03-25 00:01:15 -0400
commit73204984098c96ecc28a1367a5da9613e7103a35 (patch)
tree0ab93c76c03eaedc10e94eed67dbbc1d38addf58
parent0b37ac18693c7f51212f250b8a9990071a1dda2b (diff)
downloadscummvm-rg350-73204984098c96ecc28a1367a5da9613e7103a35.tar.gz
scummvm-rg350-73204984098c96ecc28a1367a5da9613e7103a35.tar.bz2
scummvm-rg350-73204984098c96ecc28a1367a5da9613e7103a35.zip
TITANIC: Implementing more CTelevision code, CGameState movie list
-rw-r--r--engines/titanic/core/game_object.cpp16
-rw-r--r--engines/titanic/core/game_object.h5
-rw-r--r--engines/titanic/core/list.h12
-rw-r--r--engines/titanic/game/television.cpp2
-rw-r--r--engines/titanic/game_state.cpp36
-rw-r--r--engines/titanic/game_state.h18
-rw-r--r--engines/titanic/movie.cpp9
-rw-r--r--engines/titanic/movie.h10
-rw-r--r--engines/titanic/titanic.h2
-rw-r--r--engines/titanic/video_surface.cpp5
-rw-r--r--engines/titanic/video_surface.h6
11 files changed, 101 insertions, 20 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index a442f09937..a215633932 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -304,4 +304,20 @@ void CGameObject::fn1(int val1, int val2, int val3) {
warning("TODO: CGameObject::fn1");
}
+void CGameObject::changeStatus(int newStatus) {
+ if (_frameNumber == -1 && !_resource.empty()) {
+ loadResource(_resource);
+ _resource.clear();
+ }
+
+ CVideoSurface *surface = (newStatus & 4) ? _surface : nullptr;
+ if (_surface) {
+ _surface->proc32(newStatus, surface);
+
+ if (newStatus & 0x10) {
+ getGameManager()->_gameState.addMovie(_surface->_movie);
+ }
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 46ec502c56..2f56f599a0 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -130,6 +130,11 @@ public:
bool checkPoint(const Point &pt, int v0, int v1);
void fn1(int val1, int val2, int val3);
+
+ /**
+ * Change the object's status
+ */
+ void changeStatus(int newStatus);
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/list.h b/engines/titanic/core/list.h
index e3623c15b4..63bd6227b9 100644
--- a/engines/titanic/core/list.h
+++ b/engines/titanic/core/list.h
@@ -71,6 +71,8 @@ public:
template<typename T>
class List : public CSaveableObject, public Common::List<T *> {
public:
+ virtual ~List() { destroyContents(); }
+
/**
* Save the data for the class to file
*/
@@ -145,6 +147,16 @@ public:
Common::List<T *>::push_back(item);
return item;
}
+
+ bool contains(const T *item) const {
+ for (Common::List<T *>::const_iterator i = Common::List<T *>::begin();
+ i != Common::List<T *>::end(); ++i) {
+ if (*i == item)
+ return true;
+ }
+
+ return false;
+ }
};
} // End of namespace Titanic
diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp
index cb59647cc1..8149b8d017 100644
--- a/engines/titanic/game/television.cpp
+++ b/engines/titanic/game/television.cpp
@@ -164,7 +164,7 @@ bool CTelevision::handleMessage(CPETDownMsg &msg) {
bool CTelevision::handleMessage(CStatusChangeMsg &msg) {
if (_isOn) {
stopMovie();
- // TODO:
+ changeStatus(1);
}
warning("TODO");
diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp
index 2885b3ad0c..d191d982b0 100644
--- a/engines/titanic/game_state.cpp
+++ b/engines/titanic/game_state.cpp
@@ -27,9 +27,18 @@
namespace Titanic {
-bool CGameStateList::isViewChanging() const {
- warning("TODO: CGameStateList::isViewChanging");
- return false;
+bool CGameStateMovieList::clear() {
+ for (iterator i = begin(); i != end(); ) {
+ CMovieListItem *listItem = *i;
+ ++i;
+
+ if (!g_vm->_movieList.contains(listItem->_item)) {
+ remove(listItem);
+ delete listItem;
+ }
+ }
+
+ return size() > 0;
}
/*------------------------------------------------------------------------*/
@@ -98,20 +107,20 @@ void CGameState::enterNode() {
void CGameState::enterView() {
CViewItem *oldView = _gameLocation.getView();
- CViewItem *newView = _list._view;
+ CViewItem *newView = _movieList._view;
oldView->preEnterView(newView);
_gameManager->_gameView->setView(newView);
CRoomItem *oldRoom = oldView->findNode()->findRoom();
CRoomItem *newRoom = newView->findNode()->findRoom();
- _gameManager->playClip(_list._movieClip, oldRoom, newRoom);
+ _gameManager->playClip(_movieList._movieClip, oldRoom, newRoom);
_gameManager->_sound.preEnterView(newView, newRoom != oldRoom);
_gameManager->dec54();
oldView->enterView(newView);
- _list._view = nullptr;
- _list._movieClip = nullptr;
+ _movieList._view = nullptr;
+ _movieList._movieClip = nullptr;
}
void CGameState::triggerLink(CLinkItem *link) {
@@ -128,8 +137,8 @@ void CGameState::changeView(CViewItem *newView, CMovieClip *clip) {
clip = nullptr;
if (_mode == GSMODE_2) {
- _list._view = newView;
- _list._movieClip = clip;
+ _movieList._view = newView;
+ _movieList._movieClip = clip;
} else {
oldView->preEnterView(newView);
_gameManager->_gameView->setView(newView);
@@ -147,11 +156,16 @@ void CGameState::changeView(CViewItem *newView, CMovieClip *clip) {
}
void CGameState::checkForViewChange() {
- if (_mode == GSMODE_2 && _list.isViewChanging()) {
+ if (_mode == GSMODE_2 && _movieList.clear()) {
setMode(GSMODE_1);
- if (_list._view)
+ if (_movieList._view)
enterView();
}
}
+void CGameState::addMovie(CMovie *movie) {
+ _movieList.push_back(new CMovieListItem(movie));
+ setMode(GSMODE_2);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h
index 49bcbcdd97..49180aa38c 100644
--- a/engines/titanic/game_state.h
+++ b/engines/titanic/game_state.h
@@ -27,6 +27,7 @@
#include "titanic/core/link_item.h"
#include "titanic/simple_file.h"
#include "titanic/game_location.h"
+#include "titanic/movie.h"
namespace Titanic {
@@ -34,21 +35,25 @@ class CGameManager;
enum GameStateMode { GSMODE_0 = 0, GSMODE_1 = 1, GSMODE_2 = 2, GSMODE_3 = 3, GSMODE_4 = 4, GSMODE_5 = 5 };
-class CGameStateList : public List<ListItem> {
+PTR_LIST_ITEM(CMovie);
+class CGameStateMovieList : public List<CMovieListItem> {
public:
CViewItem *_view;
CMovieClip *_movieClip;
public:
- CGameStateList() : List<ListItem>(), _view(nullptr), _movieClip(nullptr) {}
+ CGameStateMovieList() : List<CMovieListItem>(), _view(nullptr), _movieClip(nullptr) {}
- bool isViewChanging() const;
+ /**
+ * Clear the movie list
+ */
+ bool clear();
};
class CGameState {
public:
CGameManager *_gameManager;
CGameLocation _gameLocation;
- CGameStateList _list;
+ CGameStateMovieList _movieList;
int _field8;
int _fieldC;
GameStateMode _mode;
@@ -108,6 +113,11 @@ public:
* Check for whether it's time to change the active view
*/
void checkForViewChange();
+
+ /**
+ * Adds a movie to the movie list
+ */
+ void addMovie(CMovie *movie);
};
} // End of namespace Titanic
diff --git a/engines/titanic/movie.cpp b/engines/titanic/movie.cpp
index 58da09e61f..09c02a7964 100644
--- a/engines/titanic/movie.cpp
+++ b/engines/titanic/movie.cpp
@@ -21,6 +21,7 @@
*/
#include "titanic/movie.h"
+#include "titanic/titanic.h"
namespace Titanic {
@@ -28,7 +29,7 @@ OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) : _videoSurfa
// _aviDecoder.loadFile(name.getString());
}
-void OSMovie::proc8() {
+void OSMovie::proc8(int v1, CVideoSurface *surface) {
warning("TODO: OSMovie::proc8");
}
@@ -91,4 +92,10 @@ void *OSMovie::proc21() {
return nullptr;
}
+bool OSMovie::isInGlobalList() const {
+ return g_vm->_movieList.contains(this);
+}
+
+/*------------------------------------------------------------------------*/
+
} // End of namespace Titanic
diff --git a/engines/titanic/movie.h b/engines/titanic/movie.h
index 4409712809..4a5777aa03 100644
--- a/engines/titanic/movie.h
+++ b/engines/titanic/movie.h
@@ -33,7 +33,7 @@ class CVideoSurface;
class CMovie : public ListItem {
public:
- virtual void proc8() = 0;
+ virtual void proc8(int v1, CVideoSurface *surface) = 0;
virtual void proc9() = 0;
virtual void proc10() = 0;
virtual void proc11() = 0;
@@ -56,7 +56,7 @@ private:
public:
OSMovie(const CResourceKey &name, CVideoSurface *surface);
- virtual void proc8();
+ virtual void proc8(int v1, CVideoSurface *surface);
virtual void proc9();
virtual void proc10();
virtual void proc11();
@@ -75,6 +75,12 @@ public:
virtual void proc19();
virtual void proc20();
virtual void *proc21();
+
+ bool isInGlobalList() const;
+};
+
+class CGlobalMovies : public List<CMovie> {
+public:
};
} // End of namespace Titanic
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index 94ba316836..512dfc39ad 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -33,6 +33,7 @@
#include "titanic/debugger.h"
#include "titanic/events.h"
#include "titanic/files_manager.h"
+#include "titanic/movie.h"
#include "titanic/screen_manager.h"
#include "titanic/main_game_window.h"
@@ -101,6 +102,7 @@ public:
OSScreenManager *_screenManager;
CMainGameWindow *_window;
Common::RandomSource _randomSource;
+ CGlobalMovies _movieList;
public:
TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDesc);
virtual ~TitanicEngine();
diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp
index 7a4aba565f..e8f0e03136 100644
--- a/engines/titanic/video_surface.cpp
+++ b/engines/titanic/video_surface.cpp
@@ -299,6 +299,11 @@ void OSVideoSurface::shiftColors() {
unlock();
}
+void OSVideoSurface::proc32(int v1, CVideoSurface *surface) {
+ if (loadIfReady() && _movie)
+ _movie->proc8(v1, surface);
+}
+
void OSVideoSurface::stopMovie() {
if (_movie)
_movie->stop();
diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h
index f3459b456f..b2390fb358 100644
--- a/engines/titanic/video_surface.h
+++ b/engines/titanic/video_surface.h
@@ -57,7 +57,6 @@ protected:
CResourceKey _resourceKey;
DirectDrawSurface *_ddSurface;
Graphics::ManagedSurface *_rawSurface;
- CMovie *_movie;
bool _pendingLoad;
void *_field40;
int _field44;
@@ -66,6 +65,7 @@ protected:
int _field50;
int _lockCount;
public:
+ CMovie *_movie;
bool _blitFlag;
bool _blitStyleFlag;
public:
@@ -139,6 +139,8 @@ public:
*/
virtual void shiftColors() = 0;
+ virtual void proc32(int v1, CVideoSurface *surface) = 0;
+
/**
* Stops any movie currently attached to the surface
*/
@@ -248,6 +250,8 @@ public:
*/
virtual void shiftColors();
+ virtual void proc32(int v1, CVideoSurface *surface);
+
/**
* Stops any movie currently attached to the surface
*/