Example #1
0
        private void AddRibbonChoice(RibbonInfo rib)
        {
            // Get row we add to
            int row = TLP_Ribbons.RowCount;

            TLP_Ribbons.RowCount++;

            var label = new Label
            {
                Anchor   = AnchorStyles.Left,
                Name     = PrefixLabel + rib.Name,
                Text     = RibbonStrings.GetName(rib.Name),
                Padding  = Padding.Empty,
                Margin   = Padding.Empty,
                AutoSize = true,
            };

            TLP_Ribbons.Controls.Add(label, 1, row);

            if (rib.RibbonCount >= 0) // numeric count ribbon
            {
                AddRibbonNumericUpDown(rib, row);
            }
            else // boolean ribbon
            {
                AddRibbonCheckBox(rib, row, label);
            }
        }
Example #2
0
        public RibbonEditor(PKM pk)
        {
            pkm = pk;
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            riblist = RibbonInfo.GetRibbonInfo(pkm);
            int vertScrollWidth = SystemInformation.VerticalScrollBarWidth;

            TLP_Ribbons.Padding = FLP_Ribbons.Padding = new Padding(0, 0, vertScrollWidth, 0);

            // Updating a Control display with autosized elements on every row addition is cpu intensive. Disable layout updates while populating.
            TLP_Ribbons.SuspendLayout();
            FLP_Ribbons.Scroll += WinFormsUtil.PanelScroll;
            TLP_Ribbons.Scroll += WinFormsUtil.PanelScroll;
            PopulateRibbons();
            TLP_Ribbons.ResumeLayout();

            if (pk is PK8 pk8)
            {
                var names  = Enum.GetNames(typeof(RibbonIndex));
                var values = (RibbonIndex[])Enum.GetValues(typeof(RibbonIndex));
                var items  = names.Select((z, i) => new ComboItem(RibbonStrings.GetName("Ribbon" + z), (int)values[i])).OrderBy(z => z.Text);
                var ds     = new List <ComboItem> {
                    new(GameInfo.GetStrings(Main.CurrentLanguage).Move[0], -1)
                };
                ds.AddRange(items.ToArray());
                CB_Affixed.InitializeBinding();
                CB_Affixed.DataSource    = ds;
                CB_Affixed.SelectedValue = (int)pk8.AffixedRibbon;
            }
            else
            {
                CB_Affixed.Visible = false;
            }
        }
        public static void ClearAllRibbon(this PKM pkm)
        {
            IEnumerable <RibbonInfo> riblist = RibbonInfo.GetRibbonInfo(pkm);

            foreach (var rib in riblist)
            {
                ReflectUtil.SetValue(pkm, rib.Name, rib.RibbonCount < 0 ? false : (object)0);
            }
        }
Example #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);
        }
Example #5
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);
        }
Example #6
0
        public RibbonEditor(PKM pk)
        {
            pkm = pk;
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            riblist = RibbonInfo.GetRibbonInfo(pkm);
            int vertScrollWidth = SystemInformation.VerticalScrollBarWidth;

            TLP_Ribbons.Padding = FLP_Ribbons.Padding = new Padding(0, 0, vertScrollWidth, 0);

            // Updating a Control display with autosized elements on every row addition is cpu intensive. Disable layout updates while populating.
            TLP_Ribbons.SuspendLayout();
            FLP_Ribbons.Scroll += WinFormsUtil.PanelScroll;
            TLP_Ribbons.Scroll += WinFormsUtil.PanelScroll;
            PopulateRibbons();
            TLP_Ribbons.ResumeLayout();
        }
Example #7
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 = Properties.Resources.ResourceManager.GetObject(rib.Name.Replace("CountG3", "G3").ToLower());

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

            FLP_Ribbons.Controls.Add(pb);
        }
Example #8
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);
        }
Example #9
0
        private void AddRibbonCheckBox(RibbonInfo rib, int row, Control label)
        {
            var chk = new CheckBox
            {
                Anchor   = AnchorStyles.Right,
                Name     = PrefixCHK + rib.Name,
                AutoSize = true,
                Padding  = Padding.Empty,
                Margin   = Padding.Empty,
            };

            chk.CheckedChanged += (sender, e) =>
            {
                rib.HasRibbon = chk.Checked;
                FLP_Ribbons.Controls[PrefixPB + rib.Name].Visible = rib.HasRibbon;
            };
            chk.Checked = rib.HasRibbon;
            TLP_Ribbons.Controls.Add(chk, 0, row);

            label.Click += (s, e) => chk.Checked ^= true;
        }
Example #10
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);
        }
Example #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,
            };

            if (rib.Name.Contains("MemoryContest"))
            {
                nud.Maximum = 40;
            }
            else if (rib.Name.Contains("MemoryBattle"))
            {
                nud.Maximum = 8;
            }
            else
            {
                nud.Maximum = 4;  // g3 contest ribbons
            }
            nud.ValueChanged += (sender, e) =>
            {
                rib.RibbonCount = (int)nud.Value;
                FLP_Ribbons.Controls[PrefixPB + rib.Name].Visible = rib.RibbonCount > 0;
                if (nud.Maximum == 4)
                {
                    string n = rib.Name.Replace("Count", "");
                    switch ((int)nud.Value)
                    {
                    case 2:
                        n += "Super";
                        break;

                    case 3:
                        n += "Hyper";
                        break;

                    case 4:
                        n += "Master";
                        break;
                    }
                    FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage =
                        (Bitmap)Properties.Resources.ResourceManager.GetObject(n.ToLower());
                }
                else if (nud.Maximum == nud.Value)
                {
                    FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage =
                        (Bitmap)Properties.Resources.ResourceManager.GetObject(rib.Name.ToLower() + "2");
                }
                else
                {
                    FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage =
                        (Bitmap)Properties.Resources.ResourceManager.GetObject(rib.Name.ToLower());
                }
            };
            nud.Value = rib.RibbonCount > nud.Maximum ? nud.Maximum : rib.RibbonCount;
            TLP_Ribbons.Controls.Add(nud, 0, row);
        }
Example #12
0
        private void addRibbonChoice(RibbonInfo rib)
        {
            // Get row we add to
            int row = TLP_Ribbons.RowCount;

            TLP_Ribbons.RowCount++;

            var label = new Label
            {
                Anchor   = AnchorStyles.Left,
                Name     = PrefixLabel + rib.Name,
                Text     = rib.Name,
                Padding  = Padding.Empty,
                Margin   = Padding.Empty,
                AutoSize = true,
            };

            TLP_Ribbons.Controls.Add(label, 1, row);

            if (rib.RibbonCount >= 0) // numeric count ribbon
            {
                var nud = new NumericUpDown
                {
                    Anchor    = AnchorStyles.Right,
                    Name      = PrefixNUD + rib.Name,
                    Minimum   = 0,
                    Width     = 35,
                    Increment = 1,
                    Padding   = Padding.Empty,
                    Margin    = Padding.Empty,
                };
                if (rib.Name.Contains("MemoryContest"))
                {
                    nud.Maximum = 40;
                }
                else if (rib.Name.Contains("MemoryBattle"))
                {
                    nud.Maximum = 8;
                }
                else
                {
                    nud.Maximum = 4;  // g3 contest ribbons
                }
                nud.ValueChanged += (sender, e) =>
                {
                    rib.RibbonCount = (int)nud.Value;
                    FLP_Ribbons.Controls[PrefixPB + rib.Name].Visible = rib.RibbonCount > 0;
                    if (nud.Maximum == 4)
                    {
                        string n = rib.Name.Replace("Count", "");
                        switch ((int)nud.Value)
                        {
                        case 2: n += "Super"; break;

                        case 3: n += "Hyper"; break;

                        case 4: n += "Master"; break;
                        }
                        FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject(n.ToLower());
                    }
                    else if (nud.Maximum == nud.Value)
                    {
                        FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject(rib.Name.ToLower() + "2");
                    }
                    else
                    {
                        FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject(rib.Name.ToLower());
                    }
                };
                nud.Value = rib.RibbonCount > nud.Maximum ? nud.Maximum : rib.RibbonCount;
                TLP_Ribbons.Controls.Add(nud, 0, row);
            }
            else // boolean ribbon
            {
                var chk = new CheckBox
                {
                    Anchor   = AnchorStyles.Right,
                    Name     = PrefixCHK + rib.Name,
                    AutoSize = true,
                    Padding  = Padding.Empty,
                    Margin   = Padding.Empty,
                };
                chk.CheckedChanged += (sender, e) => { rib.HasRibbon = chk.Checked; FLP_Ribbons.Controls[PrefixPB + rib.Name].Visible = rib.HasRibbon; };
                chk.Checked         = rib.HasRibbon;
                TLP_Ribbons.Controls.Add(chk, 0, row);

                label.Click += (sender, e) => { chk.Checked ^= true; };
            }
        }
