Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            using (var stream = new MemoryStream())
            {
                using (var xr = XmlWriter.Create(stream, new XmlWriterSettings()
                {
                    Indent = true, Encoding = Form1.DefEnc
                }))
                {
                    xr.WriteStartDocument();
                    xr.WriteStartElement("Root");
                    xr.WriteStartElement("isBigEndian");
                    xr.WriteAttributeString("Value", "False");
                    xr.WriteEndElement();
                    xr.WriteStartElement("BymlFormatVersion");
                    xr.WriteAttributeString("Value", ((uint)1).ToString());
                    xr.WriteEndElement();
                    xr.WriteStartElement("C1");
                    xr.WriteStartElement("C0");
                    xr.WriteAttributeString("Name", "StageDefaultBgmList");
                    foreach (string k in Levels.Keys.ToArray())
                    {
                        xr.WriteStartElement("C1");
                        xr.WriteStartElement("A0");
                        xr.WriteAttributeString("Name", "BgmLabel");
                        xr.WriteAttributeString("StringValue", Levels[k]);
                        xr.WriteEndElement();
                        xr.WriteStartElement("D1");
                        xr.WriteAttributeString("Name", "Scenario");
                        xr.WriteAttributeString("StringValue", k.Substring(k.Length - 5, 1));
                        xr.WriteEndElement();
                        xr.WriteStartElement("A0");
                        xr.WriteAttributeString("Name", "StageName");
                        xr.WriteAttributeString("StringValue", k.Substring(0, k.Length - 8));
                        xr.WriteEndElement();
                        xr.WriteEndElement();
                    }
                    xr.WriteEndElement();
                    xr.WriteEndElement();
                    xr.WriteEndElement();
                    xr.Close();
                }
                Clipboard.SetText(Form1.DefEnc.GetString(stream.ToArray()));
                SzsFiles["StageDefaultBgmList.byml"] = BymlConverter.GetByml(Form1.DefEnc.GetString(stream.ToArray()));
            }
            CommonCompressors.YAZ0   y       = new CommonCompressors.YAZ0();
            NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC();
            SFSDirectory             dir     = new SFSDirectory("", true);

            for (int i = 0; i < SzsFiles.Count; i++)
            {
                SFSFile file = new SFSFile(i, SzsFiles.Keys.ToArray()[i], dir);
                file.Data = SzsFiles.Values.ToArray()[i];
                dir.Files.Add(file);
            }
            SzsArch.FromFileSystem(dir);
            File.WriteAllBytes(@"BgmTable.szs", y.Compress(SzsArch.Write()));
            MessageBox.Show("Done, file was saved as BgmTable.szs in this program folder");
            this.Close();
        }
