Ejemplo n.º 1
0
        private void SavePacMsbn(MSBinNode msbn, string pacPath, string childNodeName)
        {
            string tmpPac  = Path.GetTempFileName();
            string tmpMsbn = Path.GetTempFileName();

            msbn.Export(tmpMsbn);
            File.Copy(pacPath, tmpPac, true);

            using (ResourceNode tmpPacNode = NodeFactory.FromFile(null, tmpPac))
            {
                MSBinNode tmpPacChildNode = tmpPacNode.FindChild(childNodeName, true) as MSBinNode;
                if (tmpPacChildNode == null)
                {
                    throw new Exception("Error saving '" + pacPath
                                        + "': The file does not appear to have a '" + childNodeName +
                                        "'");
                }
                else
                {
                    tmpPacChildNode.Replace(tmpMsbn);
                    tmpPacNode.Merge();
                    tmpPacNode.Export(pacPath);
                }
            }

            File.Delete(tmpPac);
            File.Delete(tmpMsbn);
        }
Ejemplo n.º 2
0
        private void updateMumenumainToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string mu_menumain_path = null;

            string[] lookIn = { "../../menu2/mu_menumain.pac",
                                "../../menu2/mu_menumain_en.pac",
                                "../../../pfmenu2/mu_menumain.pac",
                                "../../../pfmenu2/mu_menumain_en.pac" };
            foreach (string path in lookIn)
            {
                if (File.Exists(path))
                {
                    mu_menumain_path = path;
                    break;
                }
            }
            if (mu_menumain_path == null)
            {
                MessageBox.Show("mu_menumain / mu_menumain_en not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (DialogResult.OK == MessageBox.Show("Overwrite the current mu_menumain?", "Overwrite File", MessageBoxButtons.OKCancel))
            {
                string tempfile = Path.GetTempFileName();
                string infotmp  = Path.GetTempFileName();
                songPanel1.ExportMSBin(infotmp);
                File.Copy(mu_menumain_path, tempfile, true);

                ResourceNode mu_menumain = NodeFactory.FromFile(null, tempfile);
                MSBinNode    m7          = mu_menumain.FindChild("Misc Data [7]", false) as MSBinNode;
                if (m7 == null)
                {
                    MessageBox.Show(this.ParentForm, "The mu_menumain file does not appear to have a Misc Data [7].",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    m7.Replace(infotmp);
                    mu_menumain.Merge();
                    mu_menumain.Export(mu_menumain_path);
                }

                File.Delete(tempfile);
                File.Delete(infotmp);
            }
        }