Gnash 0.8.10dev
DefineSceneAndFrameLabelDataTag.h
Go to the documentation of this file.
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_SCENEANDLABELTAG_H
00019 #define GNASH_SWF_SCENEANDLABELTAG_H
00020 
00021 #include "ControlTag.h"
00022 #include "SWF.h" 
00023 #include "MovieClip.h" 
00024 #include "SWFStream.h"
00025 #include "log.h"
00026 
00027 #include <string>
00028 #include <map>
00029 
00030 // Forward declarations
00031 namespace gnash {
00032     class movie_definition;
00033 }
00034 
00035 namespace gnash {
00036 namespace SWF {
00037 
00038 class DefineSceneAndFrameLabelDataTag : public ControlTag
00039 {
00040 public:
00041 
00043         virtual void executeState(MovieClip* /*m*/, DisplayList& /* dlist */) const
00044         {
00045         log_unimpl("DefineSceneAndFrameLabelDataTag");
00046         }
00047 
00048         static void loader(SWFStream& in, TagType tag, movie_definition& m,
00049             const RunResources& /*r*/)
00050         {
00051                 assert(tag == DEFINESCENEANDFRAMELABELDATA); 
00052         
00053         if (!m.isAS3()) {
00054             IF_VERBOSE_MALFORMED_SWF(
00055                 log_swferror("SWF contains DefineSceneAndFrameLabelData tag, "
00056                     "but is not an AS3 SWF!");
00057             );
00058             throw ParserException("DefineSceneAndFrameLabelData tag found in "
00059                     "non-AS3 SWF!");
00060         }
00061 
00062         boost::intrusive_ptr<ControlTag> t(
00063             new DefineSceneAndFrameLabelDataTag(in));
00064 
00066         m.addControlTag(t);
00067         
00068     }
00069 
00070 private:
00071     
00072     DefineSceneAndFrameLabelDataTag(SWFStream& in)
00073     {
00074         read(in);
00075     }
00076 
00077     void read(SWFStream& in) {
00078         
00079         boost::uint32_t scenes = in.read_V32();
00080 
00081         IF_VERBOSE_PARSE(log_parse("Scene count: %d", scenes));
00082 
00083         for (size_t i = 0; i < scenes; ++i) {
00084             boost::uint32_t offset = in.read_V32();
00085             std::string name;
00086             in.read_string(name);
00087             IF_VERBOSE_PARSE(log_parse("Offset %d name: %s", offset, name));
00088             _scenes[offset] = name;
00089         }
00090 
00091         boost::uint32_t labels = in.read_V32();
00092 
00093         for (size_t i = 0; i < labels; ++i) {
00094             boost::uint32_t num = in.read_V32();
00095             std::string label;
00096             in.read_string(label);
00097             IF_VERBOSE_PARSE(log_parse("Frame %d label: %s", num, label));
00098             _frames[num] = label;
00099         }
00100 
00101     }
00102 
00103     std::map<boost::uint32_t, std::string> _scenes;
00104     std::map<boost::uint32_t, std::string> _frames;
00105 
00106 };
00107 
00108 } // namespace gnash::SWF
00109 } // namespace gnash
00110 
00111 
00112 #endif // GNASH_SWF_SYMBOLCLASSTAG_H
00113 
00114 
00115 // Local Variables:
00116 // mode: C++
00117 // indent-tabs-mode: t
00118 // End: