Ejemplo n.º 1
0
        private void CustomLocation_Button_Click(object sender, EventArgs e)
        {
            string path = GeneralMethods.BrowseForDirectory("Please choose where to save the project", Environment.CurrentDirectory);

            this.Focus();

            if (!Guard.IsStringValid(path))
            {
                ConsoleHandler.append("You didn't select a valid folder. Please try again, or use let toolbox use the default folder");
                MessageBox.Show("You didn't select a valid folder. Please try again, or use let toolbox use the default folder");
                return;
            }

            customFolder = path;
        }
Ejemplo n.º 2
0
        public Browser(string url)
        {
            InitializeComponent();
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                ConsoleHandler.append("Attempted to open the url |  " + url + "  | this is a bad url");
                this.Close();
                return;
            }

            try { webBrowser1.Url = new Uri(url); }
            catch { System.Diagnostics.Process.Start(url); }

            this.TitleLabel.Text = "Browser";
        }
Ejemplo n.º 3
0
        private void ExtractUpdate()
        {
            string zipPath           = Environment.CurrentDirectory + "\\" + toolbox_updater_zipName;
            string extractedFilePath = Environment.CurrentDirectory;

            ConsoleHandler.append("Extracting updater...");
            ZipFile archive = new ZipFile(zipPath);

            foreach (ZipEntry e in archive)
            {
                e.Extract(extractedFilePath, ExtractExistingFileAction.DoNotOverwrite);
            }
            archive.Dispose();
            ConsoleHandler.append("BTD Toolbox updater has been successfully downloaded and extracted...");
        }
Ejemplo n.º 4
0
 private void ReformatJSON_Button_Click(object sender, EventArgs e)
 {
     ConsoleHandler.append("JSON Formatted!");
     if (!Serializer.cfg.autoFormatJSON)
     {
         DialogResult diag = MessageBox.Show("Autoformatting isn't enabled in your settings. Would you like to toolbox to enable it, " +
                                             "or keep it set to manual, so you have to press this button to format?", "Enable AutoFormating?", MessageBoxButtons.YesNo);
         if (diag == DialogResult.Yes)
         {
             Serializer.cfg.autoFormatJSON = true;
             Serializer.SaveSettings();
         }
     }
     ReformatText();
 }
Ejemplo n.º 5
0
 private void ToggleConsole_Click(object sender, EventArgs e)
 {
     if (ConsoleHandler.validateConsole())
     {
         if (ConsoleHandler.console.Visible)
         {
             ConsoleHandler.append("Hiding console.");
             ConsoleHandler.console.Hide();
         }
         else
         {
             ConsoleHandler.append("Showing console.");
             ConsoleHandler.console.Show();
         }
     }
 }
Ejemplo n.º 6
0
        private void LaunchUpdate()
        {
            ConsoleHandler.append("Toolbox needs to close in order to update..");
            MessageBox.Show("Closing Toolbox to continue update...");

            //save config real quick
            Serializer.cfg.recentUpdate = true;
            Serializer.SaveSettings();

            Process p = new Process();

            p.StartInfo.Arguments = "-lineNumber:0 -url:https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/Updater_launch%20parameters";
            //p.StartInfo.Arguments = "-fileName:BTD_Toolbox -processName:BTDToolbox -exeName:BTDToolbox.exe -updateZip_Name:BTDToolbox_Updater.zip -ignoreFiles:BTDToolbox_Updater,Backups,DotNetZip,.json -deleteFiles:BTDToolbox_Updater.zip,Update -url:https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/Version -replaceText:toolbox2019: -lineNumber:0";
            p.StartInfo.FileName = Environment.CurrentDirectory + "\\BTDToolbox_Updater.exe";
            p.Start();
        }
Ejemplo n.º 7
0
 private void DisableAutoformattinhToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Serializer.cfg.autoFormatJSON == true)
     {
         ConsoleHandler.append("Auto-formatting disabled.");
         ConsoleHandler.force_append_Notice("You can enable or disable this in Settings, " +
                                            "which you can find under the \"File\" button at the top of toolbox.");
         Serializer.cfg.autoFormatJSON = false;
         Serializer.SaveSettings();
     }
     else
     {
         ConsoleHandler.append_Force("It is already disabled. You can use it manually by pressing the \"Re-format JSON\" button above. " +
                                     "Or, you can change it in  Settings, which you can find under the \"File\" button at the top of toolbox.");
     }
 }
