Example #1
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LandTableFormat outfmt = LevelData.geo.Format;

            if (outfmt == LandTableFormat.SADX)
            {
                outfmt = LandTableFormat.SA1;
            }
            using (SaveFileDialog a = new SaveFileDialog()
            {
                DefaultExt = outfmt.ToString().ToLowerInvariant() + "lvl",
                Filter = outfmt.ToString().ToUpperInvariant() + "LVL Files|*." + outfmt.ToString().ToLowerInvariant() + "lvl|All Files|*.*"
            })
                if (a.ShowDialog(this) == DialogResult.OK)
                {
                    LevelData.geo.SaveToFile(a.FileName, outfmt);
                }
        }
Example #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     LandTableFormat format = (LandTableFormat)comboBox2.SelectedIndex;
     LandTableFormat outfmt = format;
     if (format == LandTableFormat.SADX) outfmt = LandTableFormat.SA1;
     ByteConverter.BigEndian = checkBox1.Checked;
     using (SaveFileDialog sd = new SaveFileDialog() { DefaultExt = outfmt.ToString().ToLowerInvariant() + "lvl", Filter = outfmt.ToString().ToUpperInvariant() + "LVL Files|*." + outfmt.ToString().ToLowerInvariant() + "lvl|All Files|*.*" })
         if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             new LandTable(file, (int)NumericUpDown1.Value, (uint)numericUpDown2.Value, format) { Author = author.Text, Description = description.Text }.SaveToFile(sd.FileName, outfmt);
             Settings.Author = author.Text;
             Settings.Save();
         }
 }
