Esempio n. 1
0
 private void Main_Load(object sender, EventArgs e)
 {
     if (Args.Length > 0)
     {
         foreach (var arg in Args)
         {
             var f = new FileInfo(arg);
             if (f.Extension == ".byml")
             {
                 var b    = File.ReadAllBytes(f.FullName);
                 var m    = new MemoryStream(b);
                 var byml = m.GetByml();
                 var y    = byml.ToYaml();
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 using var s = new StreamWriter(f.Name + ".yml");
                 s.Write(y);
                 s.Close();
             }
             else if (f.Extension == ".yml")
             {
                 var y = f.FullName.FromYaml();
                 var b = ByamlFile.SaveN(y);
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 File.WriteAllBytes(f.Name + ".byml", b);
             }
         }
     }
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     Application.SetHighDpiMode(HighDpiMode.SystemAware);
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (args.Length > 0)
     {
         foreach (var arg in args)
         {
             var f = new FileInfo(arg);
             if (f.Extension == ".byml")
             {
                 var b    = File.ReadAllBytes(f.FullName);
                 var m    = new MemoryStream(b);
                 var byml = m.GetByml();
                 var y    = byml.ToYaml();
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 var n = Path.GetFileNameWithoutExtension(f.FullName);
                 using var s = new StreamWriter(n + ".yml");
                 s.Write(y);
                 s.Close();
             }
             else if (f.Extension == ".yml")
             {
                 var y = f.FullName.FromYaml();
                 var b = ByamlFile.SaveN(y);
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 var n = Path.GetFileNameWithoutExtension(f.FullName);
                 File.WriteAllBytes(n + ".byml", b);
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         foreach (var arg in args)
         {
             var f = new FileInfo(arg);
             if (f.Extension == ".byml")
             {
                 var b    = File.ReadAllBytes(f.FullName);
                 var m    = new MemoryStream(b);
                 var byml = m.GetByml();
                 var y    = byml.ToYaml();
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 var n = Path.GetFileNameWithoutExtension(f.FullName);
                 var s = new StreamWriter(n + ".yml");
                 s.Write(y);
                 s.Close();
             }
             else if (f.Extension == ".yml")
             {
                 var y = f.FullName.FromYaml();
                 var b = ByamlFile.SaveN(y);
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 var n = Path.GetFileNameWithoutExtension(f.FullName);
                 File.WriteAllBytes(n + ".byml", b);
             }
         }
     }
     else
     {
         Console.WriteLine("Enter a file here.");
         var R = Console.ReadLine();
         var f = new FileInfo(R);
         if (f.Exists)
         {
             if (f.Extension == ".byml")
             {
                 var b    = File.ReadAllBytes(f.FullName);
                 var m    = new MemoryStream(b);
                 var byml = m.GetByml();
                 var y    = byml.ToYaml();
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 var n = Path.GetFileNameWithoutExtension(f.FullName);
                 var s = new StreamWriter(n + ".yml");
                 s.Write(y);
                 s.Close();
             }
             else if (f.Extension == ".yml")
             {
                 var y = f.FullName.FromYaml();
                 var b = ByamlFile.SaveN(y);
                 Directory.SetCurrentDirectory(f.Directory.FullName);
                 var n = Path.GetFileNameWithoutExtension(f.FullName);
                 File.WriteAllBytes(n + ".byml", b);
             }
         }
     }
 }
Esempio n. 4
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     saveStream.Position = 0;
     saveStream.SetLength(0);
     ByamlFile.SaveN(saveStream, new BymlFileData {
         Version = bymlVer, byteOrder = byteOrder, SupportPaths = pathSupport, RootNode = byml
     });
 }
Esempio n. 5
0
 public void Save(System.IO.Stream stream)
 {
     ByamlFile.SaveN(stream, new BymlFileData
     {
         Version      = BymlData.Version,
         byteOrder    = BymlData.byteOrder,
         SupportPaths = BymlData.SupportPaths,
         RootNode     = BymlData.RootNode
     });
 }
Esempio n. 6
0
        private void SaveAttributeByml(bool UpdateArchive = false)
        {
            if (AttributeByml == null || AttributeByml.RootNode == null)
            {
                return;
            }

            string byml = $"{Path.GetFileNameWithoutExtension(Text)}Attribute.byml";

            if (IFileInfo.ArchiveParent != null)
            {
                foreach (var file in IFileInfo.ArchiveParent.Files)
                {
                    if (file.FileName == byml)
                    {
                        var mem = new MemoryStream();
                        ByamlFile.SaveN(mem, new BymlFileData
                        {
                            Version      = AttributeByml.Version,
                            byteOrder    = AttributeByml.byteOrder,
                            SupportPaths = AttributeByml.SupportPaths,
                            RootNode     = AttributeByml.RootNode
                        });

                        file.FileData = mem.ToArray();
                        //Reload the file format
                        if (file.FileFormat != null)
                        {
                            file.FileFormat = null;
                            file.FileFormat = file.OpenFile();
                        }
                    }
                }
            }
            else if (!UpdateArchive)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter     = "Supported Formats|*.byml";
                sfd.FileName   = byml;
                sfd.DefaultExt = ".byml";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    using (var fileStream = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write)) {
                        ByamlFile.SaveN(fileStream, new BymlFileData
                        {
                            Version      = AttributeByml.Version,
                            byteOrder    = AttributeByml.byteOrder,
                            SupportPaths = AttributeByml.SupportPaths,
                            RootNode     = AttributeByml.RootNode
                        });
                    }
                }
            }
        }
Esempio n. 7
0
        public void Save()
        {
            //byte[] tmp = ToByaml();
            //File.WriteAllBytes("Test.byml", tmp);
            BymlFileData Output = new BymlFileData()
            {
                Version = 1, SupportPaths = false, byteOrder = ByteOrder
            };

            Dictionary <string, dynamic> FinalRoot = new Dictionary <string, dynamic>();
            List <dynamic> worlds = new List <dynamic>();

            for (int i = 0; i < Worlds.Count; i++)
            {
                worlds.Add(Worlds[i].ToByaml());
            }

            FinalRoot.Add("WorldList", worlds);
            Output.RootNode = FinalRoot;



            SarcData Data = new SarcData()
            {
                byteOrder = ByteOrder, Files = new Dictionary <string, byte[]>()
            };

            Data.Files.Add("StageList.byml", ByamlFile.SaveN(Output));
            Tuple <int, byte[]> x = SARC.PackN(Data);


            if (Filename.StartsWith(Program.GamePath) && !string.IsNullOrEmpty(Program.ProjectPath))
            {
                switch (MessageBox.Show(
                            Program.CurrentLanguage.GetTranslation("SaveStageListInProjectText") ?? "Would you like to save the StageList.szs to your ProjectPath instead of your BaseGame?",
                            Program.CurrentLanguage.GetTranslation("SaveStageListInProjectHeader") ?? "Save in ProjectPath",
                            MessageBoxButtons.YesNoCancel))
                {
                case DialogResult.Yes:
                    Directory.CreateDirectory(Path.Combine(Program.ProjectPath, "SystemData"));
                    Filename = Path.Combine(Program.ProjectPath, "SystemData", "StageList.szs");
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                    return;
                }
            }

            File.WriteAllBytes(Filename, YAZ0.Compress(x.Item2));
            //File.WriteAllBytes("Broken.byml", Data.Files["StageList.byml"]);
        }
Esempio n. 8
0
        public byte[] Save()
        {
            MemoryStream mem = new MemoryStream();

            ByamlFile.SaveN(mem, new BymlFileData
            {
                Version      = data.Version,
                byteOrder    = data.byteOrder,
                SupportPaths = data.SupportPaths,
                RootNode     = data.RootNode
            });

            return(mem.ToArray());
        }
Esempio n. 9
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sav = new SaveFileDialog()
            {
                FileName = FileName, Filter = "byml file | *.byml"
            };

            if (sav.ShowDialog() == DialogResult.OK)
            {
                ByamlFile.SaveN(sav.FileName,
                                new BymlFileData {
                    Version = bymlVer, byteOrder = byteOrder, SupportPaths = pathSupport, RootNode = byml
                });
            }
        }
Esempio n. 10
0
 public static byte[] GetBytes(this BymlFileData data)
 {
     return(ByamlFile.SaveN(data));
 }
 public override Stream Save()
 {
     return(new MemoryStream(ByamlFile.SaveN(BymlFile)));
 }
 public override void Save(string fileName)
 {
     File.WriteAllBytes(fileName, ByamlFile.SaveN(BymlFile));
 }