コード例 #1
0
        public MovieClip(MovieClip mv)
        {
            m_vStorageObject = mv.GetStorageObject();
            m_vDataType      = mv.GetMovieClipDataType();
            m_vShapes        = new List <ScObject>();

            this.SetOffset(-Math.Abs(mv.GetOffset()));

            //Duplicate MovieClip
            using (FileStream input = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open))
            {
                input.Seek(Math.Abs(mv.GetOffset()) + 5, SeekOrigin.Begin);
                using (var br = new BinaryReader(input))
                {
                    this.ParseData(br);
                }
            }

            //Set new clip id
            short maxMovieClipId = this.GetId();

            foreach (MovieClip clip in m_vStorageObject.GetMovieClips())
            {
                if (clip.GetId() > maxMovieClipId)
                {
                    maxMovieClipId = clip.GetId();
                }
            }
            maxMovieClipId++;
            this.SetId(maxMovieClipId);

            //Get max shape id
            short maxShapeId = 20000;//avoid collision with other objects in MovieClips

            foreach (Shape shape in m_vStorageObject.GetShapes())
            {
                if (shape.GetId() > maxShapeId)
                {
                    maxShapeId = shape.GetId();
                }
            }
            maxShapeId++;

            //Duplicate shapes associated to clip
            List <ScObject> newShapes = new List <ScObject>();

            foreach (Shape s in m_vShapes)
            {
                Shape newShape = new Shape(s);
                newShape.SetId(maxShapeId);
                maxShapeId++;
                newShapes.Add(newShape);
                m_vStorageObject.AddShape(newShape);//Add to global shapelist
                m_vStorageObject.AddChange(newShape);
            }
            this.m_vShapes = newShapes;
        }
コード例 #2
0
ファイル: MovieClip.cs プロジェクト: doio/Ultrapowa-SC-Editor
        public MovieClip(MovieClip mv)
        {
            m_vStorageObject = mv.GetStorageObject();
            m_vDataType = mv.GetMovieClipDataType();
            m_vShapes = new List<ScObject>();

            this.SetOffset(-Math.Abs(mv.GetOffset()));
            
            //Duplicate MovieClip
            using (FileStream input = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open))
            {
                input.Seek(Math.Abs(mv.GetOffset()) + 5, SeekOrigin.Begin);
                using (var br = new BinaryReader(input))
                {
                    this.ParseData(br);
                }
            }

            //Set new clip id
            short maxMovieClipId = this.GetId();
            foreach(MovieClip clip in m_vStorageObject.GetMovieClips())
            {
                if (clip.GetId() > maxMovieClipId)
                    maxMovieClipId = clip.GetId();
            }
            maxMovieClipId++;
            this.SetId(maxMovieClipId);

            //Get max shape id
            short maxShapeId = 20000;//avoid collision with other objects in MovieClips
            foreach(Shape shape in m_vStorageObject.GetShapes())
            {
                if (shape.GetId() > maxShapeId)
                    maxShapeId = shape.GetId();
            }
            maxShapeId++;

            //Duplicate shapes associated to clip
            List<ScObject> newShapes = new List<ScObject>();
            foreach(Shape s in m_vShapes)
            {
                Shape newShape = new Shape(s);
                newShape.SetId(maxShapeId);
                maxShapeId++;
                newShapes.Add(newShape);
                m_vStorageObject.AddShape(newShape);//Add to global shapelist
                m_vStorageObject.AddChange(newShape);
            }
            this.m_vShapes = newShapes;
        }
