1 // 2 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 3 // Free Software Foundation, Inc. 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 19 #ifndef GNASH_SWF_SCENEANDLABELTAG_H 20 #define GNASH_SWF_SCENEANDLABELTAG_H 21 22 #include "ControlTag.h" 23 #include "SWF.h" 24 #include "MovieClip.h" 25 #include "SWFStream.h" 26 #include "log.h" 27 28 #include <string> 29 #include <map> 30 31 // Forward declarations 32 namespace gnash { 33 class movie_definition; 34 } 35 36 namespace gnash { 37 namespace SWF { 38 39 class DefineSceneAndFrameLabelDataTag : public ControlTag 40 { 41 public: 42 43 /// TODO: implement this. executeState(MovieClip *,DisplayList &)44 virtual void executeState(MovieClip* /*m*/, DisplayList& /* dlist */) const 45 { 46 log_unimpl("DefineSceneAndFrameLabelDataTag"); 47 } 48 loader(SWFStream & in,TagType tag,movie_definition & m,const RunResources &)49 static void loader(SWFStream& in, TagType tag, movie_definition& m, 50 const RunResources& /*r*/) 51 { 52 assert(tag == DEFINESCENEANDFRAMELABELDATA); 53 54 if (!m.isAS3()) { 55 IF_VERBOSE_MALFORMED_SWF( 56 log_swferror("SWF contains DefineSceneAndFrameLabelData tag, " 57 "but is not an AS3 SWF!"); 58 ); 59 throw ParserException("DefineSceneAndFrameLabelData tag found in " 60 "non-AS3 SWF!"); 61 } 62 63 boost::intrusive_ptr<ControlTag> t( 64 new DefineSceneAndFrameLabelDataTag(in)); 65 66 /// This tag is only added to the main timeline (SWFMovieDefinition). 67 m.addControlTag(t); 68 69 } 70 71 private: 72 DefineSceneAndFrameLabelDataTag(SWFStream & in)73 DefineSceneAndFrameLabelDataTag(SWFStream& in) 74 { 75 read(in); 76 } 77 read(SWFStream & in)78 void read(SWFStream& in) { 79 80 std::uint32_t scenes = in.read_V32(); 81 82 IF_VERBOSE_PARSE(log_parse("Scene count: %d", scenes)); 83 84 for (size_t i = 0; i < scenes; ++i) { 85 std::uint32_t offset = in.read_V32(); 86 std::string name; 87 in.read_string(name); 88 IF_VERBOSE_PARSE(log_parse("Offset %d name: %s", offset, name)); 89 _scenes[offset] = name; 90 } 91 92 std::uint32_t labels = in.read_V32(); 93 94 for (size_t i = 0; i < labels; ++i) { 95 std::uint32_t num = in.read_V32(); 96 std::string label; 97 in.read_string(label); 98 IF_VERBOSE_PARSE(log_parse("Frame %d label: %s", num, label)); 99 _frames[num] = label; 100 } 101 102 } 103 104 std::map<std::uint32_t, std::string> _scenes; 105 std::map<std::uint32_t, std::string> _frames; 106 107 }; 108 109 } // namespace gnash::SWF 110 } // namespace gnash 111 112 113 #endif // GNASH_SWF_SYMBOLCLASSTAG_H 114 115 116 // Local Variables: 117 // mode: C++ 118 // indent-tabs-mode: t 119 // End: 120