Example #1
0
        private void changeTextureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReplaceTexture form       = new ReplaceTexture();
            List <short>   textureIds = new List <short>();

            foreach (Texture texture in m_vStorageObject.GetTextures())
            {
                textureIds.Add(texture.GetTextureId());
            }
            ((ComboBox)form.Controls["comboBox1"]).DataSource = textureIds;
            if (form.ShowDialog() == DialogResult.OK)
            {
                if (treeView1.SelectedNode != null)
                {
                    if (treeView1.SelectedNode.Tag != null)
                    {
                        ShapeChunk data = (ShapeChunk)treeView1.SelectedNode.Tag;
                        data.SetTextureId(Convert.ToByte(((ComboBox)form.Controls["comboBox1"]).SelectedItem));
                        m_vStorageObject.AddChange(data);
                        Render();
                    }
                }
            }
            form.Dispose();
        }
Example #2
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            DialogResult   result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    Bitmap chunk = (Bitmap)Image.FromFile(dialog.FileName);
                    if (treeView1.SelectedNode != null)
                    {
                        if (treeView1.SelectedNode.Tag != null)
                        {
                            ShapeChunk data = (ShapeChunk)treeView1.SelectedNode.Tag;
                            data.Replace(chunk);
                            m_vStorageObject.AddChange(m_vStorageObject.GetTextures()[data.GetTextureId()]);
                            Render();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Example #3
0
        public override void ParseData(BinaryReader br)
        {
            /*
             * StringBuilder hex = new StringBuilder(data.Length * 2);
             * foreach (byte b in data)
             *  hex.AppendFormat("{0:x2}", b);
             * Log(hex.ToString());
             */

            m_vShapeId = br.ReadInt16(); //0000
            br.ReadUInt16();             //0100
            br.ReadUInt16();             //0400 if datatype 18

            while (true)
            {
                byte chunkType;
                while (true)
                {
                    chunkType = br.ReadByte();  //11
                    m_vLength = br.ReadInt32(); //32000000
                    if (chunkType == 17 || chunkType == 22)
                    {
                        ShapeChunk chunk = new ShapeChunk(m_vStorageObject);
                        chunk.SetChunkId((short)m_vChunks.Count);
                        chunk.SetShapeId(m_vShapeId);
                        chunk.SetChunkType(chunkType);
                        chunk.ParseData(br);
                        m_vChunks.Add(chunk);
                    }
                    else
                    {
                        break;
                    }
                }
                if (chunkType == 0)
                {
                    break;
                }
                Log("Unmanaged chunk type " + chunkType);
                br.ReadBytes(m_vLength);
            }
        }
Example #4
0
        public override void ParseData(BinaryReader br)
        {
            /*
            StringBuilder hex = new StringBuilder(data.Length * 2);
            foreach (byte b in data)
                hex.AppendFormat("{0:x2}", b);
            Debug.WriteLine(hex.ToString());
            */

            m_vShapeId = br.ReadInt16();//0000
            br.ReadUInt16();//0100
            br.ReadUInt16();//0400 if datatype 18

            while(true)
            {
                byte chunkType;
                while (true)
                {
                    chunkType = br.ReadByte();//11
                    m_vLength = br.ReadInt32();//32000000
                    if (chunkType == 17 || chunkType == 22)
                    {
                        ShapeChunk chunk = new ShapeChunk(m_vStorageObject);
                        chunk.SetChunkId((short)m_vChunks.Count);
                        chunk.SetShapeId(m_vShapeId);
                        chunk.SetChunkType(chunkType);
                        chunk.ParseData(br);
                        m_vChunks.Add(chunk);
                    }
                    else
                    {
                        break;
                    }
                }
                if (chunkType == 0)
                    break;
                Debug.WriteLine("Unmanaged chunk type " + chunkType);
                br.ReadBytes(m_vLength);
            }
        }