示例#1
0
        public static AfsLoader CreateMissionAfs(RawFile questNbl, Dictionary <int, RawFile> zoneNbls, bool createAllLanguages)
        {
            AfsLoader toReturn    = new AfsLoader();
            int       highestZone = zoneNbls.Keys.Max();

            AddLanguages(toReturn, questNbl, "quest", createAllLanguages);

            //Alright, so.
            //0-1-10-11-...2-20-21...-
            for (int i = 0; i < 10; i++)
            {
                if (zoneNbls.ContainsKey(i))
                {
                    AddLanguages(toReturn, zoneNbls[i], "zone" + i.ToString("D2"), createAllLanguages);
                }
                if (i > 0)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        if (zoneNbls.ContainsKey(i * 10 + j))
                        {
                            AddLanguages(toReturn, zoneNbls[i], "zone" + (i * 10 + j).ToString("D2"), createAllLanguages);
                        }
                    }
                }
            }
            return(toReturn);
        }
示例#2
0
 private void createAFSToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (folderBrowserDialog1.ShowDialog() == DialogResult.OK && saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string folderToOpen = folderBrowserDialog1.SelectedPath;
         string fileToSave   = saveFileDialog1.FileName;
         AfsLoader.createFromDirectory(folderToOpen, fileToSave);
     }
 }
示例#3
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (questNbl != null)
     {
         saveFileDialog1.FileName = textBox2.Text;
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             AfsLoader.CreateMissionAfs(questNbl, zones, checkBox1.Checked);
         }
     }
 }
示例#4
0
 private static void AddLanguages(AfsLoader containingFile, RawFile fileToAdd, string filenamePrefix, bool createAllLanguages)
 {
     for (int i = 0; i < languages.Length; i++)
     {
         if (createAllLanguages || languages[i] == "_ae")
         {
             containingFile.afsList.Add(new AfsFileEntry {
                 rawContents = fileToAdd.fileContents, fileName = filenamePrefix + languages[i] + ".nbl"
             });
         }
         else
         {
             containingFile.afsList.Add(new AfsFileEntry {
                 fileName = filenamePrefix + languages[i] + ".nbl"
             });
         }
     }
 }