Ejemplo n.º 8
0
        private void bMCDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!isGamePathValid("BMC"))
            {
                string gameD = GetGameDir("BMC");
                if (!Guard.IsStringValid(gameD))
                {
                    return;
                }

                SaveGamePath("BMC", gameD);
            }

            ConsoleHandler.append("Opening BMC Directory");
            Process.Start(Serializer.cfg.BMC_Directory);
        }
Ejemplo n.º 9
0
        private void DownloadUpdate()
        {
            reader = new WebHandler();
            string git_Text   = reader.WaitOn_URL(gitURL);
            string updaterURL = reader.processGit_Text(git_Text, "toolbox2019_updater: ", 1);

            ConsoleHandler.append("Downloading BTD Toolbox updater...");
            client.DownloadFile(updaterURL, "Update");

            if (File.Exists(toolbox_updater_zipName))
            {
                File.Delete(toolbox_updater_zipName);
            }
            File.Move("Update", toolbox_updater_zipName);
            ConsoleHandler.append("Updater successfully downloaded!");
        }
Ejemplo n.º 10
0
        public static bool Validate_Backup(string gameName)
        {
            if (gameName != null && gameName != "")
            {
                string backupName    = gameName + "_Original.jet";
                string backupDir     = Environment.CurrentDirectory + "\\Backups";
                string backupLocName = gameName + "_Original_LOC.xml";

                ConsoleHandler.append("Validating backup...");
                if (Directory.Exists(backupDir))
                {
                    if (!File.Exists(backupDir + "\\" + backupName))
                    {
                        ConsoleHandler.append("Failed to validate backup...");
                        return(false);
                    }
                    if (!File.Exists(backupDir + "\\" + backupLocName))
                    {
                        ConsoleHandler.append("Failed to validate backup loc...");
                        return(false);
                    }
                    if (gameName == "BMC")
                    {
                        string backupAssetBundle = backupDir + "\\AssetBundles_Original";
                        if (!Directory.Exists(backupAssetBundle))
                        {
                            ConsoleHandler.append("Failed to validate backup Asset Bundle for BMC...");
                            return(false);
                        }
                    }

                    ConsoleHandler.append("Backup validated");
                    return(true);
                }
                else
                {
                    ConsoleHandler.append("Failed to validate one or more backup files...");
                    return(false);
                }
            }
            else
            {
                ConsoleHandler.append("Failed to validate one or more backup files...");
                return(false);
            }
        }
Ejemplo n.º 11
0
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            exit = true;
            ConsoleHandler.append("Closing toolbox");
            ProjectHandler.SaveProject();

            Serializer.cfg.EnableConsole = ConsoleHandler.console.Visible;
            Serializer.SaveSettings();

            if (New_JsonEditor.isJsonError)
            {
                MessageBox.Show("One or more of your files has a JSON error! If you dont fix it your mod wont work and it will crash your game");
            }


            //Application.Exit();
        }
Ejemplo n.º 12
0
        private void BrowseForSaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string browsedSave = SaveEditor.TryFindSteam.BrowseForSave();

            SaveEditor.SaveEditor.DecryptSave("", browsedSave);

            string save = SaveEditor.SaveEditor.savemodDir + "\\UnknownGame_Profile.save";

            if (File.Exists(save))
            {
                JsonEditorHandler.OpenFile(save);
            }
            else
            {
                ConsoleHandler.append("Decrypted save file not found");
            }
        }
Ejemplo n.º 13
0
        private void RenameProject()
        {
            string newProjName = ReturnName(ProjectName_TextBox.Text, gameName);
            string renamePath  = "";

            if (HasCustomDestination())
            {
                renamePath = customFolder + "\\" + newProjName;
            }
            else
            {
                renamePath = Environment.CurrentDirectory + "\\Projects\\" + newProjName;
            }

            ConsoleHandler.append("Renaming project to  " + newProjName);
            jetf.RenameProject(newProjName, renamePath);
        }
