Exemplo n.º 1
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         if (radioButton1.Checked)
         {
             endianness = EndiannessAwareBinaryReader.Endianness.Little;
         }
         else if (radioButton2.Checked)
         {
             endianness = EndiannessAwareBinaryReader.Endianness.Big;
         }
         iga = new IGA(openFileDialog1.FileName, endianness);
         buildTree(false);
     }
 }
Exemplo n.º 2
0
 private void Import_Load(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         if (radioButton1.Checked)
         {
             endianness = EndiannessAwareBinaryReader.Endianness.Little;
         }
         else if (radioButton2.Checked)
         {
             endianness = EndiannessAwareBinaryReader.Endianness.Big;
         }
         iga    = new IGA(openFileDialog1.FileName, endianness);
         files1 = iga.file;
         buildTree(treeView1, files1);
         buildTree(treeView2, files2);
     }
     else
     {
         this.Close();
     }
 }
Exemplo n.º 3
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (openFileDialog3.ShowDialog() == DialogResult.OK)
            {
                if (folderBrowserDialog2.ShowDialog() == DialogResult.OK)
                {
                    String NST_Folder   = folderBrowserDialog2.SelectedPath.Replace('\\', '/') + '/';
                    String Patch_Folder = openFileDialog3.FileName.Replace('\\', '/');
                    while (Patch_Folder.Last() != '/')
                    {
                        Patch_Folder = Patch_Folder.Remove(Patch_Folder.Length - 1);
                    }
                    FileStream   patch = new FileStream(openFileDialog3.FileName, FileMode.Open, FileAccess.Read);
                    StreamReader reader = new StreamReader(patch);
                    IGA          iga = null;
                    IGA          import = null;
                    Int32        index = 0; UInt32 ID = 0; FileInfo info = null; IGA tmp_pak = null; File file = null; String open = "";
                    Int32        line_num = 0;
                    while (!reader.EndOfStream)
                    {
                        line_num++;
                        String   line = reader.ReadLine();
                        String[] CMD  = line.Split(' ');
                        for (int i = 0; i < CMD.Length; ++i)
                        {
                            CMD[i] = CMD[i].Trim();
                        }
                        label1.Text = CMD[0] + "(" + open + ")";
                        switch (CMD[0].ToLower())   // open <pak>
                        {
                        case "open":
                            if (CMD.Length < 2)
                            {
                                MessageBox.Show("Too few arguments in line " + line_num.ToString() + " : " + line);
                                reader.Close();
                                return;
                            }
                            if (!System.IO.File.Exists(NST_Folder + CMD[1]))
                            {
                                MessageBox.Show("File " + NST_Folder + CMD[1] + " does not exists in line " + line_num.ToString() + " : " + line);
                                reader.Close();
                                return;
                            }
                            open = CMD[1];
                            iga  = new IGA(NST_Folder + CMD[1], endianness);
                            break;

                        case "repack":     // repack
                            iga.repack(NST_Folder + open + "tmp", progressBar1, endianness);
                            if (!System.IO.File.Exists(NST_Folder + open + ".patch_bak"))
                            {
                                System.IO.File.Move(NST_Folder + open, NST_Folder + open + ".patch_bak");
                            }
                            else
                            {
                                System.IO.File.Delete(NST_Folder + open);
                            }
                            System.IO.File.Move(NST_Folder + open + "tmp", NST_Folder + open);
                            break;

                        case "replace":
                            switch (CMD[1].ToLower())
                            {
                            case "assets":         // replace assets <ID> <asset>
                                if (CMD.Length < 4)
                                {
                                    MessageBox.Show("Too few arguments in line " + line_num.ToString() + " : " + line);
                                    reader.Close();
                                    return;
                                }
                                if (!System.IO.File.Exists(Patch_Folder + CMD[3]))
                                {
                                    MessageBox.Show("File " + Patch_Folder + CMD[3] + " does not exists in line " + line_num.ToString() + " : " + line);
                                    reader.Close();
                                    return;
                                }
                                info = new FileInfo(Patch_Folder + CMD[3]);
                                try {
                                    ID = UInt32.Parse(CMD[2]);
                                }
                                catch (Exception ex) {
                                    MessageBox.Show("Bad format of \"" + CMD[2] + "\" is not found in " + line_num.ToString() + " : " + line + "\nCheck for extra spaces between arguments.");
                                    reader.Close();
                                    return;
                                }
                                for (int i = 0; i < iga.file.Count; ++i)
                                {
                                    if ((UInt32)iga.file[i].getID() == ID)
                                    {
                                        index = i;
                                        break;
                                    }
                                }
                                iga.replace(index, Patch_Folder + CMD[3], 0, (int)info.Length);
                                break;

                            case "pak":         // replace pak <pak> <ID> <ID>
                                if (CMD.Length < 5)
                                {
                                    MessageBox.Show("Too few arguments in line " + line_num.ToString() + " : " + line);
                                    reader.Close();
                                    return;
                                }
                                tmp_pak = new IGA(NST_Folder + CMD[2], endianness);
                                index   = -1;
                                try {
                                    ID = UInt32.Parse(CMD[3]);
                                }
                                catch (Exception ex) {
                                    MessageBox.Show("Bad format of \"" + CMD[3] + "\" is not found in " + line_num.ToString() + " : " + line + "\nCheck for extra spaces between arguments.");
                                    reader.Close();
                                    return;
                                }
                                for (int i = 0; i < tmp_pak.file.Count; ++i)
                                {
                                    if ((UInt32)tmp_pak.file[i].getID() == ID)
                                    {
                                        index = i;
                                        break;
                                    }
                                }
                                if (index == -1)
                                {
                                    MessageBox.Show("ID " + ID.ToString() + " is not found in " + line_num.ToString() + " : " + line);
                                    reader.Close();
                                    return;
                                }
                                file = null;
                                try {
                                    ID = UInt32.Parse(CMD[4]);
                                } catch (Exception ex) {
                                    MessageBox.Show("Bad format of \"" + CMD[4] + "\" is not found in " + line_num.ToString() + " : " + line + "\nCheck for extra spaces between arguments.");
                                    reader.Close();
                                    return;
                                }
                                for (int i = 0; i < tmp_pak.file.Count; ++i)
                                {
                                    if ((UInt32)tmp_pak.file[i].getID() == ID)
                                    {
                                        file = tmp_pak.file[i];
                                        break;
                                    }
                                }
                                if (file == null)
                                {
                                    MessageBox.Show("ID " + ID.ToString() + " is not found in " + line_num.ToString() + " : " + line);
                                    reader.Close();
                                    return;
                                }
                                iga.replace(index, NST_Folder + CMD[2], file.getSourceOffset(), file.getSize());
                                break;
                            }
                            break;

                        case "open_import":
                            if (CMD.Length < 2)
                            {
                                MessageBox.Show("Too few arguments in: " + line);
                                reader.Close();
                                return;
                            }
                            if (!System.IO.File.Exists(NST_Folder + CMD[1]))
                            {
                                MessageBox.Show("File " + NST_Folder + CMD[1] + " does not exists in line " + line_num.ToString() + " : " + line);
                                reader.Close();
                                return;
                            }
                            import = new IGA(NST_Folder + CMD[1], endianness);
                            break;

                        case "import":
                            if (CMD.Length < 2)
                            {
                                MessageBox.Show("Too few arguments in: " + line);
                                reader.Close();
                                return;
                            }
                            index = -1;
                            try {
                                ID = UInt32.Parse(CMD[1]);
                            }
                            catch (Exception ex) {
                                MessageBox.Show("Bad format of \"" + CMD[1] + "\" is not found in " + line_num.ToString() + " : " + line + "\nCheck for extra spaces between arguments.");
                                reader.Close();
                                return;
                            }
                            for (int i = 0; i < tmp_pak.file.Count; ++i)
                            {
                                if ((UInt32)import.file[i].getID() == ID)
                                {
                                    index = i;
                                    break;
                                }
                            }
                            if (index == -1)
                            {
                                MessageBox.Show("ID " + ID.ToString() + " is not found in " + line_num.ToString() + " : " + line);
                                reader.Close();
                                return;
                            }
                            iga.add(import.file[index]);
                            break;
                        }
                    }
                    reader.Close();
                    MessageBox.Show("Done.");
                }
            }
        }