Exemple #1
0
        private void NUP_PartyIndex_ValueChanged(object sender, EventArgs e)
        {
            editing = false;
            int index  = LB_DataEntry.SelectedIndex;
            int offset = index * 0x1B4 + (Convert.ToInt32(NUP_PartyIndex.Value) - 1) * 0x48;

            if (offset < 0)
            {
                return;
            }

            int species = BitConverter.ToUInt16(data, offset + 0x00);

            CB_Species.SelectedValue = species;
            int item = BitConverter.ToUInt16(data, offset + 0x02);

            CB_HeldItem.SelectedValue = item;
            int move1 = BitConverter.ToUInt16(data, offset + 0x04);
            int move2 = BitConverter.ToUInt16(data, offset + 0x06);
            int move3 = BitConverter.ToUInt16(data, offset + 0x08);
            int move4 = BitConverter.ToUInt16(data, offset + 0x0A);

            CB_Move1.SelectedValue = move1;
            CB_Move2.SelectedValue = move2;
            CB_Move3.SelectedValue = move3;
            CB_Move4.SelectedValue = move4;

            uint EC = BitConverter.ToUInt32(data, offset + 0xC);

            TB_EC.Text = EC.ToString("X8");

            TB_TID.Text = BitConverter.ToUInt16(data, offset + 0x10).ToString("00000");
            TB_SID.Text = BitConverter.ToUInt16(data, offset + 0x12).ToString("00000");

            TB_Nickname.Text = Util.TrimFromZero(Encoding.Unicode.GetString(data, offset + 0x18, 24));
            TB_OT.Text       = Util.TrimFromZero(Encoding.Unicode.GetString(data, offset + 0x30, 24));

            uint slgf   = BitConverter.ToUInt32(data, offset + 0x14);
            uint form   = slgf & 0x1F;
            uint gender = slgf >> 5 & 3; // 0 M; 1 F; 2 G
            uint level  = slgf >> 7 & 0x7F;
            uint shiny  = slgf >> 14 & 0x1;
            uint nick   = BitConverter.ToUInt16(data, offset + 0x16);

            CHK_Shiny.Checked = shiny == 1;

            TB_Level.Text = level.ToString("000");

            CHK_Nicknamed.Checked = nick == 1;

            SetForms();
            CB_Form.SelectedIndex = (int)form;
            SetGenderLabel((int)gender);
            UpdateNickname(sender, e);
            bpkx.Image = PKMUtil.GetSprite(species, (int)form, (int)gender, item, false, shiny == 1);
            editing    = true;
        }
        private void Data_Sorted(object sender, EventArgs e)
        {
            int height = PKMUtil.GetSprite(1, 0, 0, 0, false, false).Height + 1; // dummy sprite, max height of a row

            for (int i = 0; i < dgData.Rows.Count; i++)
            {
                dgData.Rows[i].Height = height;
            }
        }
Exemple #3
0
        private void UpdateShiny(object sender, EventArgs e)
        {
            if (!editing)
            {
                return; //Don't do writing until loaded
            }
            bpkx.Image = PKMUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);

            Write_Entry(null, null);
        }
Exemple #4
0
        private void addRibbonSprite(RibbonInfo rib)
        {
            PictureBox pb = new PictureBox {
                AutoSize = false, Size = new Size(40, 40), BackgroundImageLayout = ImageLayout.Center, Visible = false, Name = PrefixPB + rib.Name
            };
            var img = PKMUtil.getRibbonSprite(rib.Name);

            if (img != null)
            {
                pb.BackgroundImage = (Bitmap)img;
            }
            if (img == null)
            {
                return;
            }

            FLP_Ribbons.Controls.Add(pb);
        }
Exemple #5
0
        private void popEntry(int index)
        {
            var p = Main.SAV.Personal[index];

            int  s      = index > Main.SAV.MaxSpeciesID ? baseForm[index] : index;
            var  f      = index <= Main.SAV.MaxSpeciesID ? 0 : formVal[index];
            bool alolan = s > 721 || Legal.PastGenAlolanNatives.Contains(s);

            if (alolanOnly && !alolan)
            {
                return;
            }

            var row = new DataGridViewRow();

            row.CreateCells(DGV);

            int r = 0;

            row.Cells[r++].Value         = s.ToString("000") + (f > 0 ? "-" + f.ToString("00") :"");
            row.Cells[r++].Value         = PKMUtil.getSprite(s, f, 0, 0, false, false, Main.SAV.Generation);
            row.Cells[r++].Value         = species[index];
            row.Cells[r++].Value         = s > 721 || Legal.PastGenAlolanNatives.Contains(s);
            row.Cells[r].Style.BackColor = mapColor((int)((p.BST - 175) / 3f));
            row.Cells[r++].Value         = p.BST.ToString("000");
            row.Cells[r++].Value         = PKMUtil.getTypeSprite(p.Types[0]);
            row.Cells[r++].Value         = p.Types[0] == p.Types[1] ? Resources.slotTrans : PKMUtil.getTypeSprite(p.Types[1]);
            row.Cells[r].Style.BackColor = mapColor(p.HP);
            row.Cells[r++].Value         = p.HP.ToString("000");
            row.Cells[r].Style.BackColor = mapColor(p.ATK);
            row.Cells[r++].Value         = p.ATK.ToString("000");
            row.Cells[r].Style.BackColor = mapColor(p.DEF);
            row.Cells[r++].Value         = p.DEF.ToString("000");
            row.Cells[r].Style.BackColor = mapColor(p.SPA);
            row.Cells[r++].Value         = p.SPA.ToString("000");
            row.Cells[r].Style.BackColor = mapColor(p.SPD);
            row.Cells[r++].Value         = p.SPD.ToString("000");
            row.Cells[r].Style.BackColor = mapColor(p.SPE);
            row.Cells[r++].Value         = p.SPE.ToString("000");
            row.Cells[r++].Value         = abilities[p.Abilities[0]];
            row.Cells[r++].Value         = abilities[p.Abilities[1]];
            row.Cells[r].Value           = abilities[p.Abilities[2]];
            DGV.Rows.Add(row);
        }
