Example #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();
        }
Example #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 = "";
     }
 }
Example #3
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()));
        }
Example #4
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();
        }
Example #5
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();
 }
Example #6
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();
        }