コード例 #3
0
 private void duplicateToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode != null)
     {
         if (treeView1.SelectedNode.Tag != null)
         {
             Export      data = (Export)treeView1.SelectedNode.Tag;
             CloneExport form = new CloneExport();
             ((TextBox)form.Controls["textBox1"]).Text = data.GetName();
             if (form.ShowDialog() == DialogResult.OK)
             {
                 string result = ((TextBox)form.Controls["textBox1"]).Text;
                 if (result != "" && m_vStorageObject.GetExports().FindIndex(exp => exp.GetName() == result) == -1)
                 {
                     MovieClip mv = new MovieClip((MovieClip)data.GetDataObject());
                     m_vStorageObject.AddMovieClip(mv);
                     m_vStorageObject.AddChange(mv);
                     Export ex = new Export(m_vStorageObject);
                     ex.SetId(mv.GetId());
                     ex.SetExportName(result);
                     ex.SetDataObject(mv);
                     m_vStorageObject.AddExport(ex);
                     m_vStorageObject.AddChange(ex);
                     treeView1.Populate(new List <ScObject>()
                     {
                         ex
                     });
                 }
                 else
                 {
                     MessageBox.Show("Cloning failed. Invalid ExportName.");
                 }
             }
             form.Dispose();
         }
     }
 }
コード例 #4
0
        public void Decode()
        {
            using (var br2 = new BinaryReader(File.Open(m_vFileName + "_tex", FileMode.Open)))
            {
                try
                {
                    while (true)
                    {
                        byte fileType = br2.ReadByte();
                        uint fileSize = br2.ReadUInt32();
                        var  texture  = new Texture(this);
                        texture.SetOffset(0);
                        texture.ParseData2(br2, fileType);
                        m_vTextures.Add(texture);
                    }
                }
                catch (EndOfStreamException e)
                {
                }
            }
            using (var br = new BinaryReader(File.Open(m_vFileName, FileMode.Open)))
            {
                ushort shapeCount          = br.ReadUInt16(); //a1 + 8
                ushort movieClipCount      = br.ReadUInt16(); //a1 + 12
                ushort textureCount        = br.ReadUInt16(); //a1 + 16
                ushort textFieldCount      = br.ReadUInt16(); //a1 + 24
                ushort matrix2x3Count      = br.ReadUInt16(); //a1 + 28
                ushort colorTransformCount = br.ReadUInt16(); //a1 + 32

                Log("ShapeCount: " + shapeCount);
                Log("MovieClipCount: " + movieClipCount);
                Log("TextureCount: " + textureCount + " -- " + m_vTextures.Count);
                Log("TextFieldCount: " + textFieldCount);
                Log("Matrix2x3Count: " + matrix2x3Count);
                Log("ColorTransformCount: " + colorTransformCount);

                //5 useless bytes, not even used by Supercell
                br.ReadByte();   //1 octet
                br.ReadUInt16(); //2 octets
                br.ReadUInt16(); //2 octets

                m_vStartExportsOffset = br.BaseStream.Position;
                m_vExportCount        = br.ReadUInt16();//a1 + 20
                Log("ExportCount: " + m_vExportCount);

                for (int i = 0; i < m_vExportCount; i++)
                {
                    var sce = new Export(this);
                    sce.SetId(br.ReadInt16());
                    m_vExports.Add(sce);
                }

                //m_vExportNames = new string[m_vExportCount];
                for (int i = 0; i < m_vExportCount; i++)
                {
                    //((Export)m_vExports[i]).SetOffset(br.BaseStream.Position);
                    byte nameLength = br.ReadByte();
                    ((Export)m_vExports[i]).SetExportName(Encoding.UTF8.GetString(br.ReadBytes(nameLength)));
                }
                while (0x1A != br.ReadByte())
                {
                    br.ReadInt32();
                }
                br.ReadInt32();
                do
                {
                    long offset     = br.BaseStream.Position;
                    byte dataType   = br.ReadByte();
                    int  dataLength = br.ReadInt32();
                    switch (dataType)
                    {
                    case 1:
                    case 16:
                    case 19:
                    {
                        var texture = new Texture(this);
                        texture.SetOffset(offset);
                        texture.ParseData(br);
                        //m_vTextures.Add(texture);
                        textureCount--;
                        continue;
                    }

                    case 24:
                    {
                        var texture = new Texture(this);
                        texture.SetOffset(offset);
                        texture.ParseData(br);
                        //m_vTextures.Add(texture);
                        textureCount--;
                        continue;
                    }

                    case 2:
                    case 18:
                    {
                        var shape = new Shape(this);
                        shape.SetOffset(offset);
                        m_vShapes.Add(shape);
                        shape.ParseData(br);
                        shapeCount--;
                        continue;
                    }

                    case 3:
                    case 10:
                    case 12:
                    case 14:
                    {
                        var movieClip = new MovieClip(this, dataType);
                        movieClip.SetOffset(offset);
                        movieClip.ParseData(br);
                        m_vMovieClips.Add(movieClip);
                        movieClipCount--;
                        continue;
                    }

                    case 7:
                    case 15:
                    case 20:
                    case 25:
                    {
                        //textFields
                        textFieldCount--;
                        break;
                    }

                    case 8:
                    {
                        //matrix2x3
                        matrix2x3Count--;
                        break;
                    }

                    case 9:
                    {
                        //colorTransform
                        colorTransformCount--;
                        break;
                    }

                    case 13:
                    {
                        Log("*** data type " + dataType.ToString());
                        break;
                    }

                    default:
                    {
                        Log("Unkown data type " + dataType.ToString());
                        break;
                    }

                    case 0:
                    {
                        m_vEofOffset = offset;
                        for (int i = 0; i < m_vExports.Count; i++)
                        {
                            int index = m_vMovieClips.FindIndex(movie => movie.GetId() == m_vExports[i].GetId());
                            if (index != -1)
                            {
                                ((Export)m_vExports[i]).SetDataObject((MovieClip)m_vMovieClips[index]);
                            }
                        }

                        Log("-----------------------------------");
                        Log("ShapeCount: " + shapeCount);
                        Log("MovieClipCount: " + movieClipCount);
                        Log("TextureCount: " + textureCount);
                        Log("TextFieldCount: " + textFieldCount);
                        Log("Matrix2x3Count: " + matrix2x3Count);
                        Log("ColorTransformCount: " + colorTransformCount);
                        return;
                    }
                    }
                    //Log("Unhandled data type " + dataType.ToString());
                    if (dataLength >= 1)
                    {
                        br.ReadBytes(dataLength);
                    }
                }while (true);
            }
        }
