Esempio n. 1
0
        public byte[] Save()
        {
            beaFile.FileList.Clear();
            beaFile.FileDictionary.Clear();

            foreach (TreeNode node in Collect(Nodes))
            {
                if (node is TreeNodeFile && node != this)
                {
                    IFileFormat fileFormat = (IFileFormat)node;
                    if (fileFormat != null && fileFormat.CanSave)
                    {
                        byte[] uncomrompressedData = new byte[0];

                        //Save any active files in the editor if supported
                        if (fileFormat.CanSave)
                        {
                            uncomrompressedData = fileFormat.Save();
                        }

                        //Create a new asset entry
                        ASST asset = new ASST();
                        asset.unk              = 2;
                        asset.unk2             = 2;
                        asset.UncompressedSize = uncomrompressedData.LongLength;

                        if (fileFormat.IFileInfo.FileIsCompressed)
                        {
                            asset.FileData = STLibraryCompression.ZSTD.Compress(uncomrompressedData);
                        }
                        else
                        {
                            asset.FileData = uncomrompressedData;
                        }

                        asset.FileName = fileFormat.FilePath;
                        beaFile.FileList.Add(fileFormat.FilePath, asset);
                        beaFile.FileDictionary.Add(fileFormat.FilePath);
                    }
                }
                else if (node is FileEntry)
                {
                    ASST asset = new ASST();
                    asset.unk      = ((FileEntry)node).unk1;
                    asset.unk2     = ((FileEntry)node).unk2;
                    asset.FileName = ((FileEntry)node).FullName;
                    asset.FileData = ((FileEntry)node).data;
                    byte[] uncomp = GetASSTData((FileEntry)node);
                    asset.UncompressedSize = uncomp.Length;
                    beaFile.FileList.Add(asset.FileName, asset);
                    beaFile.FileDictionary.Add(asset.FileName);
                }
            }

            MemoryStream mem = new MemoryStream();

            beaFile.Save(mem);
            return(mem.ToArray());
        }
Esempio n. 2
0
        public byte[] Save()
        {
            foreach (TreeNode node in Collect(EditorRoot.Nodes))
            {
                if (node is FileEntry)
                {
                    Console.WriteLine(node);
                    if (((FileEntry)node).FileHandle != null)
                    {
                        Console.WriteLine("Saving FileHandle");
                        SaveFileEntryData((FileEntry)node);
                    }
                }
            }

            MemoryStream mem = new MemoryStream();

            beaFile.Save(mem);
            return(mem.ToArray());
        }
Esempio n. 3
0
        public void Save(System.IO.Stream stream)
        {
            beaFile.FileList.Clear();
            beaFile.FileDictionary.Clear();

            foreach (FileEntry node in Files)
            {
                node.SaveFileFormat();

                ASST asset = new ASST();
                asset.unk              = node.unk1;
                asset.unk2             = node.unk2;
                asset.FileName         = node.FileName;
                asset.FileData         = node.CompressedData;
                asset.UncompressedSize = node.FileData.Length;
                beaFile.FileList.Add(asset.FileName, asset);
                beaFile.FileDictionary.Add(asset.FileName);
            }

            beaFile.Save(stream);
        }
Esempio n. 4
0
        static void Save(string FilePath)
        {
            beaFile.Save(FilePath);

            MessageBox.Show("Saved file!");
        }