diff options
author | Willem Jan Palenstijn | 2013-10-17 23:00:00 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-10-17 23:00:00 +0200 |
commit | a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8 (patch) | |
tree | eebd8ce8883e50be1487d18c19b818e4e7b91dc9 /engines/zvision/timer_node.cpp | |
parent | 6b9abcc2ec8409f37a9926a35d061096fab60018 (diff) | |
parent | 7a97c992de67152514886f80f3cf4f2f3686d3d4 (diff) | |
download | scummvm-rg350-a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8.tar.gz scummvm-rg350-a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8.tar.bz2 scummvm-rg350-a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8.zip |
Merge branch 'zvision'
This merges pull request 395 for the ZVision engine developed during
GSoC2013.
Diffstat (limited to 'engines/zvision/timer_node.cpp')
-rw-r--r-- | engines/zvision/timer_node.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp new file mode 100644 index 0000000000..55dfa51dfe --- /dev/null +++ b/engines/zvision/timer_node.cpp @@ -0,0 +1,59 @@ +/* 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 "common/scummsys.h" + +#include "zvision/timer_node.h" + +#include "zvision/zvision.h" +#include "zvision/script_manager.h" + +#include "common/stream.h" + + +namespace ZVision { + +TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) + : Control(engine, key), _timeLeft(timeInSeconds * 1000) { +} + +bool TimerNode::process(uint32 deltaTimeInMillis) { + _timeLeft -= deltaTimeInMillis; + + if (_timeLeft <= 0) { + _engine->getScriptManager()->setStateValue(_key, 0); + return true; + } + + return false; +} + +void TimerNode::serialize(Common::WriteStream *stream) { + stream->writeUint32LE(_key); + stream->writeUint32LE(_timeLeft); +} + +void TimerNode::deserialize(Common::SeekableReadStream *stream) { + _timeLeft = stream->readUint32LE(); +} + +} // End of namespace ZVision |