コード例 #5
0
 public void AddMovieClip(MovieClip mc)
 {
     m_vMovieClips.Add(mc);
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: doio/Ultrapowa-SC-Editor
 private void duplicateToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode != null)
     {
         if (treeView1.SelectedNode.Tag != null)
         {
             Export data = (Export)treeView1.SelectedNode.Tag;
             CloneExport form = new CloneExport();
             ((TextBox)form.Controls["textBox1"]).Text = data.GetName();
             if (form.ShowDialog() == DialogResult.OK)
             {
                 string result = ((TextBox)form.Controls["textBox1"]).Text;
                 if(result != "" && m_vStorageObject.GetExports().FindIndex(exp => exp.GetName() == result) == -1 )
                 {
                     MovieClip mv = new MovieClip((MovieClip)data.GetDataObject());
                     m_vStorageObject.AddMovieClip(mv);
                     m_vStorageObject.AddChange(mv);
                     Export ex = new Export(m_vStorageObject);
                     ex.SetId(mv.GetId());
                     ex.SetExportName(result);
                     ex.SetDataObject(mv);
                     m_vStorageObject.AddExport(ex);
                     m_vStorageObject.AddChange(ex);
                     treeView1.Populate(new List<ScObject>() { ex });
                 }
                 else
                 {
                     MessageBox.Show("Cloning failed. Invalid ExportName.");
                 }
             }
             form.Dispose();
         }
     }
 }
コード例 #7
0
 public void SetDataObject(MovieClip sd)
 {
     m_vDataObject = sd;
 }
コード例 #8
0
        public void Decode()
        {
            using (var br = new BinaryReader(File.Open(m_vFileName, FileMode.Open)))
            {
                ushort m_vShapeCount          = br.ReadUInt16(); //a1 + 8
                ushort m_vMovieClipCount      = br.ReadUInt16(); //a1 + 12
                ushort m_vTextureCount        = br.ReadUInt16(); //a1 + 16
                ushort m_vTextFieldCount      = br.ReadUInt16(); //a1 + 24
                ushort m_vMatrix2x3Count      = br.ReadUInt16(); //a1 + 28
                ushort m_vColorTransformCount = br.ReadUInt16(); //a1 + 32

                Debug.WriteLine("ShapeCount: " + m_vShapeCount);
                Debug.WriteLine("MovieClipCount: " + m_vMovieClipCount);
                Debug.WriteLine("TextureCount: " + m_vTextureCount);
                Debug.WriteLine("TextFieldCount: " + m_vTextFieldCount);
                Debug.WriteLine("Matrix2x3Count: " + m_vMatrix2x3Count);
                Debug.WriteLine("ColorTransformCount: " + m_vColorTransformCount);

                //5 useless bytes, not even used by Supercell
                br.ReadByte();   //1 octet
                br.ReadUInt16(); //2 octets
                br.ReadUInt16(); //2 octets

                m_vStartExportsOffset = br.BaseStream.Position;
                m_vExportCount        = br.ReadUInt16();//a1 + 20
                Debug.WriteLine("ExportCount: " + m_vExportCount);

                for (int i = 0; i < m_vExportCount; i++)
                {
                    var sce = new Export(this);
                    sce.SetId(br.ReadInt16());
                    m_vExports.Add(sce);
                }

                //m_vExportNames = new string[m_vExportCount];
                for (int i = 0; i < m_vExportCount; i++)
                {
                    //((Export)m_vExports[i]).SetOffset(br.BaseStream.Position);
                    byte nameLength = br.ReadByte();
                    ((Export)m_vExports[i]).SetExportName(Encoding.UTF8.GetString(br.ReadBytes(nameLength)));
                }

                do
                {
                    long offset     = br.BaseStream.Position;
                    byte dataType   = br.ReadByte();
                    int  dataLength = br.ReadInt32();
                    switch (dataType)
                    {
                    case 1:
                    case 16:
                    case 19:
                    {
                        var texture = new Texture(this);
                        texture.SetOffset(offset);
                        texture.ParseData(br);
                        m_vTextures.Add(texture);
                        continue;
                    }

                    case 2:
                    case 18:
                    {
                        var shape = new Shape(this);
                        shape.SetOffset(offset);
                        m_vShapes.Add(shape);
                        shape.ParseData(br);
                        continue;
                    }

                    case 3:
                    case 10:
                    case 12:
                    case 14:
                    {
                        var movieClip = new MovieClip(this, dataType);
                        movieClip.SetOffset(offset);
                        movieClip.ParseData(br);
                        m_vMovieClips.Add(movieClip);
                        continue;
                    }

                    case 7:
                    case 15:
                    case 20:
                    {
                        //textFields
                        break;
                    }

                    case 8:
                    {
                        //matrix2x3
                        break;
                    }

                    case 9:
                    {
                        //colorTransform
                        break;
                    }

                    case 13:
                    {
                        break;
                    }

                    default:
                    {
                        Debug.WriteLine("Unkown data type " + dataType.ToString());
                        break;
                    }

                    case 0:
                    {
                        m_vEofOffset = offset;
                        for (int i = 0; i < m_vExports.Count; i++)
                        {
                            int index = m_vMovieClips.FindIndex(movie => movie.GetId() == m_vExports[i].GetId());
                            if (index != -1)
                            {
                                ((Export)m_vExports[i]).SetDataObject((MovieClip)m_vMovieClips[index]);
                            }
                        }
                        return;
                    }
                    }
                    if (dataLength >= 1)
                    {
                        br.ReadBytes(dataLength);
                    }
                }while (true);
            }
        }
コード例 #9
0
ファイル: Export.cs プロジェクト: doio/Ultrapowa-SC-Editor
 public void SetDataObject(MovieClip sd)
 {
     m_vDataObject = sd;
 }
