Exemple #1
0
        private void WC3ImportButton_Click(object sender, EventArgs e)
        {
            bool success = false;

            using (var ofd = new OpenFileDialog())
            {
                ofd.Filter      = "WC3 (*.wc3)|*.wc3|All files (*.*)|*.*";
                ofd.Title       = "Open Mystery Gift file";
                ofd.FilterIndex = 1;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    long fileSize = new FileInfo(ofd.FileName).Length;

                    if (fileSize == Length)
                    {
                        try
                        {
                            byte[] data   = Checksums.FixWC3Checksum(File.ReadAllBytes(ofd.FileName));
                            byte[] wc     = new byte[Length_WC];
                            byte[] script = new byte[Length_Script];

                            Array.Copy(data, 0, wc, 0, Length_WC);
                            Array.Copy(data, Offset_Script_WC3, script, 0, Length_Script);

                            sav.SetData(wc, sav.GetBlockOffset(Block) + Offset_WC);
                            sav.SetData(script, sav.GetBlockOffset(Block) + Offset_Script);

                            success = true;
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Unable to read Mystery Gift file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show($"Invalid file size ({fileSize} bytes). Expected {Length} bytes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                if (success)
                {
                    Close();
                    MessageBox.Show("Mystery Gift imported!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemple #2
0
        private void B_Save_Click(object sender, EventArgs e)
        {
            if (tabControl1.Controls.Contains(TAB_Joyful))
            {
                SaveJoyful();
            }
            if (tabControl1.Controls.Contains(TAB_Ferry))
            {
                SaveFerry();
            }
            if (tabControl1.Controls.Contains(TAB_BF))
            {
                SaveBattleFrontier();
            }
            if (SAV.FRLG)
            {
                SAV.SetData(SAV.SetString(TB_OTName.Text, TB_OTName.MaxLength), SAV.GetBlockOffset(4) + 0xBCC);
                ComboBox[] cba    = { CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6 };
                int        ofsTCM = SAV.GetBlockOffset(2) + 0x106;
                for (int i = 0; i < cba.Length; i++)
                {
                    BitConverter.GetBytes((ushort)(int)cba[i].SelectedValue).CopyTo(SAV.Data, ofsTCM + (i << 1));
                }
            }

            SAV.BP   = (ushort)NUD_BP.Value;
            SAV.Coin = (ushort)NUD_Coins.Value;

            Origin.SetData(SAV.Data, 0);
            Close();
        }
Exemple #3
0
        private void B_Save_Click(object sender, EventArgs e)
        {
            if (tabControl1.Controls.Contains(TAB_Joyful))
            {
                SaveJoyful();
            }
            if (tabControl1.Controls.Contains(TAB_Ferry))
            {
                SaveFerry();
            }
            if (tabControl1.Controls.Contains(TAB_BF))
            {
                SaveBattleFrontier();
            }
            if (SAV.FRLG)
            {
                SAV.SetData(SAV.Large, SAV.SetString(TB_RivalName.Text, TB_RivalName.MaxLength), 0x3A4C);
                ComboBox[] cba = { CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6 };
                for (int i = 0; i < cba.Length; i++)
                {
                    SAV.SetEventConst(0x43 + i, (ushort)(int)cba[i].SelectedValue);
                }
            }

            if (!SAV.RS)
            {
                SAV.BP = (ushort)NUD_BP.Value;
            }
            SAV.Coin = (ushort)NUD_Coins.Value;

            Origin.CopyChangesFrom(SAV);
            Close();
        }
Exemple #4
0
        private void ECBImportButton_Click(object sender, EventArgs e)
        {
            bool success = false;

            using (var ofd = new OpenFileDialog())
            {
                ofd.Filter      = "ECB (*.ecb)|*.ecb|All files (*.*)|*.*";
                ofd.Title       = "Open e-Card Berry file";
                ofd.FilterIndex = 1;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    long fileSize = new FileInfo(ofd.FileName).Length;

                    if (fileSize == Length)
                    {
                        try
                        {
                            sav.SetData(Checksums.FixECBChecksum(File.ReadAllBytes(ofd.FileName)), sav.GetBlockOffset(Block) + Offset);

                            success = true;
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Unable to read e-Card Berry file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show($"Invalid file size ({fileSize} bytes). Expected {Length} bytes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                if (success)
                {
                    Close();
                    MessageBox.Show("e-Card Berry imported!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }