Gnash  0.8.10
DefineSceneAndFrameLabelDataTag.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc.
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_SWF_SCENEANDLABELTAG_H
00020 #define GNASH_SWF_SCENEANDLABELTAG_H
00021 
00022 #include "ControlTag.h"
00023 #include "SWF.h" 
00024 #include "MovieClip.h" 
00025 #include "SWFStream.h"
00026 #include "log.h"
00027 
00028 #include <string>
00029 #include <map>
00030 
00031 // Forward declarations
00032 namespace gnash {
00033     class movie_definition;
00034 }
00035 
00036 namespace gnash {
00037 namespace SWF {
00038 
00039 class DefineSceneAndFrameLabelDataTag : public ControlTag
00040 {
00041 public:
00042 
00044         virtual void executeState(MovieClip* /*m*/, DisplayList& /* dlist */) const
00045         {
00046         log_unimpl("DefineSceneAndFrameLabelDataTag");
00047         }
00048 
00049         static void loader(SWFStream& in, TagType tag, movie_definition& m,
00050             const RunResources& /*r*/)
00051         {
00052                 assert(tag == DEFINESCENEANDFRAMELABELDATA); 
00053         
00054         if (!m.isAS3()) {
00055             IF_VERBOSE_MALFORMED_SWF(
00056                 log_swferror("SWF contains DefineSceneAndFrameLabelData tag, "
00057                     "but is not an AS3 SWF!");
00058             );
00059             throw ParserException("DefineSceneAndFrameLabelData tag found in "
00060                     "non-AS3 SWF!");
00061         }
00062 
00063         boost::intrusive_ptr<ControlTag> t(
00064             new DefineSceneAndFrameLabelDataTag(in));
00065 
00067         m.addControlTag(t);
00068         
00069     }
00070 
00071 private:
00072     
00073     DefineSceneAndFrameLabelDataTag(SWFStream& in)
00074     {
00075         read(in);
00076     }
00077 
00078     void read(SWFStream& in) {
00079         
00080         boost::uint32_t scenes = in.read_V32();
00081 
00082         IF_VERBOSE_PARSE(log_parse("Scene count: %d", scenes));
00083 
00084         for (size_t i = 0; i < scenes; ++i) {
00085             boost::uint32_t offset = in.read_V32();
00086             std::string name;
00087             in.read_string(name);
00088             IF_VERBOSE_PARSE(log_parse("Offset %d name: %s", offset, name));
00089             _scenes[offset] = name;
00090         }
00091 
00092         boost::uint32_t labels = in.read_V32();
00093 
00094         for (size_t i = 0; i < labels; ++i) {
00095             boost::uint32_t num = in.read_V32();
00096             std::string label;
00097             in.read_string(label);
00098             IF_VERBOSE_PARSE(log_parse("Frame %d label: %s", num, label));
00099             _frames[num] = label;
00100         }
00101 
00102     }
00103 
00104     std::map<boost::uint32_t, std::string> _scenes;
00105     std::map<boost::uint32_t, std::string> _frames;
00106 
00107 };
00108 
00109 } // namespace gnash::SWF
00110 } // namespace gnash
00111 
00112 
00113 #endif // GNASH_SWF_SYMBOLCLASSTAG_H
00114 
00115 
00116 // Local Variables:
00117 // mode: C++
00118 // indent-tabs-mode: t
00119 // End: