Beispiel #1
0
        void LoadObjects(int scenarioIndex = -1)
        {
            Stream s = new MemoryStream(SzsFiles[Path.GetFileNameWithoutExtension(Filename) + ".byml"]);

            LoadedByml = ByamlFile.Load(s, false, Syroot.BinaryData.ByteOrder.LittleEndian);

            if (scenarioIndex == -1)
            {
                string res = "0";
                InputDialog.Show("Select scenario", $"enter scenario value [0,{LoadedByml.Count- 1}]", ref res);
                if (!int.TryParse(res, out scenarioIndex))
                {
                    scenarioIndex = 0;
                }
            }

            _ScenarioIndex = scenarioIndex;
            var Scenario = (Dictionary <string, dynamic>)LoadedByml[scenarioIndex];

            if (Scenario.Keys.Count == 0)
            {
                Scenario.Add("ObjectList", new List <dynamic>());
            }
            foreach (string k in Scenario.Keys)
            {
                objs.Add(k, new ObjList(k, Scenario[k]));
            }
        }
Beispiel #2
0
        private void OpenSzsFile_click(object sender, EventArgs e)
        {
            string name = ((ToolStripMenuItem)sender).Text;
            var    byml = ByamlFile.Load(new MemoryStream(LoadedLevel.SzsFiles[name]), false, Syroot.BinaryData.ByteOrder.LittleEndian);

            new RedCarpet.ByamlViewer(byml).Show();
        }
Beispiel #3
0
        private void bymlViewerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog opn = new OpenFileDialog();

            opn.InitialDirectory = BASEPATH + "StageData";
            opn.Filter           = "byml files, szs files |*.byml;*.szs";
            if (opn.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            dynamic byml = null;

            if (opn.FileName.EndsWith("byml"))
            {
                byml = ByamlFile.Load(opn.FileName);
            }
            else if (opn.FileName.EndsWith("szs"))
            {
                SARC   sarc         = new SARC();
                var    unpackedsarc = sarc.unpackRam(YAZ0.Decompress(opn.FileName));
                string bymlName     = Path.GetFileNameWithoutExtension(opn.FileName) + ".byml";
                if (bymlName.EndsWith("Map1.byml"))  //the szs name always ends with 1, but the map byml doesn't, this seems to be true for every level
                {
                    bymlName = bymlName.Replace("Map1.byml", "Map.byml");
                }
                else if (bymlName.EndsWith("Design1.byml"))
                {
                    bymlName = bymlName.Replace("Design1.byml", "Design.byml");
                }
                else if (bymlName.EndsWith("Sound1.byml"))
                {
                    bymlName = bymlName.Replace("Sound1.byml", "Sound.byml");
                }
                byml = ByamlFile.Load(new MemoryStream(unpackedsarc[bymlName]));
            }
            else
            {
                throw new Exception("Not supported");
            }
            if (byml is Dictionary <string, dynamic> )
            {
                new ByamlViewer(byml).Show();
            }
            else
            {
                throw new Exception("Not supported");
            }
        }
Beispiel #4
0
        public void parseBYML(string name)
        {
            //calling it Object wasn't a great idea, i stared at the code for half hour before realizing that it's a custom class lol
            loadedMap = new Object();
            if (name.EndsWith("Map1.byml"))  //the szs name always ends with 1, but the map byml doesn't, this seems to be true for every level
            {
                loadedBymlFileName = name.Replace("Map1.byml", "Map.byml");
            }
            else if (name.EndsWith("Design1.byml"))
            {
                loadedBymlFileName = name.Replace("Design1.byml", "Design.byml");
            }
            else if (name.EndsWith("Sound1.byml"))
            {
                loadedBymlFileName = name.Replace("Sound1.byml", "Sound.byml");
            }
            else
            {
                loadedBymlFileName = name;
            }

            LoadedByml = ByamlFile.Load(new MemoryStream(LoadedSarc[loadedBymlFileName]));
            foreach (string k in LoadedByml.Keys)
            {
                if (!(LoadedByml[k] is List <dynamic>))
                {
                    continue;
                }
                SectionSelect.Items.Add(k);
                loadedMap.mobjs.Add(k, new List <MapObject>());
                LoadObjectsSection(k);
            }

            if (SectionSelect.Items.Contains("Objs"))
            {
                SectionSelect.SelectedItem = "Objs";
            }
            else if (SectionSelect.Items.Contains("ObjectList"))
            {
                SectionSelect.SelectedItem = "ObjectList";
            }
            else
            {
                SectionSelect.SelectedIndex = 0;
            }

            cpath.Text = LoadedByml["FilePath"];
        }
Beispiel #5
0
        private void convertToLittleEndianToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog d = new OpenFileDialog())
            {
                if (d.ShowDialog() == DialogResult.OK)
                {
                    dynamic byaml = ByamlFile.Load(d.FileName, SupportPaths, byteOrder);

                    ByamlFile.Save(d.FileName + ".new.byaml", byaml, SupportPaths, byteOrderLE);

                    const string message = "Successfully converted byaml to little endian!";
                    const string caption = "Success";
                    var          result  = MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Beispiel #6
0
        private void convertToBigEndianToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog d = new OpenFileDialog())
            {
                d.Title  = "Open File";
                d.Filter = "Binary yaml|*.byaml;*.bprm;*.szs;|All files (*.*)|*.*";

                if (d.ShowDialog() == DialogResult.OK)
                {
                    dynamic byaml = ByamlFile.Load(d.FileName, SupportPaths, byteOrderLE);

                    ByamlFile.Save(d.FileName + ".new.byaml", byaml, SupportPaths, byteOrder);

                    const string message = "Successfully converted byaml to big endian!";
                    const string caption = "Success";
                    var          result  = MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void ButtonLoadByml_Click(object sender, EventArgs e)
        {
            string path = textBoxBrowseByml.Text;

            if (path == null || path.Length == 0)
            {
                MessageBox.Show("Please entery a valid byml path.");
                return;
            }
            if (!File.Exists(path))
            {
                return;
            }
            File.Copy(path, path + ".bak", true);

            using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.UTF8, true))
                {
                    UInt16 magicBytes = reader.ReadUInt16();
                    compressed = magicBytes == YAZ0_MAGIC_BYTES;
                }
            }
            if (compressed)
            {
                Yaz0Compression.Decompress(path, TEMP_FILE);
                if (textBoxBrowseByml.Text.Contains("sbyml"))
                {
                    textBoxBrowseByml.Text = textBoxBrowseByml.Text.Replace("sbyml", "byml");
                }
                path = TEMP_FILE;
            }
            Dictionary <string, dynamic> byamlData = ByamlFile.Load(path);

            treeViewByml.Nodes.Clear();
            treeViewByml.Nodes.Add(AddNode(byamlData, null));
        }
Beispiel #8
0
        public static void OpenByml(string Filename)
        {
            var byml = ByamlFile.Load(Filename);

            new ByamlViewer(byml).Show();
        }
Beispiel #9
0
 private static dynamic LoadByamlDynamic(ByamlSettings settings, Stream stream)
 {
     return(ByamlFile.Load(stream, settings.supportsPaths, settings.byteOrder));
 }
Beispiel #10
0
        private void generateBymlList(string file)
        {
            dynamic byml = ByamlFile.Load(file, false, Syroot.BinaryData.ByteOrder.LittleEndian);

            tree.Nodes.Add(parseDynamic(byml, "root"));
        }