Exemple #1
0
        private void B_SAV2FAV(object sender, EventArgs e)
        {
            loading = true;
            int index = LB_Favorite.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            var offset = GetSecretBaseOffset(index);

            var bdata = new SecretBase6(SAV.Data, offset);

            NUD_FBaseLocation.Value = bdata.BaseLocation;

            TB_FOT.Text = bdata.TrainerName;
            TB_FT1.Text = bdata.FlavorText1;
            TB_FT2.Text = bdata.FlavorText2;

            TB_FSay1.Text = bdata.Saying1;
            TB_FSay2.Text = bdata.Saying2;
            TB_FSay3.Text = bdata.Saying3;
            TB_FSay4.Text = bdata.Saying4;

            // Gather data for Object Array
            byte[] data = SAV.Data;
            objdata = new byte[25, 12];
            for (int i = 0; i < 25; i++)
            {
                for (int z = 0; z < 12; z++)
                {
                    objdata[i, z] = data[offset + 2 + (12 * i) + z];
                }
            }

            NUD_FObject.Value = 1; // Trigger Update
            ChangeObjectIndex(null, EventArgs.Empty);

            GB_PKM.Enabled = index > 0;

            // Trainer Pokemon
            pkmdata = new byte[3, 0x34];
            if (index > 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int z = 0; z < 0x34; z++)
                    {
                        pkmdata[i, z] = SAV.Data[offset + 0x32E + (0x34 * i) + z];
                    }
                }
            }

            NUD_FPKM.Value = 1;
            ChangeFavPKM(null, EventArgs.Empty); // Trigger Update

            loading          = false;
            B_Import.Enabled = B_Export.Enabled = index > 0;
            currentIndex     = index;
        }
Exemple #2
0
        private void B_Export_Click(object sender, EventArgs e)
        {
            LB_Favorite.SelectedIndex = currentIndex;
            B_FAV2SAV(sender, e); // save back to current index
            var ofs = GetSecretBaseOffset(currentIndex);
            var sb  = new SecretBase6(SAV.Data, ofs);
            var tr  = sb.TrainerName;

            if (string.IsNullOrWhiteSpace(tr))
            {
                tr = "Trainer";
            }
            var sfd = new SaveFileDialog {
                Filter = "Secret Base Data|*.sb6", FileName = $"{sb.BaseLocation:D2} - {Util.CleanFileName(tr)}.sb6"
            };

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var path = sfd.FileName;
            var data = SAV.GetData(ofs, SecretBase6.SIZE);

            File.WriteAllBytes(path, data);
        }
Exemple #3
0
 private void SaveCurrent(SecretBase6 bdata)
 {
     SavePlacement(bdata, (int)NUD_FObject.Value);
     if (bdata is SecretBase6Other o)
     {
         SaveOtherData(o);
     }
 }
        private void B_SAV2FAV(object sender, EventArgs e)
        {
            loading = true;
            int index = LB_Favorite.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            var offset = GetSecretBaseOffset(index);

            var bdata = new SecretBase6(SAV.Data, offset);

            NUD_FBaseLocation.Value = bdata.BaseLocation;

            TB_FOT.Text = bdata.TrainerName;
            TB_FT1.Text = bdata.FlavorText1;
            TB_FT2.Text = bdata.FlavorText2;

            TB_FSay1.Text = bdata.Saying1;
            TB_FSay2.Text = bdata.Saying2;
            TB_FSay3.Text = bdata.Saying3;
            TB_FSay4.Text = bdata.Saying4;

            // Gather data for Object Array
            objdata = LoadObjectArray(offset);

            NUD_FObject.Value = 1; // Trigger Update
            ChangeObjectIndex(this, EventArgs.Empty);

            GB_PKM.Enabled = index > 0;

            // Trainer Pokemon
            pkmdata = LoadPKMData(index, offset);

            NUD_FPKM.Value = 1;
            ChangeFavPKM(this, EventArgs.Empty); // Trigger Update

            loading          = false;
            B_Import.Enabled = B_Export.Enabled = index > 0;
            currentIndex     = index;
        }
Exemple #5
0
        private void LoadCurrent(SecretBase6 bdata)
        {
            loading     = true;
            CurrentBase = bdata;

            PG_Base.SelectedObject = bdata;

            var pIndex = (int)NUD_FObject.Value;

            LoadPlacement(bdata, bdata.GetPlacement(pIndex), pIndex);
            if (bdata is SecretBase6Other o)
            {
                LoadOtherData(o);
            }
            else
            {
                SetOtherDataVisible(false);
            }

            loading = false;
        }
Exemple #6
0
 private void LoadPlacement(SecretBase6 bdata, SecretBase6GoodPlacement p, int index)
 {
     SavePlacement(bdata, index);
     CurrentPlacement      = p;
     CurrentPlacementIndex = index;
Exemple #7
0
        private void B_FAV2SAV(object sender, EventArgs e)
        {
            // Write data back to save
            int index = LB_Favorite.SelectedIndex; // store for restoring

            if (!GB_PKM.Enabled && index > 0)
            {
                WinFormsUtil.Error("Sorry, no overwriting someone else's base with your own data."); return;
            }
            if (GB_PKM.Enabled && index == 0)
            {
                WinFormsUtil.Error("Sorry, no overwriting of your own base with someone else's."); return;
            }

            var name = LB_Favorite.Items[index].ToString();

            if (name == "* " || name == $"{index} Empty")
            {
                WinFormsUtil.Error("Sorry, no overwriting an empty base with someone else's."); return;
            }
            if (index < 0)
            {
                return;
            }
            int offset = GetSecretBaseOffset(index);

            var bdata = new SecretBase6(SAV.Data, offset);

            int baseloc = (int)NUD_FBaseLocation.Value;

            if (baseloc < 3)
            {
                baseloc = 0; // skip 1/2 baselocs as they are dummied out ingame.
            }
            bdata.BaseLocation = baseloc;

            bdata.TrainerName = TB_FOT.Text;
            bdata.FlavorText1 = TB_FT1.Text;
            bdata.FlavorText2 = TB_FT2.Text;

            bdata.Saying1 = TB_FSay1.Text;
            bdata.Saying2 = TB_FSay2.Text;
            bdata.Saying3 = TB_FSay3.Text;
            bdata.Saying4 = TB_FSay4.Text;

            // Copy back Objects
            for (int i = 0; i < 25; i++)
            {
                for (int z = 0; z < 12; z++)
                {
                    SAV.Data[offset + 2 + (12 * i) + z] = objdata[i, z];
                }
            }

            if (GB_PKM.Enabled) // Copy pkm data back in
            {
                SaveFavPKM();
                for (int i = 0; i < 3; i++)
                {
                    for (int z = 0; z < 0x34; z++)
                    {
                        SAV.Data[offset + 0x32E + (0x34 * i) + z] = pkmdata[i, z];
                    }
                }
            }
            PopFavorite();
            LB_Favorite.SelectedIndex = currentIndex = index;
        }