예제 #1
0
파일: Form1.cs 프로젝트: xpoi5010/JMDReader
        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();
                JMDPackedFileInfo fileInfo = (JMDPackedFileInfo)Array.Find(BaseJMDFile.NowFolderContent, x => x.Type == ObjectType.File && (((JMDPackedFileInfo)x).FileName + $".{((JMDPackedFileInfo)x).Extension}") == lvii.Text);
                if (BaseJMDFile.ModifiedFileInfos.Exists(x => x.FileIndex == fileInfo.Index))
                {
                    MessageBox.Show("message_filemodified".GetStringBag(), "title".GetStringBag(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (fileInfo.Extension == "dds" || fileInfo.Extension == "tga")
                {
                    TgaDDsViewer tdv = new TgaDDsViewer();
                    tdv.Data = BaseJMDFile.GetPackedFile(fileInfo);
                    tdv.Type = fileInfo.Extension == "dds" ? TgaDDsViewer.FileType.dds : fileInfo.Extension == "tga" ? TgaDDsViewer.FileType.tga : throw new Exception();
                    tdv.ShowBox();
                    return;
                }
                FileStream fs = new FileStream(Environment.GetEnvironmentVariable("TEMP") + $"\\{lvii.Text}", FileMode.Create);
                byte[]     a  = BaseJMDFile.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;

            BaseJMDFile.EnterToFolder(FolderName);
            UpdateFolders();
            this.toolStripButton1.Enabled = true;
        }
예제 #2
0
        private void ExportAllFolder_bg(string outputPath, bool IncludeSubFolder, JMDFile file)
        {
            IPackedObject[]         ipos  = JMDPackedFilesInfoDecoder.GetJMDPackedFileInfos(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)
                    {
                        JMDPackedFolderInfo jpfi = (JMDPackedFolderInfo)ipo;
                        ExportProcessor     nep  = new ExportProcessor
                        {
                            Path = ep.Path + $"\\{jpfi.FolderName}",
                            ipos = JMDPackedFilesInfoDecoder.GetJMDPackedFileInfos(file.GetStreamData(jpfi.Index), file.HeaderKey, jpfi.Index)
                        };
                        Stack.Push(nep);
                        if (!Directory.Exists($"{outPath}\\{((JMDPackedFolderInfo)ipo).FolderName}"))
                        {
                            Directory.CreateDirectory($"{outPath}\\{((JMDPackedFolderInfo)ipo).FolderName}");
                        }
                        continue;
                    }
                    if (ipo.Type == ObjectType.File)
                    {
                        JMDPackedFileInfo jfi = (JMDPackedFileInfo)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();
        }