Пример #1
0
 public void PrepareMUM()
 {
     mumPath = FindFile(MUM_PATHS);
     mumMsbn = LoadPacMsbn(mumPath, "MiscData[7]");
 }
Пример #2
0
 public void PrepareINFO()
 {
     infoPath = FindFile(INFO_PATHS);
     infoMsbn = LoadPacMsbn(infoPath, "MiscData[140]");
 }
Пример #3
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);
        }
Пример #4
0
 public void PrepareTRNG()
 {
     trngPath = FindFile(TRNG_PATHS);
     trngMsbn = LoadPacMsbn(trngPath, "MiscData[140]");
 }
Пример #5
0
        /// <summary>
        /// This function finds the new info.pac. It should be called whenever you change the working directory.
        /// It also clears the list of edited ("dirty") strings, and records the current names (for the "restore" button).
        /// </summary>
        public String findInfoFile()
        {
            _index = -1;

            info = info_training = null;
            _currentFile = _currentTrainingFile = null;

            string tempfile = Path.GetTempFileName();
            if (new FileInfo("MiscData[140].msbin").Exists) {
                _currentFile = "MiscData[140].msbin";
                File.Copy("MiscData[140].msbin", tempfile, true);
                info = NodeFactory.FromFile(null, tempfile) as MSBinNode;
                return "Loaded .\\MiscData[140].msbin";
            } else if (new FileInfo("\\MiscData[140].msbin").Exists) {
                _currentFile = "\\MiscData[140].msbin";
                File.Copy("\\MiscData[140].msbin", tempfile, true);
                info = NodeFactory.FromFile(null, tempfile) as MSBinNode;
                return "Loaded \\MiscData[140].msbin";
            } else {
                string[] infopaths = { "..\\..\\info2\\info.pac", "..\\..\\info2\\info_en.pac", "..\\info.pac" };

                foreach (string relativepath in infopaths) {
                    if (info == null) {
                        string s = Path.GetFullPath(relativepath);
                        if (new FileInfo(s).Exists) {
                            _currentFile = s;
                            File.Copy(s, tempfile, true);
                            info_pac = NodeFactory.FromFile(null, tempfile);
                            info = (MSBinNode)info_pac.FindChild("MiscData[140]", true);
                        }
                    }
                }

                if (info == null) {
                    return "No song list loaded";
                } else {
                    modifiedStringIndices.Clear();
                    copyIntoFileStrings();

                    // info found; try info_training in same directory
                    string trainingpath = _currentFile.Replace("info.pac", "info_training.pac").Replace("info_en.pac", "info_training_en.pac");
                    if (trainingpath != _currentFile && new FileInfo(trainingpath).Exists) {
                        _currentTrainingFile = trainingpath;
                        string tempfile_training = Path.GetTempFileName();
                        File.Copy(trainingpath, tempfile_training, true);
                        info_training_pac = NodeFactory.FromFile(null, tempfile_training);
                        info_training = (MSBinNode)info_training_pac.FindChild("MiscData[140]", true);
                        return "Loaded info.pac and info_training.pac";
                    } else {
                        return "Loaded info.pac";
                    }
                }
            }
        }
Пример #6
0
        public MSBinNode NewMSBin()
        {
            MSBinNode node = new MSBinNode() { FileType = ARCFileType.MiscData };
            _resource.AddChild(node);

            BaseWrapper w = this.FindResource(node, false);
            w.EnsureVisible();
            w.TreeView.SelectedNode = w;
            return node;
        }