示例#1
0
        private void FillPKXBoxes(int start)
        {
            if (Results == null)
            {
                for (int i = 0; i < RES_MAX; i++)
                {
                    PKXBOXES[i].Image = null;
                }
                return;
            }
            int begin = start * RES_MIN;
            int end   = Math.Min(RES_MAX, Results.Count - begin);

            for (int i = 0; i < end; i++)
            {
                var enc  = Results[i + begin];
                var form = GetForm(enc);
                PKXBOXES[i].Image = SpriteUtil.GetSprite(enc.Species, form, 0, 0, enc.EggEncounter, false, enc is IGeneration g ? g.Generation : -1);
            }
            for (int i = end; i < RES_MAX; i++)
            {
                PKXBOXES[i].Image = null;
            }

            for (int i = 0; i < RES_MAX; i++)
            {
                PKXBOXES[i].BackgroundImage = SpriteUtil.Spriter.Transparent;
            }
            if (slotSelected != -1 && slotSelected >= begin && slotSelected < begin + RES_MAX)
            {
                PKXBOXES[slotSelected - begin].BackgroundImage = slotColor ?? SpriteUtil.Spriter.View;
            }
        }
示例#2
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 = StringConverter.GetString6(data, offset + 0x18, 24);
            TB_OT.Text       = StringConverter.GetString6(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 = SpriteUtil.GetSprite(species, (int)form, (int)gender, 0, item, false, shiny == 1);
            editing    = true;
        }
        private void Data_Sorted(object sender, EventArgs e)
        {
            int height = SpriteUtil.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;
            }
        }
示例#4
0
        private void UpdateShiny(object sender, EventArgs e)
        {
            if (!editing)
            {
                return; //Don't do writing until loaded
            }
            bpkx.Image = SpriteUtil.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, EventArgs.Empty);
        }
示例#5
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 * HallFame6Entity.SIZE);
            var span        = data.AsSpan(offset, HallFame6Entity.SIZE);
            var entry       = new HallFame6Entity(span)
            {
                Species            = Convert.ToUInt16(CB_Species.SelectedValue),
                HeldItem           = Convert.ToUInt16(CB_HeldItem.SelectedValue),
                Move1              = Convert.ToUInt16(CB_Move1.SelectedValue),
                Move2              = Convert.ToUInt16(CB_Move2.SelectedValue),
                Move3              = Convert.ToUInt16(CB_Move3.SelectedValue),
                Move4              = Convert.ToUInt16(CB_Move4.SelectedValue),
                EncryptionConstant = Util.GetHexValue(TB_EC.Text),
                TID         = Convert.ToUInt16(TB_TID.Text),
                SID         = Convert.ToUInt16(TB_SID.Text),
                Form        = (uint)CB_Form.SelectedIndex,
                Gender      = (uint)EntityGender.GetFromString(Label_Gender.Text) & 0x3,
                Level       = Convert.ToUInt16(TB_Level.Text),
                IsShiny     = CHK_Shiny.Checked,
                IsNicknamed = CHK_Nicknamed.Checked,
                Nickname    = TB_Nickname.Text,
                OT_Name     = TB_OT.Text,
                OT_Gender   = (uint)EntityGender.GetFromString(Label_OTGender.Text) & 1,
            };

            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 = ReadUInt32LittleEndian(data.AsSpan(offset + 0x1B0));

            vnd |= rawvnd & 0x80000000;
            WriteUInt32LittleEndian(data.AsSpan(offset + 0x1B0), vnd);

            bpkx.Image = SpriteUtil.GetSprite(entry.Species, (int)entry.Form, (int)entry.Gender, 0, entry.HeldItem, false, CHK_Shiny.Checked, 6);
            DisplayEntry(this, EventArgs.Empty); // refresh text view
        }
