aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/game_manager.cpp49
-rw-r--r--engines/titanic/game_manager.h46
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/support/timer.cpp109
-rw-r--r--engines/titanic/support/timer.h94
5 files changed, 213 insertions, 86 deletions
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index a4e3420702..56355dc58b 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -30,41 +30,6 @@
namespace Titanic {
-void CGameManagerList::postLoad(uint ticks, CProjectItem *project) {
- for (iterator i = begin(); i != end(); ++i)
- (*i)->postLoad(ticks, project);
-}
-
-void CGameManagerList::preSave() {
- for (iterator i = begin(); i != end(); ++i)
- (*i)->preSave();
-}
-
-void CGameManagerList::postSave() {
- for (iterator i = begin(); i != end(); ++i)
- (*i)->postSave();
-}
-
-void CGameManagerList::update(uint ticks) {
- warning("TODO: CGameManagerList::update");
-}
-
-/*------------------------------------------------------------------------*/
-
-void CGameManagerListItem::postLoad(uint ticks, CProjectItem *project) {
- warning("TODO");
-}
-
-void CGameManagerListItem::preSave() {
- warning("TODO: CGameManagerListItem::preSave");
-}
-
-void CGameManagerListItem::postSave() {
- warning("TODO: CGameManagerListItem::postSave");
-}
-
-/*------------------------------------------------------------------------*/
-
CGameManager::CGameManager(CProjectItem *project, CGameView *gameView):
_project(project), _gameView(gameView), _trueTalkManager(this),
_inputHandler(this), _inputTranslator(&_inputHandler),
@@ -82,14 +47,14 @@ void CGameManager::load(SimpleFile *file) {
file->readNumber();
_gameState.load(file);
- _list.load(file);
+ _timers.load(file);
_trueTalkManager.load(file);
_sound.load(file);
}
void CGameManager::preLoad() {
updateDiskTicksCount();
- _list.destroyContents();
+ _timers.destroyContents();
_soundMaker = nullptr;
_trueTalkManager.preLoad();
@@ -111,8 +76,8 @@ void CGameManager::postLoad(CProjectItem *project) {
CLoadSuccessMsg msg(_lastDiskTicksCount - _tickCount2);
msg.execute(project, nullptr, MSGFLAG_SCAN);
- // Signal to any registered list items
- _list.postLoad(_lastDiskTicksCount, _project);
+ // Signal to any registered timers
+ _timers.postLoad(_lastDiskTicksCount, _project);
// Signal the true talk manager and sound
_trueTalkManager.postLoad();
@@ -126,13 +91,13 @@ void CGameManager::preSave(CProjectItem *project) {
msg.execute(project, nullptr, MSGFLAG_SCAN);
// Notify sub-objects of the save
- _list.preSave();
+ _timers.preSave();
_trueTalkManager.preSave();
_sound.preSave();
}
void CGameManager::postSave() {
- _list.postSave();
+ _timers.postSave();
_trueTalkManager.postSave();
}
@@ -151,7 +116,7 @@ void CGameManager::playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *new
void CGameManager::update() {
updateMovies();
frameMessage(getRoom());
- _list.update(g_vm->_events->getTicksCount());
+ _timers.update(g_vm->_events->getTicksCount());
_trueTalkManager.update1();
_trueTalkManager.update2();
CScreenManager::_screenManagerPtr->_mouseCursor->update();
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 5a2787daf2..8b4c0be34e 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -28,6 +28,7 @@
#include "titanic/input_handler.h"
#include "titanic/input_translator.h"
#include "titanic/support/simple_file.h"
+#include "titanic/support/timer.h"
#include "titanic/support/video_surface.h"
#include "titanic/true_talk/true_talk_manager.h"
#include "titanic/sound/background_sound_maker.h"
@@ -39,53 +40,10 @@ namespace Titanic {
class CProjectItem;
class CGameView;
-class CGameManagerListItem : public ListItem {
-private:
- static int _v1;
-public:
- /**
- * Called after loading a game has finished
- */
- void postLoad(uint ticks, CProjectItem *project);
-
- /**
- * Called when a game is about to be saved
- */
- void preSave();
-
- /**
- * Called when a game has finished being saved
- */
- void postSave();
-};
-
-class CGameManagerList : public List<CGameManagerListItem> {
-public:
- /**
- * Called after loading a game has finished
- */
- void postLoad(uint ticks, CProjectItem *project);
-
- /**
- * Called when a game is about to be saved
- */
- void preSave();
-
- /**
- * Called when a game has finished being saved
- */
- void postSave();
-
- /**
- * Handles an update
- */
- void update(uint ticks);
-};
-
class CGameManager {
private:
CTrueTalkManager _trueTalkManager;
- CGameManagerList _list;
+ CTimerList _timers;
int _field30;
CBackgroundSoundMaker *_soundMaker;
CVideoSurface *_videoSurface1;
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 80abc1a760..74dfbfbb7c 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -437,6 +437,7 @@ MODULE_OBJS := \
support/simple_file.o \
support/string.o \
support/text_cursor.o \
+ support/timer.o \
support/video_surface.o \
true_talk/barbot_script.o \
true_talk/bellbot_script.o \
diff --git a/engines/titanic/support/timer.cpp b/engines/titanic/support/timer.cpp
new file mode 100644
index 0000000000..6f99a67fd8
--- /dev/null
+++ b/engines/titanic/support/timer.cpp
@@ -0,0 +1,109 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/support/timer.h"
+#include "titanic/core/project_item.h"
+
+namespace Titanic {
+
+void CTimerList::postLoad(uint ticks, CProjectItem *project) {
+ for (iterator i = begin(); i != end(); ++i)
+ (*i)->postLoad(ticks, project);
+}
+
+void CTimerList::preSave() {
+ for (iterator i = begin(); i != end(); ++i)
+ (*i)->preSave();
+}
+
+void CTimerList::postSave() {
+ for (iterator i = begin(); i != end(); ++i)
+ (*i)->postSave();
+}
+
+void CTimerList::update(uint ticks) {
+ // Remove any items that are done
+ for (iterator i = begin(); i != end(); ) {
+ CTimer *item = *i;
+ if (item->_done) {
+ i = erase(i);
+ delete item;
+ } else {
+ ++i;
+ }
+ }
+
+ // Handle updating the items
+ for (iterator i = begin(); i != end(); ) {
+ CTimer *item = *i;
+ if (!item->update(ticks)) {
+ ++i;
+ } else {
+ i = erase(i);
+ delete item;
+ }
+ }
+}
+
+void CTimerList::stop(uint id) {
+ for (iterator i = begin(); i != end(); ++i) {
+ CTimer *item = *i;
+ if (item->_id == id) {
+ item->_done = true;
+ return;
+ }
+ }
+}
+
+void CTimerList::set44(uint id, uint val) {
+ for (iterator i = begin(); i != end(); ++i) {
+ CTimer *item = *i;
+ if (item->_id == id) {
+ item->set44(val);
+ return;
+ }
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+CTimer::CTimer() : _id(0), _done(false),
+ _field44(0) {
+}
+
+void CTimer::postLoad(uint ticks, CProjectItem *project) {
+ warning("TODO");
+}
+
+void CTimer::preSave() {
+ warning("TODO: CTimer::preSave");
+}
+
+void CTimer::postSave() {
+ warning("TODO: CTimer::postSave");
+}
+
+bool CTimer::update(uint ticks) {
+ return false;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/support/timer.h b/engines/titanic/support/timer.h
new file mode 100644
index 0000000000..4d74bae34c
--- /dev/null
+++ b/engines/titanic/support/timer.h
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_TIMER_H
+#define TITANIC_TIMER_H
+
+#include "titanic/core/list.h"
+
+namespace Titanic {
+
+class CProjectItem;
+
+class CTimer : public ListItem {
+private:
+ static int _v1;
+public:
+ uint _id;
+ bool _done;
+ uint _field44;
+public:
+ CTimer();
+
+ /**
+ * Called after loading a game has finished
+ */
+ void postLoad(uint ticks, CProjectItem *project);
+
+ /**
+ * Called when a game is about to be saved
+ */
+ void preSave();
+
+ /**
+ * Called when a game has finished being saved
+ */
+ void postSave();
+
+ bool update(uint ticks);
+
+ void set44(uint val) { _field44 = val; }
+};
+
+class CTimerList : public List<CTimer> {
+public:
+ /**
+ * Called after loading a game has finished
+ */
+ void postLoad(uint ticks, CProjectItem *project);
+
+ /**
+ * Called when a game is about to be saved
+ */
+ void preSave();
+
+ /**
+ * Called when a game has finished being saved
+ */
+ void postSave();
+
+ /**
+ * Handles an update
+ */
+ void update(uint ticks);
+
+ /**
+ * Remove an item with the given Id
+ */
+ void stop(uint id);
+
+ void set44(uint id, uint val);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TIMER_H */