Ejemplo n.º 14
0
        private void ShowBMCPass_Button_Click(object sender, EventArgs e)
        {
            string pass = "******";

            ConsoleHandler.append_Force("The password for BMC's data.jet is:   Q%_{6#Px]]\n>> Make sure you don't copy it with spaces in it");

            DialogResult diag = MessageBox.Show("Would you like toolbox to copy it to your clipboard? It will overwrite whatever is currently copied?", "Copy to clipboard?", MessageBoxButtons.YesNo);

            if (diag == DialogResult.Yes)
            {
                Clipboard.SetText(pass);
                ConsoleHandler.append("The password has been automatically copied to your clipboard so you can paste it easily.");
            }
            else
            {
                ConsoleHandler.append("The password was not copied to clipboard... You can see it in the messages above");
            }
        }
Ejemplo n.º 15
0
        public static bool isGamePathValid(string game)
        {
            string gameDir = ReturnGamePath(game);

            if (gameDir == null || gameDir == "")
            {
                ConsoleHandler.append("Unable to detect launch directory for " + game);
                return(false);
            }
            else
            {
                if (Main.getInstance().Launch_Program_ToolStrip.Visible == false)
                {
                    Main.getInstance().Launch_Program_ToolStrip.Visible = true;
                }
                return(true);
            }
        }
Ejemplo n.º 16
0
        private void Main_Shown(object sender, EventArgs e)
        {
            ConsoleHandler.append("Searching for existing projects...");
            OpenJetForm();

            if (JetProps.getForm(0) == null)
            {
                ConsoleHandler.append("No projects detected.");
            }
            //taken from here
            if (Serializer.cfg.ExistingUser == false)
            {
                FirstTimeUse();
            }

            showUpdateChangelog();
            finishedLoading = true;
        }
Ejemplo n.º 17
0
 private void Find_Button_Click(object sender, EventArgs e)
 {
     if (Find_TB.Text.Length > 0)
     {
         Editor_TextBox.Focus();
         if (Option1_CB.Checked)
         {
             SearchForSubtask();
         }
         else
         {
             FindText();
         }
     }
     else
     {
         ConsoleHandler.append("You didn't enter anything to search");
     }
 }
Ejemplo n.º 18
0
        public void GetPass()
        {
            string password = Password_TextBox.Text.ToString();

            if (password.Length < 3)
            {
                ConsoleHandler.append("The password you entered was too short...");
                MessageBox.Show("The password you entered was too short...");
            }
            else
            {
                ConsoleHandler.append("You entered the password:  "******"BTDB";
                zip.password     = password;
                zip.projName     = projName;
                zip.Show();

                if (Dont_Ask_Again_Checkbox.Checked)
                {
                    rememberPass = true;
                    ConsoleHandler.append("Program will remember your password for the rest of this session.");
                    ZipForm.rememberedPassword = Password_TextBox.Text;
                }
                else
                {
                    rememberPass = false;
                    ZipForm.rememberedPassword = "";
                }
                if (isExtracting == true)
                {
                    zip.Extract();
                }
                else
                {
                    zip.destPath = destPath;
                    zip.launch   = launch;
                    zip.Compile();
                }
                this.Close();
            }
        }
Ejemplo n.º 19
0
        public 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);

            Invoke((MethodInvoker) delegate
            {
                output_log.SelectionColor = Color.LawnGreen;
            });


            if (!Guard.IsStringValid(answer))
            {
                ConsoleHandler.append("Failed to read announcement...");
            }

            ConsoleHandler.append("Announcement: " + answer);
        }
Ejemplo n.º 20
0
        public static void LaunchGame(string game)
        {
            string exePath = "";
            string gameDir = "";
            string exeName = "";

            if (isGamePathValid(game) == true)
            {
                gameDir = CurrentProjectVariables.GamePath;
                exeName = Get_EXE_Name(game);

                exePath = gameDir + "\\" + exeName;
                ConsoleHandler.append("Launching " + game + "...");
                Process.Start(exePath);
                ConsoleHandler.append("Steam is taking over for the rest of the launch.");
            }
            else
            {
                ConsoleHandler.append("Unable to launch game... Game directory not detected...");
            }
        }
