Esempio n. 1
0
        private void UpdateFolders()
        {
            this.listView1.Items.Clear();
            this.toolStripTextBox1.Text = BaseRhoFile.NowPath;
            List <ListViewItem> lists = new List <ListViewItem>();

            foreach (IPackedObject ipo in BaseRhoFile.NowFolderContent)
            {
                ListViewItem lvi;
                if (ipo.Type == ObjectType.File)
                {
                    RhoPackedFileInfo jpfi = (RhoPackedFileInfo)ipo;
                    lvi          = new ListViewItem(new string[] { jpfi.FileName + '.' + jpfi.Extension, $"0x{Convert.ToString(jpfi.Index, 16).PadLeft(8, '0')}", ("listview_item2_file").GetStringBag() });
                    lvi.ImageKey = "file";
                }
                else
                {
                    RhoPackedFolderInfo jpfi = (RhoPackedFolderInfo)ipo;
                    lvi          = new ListViewItem(new string[] { jpfi.FolderName, $"0x{Convert.ToString(jpfi.Index, 16).PadLeft(8, '0')}", ("listview_item2_folder").GetStringBag() });
                    lvi.ImageKey = "folder";
                }
                lists.Add(lvi);
            }
            listView1.Items.AddRange(lists.ToArray());
        }
        public static uint GetDataKey(uint HeaderKey, RhoPackedFileInfo info)
        {
            byte[] strData = Encoding.GetEncoding("UTF-16").GetBytes(info.FileName);
            uint   key     = Adler.Adler32(0, strData, 0, strData.Length);

            key += info.Ext;
            key += (HeaderKey - 0x756DE654);
            return(key);
        }
Esempio n. 3
0
        private void ExportAllFolder_bg(string outputPath, bool IncludeSubFolder, RhoFile file)
        {
            IPackedObject[]         ipos  = RhoPackedFilesInfoDecoder.GetRhoPackedFileInfos(file.GetStreamData(0xFFFFFFFF), file.HeaderKey, 0xFFFFFFFF);
            Stack <ExportProcessor> Stack = new Stack <ExportProcessor>();

            if (!Directory.Exists(outputPath))
            {
                throw new Exception("");
            }
            string StartPath = "";

            Stack.Push(new ExportProcessor
            {
                Path = StartPath,
                ipos = ipos
            });
            while (Stack.Count > 0 && !Canceled)
            {
                ExportProcessor ep      = Stack.Pop();
                string          outPath = outputPath + (StartPath == "" ? ep.Path : ep.Path.Replace(StartPath, ""));
                foreach (IPackedObject ipo in ep.ipos)
                {
                    if (ipo.Type == ObjectType.Folder && IncludeSubFolder)
                    {
                        RhoPackedFolderInfo jpfi = (RhoPackedFolderInfo)ipo;
                        ExportProcessor     nep  = new ExportProcessor
                        {
                            Path = ep.Path + $"\\{jpfi.FolderName}",
                            ipos = RhoPackedFilesInfoDecoder.GetRhoPackedFileInfos(file.GetStreamData(jpfi.Index), file.HeaderKey, jpfi.Index)
                        };
                        Stack.Push(nep);
                        if (!Directory.Exists($"{outPath}\\{((RhoPackedFolderInfo)ipo).FolderName}"))
                        {
                            Directory.CreateDirectory($"{outPath}\\{((RhoPackedFolderInfo)ipo).FolderName}");
                        }
                        continue;
                    }
                    if (ipo.Type == ObjectType.File)
                    {
                        RhoPackedFileInfo jfi = (RhoPackedFileInfo)ipo;
                        ChangeText(label5, $"Outputing: {ep.Path}\\{jfi.FileName}.{jfi.Extension}");
                        FileStream fs   = new FileStream($"{outPath}\\{jfi.FileName}.{jfi.Extension}", FileMode.Create);
                        byte[]     data = file.GetPackedFile(jfi);
                        fs.Write(data, 0, data.Length);
                        fs.Close();
                        data = null;
                    }
                    if (Canceled)
                    {
                        break;
                    }
                }
            }
            CloseWindow();
        }
Esempio n. 4
0
        private void convertToPngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RhoPackedFileInfo fileInfo = (RhoPackedFileInfo)Array.Find(BaseRhoFile.NowFolderContent, x => x.Type == ObjectType.File && (((RhoPackedFileInfo)x).FileName + $".{((RhoPackedFileInfo)x).Extension}") == listView1.SelectedItems[0].SubItems[0].Text);

            byte[]       a = BaseRhoFile.GetPackedFile(fileInfo);
            TgaDDsViewer t = new TgaDDsViewer();

            t.Data = a;
            t.ConvertTGADDSToPng();
            a = null;
        }
Esempio n. 5
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RhoPackedFileInfo fileInfo = (RhoPackedFileInfo)Array.Find(BaseRhoFile.NowFolderContent, x => x.Type == ObjectType.File && (((RhoPackedFileInfo)x).FileName + $".{((RhoPackedFileInfo)x).Extension}") == listView1.SelectedItems[0].SubItems[0].Text);

            ofd.Filter   = "AllFiles|*.*";
            ofd.FileName = $"{fileInfo.FileName}.{fileInfo.Extension}";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileStream fs = new FileStream(ofd.FileName, FileMode.Create);
                byte[]     a  = BaseRhoFile.GetPackedFile(fileInfo);
                fs.Write(a, 0, a.Length);
                fs.Close();
                a = null;
            }
        }
Esempio n. 6
0
        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }
            ListViewItem lvii = listView1.SelectedItems[0];

            if (listView1.SelectedItems[0].SubItems[2].Text == ("listview_item2_file").GetStringBag())
            {
                Random            rm       = new Random();
                RhoPackedFileInfo fileInfo = (RhoPackedFileInfo)Array.Find(BaseRhoFile.NowFolderContent, x => x.Type == ObjectType.File && (((RhoPackedFileInfo)x).FileName + $".{((RhoPackedFileInfo)x).Extension}") == lvii.Text);
                if (fileInfo.Extension == "dds" || fileInfo.Extension == "tga")
                {
                    TgaDDsViewer tdv = new TgaDDsViewer();
                    tdv.Data = BaseRhoFile.GetPackedFile(fileInfo);
                    tdv.Type = fileInfo.Extension == "dds" ? TgaDDsViewer.FileType.dds : fileInfo.Extension == "tga" ? TgaDDsViewer.FileType.tga : throw new Exception();
                    tdv.ShowBox();
                    return;
                }
                else if (fileInfo.Extension == "bml")
                {
                    byte[]    bmlData = BaseRhoFile.GetPackedFile(fileInfo);
                    bmlViewer bv      = new bmlViewer(bmlData, fileInfo.FileName);
                    bv.Show();
                    return;
                }
                FileStream fs = new FileStream(Environment.GetEnvironmentVariable("TEMP") + $"\\{lvii.Text}", FileMode.Create);
                byte[]     a  = BaseRhoFile.GetPackedFile(fileInfo);
                fs.Write(a, 0, a.Length);
                fs.Close();
                a = null;
                Process ps = new Process();
                ps.StartInfo.FileName = Environment.GetEnvironmentVariable("TEMP") + $"\\{lvii.Text}";
                ps.Start();
                return;
            }

            string FolderName = lvii.SubItems[0].Text;

            BaseRhoFile.EnterToFolder(FolderName);
            UpdateFolders();
            this.toolStripButton1.Enabled = true;
        }