コード例 #10
0
ファイル: Decoder.cs プロジェクト: doio/Ultrapowa-SC-Editor
        public void Decode()
        {
            using (var br = new BinaryReader(File.Open(m_vFileName, FileMode.Open)))
            {
                ushort m_vShapeCount = br.ReadUInt16();//a1 + 8
                ushort m_vMovieClipCount = br.ReadUInt16();//a1 + 12
                ushort m_vTextureCount = br.ReadUInt16();//a1 + 16
                ushort m_vTextFieldCount = br.ReadUInt16();//a1 + 24
                ushort m_vMatrix2x3Count = br.ReadUInt16();//a1 + 28
                ushort m_vColorTransformCount = br.ReadUInt16();//a1 + 32

                Debug.WriteLine("ShapeCount: " + m_vShapeCount);
                Debug.WriteLine("MovieClipCount: " + m_vMovieClipCount);
                Debug.WriteLine("TextureCount: " + m_vTextureCount);
                Debug.WriteLine("TextFieldCount: " + m_vTextFieldCount);
                Debug.WriteLine("Matrix2x3Count: " + m_vMatrix2x3Count);
                Debug.WriteLine("ColorTransformCount: " + m_vColorTransformCount);

                //5 useless bytes, not even used by Supercell
                br.ReadByte();//1 octet
                br.ReadUInt16();//2 octets
                br.ReadUInt16();//2 octets

                m_vStartExportsOffset = br.BaseStream.Position;
                m_vExportCount = br.ReadUInt16();//a1 + 20
                Debug.WriteLine("ExportCount: " + m_vExportCount);

                for (int i = 0; i < m_vExportCount; i++)
                {
                    var sce = new Export(this);
                    sce.SetId(br.ReadInt16());
                    m_vExports.Add(sce);
                }

                //m_vExportNames = new string[m_vExportCount];
                for (int i = 0; i < m_vExportCount; i++)
                {
                    //((Export)m_vExports[i]).SetOffset(br.BaseStream.Position);
                    byte nameLength = br.ReadByte();
                    ((Export)m_vExports[i]).SetExportName(Encoding.UTF8.GetString(br.ReadBytes(nameLength)));
                }

                do
                {
                    long offset = br.BaseStream.Position;
                    byte dataType = br.ReadByte();
                    int dataLength = br.ReadInt32();
                    switch (dataType)
                    {
                        case 1:
                        case 16:
                        case 19:
                            {
                                var texture = new Texture(this);
                                texture.SetOffset(offset);
                                texture.ParseData(br);
                                m_vTextures.Add(texture);
                                continue;
                            }
                        case 2:
                        case 18:
                            {
                                var shape = new Shape(this);
                                shape.SetOffset(offset);
                                m_vShapes.Add(shape);
                                shape.ParseData(br);
                                continue;
                            }
                        case 3:
                        case 10:
                        case 12:
                        case 14:
                            {
                                var movieClip = new MovieClip(this, dataType);
                                movieClip.SetOffset(offset);
                                movieClip.ParseData(br);
                                m_vMovieClips.Add(movieClip);
                                continue;
                            }
                        case 7:
                        case 15:
                        case 20:
                            {
                                //textFields
                                break;
                            }
                        case 8:
                            {
                                //matrix2x3
                                break;
                            }
                        case 9:
                            {
                                //colorTransform
                                break;
                            }
                        case 13:
                            {
                                break;
                            }
                        default:
                            {
                                Debug.WriteLine("Unkown data type " + dataType.ToString());
                                break;
                            }
                        case 0:
                            {
                                m_vEofOffset = offset;
                                for (int i = 0; i < m_vExports.Count; i++)
                                {
                                    int index = m_vMovieClips.FindIndex(movie => movie.GetId() == m_vExports[i].GetId());
                                    if (index != -1)
                                        ((Export)m_vExports[i]).SetDataObject((MovieClip)m_vMovieClips[index]);
                                }
                                return;
                            }
                    }
                    if (dataLength >= 1)
                    {
                        br.ReadBytes(dataLength);
                    }
                }
                while (true);
            }
        }
コード例 #11
0
ファイル: Decoder.cs プロジェクト: doio/Ultrapowa-SC-Editor
 public void AddMovieClip(MovieClip mc)
 {
     m_vMovieClips.Add(mc);
 }