Gnash 0.8.9
|
00001 // 00002 // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00017 00018 #ifndef GNASH_SWF_DOINITACTIONTAG_H 00019 #define GNASH_SWF_DOINITACTIONTAG_H 00020 00021 #include "ControlTag.h" // for inheritance 00022 #include "SWF.h" // for TagType definition 00023 #include "action_buffer.h" // for composition 00024 #include "MovieClip.h" // for inlines 00025 #include "SWFStream.h" // for inlines 00026 00027 // Forward declarations 00028 namespace gnash { 00029 class movie_definition; 00030 } 00031 00032 namespace gnash { 00033 namespace SWF { 00034 00036 // 00039 class DoInitActionTag : public ControlTag 00040 { 00041 public: 00042 00043 DoInitActionTag(SWFStream& in, movie_definition& md, int cid) 00044 : 00045 _buf(md), 00046 _cid(cid) 00047 { 00048 read(in); 00049 } 00050 00052 // 00055 // 00058 virtual void executeState(MovieClip* m, DisplayList& /*dlist*/) const { 00059 m->execute_init_action_buffer(_buf, _cid); 00060 } 00061 00062 static void loader(SWFStream& in, TagType tag, movie_definition& m, 00063 const RunResources& /*r*/) 00064 { 00065 if (m.isAS3()) { 00066 IF_VERBOSE_MALFORMED_SWF( 00067 log_swferror("SWF contains DoInitAction tag, but is an " 00068 "AS3 SWF!"); 00069 ); 00070 throw ParserException("DoInitAction tag found in AS3 SWF!"); 00071 } 00072 00073 in.ensureBytes(2); 00074 const boost::uint16_t cid = in.read_u16(); 00075 00076 IF_VERBOSE_PARSE( 00077 log_parse(_(" tag %d: do_init_action_loader"), tag); 00078 log_parse(_(" -- init actions for sprite %d"), cid); 00079 ); 00080 00081 // TODO: Currently, tags are only be executed for already parsed 00082 // character ids. This is known to be wrong: a more accurate 00083 // description is: 00084 // 00085 // The DoInitAction tag is executed only for characters on the stage 00086 // or exported characters. It is only executed once. 00087 // 00088 // It's not known whether characters that were placed on the stage 00089 // but then removed before the InitAction tag is encountered cause 00090 // the actions to be executed. 00091 // 00092 // Gnash currently doesn't know which characters are on the stage, or 00093 // which IDs have been exported. 00094 boost::intrusive_ptr<ControlTag> da(new DoInitActionTag(in, m, cid)); 00095 m.addControlTag(da); // ownership transferred 00096 } 00097 00098 private: 00099 00101 // 00102 void read(SWFStream& in) 00103 { 00104 _buf.read(in, in.get_tag_end_position()); 00105 } 00106 00107 00108 action_buffer _buf; 00109 00110 // id of referenced DisplayObject definition 00111 int _cid; 00112 }; 00113 00114 } // namespace gnash::SWF 00115 } // namespace gnash 00116 00117 00118 #endif // GNASH_SWF_DOINITACTIONTAG_H 00119 00120 00121 // Local Variables: 00122 // mode: C++ 00123 // indent-tabs-mode: t 00124 // End: 00125