示例#1
0
        private void importRAWToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IdxFile       idx = null;
            FileReference fr  = null;

            GetFileReference(tv1.SelectedNode, out idx, out fr);
            if (fr != null)
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = "*.*|*.*";
                if (tv1.SelectedNode != null)
                {
                    d.FileName = tv1.SelectedNode.Text;
                }
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    byte[] buff   = File.ReadAllBytes(d.FileName);
                    uint   ucsize = (uint)buff.Length;
                    if (fr.compression != 0)
                    {
                        buff = Helper.CompressRLE(buff, fr.compression);
                    }
                    idx.SaveEntry(fr, buff, ucsize);
                }
            }
        }
示例#2
0
 public static void FindFile(string s, out IdxFile idf, out FileReference r)
 {
     r   = null;
     idf = null;
     string[] parts = s.Split('>');
     foreach (IdxFile idx in FileSystem.idxFiles)
     {
         if (idx.basepath + idx.filename == parts[0])
         {
             idf = idx;
             break;
         }
     }
     if (idf == null)
     {
         Log.WriteLine("Error: IDX File not found (" + parts[0] + ")");
         return;
     }
     foreach (FileReference fr in idf.refs)
     {
         if (fr.name == parts[1])
         {
             r = fr;
             break;
         }
     }
     if (r == null)
     {
         Log.WriteLine("Error: File reference not found (" + parts[1] + ")");
         return;
     }
 }
示例#3
0
        private void tv1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode      sel = e.Node;
            IdxFile       idx = null;
            FileReference fr  = null;

            GetFileReference(sel, out idx, out fr);
            if (fr != null)
            {
                byte[] data = idx.LoadEntry(fr);
                hb1.ByteProvider = new DynamicByteProvider(data);
            }
        }
示例#4
0
 public static void Init(string path)
 {
     basePath = path;
     Log.WriteLine("Loading files from path : " + path);
     idxFilenames = new List <string>(SearchIdxFiles(basePath));
     idxFiles     = new List <IdxFile>();
     foreach (string file in idxFilenames)
     {
         string check = Path.GetDirectoryName(file) + "\\" + Path.GetFileNameWithoutExtension(file) + ".wad";
         if (!File.Exists(check))
         {
             continue;
         }
         IdxFile idx = new IdxFile(file, basePath.Length + 6);
         Log.WriteLine("Adding " + idx.filename + " ...");
         idxFiles.Add(idx);
     }
 }
示例#5
0
        public void GetFileReference(TreeNode sel, out IdxFile idxFile, out FileReference fileRef)
        {
            idxFile = null;
            fileRef = null;
            bool found = false;

            if (sel != null && sel.Parent != null && sel.Parent.Text.EndsWith(".idx"))
            {
                string idxpath = "";
                if (sel.Parent.Parent == null)
                {
                    idxpath = sel.Parent.Text;
                }
                else
                {
                    idxpath = sel.Parent.Parent.Text.Substring(1) + "\\" + sel.Parent.Text;
                }
                foreach (IdxFile idx in FileSystem.idxFiles)
                {
                    if (idx.filename == idxpath)
                    {
                        foreach (FileReference r in idx.refs)
                        {
                            if (r.name == sel.Text)
                            {
                                found   = true;
                                fileRef = r;
                                break;
                            }
                        }
                    }
                    if (found)
                    {
                        idxFile = idx;
                        break;
                    }
                }
            }
        }