Ejemplo n.º 21
0
        public static string GetJetPath(string game)
        {
            string steamJetPath = "";
            string jetName      = "";
            string gameDir      = "";

            if (isGamePathValid(game) == true)
            {
                jetName      = ReturnJetName(game);
                gameDir      = ReturnGamePath(game);
                steamJetPath = gameDir + "\\Assets\\" + jetName;

                return(steamJetPath);
            }
            else
            {
                ConsoleHandler.append("Unable to locate the original" + jetName + ". Are you sure it exists?");
                ConsoleHandler.append("If this problem continues, double check that your " + jetName + " is spelled just like this:  " + jetName);
                return(null);
            }
        }
Ejemplo n.º 22
0
        private void TowerSpriteUpgradeDef_Button_Click(object sender, EventArgs e)
        {
            if (towerSpriteUpgradeDef == "")
            {
                towerSpriteUpgradeDef = file;
            }
            string filepath = CurrentProjectVariables.PathToProjectFiles + "\\Assets\\JSON\\TowerSpriteUpgradeDefinitions\\" + towerSpriteUpgradeDef;

            if (!filepath.EndsWith(".json"))
            {
                filepath = filepath + ".json";
            }

            if (File.Exists(filepath))
            {
                JsonEditorHandler.OpenFile(filepath);
            }
            else
            {
                ConsoleHandler.append("The TowerSpriteUpgradeDef  " + towerSpriteUpgradeDef + " was not found");
            }
        }
Ejemplo n.º 23
0
        private void PrintError(string exception)
        {
            if (this == null)
            {
                return;
            }

            ConsoleHandler.append("An error occured that may prevent the program from running properly.\r\nThe error is below: \r\n\r\n" + exception + "\r\n");

            if (exception == "The password did not match.")
            {
                MessageBox.Show("Failed to create project!!!\n\nThe password for the zip was incorrect, " +
                                "make sure you entered the correct password" +
                                " and selected the correct game for your mod (if you browsed for an existing" +
                                " mod rather than creating a new one)");
            }

            try
            { this.Invoke(new Action(() => this.Close())); }
            catch (System.InvalidOperationException)
            { }
        }
Ejemplo n.º 24
0
        public void StartCreditsView()
        {
            new Thread(() =>
            {
                WebHandler web = new WebHandler();
                string url     = "https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/credits.tdc";
                string answer  = web.WaitOn_URL(url);

                if (!Guard.IsStringValid(answer))
                {
                    ConsoleHandler.append("Failed to read update Changelog");
                    Serializer.cfg.recentUpdate = true;
                    Serializer.SaveSettings();
                    return;
                }

                if (GotCredits != null)
                {
                    GotCredits(this, new CreditsEventArgs(answer));
                }
            }).Start();
        }
Ejemplo n.º 25
0
        public static void BackupLOC(string game)
        {
            string backupDir     = Environment.CurrentDirectory + "\\Backups";
            string backupLocName = game + "_Original_LOC.xml";

            if (!Directory.Exists(backupDir))
            {
                ConsoleHandler.append("Backup directory does not exist. Creating directory...");
                Directory.CreateDirectory(backupDir);
            }

            string gameDir      = ReturnGamePath(game);
            string steamJetPath = GetJetPath(game);

            if (steamJetPath != null)
            {
                CopyFile(gameDir + "\\Assets\\Loc\\English.xml", backupDir + "\\" + backupLocName);
            }
            else
            {
                ConsoleHandler.append("Unable to create backup for " + game + ".");
            }
        }
Ejemplo n.º 26
0
        public static void CopyDirectory(string source, string destination)
        {
            if (!Directory.Exists(source))
            {
                ConsoleHandler.append("Unable to copy directory. It doesn't exist");
                return;
            }

            string[] split   = source.Split('\\');
            string   dirname = split[split.Length - 1];

            ConsoleHandler.append("Copying " + dirname + "...");
            foreach (string dirPath in Directory.GetDirectories(source, "*", SearchOption.AllDirectories))
            {
                Directory.CreateDirectory(dirPath.Replace(source, destination));
            }

            foreach (string newPath in Directory.GetFiles(source, "*.*", SearchOption.AllDirectories))
            {
                File.Copy(newPath, newPath.Replace(source, destination), true);
            }
            ConsoleHandler.append("Copied " + dirname + "!");
        }