Exemple #6
0
        private void AddRibbonSprite(RibbonInfo rib)
        {
            var        name = rib.Name;
            PictureBox pb   = new PictureBox {
                AutoSize = false, Size = new Size(40, 40), BackgroundImageLayout = ImageLayout.Center, Visible = false, Name = PrefixPB + name
            };
            var img = PKMUtil.GetRibbonSprite(name);

            if (img != null)
            {
                pb.BackgroundImage = (Bitmap)img;
            }
            if (img == null)
            {
                return;
            }

            var display = RibbonStrings.GetName(name);

            pb.MouseEnter += (s, e) => tipName.SetToolTip(pb, display);
            FLP_Ribbons.Controls.Add(pb);
        }
Exemple #7
0
        private void Write_Entry(object sender, EventArgs e)
        {
            if (!editing)
            {
                return; //Don't do writing until loaded
            }
            Validate_TextBoxes();

            int index       = LB_DataEntry.SelectedIndex;
            int partymember = Convert.ToInt32(NUP_PartyIndex.Value) - 1;
            int offset      = index * 0x1B4 + partymember * 0x48;

            BitConverter.GetBytes(Convert.ToUInt16(CB_Species.SelectedValue)).CopyTo(data, offset + 0x00);
            BitConverter.GetBytes(Convert.ToUInt16(CB_HeldItem.SelectedValue)).CopyTo(data, offset + 0x02);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move1.SelectedValue)).CopyTo(data, offset + 0x04);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move2.SelectedValue)).CopyTo(data, offset + 0x06);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move3.SelectedValue)).CopyTo(data, offset + 0x08);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move4.SelectedValue)).CopyTo(data, offset + 0x0A);
            BitConverter.GetBytes(Convert.ToUInt32(TB_EC.Text, 16)).CopyTo(data, offset + 0x0C);

            BitConverter.GetBytes(Convert.ToUInt16(TB_TID.Text)).CopyTo(data, offset + 0x10);
            BitConverter.GetBytes(Convert.ToUInt16(TB_SID.Text)).CopyTo(data, offset + 0x12);

            uint rawslgf = BitConverter.ToUInt32(data, offset + 0x14);
            uint slgf    = 0;

            slgf |= (uint)(CB_Form.SelectedIndex & 0x1F);
            slgf |= (uint)((PKX.GetGenderFromString(Label_Gender.Text) & 0x3) << 5);
            slgf |= (uint)((Convert.ToUInt16(TB_Level.Text) & 0x7F) << 7);
            if (CHK_Shiny.Checked)
            {
                slgf |= 1 << 14;
            }

            slgf |= rawslgf & 0x8000;
            Array.Copy(BitConverter.GetBytes(slgf), 0, data, offset + 0x14, 2);

            uint nick = 0;

            if (CHK_Nicknamed.Checked)
            {
                nick = 1;
            }
            Array.Copy(BitConverter.GetBytes(nick), 0, data, offset + 0x16, 2);

            //Mimic in-game behavior of not clearing strings. It's awful, but accuracy > good.
            string pk = TB_Nickname.Text; if (pk.Length != 12)
            {
                pk = pk.PadRight(pk.Length + 1, '\0');
            }
            string ot = TB_OT.Text; if (ot.Length != 12)

            {
                ot = ot.PadRight(pk.Length + 1, '\0');
            }

            Encoding.Unicode.GetBytes(pk).CopyTo(data, offset + 0x18);
            Encoding.Unicode.GetBytes(ot).CopyTo(data, offset + 0x30);

            offset = index * 0x1B4;

            uint vnd  = 0;
            uint date = 0;

            vnd  |= Convert.ToUInt32(TB_VN.Text) & 0xFF;
            date |= (uint)((CAL_MetDate.Value.Year - 2000) & 0xFF);
            date |= (uint)((CAL_MetDate.Value.Month & 0xF) << 8);
            date |= (uint)((CAL_MetDate.Value.Day & 0x1F) << 12);
            vnd  |= (date & 0x1FFFF) << 14;
            //Fix for top bit
            uint rawvnd = BitConverter.ToUInt32(data, offset + 0x1B0);

            vnd |= rawvnd & 0x80000000;
            Array.Copy(BitConverter.GetBytes(vnd), 0, data, offset + 0x1B0, 4);

            bpkx.Image = PKMUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
            DisplayEntry(null, null); // refresh text view
        }
Exemple #8
0
 private void SetSprite(EntreeSlot slot)
 {
     PB_SlotPreview.Image = PKMUtil.GetSprite(slot.Species, slot.Form, slot.Gender, 0, false, false);
 }