From 4963c9f50b53cbd663c18387d8606ad4623cca34 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 4 May 2016 07:03:13 -0400 Subject: TITANIC: Implement CMovieEvent & CMovieRangeInfo --- engines/titanic/core/game_object.cpp | 12 +++++ engines/titanic/core/game_object.h | 5 +++ engines/titanic/core/movie_clip.cpp | 31 ++++++++----- engines/titanic/core/movie_clip.h | 17 ++++--- engines/titanic/module.mk | 2 + engines/titanic/support/movie.cpp | 2 +- engines/titanic/support/movie.h | 4 +- engines/titanic/support/movie_event.cpp | 61 +++++++++++++++++++++++++ engines/titanic/support/movie_event.h | 58 ++++++++++++++++++++++++ engines/titanic/support/movie_range_info.cpp | 67 ++++++++++++++++++++++++++++ engines/titanic/support/movie_range_info.h | 64 ++++++++++++++++++++++++++ engines/titanic/support/video_surface.cpp | 6 +++ engines/titanic/support/video_surface.h | 4 ++ 13 files changed, 313 insertions(+), 20 deletions(-) create mode 100644 engines/titanic/support/movie_event.cpp create mode 100644 engines/titanic/support/movie_event.h create mode 100644 engines/titanic/support/movie_range_info.cpp create mode 100644 engines/titanic/support/movie_range_info.h diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 5e601f97b3..e6b51f7c12 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -737,4 +737,16 @@ bool CGameObject::clipExistsByStart(const CString &name, int startFrame) const { bool CGameObject::clipExistsByEnd(const CString &name, int endFrame) const { return _clipList1.existsByEnd(name, endFrame); } + +void CGameObject::checkPlayMovie(const CString &name, int flags) { + if (!_surface && !_resource.empty()) + loadResource(_resource); + + if (_surface ) { + _surface->proc35(name, flags, (flags & CLIPFLAG_4) ? this : nullptr); + if (flags & CLIPFLAG_PLAY) + 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 5264d0c8e6..7c40c5f027 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -338,6 +338,11 @@ public: * and ending frame number */ bool clipExistsByEnd(const CString &name, int endFrame = 0) const; + + /** + * Checks and plays a pending clip + */ + void checkPlayMovie(const CString &name, int flags); }; } // End of namespace Titanic diff --git a/engines/titanic/core/movie_clip.cpp b/engines/titanic/core/movie_clip.cpp index a0a6386df8..9e5df67bd7 100644 --- a/engines/titanic/core/movie_clip.cpp +++ b/engines/titanic/core/movie_clip.cpp @@ -21,16 +21,15 @@ */ #include "titanic/core/movie_clip.h" +#include "titanic/core/game_object.h" namespace Titanic { -CMovieClip::CMovieClip(): ListItem(), _startFrame(0), _endFrame(0), - _field20(0), _field24(0), _field28(0), _field2C(0), _field30(0) { +CMovieClip::CMovieClip(): ListItem(), _startFrame(0), _endFrame(0) { } CMovieClip::CMovieClip(const CString &name, int startFrame, int endFrame): - ListItem(), _name(name), _startFrame(startFrame), _endFrame(endFrame), - _field20(0), _field24(0), _field28(0), _field2C(0), _field30(0) { + ListItem(), _name(name), _startFrame(startFrame), _endFrame(endFrame) { } void CMovieClip::save(SimpleFile *file, int indent) const { @@ -48,14 +47,8 @@ void CMovieClip::load(SimpleFile *file) { switch (val) { case 1: - _name = file->readString(); - _startFrame = file->readNumber(); - _endFrame = file->readNumber(); - _field20 = file->readNumber(); - _field24 = file->readNumber(); - _field28 = file->readNumber(); - _field2C = file->readNumber(); - _field30 = file->readNumber(); + // This should never be used + assert(0); break; case 2: @@ -72,6 +65,20 @@ void CMovieClip::load(SimpleFile *file) { ListItem::load(file); } +void CMovieClip::process(CGameObject *owner) { + int flags = 0; + if (_endFrame) + flags |= CLIPFLAG_HAS_END_FRAME; + if (_startFrame) + flags |= CLIPFLAG_HAS_START_FRAME; + + warning("TODO: CMovieClip::process"); + + owner->checkPlayMovie(_name, flags); + + +} + CMovieClip *CMovieClipList::findByName(const Common::String &name) const { for (const_iterator i = begin(); i != end(); ++i) { CMovieClip *clip = *i; diff --git a/engines/titanic/core/movie_clip.h b/engines/titanic/core/movie_clip.h index 9ee88fd7a7..6486259c3b 100644 --- a/engines/titanic/core/movie_clip.h +++ b/engines/titanic/core/movie_clip.h @@ -27,16 +27,21 @@ namespace Titanic { +enum ClipFlag { + CLIPFLAG_HAS_END_FRAME = 1, + CLIPFLAG_4 = 4, + CLIPFLAG_HAS_START_FRAME = 8, + CLIPFLAG_PLAY = 0x10 +}; + +class CGameObject; + /** * Movie clip */ class CMovieClip : public ListItem { private: - int _field20; - int _field24; - int _field28; - int _field2C; - int _field30; + Common::List _items; CString _string2; CString _string3; public: @@ -57,6 +62,8 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file); + + void process(CGameObject *owner); }; /** diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index ae0c563f24..f570311add 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -436,6 +436,8 @@ MODULE_OBJS := \ support/image_decoders.o \ support/mouse_cursor.o \ support/movie.o \ + support/movie_event.o \ + support/movie_range_info.o \ support/proximity.o \ support/rect.o \ support/screen_manager.o \ diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp index 3ae2636404..1c94cab250 100644 --- a/engines/titanic/support/movie.cpp +++ b/engines/titanic/support/movie.cpp @@ -91,7 +91,7 @@ void OSMovie::proc11() { warning("TODO: OSMovie::proc11"); } -void OSMovie::proc12() { +void OSMovie::proc12(const CString &name, int flags, CGameObject *obj) { warning("TODO: OSMovie::proc12"); } diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h index 644f582d64..20de84afa5 100644 --- a/engines/titanic/support/movie.h +++ b/engines/titanic/support/movie.h @@ -61,7 +61,7 @@ public: virtual void proc10() = 0; virtual void proc11() = 0; - virtual void proc12() = 0; + virtual void proc12(const CString &name, int flags, CGameObject *obj) = 0; /** * Stops the movie @@ -119,7 +119,7 @@ public: virtual void proc10(); virtual void proc11(); - virtual void proc12(); + virtual void proc12(const CString &name, int flags, CGameObject *obj); /** * Stops the movie diff --git a/engines/titanic/support/movie_event.cpp b/engines/titanic/support/movie_event.cpp new file mode 100644 index 0000000000..b3e788e6fc --- /dev/null +++ b/engines/titanic/support/movie_event.cpp @@ -0,0 +1,61 @@ +/* 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/movie_event.h" + +namespace Titanic { + +CMovieEvent::CMovieEvent() : ListItem(), _fieldC(0), _field10(0), + _field14(0), _field1C(0) { +} + +CMovieEvent::CMovieEvent(const CMovieEvent *src) { + _fieldC = src->_fieldC; + _field10 = src->_field10; + _field14 = src->_field14; + _field18 = src->_field18; + _field1C = src->_field1C; +} + +void CMovieEvent::save(SimpleFile *file, int indent) const { + file->writeNumberLine(0, indent); + file->writeNumberLine(_fieldC, indent + 1); + file->writeNumberLine(_field10, indent + 1); + file->writeNumberLine(_field14, indent + 1); + file->writeNumberLine(_field1C, indent + 1); + + ListItem::save(file, indent); +} + +void CMovieEvent::load(SimpleFile *file) { + int val = file->readNumber(); + if (!val) { + _fieldC = file->readNumber(); + _field10 = file->readNumber(); + _field14 = file->readNumber(); + _field1C = file->readNumber(); + } + + ListItem::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/movie_event.h b/engines/titanic/support/movie_event.h new file mode 100644 index 0000000000..5c62220919 --- /dev/null +++ b/engines/titanic/support/movie_event.h @@ -0,0 +1,58 @@ +/* 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_MOVIE_EVENT_H +#define TITANIC_MOVIE_EVENT_H + +#include "titanic/core/list.h" + +namespace Titanic { + +class CMovieEvent : public ListItem { +public: + int _fieldC; + int _field10; + int _field14; + int _field18; + int _field1C; +public: + CMovieEvent(); + CMovieEvent(const CMovieEvent *src); + virtual ~CMovieEvent() {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) const; + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +class CMovieEventList : public List { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_EVENT_H */ diff --git a/engines/titanic/support/movie_range_info.cpp b/engines/titanic/support/movie_range_info.cpp new file mode 100644 index 0000000000..6242673c10 --- /dev/null +++ b/engines/titanic/support/movie_range_info.cpp @@ -0,0 +1,67 @@ +/* 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/movie_range_info.h" + +namespace Titanic { + +CMovieRangeInfo::CMovieRangeInfo() : ListItem(), _fieldC(0), + _field10(0), _field14(0), _field18(0), _field1C(0) { +} + +CMovieRangeInfo::CMovieRangeInfo(const CMovieRangeInfo *src) : ListItem() { + _fieldC = src->_fieldC; + _field10 = src->_field10; + _field14 = src->_field14; + _field18 = src->_field18; + _field1C = src->_field1C; + + // Duplicate the events list + for (CMovieEventList::const_iterator i = _events.begin(); + i != _events.end(); ++i) { + _events.push_back(new CMovieEvent(*i)); + } +} + +void CMovieRangeInfo::save(SimpleFile *file, int indent) const { + file->writeNumberLine(0, indent); + file->writeNumberLine(_fieldC, indent + 1); + file->writeNumberLine(_field10, indent + 1); + file->writeNumberLine(_field14, indent + 1); + file->writeNumberLine(_field1C, indent + 1); + file->writeNumberLine(_field18, indent + 1); + _events.save(file, indent + 1); +} + +void CMovieRangeInfo::load(SimpleFile *file) { + int val = file->readNumber(); + if (!val) { + _fieldC = file->readNumber(); + _field10 = file->readNumber(); + _field14 = file->readNumber(); + _field1C = file->readNumber(); + _field18 = file->readNumber(); + _events.load(file); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/movie_range_info.h b/engines/titanic/support/movie_range_info.h new file mode 100644 index 0000000000..e751e303db --- /dev/null +++ b/engines/titanic/support/movie_range_info.h @@ -0,0 +1,64 @@ +/* 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_MOVIE_RANGE_INFO_H +#define TITANIC_MOVIE_RANGE_INFO_H + +#include "video/video_decoder.h" +#include "titanic/core/list.h" +#include "titanic/core/resource_key.h" +#include "titanic/support/movie_event.h" + +namespace Titanic { + +class CMovieRangeInfo : public ListItem { +public: + int _fieldC; + int _field10; + int _field14; + int _field18; + int _field1C; + CMovieEventList _events; +public: + CMovieRangeInfo(); + CMovieRangeInfo(const CMovieRangeInfo *src); + virtual ~CMovieRangeInfo() {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) const; + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Adds an event to the events list + */ + void add(CMovieEvent *movieEvent) { _events.push_back(movieEvent); } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_RANGE_INFO_H */ diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp index e6b2fa7958..813138da4a 100644 --- a/engines/titanic/support/video_surface.cpp +++ b/engines/titanic/support/video_surface.cpp @@ -402,6 +402,12 @@ void OSVideoSurface::playMovie(uint startFrame, uint endFrame, int v3, bool v4) } } +void OSVideoSurface::proc35(const CString &name, int flags, CGameObject *owner) { + if (loadIfReady() && _movie) { + _movie->proc12(name, flags, owner); + } +} + void OSVideoSurface::stopMovie() { if (_movie) _movie->stop(); diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h index 7521a53b4b..aee28be730 100644 --- a/engines/titanic/support/video_surface.h +++ b/engines/titanic/support/video_surface.h @@ -166,6 +166,8 @@ public: */ virtual void playMovie(uint startFrame, uint endFrame, int v3, bool v4) = 0; + virtual void proc35(const CString &name, int flags, CGameObject *owner) = 0; + /** * Stops any movie currently attached to the surface */ @@ -329,6 +331,8 @@ public: */ virtual void playMovie(uint startFrame, uint endFrame, int v3, bool v4); + virtual void proc35(const CString &name, int flags, CGameObject *owner); + /** * Stops any movie currently attached to the surface */ -- cgit v1.2.3