Exemple #2
0
 private void Save(bool isBigEndian)
 {
     saveFileDialog.ShowDialog();
     if (saveFileDialog.FileName != "")
     {
         FileInfo savePath = new FileInfo(saveFileDialog.FileName);
         if (isXML)
         {
             if (isBigEndian)
             {
                 bymltext.Text.Replace($"isBigEndian Value=\"False\"", $"isBigEndian Value=\"True\"");
             }
             else
             {
                 bymltext.Text.Replace($"isBigEndian Value=\"True\"", $"isBigEndian Value=\"False\"");
             }
             File.WriteAllBytes(savePath.FullName, BymlConverter.GetByml(bymltext.Text));
         }
         else
         {
             File.WriteAllText(YamlPath.FullName, bymltext.Text);
             Process          process   = new Process();
             ProcessStartInfo startInfo = new ProcessStartInfo
             {
                 WindowStyle            = ProcessWindowStyle.Hidden,
                 FileName               = "cmd.exe",
                 RedirectStandardOutput = true,
                 UseShellExecute        = false,
                 CreateNoWindow         = true
             };
             if (isBigEndian)
             {
                 startInfo.Arguments = $"/C yml_to_byml.exe \"{YamlPath.FullName}\" \"{savePath.FullName}\" -b";
             }
             else
             {
                 startInfo.Arguments = $"/C yml_to_byml.exe \"{YamlPath.FullName}\" \"{savePath.FullName}\"";
             }
             process.StartInfo = startInfo;
             process.Start();
             process.WaitForExit();
             //If byml-v2 worked there should be no output.
             if (process.StandardOutput.ReadLine() != null)
             {
                 MessageBox.Show("Something went wrong, check that Python is installed and in your path with byml-v2 installed via PIP (pip install byml).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         Text = $"BYML-Editor | {savePath.Name}";
         saveFileDialog.FileName = "";
     }
 }
Exemple #3
0
        private void ConvertBYML(bool wantXML)
        {
            OpenFileDialog bymlselect;

            if (wantXML)
            {
                bymlselect = openxmlFileDialog;
            }
            else
            {
                bymlselect = openyamlFileDialog;
            }

            if (bymlselect.ShowDialog() == DialogResult.OK)
            {
                FileInfo selected = new FileInfo(bymlselect.FileName);

                if (wantXML)
                {
                    bymltext.Text = BymlConverter.GetXml(selected.FullName);
                    isXML         = true;
                }
                else
                {
                    Directory.CreateDirectory(TempPath.FullName);
                    Process          process   = new Process();
                    ProcessStartInfo startInfo = new ProcessStartInfo
                    {
                        WindowStyle            = ProcessWindowStyle.Hidden,
                        FileName               = "cmd.exe",
                        Arguments              = $"/C byml_to_yml.exe \"{selected.FullName}\" \"{YamlPath.FullName}\"",
                        RedirectStandardOutput = true,
                        UseShellExecute        = false,
                        CreateNoWindow         = true
                    };
                    process.StartInfo = startInfo;
                    process.Start();
                    process.WaitForExit();
                    //If byml-v2 worked there should be no output.
                    if (process.StandardOutput.ReadLine() != null)
                    {
                        MessageBox.Show("Something went wrong, check that Python is installed and in your path with byml-v2 installed via PIP (pip install byml).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    bymltext.Text = File.ReadAllText(YamlPath.FullName);
                    isXML         = false;
                }
                Text = $"BYML-Editor | {selected.Name}";
                bymlselect.FileName = "";
                bymltext.ReadOnly   = false;
            }
        }
Exemple #4
0
        public static void SaveFile(ref Dictionary <string, string> ccnt_r)
        {
            CommonCompressors.YAZ0   y       = new CommonCompressors.YAZ0();
            NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC();
            SFSDirectory             dir     = new SFSDirectory("", true);
            SFSFile StgData = new SFSFile(0, "CreatorClassNameTable.byml", dir);

            StgData.Data = BymlConverter.GetByml(MakeXML(ref ccnt_r));
            dir.Files.Add(StgData);
            SzsArch.FromFileSystem(dir);
            File.Delete("CreatorClassNameTable.szs");
            File.WriteAllBytes("CreatorClassNameTable.szs", y.Compress(SzsArch.Write()));
        }
Exemple #5
0
        private void FrmBgmMain_Load(object sender, EventArgs e)
        {
            CommonCompressors.YAZ0   y       = new CommonCompressors.YAZ0();
            NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC();
            SzsArch = new NDS.NitroSystem.FND.NARC(y.Decompress(File.ReadAllBytes(@"BgmTable.szs")));
            foreach (LibEveryFileExplorer.Files.SimpleFileSystem.SFSFile file in SzsArch.ToFileSystem().Files)
            {
                SzsFiles.Add(file.FileName, file.Data);
            }

            string      ConvertedXml = BymlConverter.GetXml(SzsFiles["StageDefaultBgmList.byml"]);
            XmlDocument xml          = new XmlDocument();

            xml.LoadXml(ConvertedXml);
            XmlNode nodes = xml.SelectSingleNode("/Root/C1/C0");

            foreach (XmlNode no in nodes.ChildNodes)
            {
                int    scenario = 0;
                string name     = "";
                string music    = "";
                foreach (XmlNode n in no.ChildNodes)
                {
                    if (n.Attributes["Name"].Value == "Scenario")
                    {
                        scenario = Int32.Parse(n.Attributes["StringValue"].Value);
                    }
                    else if (n.Attributes["Name"].Value == "StageName")
                    {
                        name = n.Attributes["StringValue"].Value;
                    }
                    else if (n.Attributes["Name"].Value == "BgmLabel")
                    {
                        music = n.Attributes["StringValue"].Value;
                    }
                }
                name = name + "Map" + scenario.ToString() + ".szs";
                Levels.Add(name, music);
                if (!Music.Contains(music))
                {
                    Music.Add(music);
                }
            }

            foreach (string k in LevelsNum.Keys.ToArray())
            {
                listBox1.Items.Add(k + " (" + LevelsNum[k] + ")");
            }
            comboBox1.Items.AddRange(Music.ToArray());
            listBox1.SelectedIndex = 0;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string str = "\r\n";

            str    += "<C1>\r\n";
            str    += "<D2 Name=\"AngleH\" StringValue=\"" + numericUpDown3.Value.ToString() + "\" />\r\n";
            str    += "<D2 Name=\"AngleV\" StringValue=\"" + numericUpDown2.Value.ToString() + "\" />\r\n";
            str    += "<A0 Name=\"Category\" StringValue=\"Map\" />\r\n<A0 Name=\"Class\" StringValue=\"Parallel\" />\r\n";
            str    += "<D2 Name=\"Distance\" StringValue=\"" + numericUpDown4.Value.ToString() + "\" />\r\n";
            str    += "<D1 Name=\"UserGroupId\" StringValue=\"" + CameraId.ToString() + "\" />\r\n";
            str    += "<A0 Name=\"UserName\" StringValue=\"CameraArea\" />\r\n</C1>\r\n";
            XmlFile = XmlFile.Insert(TextInsertIndex, str);
            owner.SzsFiles["CameraParam.byml"] = BymlConverter.GetByml(XmlFile);
            this.Close();
        }
Exemple #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            OpenFileDialog opn = new OpenFileDialog();

            opn.Title  = "Open a file";
            opn.Filter = "Supported formats (.szs, .byml, .xml)|*.szs; *.byml; *.xml|Every file|*.*";
            if (opn.ShowDialog() == DialogResult.OK)
            {
                if (Path.GetExtension(opn.FileName).ToLower() == ".xml")
                {
                    LoadCCNT2(File.ReadAllText(opn.FileName));
                }
                else if (Path.GetExtension(opn.FileName).ToLower() == ".byml")
                {
                    LoadCCNT2(BymlConverter.GetXml(opn.FileName));
                }
                else if (Path.GetExtension(opn.FileName).ToLower() == ".szs")
                {
                    CommonCompressors.YAZ0   y       = new CommonCompressors.YAZ0();
                    NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC();
                    SzsArch = new NDS.NitroSystem.FND.NARC(y.Decompress(File.ReadAllBytes(opn.FileName)));
                    string ConvertedCCN = BymlConverter.GetXml(SzsArch.ToFileSystem().Files[0].Data);
                    LoadCCNT2(ConvertedCCN);
                }
                else
                {
                    MessageBox.Show("Unknown format !");
                    return;
                }
            }
            else
            {
                return;
            }
            foreach (string k in CCNT2.Keys.ToArray())
            {
                if (!CCNT.ContainsKey(k))
                {
                    CCNT.Add(k, CCNT2[k]);
                }
            }
            updateListbox();
            MessageBox.Show("Done");
        }
Exemple #8
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (IsConverter)
     {
         SaveFileDialog s = new SaveFileDialog();
         s.Filter = ".xml file|*.xml|.byml file|*.byml";
         if (s.ShowDialog() == DialogResult.OK)
         {
             if (Path.GetFileName(s.FileName).EndsWith(".xml"))
             {
                 File.WriteAllText(s.FileName, fastColoredTextBox1.Text, Encoding.GetEncoding(932));
             }
             else
             {
                 File.WriteAllBytes(s.FileName, BymlConverter.GetByml(fastColoredTextBox1.Text));
             }
         }
     }
     else
     {
         XmlRes = fastColoredTextBox1.Text;
     }
     this.Close();
 }
Exemple #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!File.Exists(PaPath))
            {
                MessageBox.Show("Pa file not found !"); return;
            }
            if (!File.Exists(KclPath))
            {
                MessageBox.Show("kcl file not found !"); return;
            }
            if (!File.Exists(modelPath))
            {
                MessageBox.Show("Model file not found !"); return;
            }
            SaveFileDialog s = new SaveFileDialog();

            s.Filter   = "Szs files|*.szs";
            s.FileName = textBox1.Text;
            if (s.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            CommonCompressors.YAZ0   y       = new CommonCompressors.YAZ0();
            NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC();
            SFSDirectory             dir     = new SFSDirectory("", true);

            //Model
            SFSFile Model = new SFSFile(0, textBox1.Text + ".bcmdl", dir);

            if (IsObj)
            {
                CGFX mod = null;
                mod = new CGFX();
                CGFXGenerator.FromOBJ(mod, modelPath, textBox1.Text);
                Model.Data = mod.Write();
            }
            else
            {
                Model.Data = File.ReadAllBytes(modelPath);
            }
            dir.Files.Add(Model);
            //Collisions
            SFSFile KclFile = new SFSFile(1, textBox1.Text + ".kcl", dir);

            KclFile.Data = File.ReadAllBytes(KclPath);
            dir.Files.Add(KclFile);
            SFSFile PaFile = new SFSFile(2, textBox1.Text + ".pa", dir);

            PaFile.Data = File.ReadAllBytes(PaPath);
            dir.Files.Add(PaFile);
            //InitSensor
            SFSFile Sensor = new SFSFile(3, "InitSensor.byml", dir);

            Sensor.Data = BymlConverter.GetByml(Properties.Resources.Sensor);
            dir.Files.Add(Sensor);
            //InitActor
            SFSFile Actor = new SFSFile(4, "InitActor.byml", dir);

            Actor.Data = BymlConverter.GetByml(Properties.Resources.Actor);
            dir.Files.Add(Actor);
            //InitClipping
            string  clip     = "<?xml version=\"1.0\" encoding=\"shift_jis\"?>\r\n<Root>\r\n  <isBigEndian Value=\"False\" />\r\n  <BymlFormatVersion Value=\"1\" />\r\n  <C1>\r\n    <D2 Name=\"Radius\" StringValue=\"" + numericUpDown1.Value.ToString() + "\" />\r\n  </C1>\r\n</Root>";
            SFSFile Clipping = new SFSFile(5, "InitClipping.byml", dir);

            Clipping.Data = BymlConverter.GetByml(clip);
            dir.Files.Add(Clipping);

            SzsArch.FromFileSystem(dir);
            File.WriteAllBytes(s.FileName, y.Compress(SzsArch.Write()));
            MessageBox.Show("Done !");
            MessageBox.Show("Remember you need to add the object to the CreatorClassNameTable to use the object in-game (Other modding -> CreatorClassNameTable editor)");
            MessageBox.Show("To view the model in the editor you must copy it in the models folder with the name " + textBox1.Text + ".obj or else you will see a blue box");
            this.Close();
        }