Example #3
0
        // Scan for Landtables
        static void ScanLandtable(LandTableFormat landfmt)
        {
            CurrentStep++;
            CurrentScanData         = "Landtables " + landfmt.ToString();
            ByteConverter.BigEndian = BigEndian;
            Console.WriteLine("Step {0}: Scanning for {1} landtables", CurrentStep, landfmt.ToString());
            string landtable_extension = ".sa1lvl";
            int    count = 0;

            switch (landfmt)
            {
            case LandTableFormat.SA1:
                landtable_extension = ".sa1lvl";
                break;

            case LandTableFormat.SADX:
            default:
                landtable_extension = ".sa1lvl";
                break;

            case LandTableFormat.SA2:
                landtable_extension = ".sa2lvl";
                break;

            case LandTableFormat.SA2B:
                landtable_extension = ".sa2blvl";
                break;
            }
            if (!SingleOutputFolder)
            {
                Directory.CreateDirectory(Path.Combine(OutputFolder, "levels"));
            }
            for (uint address = StartAddress; address < EndAddress; address += 1)
            {
                if (CancelScan)
                {
                    break;
                }
                if (ConsoleMode && address % 1000 == 0)
                {
                    Console.Write("\r{0} ", address.ToString("X8"));
                }
                CurrentAddress = address;
                string fileOutputPath = Path.Combine(OutputFolder, "levels", address.ToString("X8"));
                if (SingleOutputFolder)
                {
                    fileOutputPath = Path.Combine(OutputFolder, address.ToString("X8"));
                }
                if (!CheckLandTable(address, landfmt))
                {
                    continue;
                }
                try
                {
                    //Console.WriteLine("Try {0}", address.ToString("X"));
                    LandTable land = new LandTable(datafile, (int)address, ImageBase, landfmt);
                    if (land.COL.Count > 3)
                    {
                        land.SaveToFile(fileOutputPath + landtable_extension, landfmt, NoMeta);
                        count++;
                        switch (landfmt)
                        {
                        case LandTableFormat.SA1:
                            FoundSA1Landtables++;
                            break;

                        case LandTableFormat.SADX:
                        default:
                            FoundSADXLandtables++;
                            break;

                        case LandTableFormat.SA2:
                            FoundSA2Landtables++;
                            break;

                        case LandTableFormat.SA2B:
                            FoundSA2BLandtables++;
                            break;
                        }
                        landtablelist.Add(address);
                        Console.WriteLine("\rLandtable {0} at {1}", landfmt.ToString(), address.ToString("X8"));
                        addresslist.Add(address, "landtable_" + landfmt.ToString());
                        address += (uint)LandTable.Size(landfmt) - 1;
                    }
                }
                catch (Exception)
                {
                    continue;
                }
            }
            Console.WriteLine("\r{0} landtables found", count);
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool success = false;
            uint address = (uint)numericUpDownBinaryAddress.Value;

            if (checkBoxBinaryMemory.Checked)
            {
                address -= (uint)numericUpDownBinaryKey.Value;
            }
            LandTableFormat format = (LandTableFormat)comboBoxBinaryFormat.SelectedIndex;
            LandTableFormat outfmt = format;

            if (format == LandTableFormat.SADX)
            {
                outfmt = LandTableFormat.SA1;
            }
            ByteConverter.BigEndian = checkBoxBinaryBigEndian.Checked;
            Settings.Author         = textBoxBinaryAuthor.Text;
            Settings.Save();
            SaveFileDialog sd = new SaveFileDialog();

            switch (comboBoxBinaryItemType.SelectedIndex)
            {
            //Level
            case 0:
                sd = new SaveFileDialog()
                {
                    DefaultExt = outfmt.ToString().ToLowerInvariant() + "lvl", Filter = outfmt.ToString().ToUpperInvariant() + "LVL Files|*." + outfmt.ToString().ToLowerInvariant() + "lvl|All Files|*.*"
                };
                if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    new LandTable(file, (int)numericUpDownBinaryAddress.Value, (uint)numericUpDownBinaryKey.Value, format)
                    {
                        Author = textBoxBinaryAuthor.Text, Description = textBoxBinaryDescription.Text
                    }.SaveToFile(sd.FileName, outfmt);
                    if (checkBoxBinaryStructs.Checked)
                    {
                        ConvertToText(sd.FileName);
                    }
                    if (!checkBoxBinarySAModel.Checked)
                    {
                        File.Delete(sd.FileName);
                    }
                    success = true;
                }
                break;

            //Model
            case 1:
                sd = new SaveFileDialog()
                {
                    DefaultExt = outfmt.ToString().ToLowerInvariant() + "mdl", Filter = outfmt.ToString().ToUpperInvariant() + "MDL Files|*." + outfmt.ToString().ToLowerInvariant() + "mdl|All Files|*.*"
                };
                if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    NJS_OBJECT tempmodel = new NJS_OBJECT(file, (int)address, (uint)numericUpDownBinaryKey.Value, (ModelFormat)comboBoxBinaryFormat.SelectedIndex, null);
                    ModelFile.CreateFile(sd.FileName, tempmodel, null, textBoxBinaryAuthor.Text, textBoxBinaryDescription.Text, null, (ModelFormat)comboBoxBinaryFormat.SelectedIndex);
                    ConvertToText(sd.FileName, checkBoxBinaryStructs.Checked, checkBoxBinaryNJA.Checked, false);
                    if (!checkBoxBinarySAModel.Checked)
                    {
                        File.Delete(sd.FileName);
                    }
                    success = true;
                }
                break;

            //Action
            case 2:
                sd = new SaveFileDialog()
                {
                    DefaultExt = outfmt.ToString().ToLowerInvariant() + "mdl", Filter = outfmt.ToString().ToUpperInvariant() + "MDL Files|*." + outfmt.ToString().ToLowerInvariant() + "mdl|All Files|*.*"
                };
                if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    //Model
                    NJS_ACTION tempaction = new NJS_ACTION(file, (int)address, (uint)numericUpDownBinaryKey.Value, (ModelFormat)comboBoxBinaryFormat.SelectedIndex, null);
                    NJS_OBJECT tempmodel  = tempaction.Model;
                    ModelFile.CreateFile(sd.FileName, tempmodel, null, textBoxBinaryAuthor.Text, textBoxBinaryDescription.Text, null, (ModelFormat)comboBoxBinaryFormat.SelectedIndex);
                    ConvertToText(sd.FileName, checkBoxBinaryStructs.Checked, checkBoxBinaryNJA.Checked, false);
                    if (!checkBoxBinarySAModel.Checked)
                    {
                        File.Delete(sd.FileName);
                    }

                    //Action
                    string saanimPath = Path.Combine(Path.GetDirectoryName(sd.FileName), Path.GetFileNameWithoutExtension(sd.FileName) + ".saanim");

                    tempaction.Animation.Save(saanimPath);
                    ConvertToText(saanimPath, checkBoxBinaryStructs.Checked, false, checkBoxBinaryJSON.Checked);

                    if (checkBoxBinarySAModel.Checked)
                    {
                        using (TextWriter twmain = File.CreateText(Path.Combine(Path.GetDirectoryName(sd.FileName), Path.GetFileNameWithoutExtension(sd.FileName) + ".action")))
                        {
                            twmain.WriteLine(Path.GetFileName(saanimPath));
                            twmain.Flush();
                            twmain.Close();
                        }
                    }
                    else
                    {
                        File.Delete(saanimPath);
                    }
                    success = true;
                }
                break;
            }
            if (success)
            {
                MessageBox.Show("Data extracted!", "Binary Data Extractor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }