Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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");
        }