Ejemplo n.º 1
0
        /// <summary>
        /// Method to check for updates to AutoLegalityMod
        /// </summary>
        public void CheckALMUpdate()
        {
            L_UpdateAvailable.Click += (sender, e) => Process.Start("https://github.com/architdate/PKHeX-Auto-Legality-Mod/releases/latest");
            try
            {
                new Task(() =>
                {
                    string data = AutomaticLegality.GetPage("https://api.github.com/repos/architdate/pkhex-auto-legality-mod/releases/latest");
                    if (data.StartsWith("Error"))
                    {
                        return;
                    }
                    int latestVersion = AutomaticLegality.ParseTagAsVersion(data.Split(new string[] { "\"tag_name\":\"" }, System.StringSplitOptions.None)[1].Split('"')[0]);
                    if (data == null || latestVersion == -1)
                    {
                        return;
                    }
                    if (int.TryParse(CurrentProgramVersion.ToString(), out var cur) && latestVersion <= cur)
                    {
                        return;
                    }

                    Invoke((MethodInvoker)(() =>
                    {
                        L_UpdateAvailable.Visible = true;
                        L_UpdateAvailable.Text = $"New Auto Legality Mod update available! {latestVersion:d}";
                    }));
                }).Start();
            }
            catch { }
        }
Ejemplo n.º 2
0
        private void URLGen(object sender, EventArgs e)
        {
            string url     = Clipboard.GetText().Trim();
            string initURL = url;
            bool   isUri   = Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute);

            if (!isUri)
            {
                MessageBox.Show("The text in the clipboard is not a valid URL");
                return;
            }
            if (!CheckPokePaste(url) && !CheckPasteBin(url))
            {
                MessageBox.Show("The URL provided is not a pokepast.es or a pastebin.com URL");
                return;
            }
            url = FixURL(url);
            string sets = GetText(url).TrimStart().TrimEnd();

            if (sets.StartsWith("Error :"))
            {
                return;
            }
            Clipboard.SetText(sets);
            try { AutomaticLegality.ImportModded(); }
            catch { MessageBox.Show("The data inside the URL are not valid Showdown Sets"); }
            Dictionary <string, string> metadata = GetMetadata(MetaDataURL(url));
            string typeOfBin = (CheckPasteBin(url)) ? "Pastebin" : "PokePaste";

            MessageBox.Show("All sets genned from the following URL: " + initURL + "\n\n" + typeOfBin + " data:\nTitle: " + metadata["Title"] + "\nAuthor: " + metadata["Author"] + "\nDescription: " + metadata["Description"]);
            Clipboard.SetText(initURL);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Main function to be called by the menu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void ClickShowdownImportPKMModded(object sender, EventArgs e)
 {
     CheckALMUpdate(); // Check for Auto Legality Mod Updates
     AutomaticLegality.C_SAV     = C_SAV;
     AutomaticLegality.PKME_Tabs = PKME_Tabs;
     AutomaticLegality.ImportModded(); // Finish the job
 }
Ejemplo n.º 4
0
        private void PGLShowdownSet(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsImage())
            {
                return;
            }
            var    rentalTeam = new QRParser().decryptQRCode(Clipboard.GetImage());
            string data       = "";

            foreach (QRPoke p in rentalTeam.team)
            {
                data += p.ToShowdownFormat(false) + Environment.NewLine + Environment.NewLine;
            }
            Clipboard.SetText(data.TrimEnd());
            AutomaticLegality.ImportModded();
            MessageBox.Show("Exported OwO", "Alert");
        }
Ejemplo n.º 5
0
        private void SmogonGenning(object sender, EventArgs e)
        {
            PKM    rough       = PKMEditor.PreparePKM();
            string speciesName = Util.GetSpeciesList("en")[rough.Species];
            string form        = new ShowdownSet(ShowdownSet.GetShowdownText(rough)).Form;
            string url         = GetURL(speciesName, form);
            string smogonPage  = GetSmogonPage(url);

            string[]      split1 = smogonPage.Split(new string[] { "\",\"abilities\":" }, StringSplitOptions.None);
            List <string> sets   = new List <string>();

            for (int i = 1; i < split1.Length; i++)
            {
                sets.Add(split1[i].Split(new string[] { "\"]}" }, StringSplitOptions.None)[0]);
            }
            string showdownSpec = speciesName;

            if (form != null)
            {
                if (form != "Mega" || form != "")
                {
                    showdownSpec += ("-" + form);
                }
            }
            string showdownsets = "";

            foreach (string set in sets)
            {
                showdownsets = showdownsets + ConvertSetToShowdown(set, showdownSpec) + Environment.NewLine + Environment.NewLine;
            }
            showdownsets.TrimEnd();
            if (showdownsets.Length == 0)
            {
                MessageBox.Show("No movesets available. Perhaps you could help out? Check the Contributions & Corrections forum.\n\nForum: https://www.smogon.com/forums/forums/contributions-corrections.388/");
                return;
            }
            Clipboard.SetText(showdownsets);
            try { AutomaticLegality.ImportModded(); }
            catch { MessageBox.Show("Something went wrong"); }
            MessageBox.Show(AlertText(showdownSpec, sets.Count, GetTitles(smogonPage)));
        }