示例#5
0
        public static bool parseScripts = true; //Because you don't always want to parse script files.

        public static PsuFile FromRaw(string filename, byte[] rawData, byte[] inHeader, int[] ptrs, int baseAddr, bool bigEndian = false)
        {
            if (filename.EndsWith("xvr"))
            {
                return(new XvrTextureFile(inHeader, rawData, filename));
            }
            else if (filename.EndsWith(".uvr"))
            {
                return(new UvrTextureFile(inHeader, rawData, filename));
            }
            else if (filename.EndsWith(".gim") && GimSharp.GimTexture.Is(rawData))
            {
                return(new GimTextureFile(inHeader, rawData, filename));
            }
            else if (filename.Contains("Weapon.bin") || filename.Contains("General.bin") || filename.Contains("Other.bin"))
            {
                return(new Psp2TextFile(filename, rawData));
            }
            else if (filename.Equals("itemObjectDrop.xnr"))
            {
                return(new ObjectDropFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Equals("filelist.rel"))
            {
                return(new QuestListFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.EndsWith("filelist.rel"))
            {
                return(new ListFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Equals("itemEnemyDrop.xnr"))
            {
                return(new EnemyDropFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.StartsWith("set_r") && filename.EndsWith(".rel"))
            {
                return(new SetFile(filename, rawData, inHeader, ptrs, baseAddr, bigEndian));
            }
            else if (filename.EndsWith(".xnt"))
            {
                return(new XntFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (parseScripts && (filename.Contains("script.bin") || filename.Contains("Tutor.bin")))
            {
                return(new ScriptFile(filename, rawData, bigEndian));
            }
            else if ((filename.EndsWith(".k") || filename.Contains(".bin")) && BitConverter.ToInt32(rawData, 0) == rawData.Length && new string(ASCIIEncoding.ASCII.GetChars(rawData, 0, 4)) != "RIPC")
            {
                return(new TextFile(filename, rawData));
            }
            else if (filename.Contains("item00ValueData"))
            {
                return(new ItemPriceFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains("itemTechParam") && !filename.Contains("EnemyB"))
            {
                return(new ItemTechParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains("itemBulletParam") && !filename.Contains("MagAt"))
            {
                return(new ItemBulletParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.StartsWith("Think") && filename.EndsWith("Dragon.xnr"))
            {
                return(new ThinkDragonFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains("itemSkillParam"))
            {
                return(new ItemSkillParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains("itemLineUnitParam"))
            {
                return(new ItemUnitParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains(".nbl") || ASCIIEncoding.ASCII.GetString(rawData, 0, 4) == "NMLL")
            {
                NblLoader toReturn = new NblLoader(new MemoryStream(rawData));
                toReturn.filename = filename;
                return(toReturn);
            }
            else if (ASCIIEncoding.ASCII.GetString(rawData, 0, 3) == "AFS")
            {
                AfsLoader toReturn = new AfsLoader(filename, new MemoryStream(rawData));
            }
            else if (new Regex("enemy.._...._r.\\.(xnr|rel|unr)").IsMatch(filename))
            {
                return(new EnemyLayoutFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains("itemWeaponParam"))
            {
                return(new WeaponParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains("itemCommonInfo.xnr"))
            {
                return(new CommonInfoFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.StartsWith("EnemyLevelBaseParam."))
            {
                return(new EnemyLevelParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Equals("itemSuitParam.xnr") || filename.Equals("itemPartsParam.xnr"))
            {
                return(new ItemSuitParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.EndsWith(".nom"))
            {
                return(new NomFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Contains("itemBulletParam_27MagAt"))
            {
                return(new RmagBulletParamFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (filename.Equals("partsinfo.xnr"))
            {
                return(new PartsInfoFile(filename, rawData, inHeader, ptrs, baseAddr));
            }
            else if (inHeader != null && ASCIIEncoding.ASCII.GetString(inHeader, 0, 4) == "NXIF" || ASCIIEncoding.ASCII.GetString(inHeader, 0, 4) == "NUIF" || ASCIIEncoding.ASCII.GetString(inHeader, 0, 4) == "NSIF")
            {
                return(new PointeredFile(filename, rawData, inHeader, ptrs, baseAddr, false));
            }
            else if (inHeader != null && ASCIIEncoding.ASCII.GetString(inHeader, 0, 4) == "NYIF")
            {
                return(new PointeredFile(filename, rawData, inHeader, ptrs, baseAddr, true));
            }
            return(new UnpointeredFile(filename, rawData, inHeader));
        }
示例#6
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                byte[] formatName = new byte[4];
                using (Stream stream = openFileDialog1.OpenFile())
                {
                    stream.Read(formatName, 0, 4);
                }
                splitContainer1.Panel2.Controls.Clear();
                string identifier = new string(Encoding.ASCII.GetChars(formatName, 0, 4));
                if (identifier == "NMLL" || identifier == "NMLB")
                {
                    treeView1.Nodes.Clear();
                    loadedAfs     = null;
                    loadedMiniAfs = null;
                    using (Stream stream = openFileDialog1.OpenFile())
                    {
                        loadedNbl = new NblLoader(stream);
                        //listBox1.Items.Clear();
                        //for (int i = 0; i < loadedNbl.filenames.Length; i++)
                        //{
                        //listBox1.Items.Add(loadedNbl.filenames[i]);
                        //}
                        addChildFiles(treeView1.Nodes, loadedNbl);

                        /*
                         * treeView1.Nodes.Add("NMLL chunk");
                         * for (int i = 0; i < loadedNbl.nmllFiles.Length; i++)
                         * {
                         *  TreeNode temp = new TreeNode(loadedNbl.nmllFiles[i].fileName);
                         *  if (temp.Text.Contains(".nbl"))
                         *      addNblFiles(temp, (NblLoader)loadedNbl.nmllFiles[i].actualFile);
                         *  treeView1.Nodes[0].Nodes.Add(temp);
                         *
                         * }
                         * if (loadedNbl.tmllFiles != null && loadedNbl.tmllFiles.Length > 0)
                         * {
                         *  treeView1.Nodes.Add("TMLL chunk");
                         *  for (int i = 0; i < loadedNbl.tmllFiles.Length; i++)
                         *  {
                         *      treeView1.Nodes[1].Nodes.Add(loadedNbl.tmllFiles[i].fileName);
                         *  }
                         * }*/
                        checkBox1.Checked = loadedNbl.isCompressed;
                    }
                }
                if (new string(Encoding.ASCII.GetChars(formatName, 0, 4)) == "AFS\0")
                {
                    treeView1.Nodes.Clear();
                    loadedNbl     = null;
                    loadedMiniAfs = null;
                    using (Stream stream = openFileDialog1.OpenFile())
                    {
                        loadedAfs = new AfsLoader(stream);
                        splitContainer1.Panel2.Controls.Clear();
                        //listBox1.Items.Clear();

                        /*TextBox txtBox = new TextBox();
                         * splitContainer1.Panel2.Controls.Add(txtBox);
                         * txtBox.Dock = DockStyle.Fill;
                         * txtBox.Multiline = true;
                         * txtBox.ScrollBars = ScrollBars.Vertical;*/

                        //for (int i = 0; i < loadedAfs.fileCount; i++)
                        //{

                        /*txtBox.Text += "\r\n" + loadedAfs.afsList[i].fileName + "\t\t" + loadedAfs.afsList[i].location.ToString("X8") + " " + loadedAfs.afsList[i].fileSize.ToString("X8") + "\t\t" + loadedAfs.afsList[i].year + "-" + loadedAfs.afsList[i].month + "-" + loadedAfs.afsList[i].day + " "
                         + loadedAfs.afsList[i].hour.ToString("D2") + ":" + loadedAfs.afsList[i].minute.ToString("D2") + ":" + loadedAfs.afsList[i].second.ToString("D2") + "\t" + loadedAfs.afsList[i].garbageInt.ToString("X8");*/
                        //  listBox1.Items.Add(loadedAfs.afsList[i].fileName);

                        /*TreeNode temp = new TreeNode(loadedAfs.afsList[i].fileName);
                         * if (loadedAfs.subPaths[i] != null)
                         *  addAfsFiles(temp, loadedAfs.subPaths[i]);
                         * else if (loadedAfs.nblContents[i] != null)
                         *  addNblFiles(temp, loadedAfs.nblContents[i]);
                         * treeView1.Nodes.Add(temp);*/
                        //}

                        addChildFiles(treeView1.Nodes, loadedAfs);
                    }
                }
                if (BitConverter.ToInt16(formatName, 0) == 0x50AF)
                {
                    treeView1.Nodes.Clear();
                    loadedAfs = null;
                    loadedNbl = null;
                    using (Stream stream = openFileDialog1.OpenFile())
                    {
                        loadedMiniAfs = new MiniAfsLoader(stream);
                        splitContainer1.Panel2.Controls.Clear();
                        //listBox1.Items.Clear();

                        /*TextBox txtBox = new TextBox();
                         * splitContainer1.Panel2.Controls.Add(txtBox);
                         * txtBox.Dock = DockStyle.Fill;
                         * txtBox.Multiline = true;
                         * txtBox.ScrollBars = ScrollBars.Vertical;*/

                        //for (int i = 0; i < loadedAfs.fileCount; i++)
                        //{

                        /*txtBox.Text += "\r\n" + loadedAfs.afsList[i].fileName + "\t\t" + loadedAfs.afsList[i].location.ToString("X8") + " " + loadedAfs.afsList[i].fileSize.ToString("X8") + "\t\t" + loadedAfs.afsList[i].year + "-" + loadedAfs.afsList[i].month + "-" + loadedAfs.afsList[i].day + " "
                         + loadedAfs.afsList[i].hour.ToString("D2") + ":" + loadedAfs.afsList[i].minute.ToString("D2") + ":" + loadedAfs.afsList[i].second.ToString("D2") + "\t" + loadedAfs.afsList[i].garbageInt.ToString("X8");*/
                        //  listBox1.Items.Add(loadedAfs.afsList[i].fileName);

                        /*TreeNode temp = new TreeNode(loadedAfs.afsList[i].fileName);
                         * if (loadedAfs.subPaths[i] != null)
                         *  addAfsFiles(temp, loadedAfs.subPaths[i]);
                         * else if (loadedAfs.nblContents[i] != null)
                         *  addNblFiles(temp, loadedAfs.nblContents[i]);
                         * treeView1.Nodes.Add(temp);*/
                        //}

                        addChildFiles(treeView1.Nodes, loadedMiniAfs);
                    }
                }
            }
        }