示例#6
0
        private PictureBox GetBallView(Ball b, ICollection <Ball> legal, IReadOnlyList <ComboItem> names)
        {
            var img = SpriteUtil.GetBallSprite((int)b);
            var pb  = new PictureBox
            {
                Size                  = img.Size,
                Image                 = img,
                BackgroundImage       = legal.Contains(b) ? Resources.slotSet : Resources.slotDel,
                BackgroundImageLayout = ImageLayout.Tile
            };

            pb.MouseEnter += (_, __) => Text = names.First(z => z.Value == (int)b).Text;
            pb.Click      += (_, __) => SelectBall(b);
            return(pb);
        }
示例#7
0
        private void UpdateShiny(object sender, EventArgs e)
        {
            if (!editing)
            {
                return; //Don't do writing until loaded
            }
            var species = WinFormsUtil.GetIndex(CB_Species);
            var form    = CB_Form.SelectedIndex & 0x1F;
            var gender  = PKX.GetGenderFromString(Label_Gender.Text);
            var item    = WinFormsUtil.GetIndex(CB_HeldItem);

            bpkx.Image = SpriteUtil.GetSprite(species, form, gender, 0, item, false, CHK_Shiny.Checked);

            Write_Entry(this, EventArgs.Empty);
        }
示例#8
0
        private void AddRibbonSprite(RibbonInfo rib)
        {
            var name = rib.Name;
            var pb   = new PictureBox {
                AutoSize = false, Size = new Size(40, 40), BackgroundImageLayout = ImageLayout.Center, Visible = false, Name = PrefixPB + name
            };
            var img = SpriteUtil.GetRibbonSprite(name);

            pb.BackgroundImage = img;

            var display = RibbonStrings.GetName(name);

            pb.MouseEnter += (s, e) => tipName.SetToolTip(pb, display);
            FLP_Ribbons.Controls.Add(pb);
        }
示例#9
0
        private void PopEntry(int index)
        {
            var p = SAV.Personal[index];

            if (p.HP == 0)
            {
                return;
            }

            int s = index > SAV.MaxSpeciesID ? baseForm[index] : index;
            var f = index <= SAV.MaxSpeciesID ? 0 : formVal[index];

            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         = SpriteUtil.GetSprite(s, f, 0, 0, 0, false, false, SAV.Generation);
            row.Cells[r++].Value         = species[index];
            row.Cells[r++].Value         = GetIsNative(p, s);
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStatTotal(p.BST);
            row.Cells[r++].Value         = p.BST.ToString("000");
            row.Cells[r++].Value         = p.CatchRate.ToString("000");
            row.Cells[r++].Value         = SpriteUtil.GetTypeSprite(p.Type1, SAV.Generation);
            row.Cells[r++].Value         = p.Type1 == p.Type2 ? SpriteUtil.Spriter.Transparent : SpriteUtil.GetTypeSprite(p.Type2, SAV.Generation);
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.HP);
            row.Cells[r++].Value         = p.HP.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.ATK);
            row.Cells[r++].Value         = p.ATK.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.DEF);
            row.Cells[r++].Value         = p.DEF.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.SPA);
            row.Cells[r++].Value         = p.SPA.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.SPD);
            row.Cells[r++].Value         = p.SPD.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.SPE);
            row.Cells[r++].Value         = p.SPE.ToString("000");
            var abils = p.Abilities;

            row.Cells[r++].Value = GetAbility(abils, 0);
            row.Cells[r++].Value = GetAbility(abils, 1);
            row.Cells[r].Value   = GetAbility(abils, 2);
            row.Height           = SpriteUtil.Spriter.Height + 1;
            DGV.Rows.Add(row);
        }
示例#10
0
        private void PopEntry(int index)
        {
            var p = SAV.Personal[index];

            int  s      = index > SAV.MaxSpeciesID ? baseForm[index] : index;
            var  f      = index <= 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         = SpriteUtil.GetSprite(s, f, 0, 0, false, false, SAV.Generation);
            row.Cells[r++].Value         = species[index];
            row.Cells[r++].Value         = s > 721 || Legal.PastGenAlolanNatives.Contains(s);
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat((int)((Math.Max(p.BST - 175, 0)) / 3f));
            row.Cells[r++].Value         = p.BST.ToString("000");
            row.Cells[r++].Value         = SpriteUtil.GetTypeSprite(p.Type1, SAV.Generation);
            row.Cells[r++].Value         = p.Type1 == p.Type2 ? Resources.slotTrans : SpriteUtil.GetTypeSprite(p.Type2, SAV.Generation);
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.HP);
            row.Cells[r++].Value         = p.HP.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.ATK);
            row.Cells[r++].Value         = p.ATK.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.DEF);
            row.Cells[r++].Value         = p.DEF.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.SPA);
            row.Cells[r++].Value         = p.SPA.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(p.SPD);
            row.Cells[r++].Value         = p.SPD.ToString("000");
            row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat(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.Length <= 2 ? 0 : p.Abilities[2]];
            DGV.Rows.Add(row);
        }
示例#11
0
        private void AddRibbonNumericUpDown(RibbonInfo rib, int row)
        {
            var nud = new NumericUpDown
            {
                Anchor    = AnchorStyles.Right,
                Name      = PrefixNUD + rib.Name,
                Minimum   = 0,
                Width     = 35,
                Increment = 1,
                Padding   = Padding.Empty,
                Margin    = Padding.Empty,
                Maximum   = rib.MaxCount,
            };

            nud.ValueChanged += (sender, e) =>
            {
                FLP_Ribbons.Controls[PrefixPB + rib.Name].Visible         = (rib.RibbonCount = (int)nud.Value) > 0;
                FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage = SpriteUtil.GetRibbonSprite(rib.Name, (int)nud.Maximum, (int)nud.Value);
            };
            nud.Value = rib.RibbonCount > nud.Maximum ? nud.Maximum : rib.RibbonCount;
            TLP_Ribbons.Controls.Add(nud, 0, row);
        }
示例#12
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) * HallFame6Entity.SIZE);

            if (offset < 0)
            {
                return;
            }

            var entry = new HallFame6Entity(data.AsSpan(offset, HallFame6Entity.SIZE));

            CB_Species.SelectedValue  = (int)entry.Species;
            CB_HeldItem.SelectedValue = (int)entry.HeldItem;
            CB_Move1.SelectedValue    = (int)entry.Move1;
            CB_Move2.SelectedValue    = (int)entry.Move2;
            CB_Move3.SelectedValue    = (int)entry.Move3;
            CB_Move4.SelectedValue    = (int)entry.Move4;

            TB_EC.Text = entry.EncryptionConstant.ToString("X8");

            TB_TID.Text = entry.TID.ToString("00000");
            TB_SID.Text = entry.SID.ToString("00000");

            TB_Nickname.Text      = entry.Nickname;
            TB_OT.Text            = entry.OT_Name;
            CHK_Shiny.Checked     = entry.IsShiny;
            TB_Level.Text         = entry.Level.ToString("000");
            CHK_Nicknamed.Checked = entry.IsNicknamed;

            SetForms();
            CB_Form.SelectedIndex = (int)entry.Form;
            SetGenderLabel((int)entry.Gender);
            Label_OTGender.Text = gendersymbols[(int)entry.OT_Gender];
            UpdateNickname(sender, e);
            bpkx.Image = SpriteUtil.GetSprite(entry.Species, (int)entry.Form, (int)entry.Gender, 0, entry.HeldItem, false, entry.IsShiny, 6);
            editing    = true;
        }
示例#13
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(Util.GetHexValue(TB_EC.Text)).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);

            var species = WinFormsUtil.GetIndex(CB_Species);
            var form    = CB_Form.SelectedIndex & 0x1F;
            var gender  = PKX.GetGenderFromString(Label_Gender.Text);
            var item    = WinFormsUtil.GetIndex(CB_HeldItem);

            bpkx.Image = SpriteUtil.GetSprite(species, form, gender, 0, item, false, CHK_Shiny.Checked);
            DisplayEntry(this, EventArgs.Empty); // refresh text view
        }
示例#14
0
 private void SetSprite(EntreeSlot slot)
 {
     PB_SlotPreview.Image = SpriteUtil.GetSprite(slot.Species, slot.Form, slot.Gender, 0, false, false);
 }