Beispiel #1
0
        public static void GetAnnouncement()
        {
            WebHandler web    = new WebHandler();
            string     url    = "https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/toolbox%20announcements";
            string     answer = web.WaitOn_URL(url);


            ConsoleHandler.append(answer);
        }
Beispiel #2
0
        public bool CheckForUpdate(string url, string deleteText, int lineNumber, string currentVersion) //Use this to check for updates
        {
            if (reader == null)
            {
                reader = new WebHandler();
            }

            string processedUrl = reader.processGit_Text(reader.WaitOn_URL(url), deleteText, lineNumber);
            string gitVersion   = reader.Get_GitVersion(processedUrl);

            LatestVersionNumber = gitVersion;

            if (!Guard.IsStringValid(currentVersion))
            {
                return(true);
            }

            if (!Guard.IsStringValid(gitVersion))
            {
                ConsoleHandler.append("Unable to determine latest version");
                return(false);
            }

            int    number         = 0;
            string toolboxVersion = "";

            foreach (char c in currentVersion)
            {
                if (Int32.TryParse(c.ToString(), out number))
                {
                    toolboxVersion = toolboxVersion + c;
                }
            }

            if (Int32.Parse(toolboxVersion) < Int32.Parse(gitVersion))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void Download_ModLoader()
        {
            WebHandler web    = new WebHandler();
            WebClient  client = new WebClient();
            string     url    = "https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/Version";


            string gitText     = web.WaitOn_URL(url);
            string downloadURL = web.processGit_Text(gitText, "modloader: ", 2);

            client.DownloadFile(downloadURL, "Update");

            if (File.Exists(modloader_zipName))
            {
                File.Delete(modloader_zipName);
            }
            File.Move("Update", modloader_zipName);
            ConsoleHandler.append("Mod Loader successfully downloaded!");
        }
Beispiel #4
0
        public static void GetTutorialsList()
        {
            if (tut == null)
            {
                tut = new Tutorials();
            }

            string     url = "https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/btd%20modding%20tutorials";
            WebHandler web = new WebHandler();

            new Thread(() =>
            {
                string returnText = web.WaitOn_URL(url);
                if (!Guard.IsStringValid(returnText))
                {
                    if (!File.Exists(tut.tutorialFilePath))
                    {
                        ConsoleHandler.append("Failed to get fresh tutorials list and unable to find the stored list. " +
                                              "If this problem continues please restart BTD Toolbox.");
                        tut = null;
                        return;
                    }
                    ConsoleHandler.append("Failed to get tutorials list. Toolbox will use the stored list instead, please note it may " +
                                          "not be updated. Restart BTD Toolbox if you want to try getting the list again.");
                }
                else
                {
                    ConsoleHandler.append("Aquired tutorials list");
                    tut.CreateTutorialsFile();
                    tut.WriteToTutFile(returnText);
                    ConsoleHandler.append("Finished writing tutorials list to file");
                }
                tut.CreateTutorialsDictionary(tutorials);
                tut.PopulateTutorialsList();
            }).Start();
        }