1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "titanic/support/movie_clip.h"
24 #include "titanic/core/game_object.h"
25
26 namespace Titanic {
27
CMovieClip()28 CMovieClip::CMovieClip(): ListItem(), _startFrame(0), _endFrame(0) {
29 }
30
CMovieClip(const CString & name,int startFrame,int endFrame)31 CMovieClip::CMovieClip(const CString &name, int startFrame, int endFrame):
32 ListItem(), _name(name), _startFrame(startFrame), _endFrame(endFrame) {
33 }
34
save(SimpleFile * file,int indent)35 void CMovieClip::save(SimpleFile *file, int indent) {
36 file->writeNumberLine(2, indent);
37 file->writeQuotedLine("Clip", indent);
38 file->writeQuotedLine(_name, indent);
39 file->writeNumberLine(_startFrame, indent);
40 file->writeNumberLine(_endFrame, indent);
41
42 ListItem::save(file, indent);
43 }
44
load(SimpleFile * file)45 void CMovieClip::load(SimpleFile *file) {
46 int val = file->readNumber();
47
48 switch (val) {
49 case 1:
50 // This should never be used
51 assert(0);
52 break;
53
54 case 2:
55 file->readString();
56 _name = file->readString();
57 _startFrame = file->readNumber();
58 _endFrame = file->readNumber();
59 break;
60
61 default:
62 break;
63 }
64
65 ListItem::load(file);
66 }
67
68 /*------------------------------------------------------------------------*/
69
findByName(const Common::String & name) const70 CMovieClip *CMovieClipList::findByName(const Common::String &name) const {
71 for (const_iterator i = begin(); i != end(); ++i) {
72 CMovieClip *clip = *i;
73 if (clip->_name == name)
74 return clip;
75 }
76
77 return nullptr;
78 }
79
existsByStart(const CString & name,int startFrame) const80 bool CMovieClipList::existsByStart(const CString &name, int startFrame) const {
81 for (const_iterator i = begin(); i != end(); ++i) {
82 CMovieClip *clip = *i;
83 if (clip->_startFrame == startFrame && clip->_name == name)
84 return true;
85 }
86
87 return false;
88 }
89
existsByEnd(const CString & name,int endFrame) const90 bool CMovieClipList::existsByEnd(const CString &name, int endFrame) const {
91 for (const_iterator i = begin(); i != end(); ++i) {
92 CMovieClip *clip = *i;
93 if (clip->_endFrame == endFrame && clip->_name == name)
94 return true;
95 }
96
97 return false;
98 }
99
100 } // End of namespace Titanic
101