コード例 #1
0
ファイル: SAV_Database.cs プロジェクト: Metryra/PKHeX
        private void ClickSet(object sender, EventArgs e)
        {
            // Don't care what slot was clicked, just add it to the database
            if (!PKME_Tabs.VerifiedPKM())
            {
                return;
            }

            PKM pk = PKME_Tabs.PreparePKM();

            Directory.CreateDirectory(DatabasePath);

            string path = Path.Combine(DatabasePath, Util.CleanFileName(pk.FileName));

            if (RawDB.Any(p => p.Identifier == path))
            {
                WinFormsUtil.Alert(MsgDBAddFailExistsFile);
                return;
            }

            File.WriteAllBytes(path, pk.Data.Take(pk.SIZE_STORED).ToArray());
            pk.Identifier = path;

            int pre = RawDB.Count;

            RawDB.Add(pk);
            RawDB = new List <PKM>(RawDB);
            int post = RawDB.Count;

            if (pre == post)
            {
                WinFormsUtil.Alert(MsgDBAddFailExistsPKM); return;
            }
            Results.Add(pk);

            // Refresh database view.
            L_Count.Text = string.Format(Counter, Results.Count);
            slotSelected = Results.Count - 1;
            slotColor    = Properties.Resources.slotSet;
            if ((SCR_Box.Maximum + 1) * 6 < Results.Count)
            {
                SCR_Box.Maximum++;
            }
            SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - (PKXBOXES.Length / 6) + 1);
            FillPKXBoxes(SCR_Box.Value);
            WinFormsUtil.Alert(MsgDBAddFromTabsSuccess);
        }
コード例 #2
0
        private void RandPIDCurrent(string flag)
        {
            var pkm    = PKMEditor.PreparePKM();
            var sav    = SaveFileEditor.SAV;
            var result = sav.SetPIDCurrent(pkm, flag);

            LegalityAnalysis la = new LegalityAnalysis(result);

            if (!la.Valid)
            {
                WinFormUtils.Alert($"Can not Set Current Pokemon to {flag}!");
                return;
            }

            PKMEditor.PopulateFields(result);
            WinFormUtils.Alert($"Set Current Pokemon to {flag}!");
        }
コード例 #3
0
        private void AutoEggCurrent()
        {
            var pkm = PKMEditor.PreparePKM();

            if (pkm.IsEgg)
            {
                return;     // already egg, should not modify it
            }
            var sav    = SaveFileEditor.SAV;
            var result = sav.SetEggCurrent(pkm);

            // Check Null
            if (result == null)
            {
                WinFormUtils.Alert($"Current Pokemon should not to be an Egg!");
                return;
            }
            PKMEditor.PopulateFields(result);
            WinFormUtils.Alert($"Set Current Pokemon to Egg!");
        }
コード例 #4
0
        private void LegalizeActive()
        {
            var pk = PKMEditor.PreparePKM();
            var la = new LegalityAnalysis(pk);

            if (la.Valid)
            {
                return; // already valid, don't modify it
            }
            var sav    = SaveFileEditor.SAV;
            var result = sav.Legalize(pk);

            // let's double check

            la = new LegalityAnalysis(result);
            if (!la.Valid)
            {
                WinFormsUtil.Error("Unable to make the Active Pokemon legal!");
                return;
            }

            PKMEditor.PopulateFields(result);
            WinFormsUtil.Alert("Legalized Active Pokemon!");
        }
コード例 #5
0
        private void SmogonGenning(object sender, EventArgs e)
        {
            var rough = PKMEditor.PreparePKM();

            GenSmogonSets(rough);
        }