Пример #1
0
        public VirtualEntry Load(VirtualEntry e)
        {
            //name = name.ToLower();
            //path = path.ToLower();


            if (e.Loaded == false)
            {
                FileStream   fs = new FileStream(arcpath, FileMode.Open, FileAccess.Read);
                BinaryReader r  = new BinaryReader(fs);
                e.RawData = new byte[(int)e.Size];
                fs.Seek(e.Start, SeekOrigin.Begin);
                r.Read(e.RawData, 0, (int)e.Size);
                if (e.Compressed)
                {
                    byte[] od;
                    ZLib.DecompressData(e.RawData, out od);
                    e.RawData = od;
                    fs.Close();
                    e.Size       = od.Length;
                    e.Compressed = false;
                }

                r        = null;
                fs       = null;
                e.Loaded = true;
            }
            return(e);
        }
Пример #2
0
        public void ReadToc(string path)
        {
            path    = path.Replace(".toc", "");
            arcpath = path + ".vfs";
            path    = path + ".toc";
            //Console.WriteLine("Opening TOC:" + path);
            FileStream   fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            BinaryReader r  = new BinaryReader(fs);
            //Console.WriteLine("Opened. Parsing table.");
            int ec = r.ReadInt32();

            Console.WriteLine("Enteries:" + ec);
            for (int i = 0; i < ec; i++)
            {
                var ne = new VirtualEntry();
                for (int i2 = 0; i2 < 16; i2++)
                {
                    ne.Par[i2] = r.ReadInt32();
                }
                ne.Name       = r.ReadString();
                ne.Path       = r.ReadString();
                ne.Compressed = r.ReadBoolean();
                //     Console.WriteLine("Name:" + ne.Name + " Path:" + ne.Path + " Compressed?" + ne.Compressed);
                //      ne.ImgW = r.ReadInt32();
                //       ne.ImgH = r.ReadInt32();
                ne.Start = r.ReadInt64();
                ne.Size  = r.ReadInt64();
                Enteries.Add(ne);
            }
        }
Пример #3
0
        public void Add(Scene.SceneGraph graph)
        {
            AddMediaFromNode(graph.Root);

            var ge = new VirtualEntry();

            ge.Path = "VirtualFile";
            ge.Name = graph.Root.Name;

            var          ms = new MemoryStream(1024 * 1024);
            BinaryWriter w  = new BinaryWriter(ms);

            graph.WriteGraph(w);

            var wd = new byte[ms.Position];

            ms.Seek(0, SeekOrigin.Begin);
            ms.Read(wd, 0, wd.Length);
            Console.WriteLine("GraphSize:" + wd.Length + " bytes.");
            ge.RawData = wd;
            ge.Size    = wd.Length;
            ms.Flush();
            w.Flush();
            ms.Dispose();
            ge.Loaded     = true;
            ge.Compressed = false;
            Enteries.Add(ge);
        }
Пример #4
0
 public void AddMediaFromNode(Scene.GraphNode node)
 {
     if (node.ImgFrame != null)
     {
         bool found = false;
         foreach (var e in Enteries)
         {
             if (e.Name == node.ImgFrame.Name && e.Path == node.ImgFrame.Path)
             {
                 found = true;
                 break;
             }
         }
         if (!found)
         {
             var ve = new VirtualEntry();
             ve.Name    = node.ImgFrame.Name;
             ve.Path    = node.ImgFrame.Path;
             ve.RawData = node.ImgFrame.RawData;
             ve.Size    = ve.RawData.Length;
             ve.Type    = EntryType.Index;
             ve.Par[0]  = node.ImgFrame.Width;
             ve.Par[1]  = node.ImgFrame.Height;
             ve.Par[2]  = node.ImgFrame.Alpha ? 1 : 0;
             Console.WriteLine("N:" + node.ImgFrame.Width + " H:" + node.ImgFrame.Height + " Alpha:" + node.ImgFrame.Alpha);
             ve.Loaded     = true;
             ve.Compressed = false;
             Enteries.Add(ve);
         }
     }
     foreach (var n2 in node.Nodes)
     {
         AddMediaFromNode(n2);
     }
 }
Пример #5
0
        public void Add(string path)
        {
            var fi = new FileInfo(path);

            var ext = fi.Extension.ToLower();
            var qn  = fi.Name.Replace(ext, "").ToLower();

            switch (ext)
            {
            case ".bmp":
            case ".jpg":
            case ".png":
                var na = new VirtualEntry();

                System.Drawing.Bitmap tb = new System.Drawing.Bitmap(path);

                var rd = new byte[tb.Width * tb.Height * 4];
                int bi = 0;
                for (int y = 0; y < tb.Height; y++)
                {
                    for (int x = 0; x < tb.Width; x++)
                    {
                        var pix = tb.GetPixel(x, y);
                        rd[bi++] = pix.R;
                        rd[bi++] = pix.G;
                        rd[bi++] = pix.B;
                        rd[bi++] = pix.A;
                    }
                }

                na.RawData = rd;
                na.Par[0]  = tb.Width;
                na.Par[1]  = tb.Height;
                na.Par[2]  = 1;
                tb.Dispose();

                na.Size = na.RawData.Length;
                na.Name = qn;
                na.Path = path;
                Enteries.Add(na);
                break;

            case ".cs":

                var sb = File.ReadAllBytes(path);

                var ve = new VirtualEntry();
                ve.RawData = sb;
                ve.Size    = sb.Length;
                ve.Name    = qn;
                ve.Path    = path;
                Enteries.Add(ve);
                break;

            case ".graph":
                var gb = File.ReadAllBytes(path);
                var e2 = new VirtualEntry();
                e2.RawData = gb;
                e2.Size    = gb.Length;
                e2.Name    = qn;
                e2.Path    = path;
                Enteries.Add(e2);
                break;
            }
        }
Пример #6
0
 public void Add(VirtualEntry entry)
 {
     Enteries.Add(entry);
 }