Ejemplo n.º 27
0
        private void NewProject(string gameName)
        {
            if (projNoGame)
            {
                return;
            }

            if (isGamePathValid(gameName) == false)
            {
                string gameDir = GetGameDir(gameName);
                if (!Guard.IsStringValid(gameDir))
                {
                    ConsoleHandler.append("The game directory wasn't found. Cancelling project creation.");
                    return;
                }

                CurrentProjectVariables.GameName = gameName;
                CurrentProjectVariables.GamePath = gameDir;

                if (Guard.IsStringValid(CurrentProjectVariables.PathToProjectClassFile))
                {
                    ProjectHandler.SaveProject();
                }

                SaveGamePath(gameName, gameDir);
                Serializer.SaveSettings();

                if (!Validate_Backup(gameName))
                {
                    CreateBackup(gameName);
                }
            }

            var setProjName = new SetProjectName();

            setProjName.Show();
        }
Ejemplo n.º 28
0
        private void BrowseForExistingProjects()    //check this if having issues with last project
        {
            string path = BrowseForDirectory("Browse for an existing project", Environment.CurrentDirectory);

            if (path != null && path != "")
            {
                string[] split = path.Split('\\');
                string   name  = split[split.Length - 1];
                if (!name.StartsWith("proj_"))
                {
                    ConsoleHandler.append("Invalid project... Please browse for a folder that starts with    proj_");
                    MessageBox.Show("Error!! Not a valid project file. Please try again...");
                }
                else
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(path);
                    Serializer.cfg.LastProject = path;
                    if (path.Contains("BTD5"))
                    {
                        Serializer.cfg.CurrentGame = "BTD5";
                    }
                    else if (path.Contains("BTDB"))
                    {
                        Serializer.cfg.CurrentGame = "BTDB";
                    }
                    else if (path.Contains("BMC"))
                    {
                        Serializer.cfg.CurrentGame = "BMC";
                    }

                    JetForm jf = new JetForm(dirInfo, name);
                    jf.MdiParent = this;
                    jf.Show();
                    Serializer.SaveSettings();
                }
            }
        }
Ejemplo n.º 29
0
        public static string GetGameDir(string gamename)
        {
            ConsoleHandler.append("Attempting to aquire " + gamename + "'s game directory automatically");
            string gameDir = TryFindSteamDir(GetSteamFolderName(gamename));

            if (Guard.IsStringValid(gameDir))
            {
                ConsoleHandler.append("Successfully aquired game directory for " + gamename + "!");
                return(gameDir);
            }
            ConsoleHandler.append("Failed to automatically aquire game dir");

            ConsoleHandler.append("Please browse for " + Get_EXE_Name(gamename));

            gameDir = browseForExe(gamename);
            if (isGamePathValid(gamename) == true)
            {
                ConsoleHandler.append("The game directory you selected for " + gamename + " is valid");
                return(gameDir);
            }

            ConsoleHandler.append("Theres been an error identifying your game");
            return(gameDir);
        }
Ejemplo n.º 30
0
        public static Config LoadSettings()
        {
            if (serializer == null)
            {
                serializer = new Serializer();
            }

            if (!File.Exists(settingsPath))
            {
                ConsoleHandler.append("Settings file doesn't exist! Creating a new settings file.");
                serializer.CreateNewSettings();
            }

            if (!JSON_Reader.IsValidJson(File.ReadAllText(settingsPath)))
            {
                ConsoleHandler.append("Settings file has invalid JSON and therefore can't be loaded. Creating a new settings file.");
                serializer.CreateNewSettings();
            }

            string json = File.ReadAllText(Environment.CurrentDirectory + "\\settings.json");

            cfg = JsonConvert.DeserializeObject <Config>(json);
            return(cfg);
        }