示例#1
0
 public Texture(Texture t)
 {
     m_vImageType = t.GetImageType();
     m_vStorageObject = t.GetStorageObject();
     m_vTextureId = (short)m_vStorageObject.GetTextures().Count();
     m_vScImageTypes = new Dictionary<byte, Type>();
     m_vScImageTypes.Add(0, typeof(ImageRgba8888));
     m_vScImageTypes.Add(2, typeof(ImageRgba4444));
     m_vScImageTypes.Add(4, typeof(ImageRgb565));
     if (m_vScImageTypes.ContainsKey(m_vImageType))
     {
         m_vImage = (ScImage)Activator.CreateInstance(m_vScImageTypes[m_vImageType]);
     }
     else
     {
         m_vImage = new ScImage();
     }
     m_vImage.SetBitmap(new Bitmap(t.GetBitmap()));
     m_vOffset = t.GetOffset() > 0 ? -t.GetOffset() : t.GetOffset();
 }
示例#2
0
 private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode != null)
     {
         if (treeView1.SelectedNode.Tag != null)
         {
             Texture data = new Texture((Texture)treeView1.SelectedNode.Tag);
             m_vStorageObject.AddTexture(data);
             m_vStorageObject.AddChange(data);
             treeView1.Populate(new List<ScObject>() { data });
         }
     }
 }
示例#3
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);
            }
        }
示例#4
0
 public void AddTexture(Texture t)
 {
     m_vTextures.Add(t);
 }