diff options
author | Paul Gilbert | 2016-04-09 17:12:41 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-04-09 17:12:41 -0400 |
commit | 6405ba6ecbbec9a8e45e6093bcacf2cab7f3b94b (patch) | |
tree | 9b386b06ff5af1b6926131c6ffe5603646c2cd4a /engines/titanic/support | |
parent | 3d166fb8a91a4d56bc1abac6f1e3899a0379cd31 (diff) | |
download | scummvm-rg350-6405ba6ecbbec9a8e45e6093bcacf2cab7f3b94b.tar.gz scummvm-rg350-6405ba6ecbbec9a8e45e6093bcacf2cab7f3b94b.tar.bz2 scummvm-rg350-6405ba6ecbbec9a8e45e6093bcacf2cab7f3b94b.zip |
TITANIC: Starting to flesh out timers
Diffstat (limited to 'engines/titanic/support')
-rw-r--r-- | engines/titanic/support/timer.cpp | 109 | ||||
-rw-r--r-- | engines/titanic/support/timer.h | 94 |
2 files changed, 203 insertions, 0 deletions
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 */ |