Example #13
0
        public PokemonSummary(PKM pkm, GameStrings strings) : base(pkm, strings)
        {
            Ribbons = new List <string>();
            foreach (var ribbon in RibbonInfo.GetRibbonInfo(pkm))
            {
                if (ribbon.HasRibbon)
                {
                    Ribbons.Add(RibbonStrings.GetName(ribbon.Name));
                }
            }
            Moves = new List <Move>
            {
                new Move()
                {
                    Move_Name = Move1, Move_Type = MoveType.MT[pkm.Move1].Type, Move_PP = Move1_PP, Move_PP_Up = Move1_PPUp
                },
                new Move()
                {
                    Move_Name = Move2, Move_Type = MoveType.MT[pkm.Move2].Type, Move_PP = Move2_PP, Move_PP_Up = Move2_PPUp
                },
                new Move()
                {
                    Move_Name = Move3, Move_Type = MoveType.MT[pkm.Move3].Type, Move_PP = Move3_PP, Move_PP_Up = Move3_PPUp
                },
                new Move()
                {
                    Move_Name = Move4, Move_Type = MoveType.MT[pkm.Move4].Type, Move_PP = Move4_PP, Move_PP_Up = Move4_PPUp
                }
            };

            Stats = new List <Stat>
            {
                new Stat()
                {
                    Stat_Name = "HP", Stat_IV = HP_IV, Stat_EV = HP_EV, Stat_Total = HP
                },
                new Stat()
                {
                    Stat_Name = "Attack", Stat_IV = ATK_IV, Stat_EV = ATK_EV, Stat_Total = ATK
                },
                new Stat()
                {
                    Stat_Name = "Defense", Stat_IV = DEF_IV, Stat_EV = DEF_EV, Stat_Total = DEF
                },
                new Stat()
                {
                    Stat_Name = "Speed", Stat_IV = SPE_IV, Stat_EV = SPE_EV, Stat_Total = SPE
                },
                new Stat()
                {
                    Stat_Name = "Special Attack", Stat_IV = SPA_IV, Stat_EV = SPA_EV, Stat_Total = SPA
                },
                new Stat()
                {
                    Stat_Name = "Special Defense", Stat_IV = SPD_IV, Stat_EV = SPD_EV, Stat_Total = SPD
                },
            };
            Generation        = Utils.GetGeneration(pkm);
            Form              = Utils.GetForm(pkm, pkm.Form);
            HeldItemSpriteURL = "";
            HT        = pkm.HT_Name;
            DexNumber = pkm.Species;
            Size      = pkm.SIZE_STORED;
            ItemNum   = pkm.HeldItem;
            var LC = new LegalityAnalysis(pkm);

            IllegalReasons   = LC.Report();
            IsLegal          = LC.Valid;
            QR               = Utils.GenerateQR(QRMessageUtil.GetMessage(pkm));
            Base64           = System.Convert.ToBase64String(pkm.DecryptedBoxData);
            SpeciesSpriteURL = Helpers.Sprite.getFormURL(DexNumber, Generation, Form, IsShiny, Gender, Species);
        }
