Пример #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);
                }
            }
        }
Пример #2
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);
                }
            }
        }
Пример #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.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();
        }
Пример #4
0
        public SAV_Misc3(SaveFile sav)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            SAV = (SAV3)(Origin = sav).Clone();

            if (SAV.FRLG || SAV.E)
            {
                ReadJoyful();
            }
            else
            {
                tabControl1.Controls.Remove(TAB_Joyful);
            }

            if (SAV.E)
            {
                ReadFerry();
                ReadBattleFrontier();
            }
            else
            {
                tabControl1.Controls.Remove(TAB_Ferry);
                tabControl1.Controls.Remove(TAB_BF);
            }

            if (SAV.FRLG)
            {
                TB_OTName.Text = SAV.GetString(SAV.GetBlockOffset(4) + 0xBCC, 8);
                ComboBox[] cba            = { CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6 };
                int[]      HoennListMixed =
                {
                    277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300,
                    304, 305, 309, 310, 392, 393, 394, 311, 312, 306, 307, 364, 365, 366, 301, 302, 303, 370, 371, 372, 335, 336, 350, 320, 315, 316,
                    322, 355, 382, 383, 384, 356, 357, 337, 338, 353, 354, 386, 387, 363, 367, 368, 330, 331, 313, 314,
                    339, 340, 321, 351, 352, 308, 332, 333, 334, 344, 345, 358, 359, 380, 379, 348, 349, 323, 324,
                    326, 327, 318, 319, 388, 389, 390, 391, 328, 329, 385, 317, 377, 378, 361, 362, 369, 411, 376, 360,
                    346, 347, 341, 342, 343, 373, 374, 375, 381, 325, 395, 396, 397, 398, 399, 400,
                    401, 402, 403, 407, 408, 404, 405, 406, 409, 410
                };
                var speciesList = GameInfo.SpeciesDataSource.Where(v => v.Value <= SAV.MaxSpeciesID).Select(v => new ComboItem {
                    Text  = v.Text,
                    Value = v.Value < 252 ? v.Value : HoennListMixed[v.Value - 252],
                }).ToList();
                int ofsTCM = SAV.GetBlockOffset(2) + 0x106;
                for (int i = 0; i < cba.Length; i++)
                {
                    cba[i].Items.Clear();
                    cba[i].InitializeBinding();
                    cba[i].DataSource    = new BindingSource(speciesList, null);
                    cba[i].SelectedValue = (int)BitConverter.ToUInt16(SAV.Data, ofsTCM + (i << 1));
                }
            }
            else
            {
                TB_OTName.Visible = L_TrainerName.Visible = GB_TCM.Visible = false;
            }

            NUD_BP.Value    = Math.Min(NUD_BP.Maximum, SAV.BP);
            NUD_Coins.Value = Math.Min(NUD_Coins.Maximum, SAV.Coin);
        }