Example #14
0
        private void addRibbonChoice(RibbonInfo rib)
        {
            // Get row we add to
            int row = TLP_Ribbons.RowCount;
            TLP_Ribbons.RowCount++;

            var label = new Label
            {
                Anchor = AnchorStyles.Left,
                Name = PrefixLabel + rib.Name,
                Text = rib.Name,
                Padding = Padding.Empty,
                Margin = Padding.Empty,
                AutoSize = true,
            };
            TLP_Ribbons.Controls.Add(label, 1, row);

            if (rib.RibbonCount >= 0) // numeric count ribbon
            {
                var nud = new NumericUpDown
                {
                    Anchor = AnchorStyles.Right,
                    Name = PrefixNUD + rib.Name,
                    Minimum = 0,
                    Width = 35,
                    Increment = 1,
                    Padding = Padding.Empty,
                    Margin = Padding.Empty,
                };
                if (rib.Name.Contains("MemoryContest"))
                    nud.Maximum = 40;
                else if (rib.Name.Contains("MemoryBattle"))
                    nud.Maximum = 8;
                else nud.Maximum = 4; // g3 contest ribbons

                nud.ValueChanged += (sender, e) => 
                {
                    rib.RibbonCount = (int)nud.Value;
                    FLP_Ribbons.Controls[PrefixPB + rib.Name].Visible = rib.RibbonCount > 0;
                    if (nud.Maximum == 4)
                    {
                        string n = rib.Name.Replace("Count", "");
                        switch ((int)nud.Value)
                        {
                            case 2: n += "Super"; break;
                            case 3: n += "Hyper"; break;
                            case 4: n += "Master"; break;
                        }
                        FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage = (Bitmap)Core.Properties.Resources.ResourceManager.GetObject(n.ToLower());
                    }
                    else if (nud.Maximum == nud.Value)
                        FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage = (Bitmap)Core.Properties.Resources.ResourceManager.GetObject(rib.Name.ToLower() +"2");
                    else
                        FLP_Ribbons.Controls[PrefixPB + rib.Name].BackgroundImage = (Bitmap)Core.Properties.Resources.ResourceManager.GetObject(rib.Name.ToLower());
                };
                nud.Value = rib.RibbonCount > nud.Maximum ? nud.Maximum : rib.RibbonCount;
                TLP_Ribbons.Controls.Add(nud, 0, row);
            }
            else // boolean ribbon
            {
                var chk = new CheckBox
                {
                    Anchor = AnchorStyles.Right,
                    Name = PrefixCHK + rib.Name,
                    AutoSize = true,
                    Padding = Padding.Empty,
                    Margin = Padding.Empty,
                };
                chk.CheckedChanged += (sender, e) => { rib.HasRibbon = chk.Checked; FLP_Ribbons.Controls[PrefixPB + rib.Name].Visible = rib.HasRibbon; };
                chk.Checked = rib.HasRibbon;
                TLP_Ribbons.Controls.Add(chk, 0, row);

                label.Click += (sender, e) => { chk.Checked ^= true; };
            }
        }
Example #15
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 = Properties.Resources.ResourceManager.GetObject(rib.Name.Replace("CountG3", "G3").ToLower());
            if (img != null)
                pb.BackgroundImage = (Bitmap)img;
            if (img == null)
                return;

            FLP_Ribbons.Controls.Add(pb);
        }
Example #16
0
 private static List <string> GetAllRibbonNames(PKM pk) => RibbonInfo.GetRibbonInfo(pk).Select(z => z.Name).ToList();