コード例 #1
0
ファイル: UpdateHandler.cs プロジェクト: yassin889/BTDToolbox
 public void HandleUpdates()
 {
     if (!reinstall)
     {
         if (CheckForUpdates())
         {
             if (AskToUpdate())
             {
                 DownloadUpdate();
                 ExtractUpdate();
                 LaunchUpdate();
             }
             else
             {
                 ConsoleHandler.append("Update cancelled...");
             }
         }
         else
         {
             ConsoleHandler.append("Toolbox is up to date!");
         }
     }
     else
     {
         DownloadUpdate();
         ExtractUpdate();
         LaunchUpdate();
     }
 }
コード例 #2
0
 public static void DeleteDirectory(string path)
 {
     if (path == Environment.CurrentDirectory)
     {
         ConsoleHandler.force_append_Notice("A Critical error occured... Attempted to delete BTD Toolbox folder...");
         return;
     }
     if (Directory.Exists(path))
     {
         ConsoleHandler.append("Deleting directory..");
         var directory = new DirectoryInfo(path)
         {
             Attributes = FileAttributes.Normal
         };
         foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories))
         {
             info.Attributes = FileAttributes.Normal;
         }
         directory.Delete(true);
         ConsoleHandler.append("Directory deleted.");
     }
     else
     {
         ConsoleHandler.append("Directory not found. Unable to delete directory at:\r\n" + path);
     }
 }
コード例 #3
0
        public static void CopyFile(string originalLocation, string newLocation)
        {
            string[] split    = originalLocation.Split('\\');
            string   filename = split[split.Length - 1];

            if (File.Exists(originalLocation))
            {
                if (!File.Exists(newLocation))
                {
                    ConsoleHandler.append("Copying " + filename + "...");
                    File.Copy(originalLocation, newLocation);
                    ConsoleHandler.append("Copied " + filename + "!");
                }
                else
                {
                    ConsoleHandler.append("A file with that name already exists...");
                    DeleteFile(newLocation);
                    ConsoleHandler.append("Replacing existing file..");
                    File.Copy(originalLocation, newLocation);
                    ConsoleHandler.append("Copied " + filename + "!");
                }
            }
            else
            {
                ConsoleHandler.append("Failed to copy " + filename + " because it was not found at: \r\n" + originalLocation);
            }
        }
コード例 #4
0
        public static string browseForExe(string game)
        {
            string exeName = Get_EXE_Name(game);

            if (!Guard.IsStringValid(exeName))
            {
                return("");
            }


            MessageBox.Show("Please browse for " + exeName + ".\n\nMake sure that your game is UNMODDED, otherwise Toolbox will make a corrupt backup");
            ConsoleHandler.append("Make sure that your game is UNMODDED, otherwise Toolbox will make a corrupt backup..");
            string exePath = BrowseForFile("Open game exe", "exe", "Exe files (*.exe)|*.exe|All files (*.*)|*.*", "");

            if (!Guard.IsStringValid(exePath))
            {
                ConsoleHandler.append_Force("Invalid EXE path!");
                return("");
            }

            if (!exePath.Contains(exeName))
            {
                ConsoleHandler.append("You selected an Invalid .exe. Please browse for the exe for your game.");
                return("");
            }

            string gameDir = exePath.Replace("\\" + exeName, "");

            SaveGamePath(game, gameDir);
            return(gameDir);
        }
コード例 #5
0
        public static void RestoreGame_ToBackup_LOC(string game)
        {
            string gameDir      = "";
            string backupJetLoc = Environment.CurrentDirectory + "\\Backups\\" + game + "_Original_LOC.xml";
            string locName      = "English.xml";

            if (isGamePathValid(game) == true)
            {
                gameDir = ReturnGamePath(game);
                string locPath = gameDir + "\\Assets\\Loc\\" + locName;

                if (!File.Exists(backupJetLoc))
                {
                    ConsoleHandler.append("Unable to restore " + locName + ". Backup file doesn't exist..");
                }
                else
                {
                    ConsoleHandler.append("Replacing " + locName + " with the backup " + locName);
                    if (File.Exists(locPath))
                    {
                        File.Delete(locPath);
                    }

                    File.Copy(backupJetLoc, locPath);
                    ConsoleHandler.append(locName + " successfully restored!");
                }
            }
            else
            {
                ConsoleHandler.append("Unable to restore " + locName + ". Game directory not detected..");
            }
        }
コード例 #6
0
 private void UseNKH_CB_CheckedChanged(object sender, EventArgs e)
 {
     if (UseNKH_CB.Checked)
     {
         ConsoleHandler.force_append_Notice("Checking this will make toolbox use NKH with your project by default. You can always change this later in Settings if you want by clicking \"File\" at the top, then \"Settings\"");
     }
     this.Focus();
 }
コード例 #7
0
 private void Tutorials_Button_Click(object sender, EventArgs e)
 {
     if (!Tutorials.HasFreshTutList())
     {
         ConsoleHandler.append("Aquiring a fresh list of availible tutorials");
         Tutorials.GetTutorialsList();
     }
 }
コード例 #8
0
 //
 //Subtask stuff
 //
 #region Subtast stuff
 private void FindSubtask_Button_Event()
 {
     if (!Find_Panel.Visible)
     {
         ShowSearchMenu("find");
     }
     Option1_CB.Checked = true;
     ConsoleHandler.force_append_Notice("Please enter the subtask numbers you are looking for in the \"Find\" text box above.\n>> Example:    0,0,1");
 }
コード例 #9
0
 private void MonkeyWrenchToolStripMenuItem_MouseHover(object sender, EventArgs e)
 {
     if (!mwMessageShown)
     {
         mwMessageShown = true;
         ConsoleHandler.append_Force("Monkey Wrench is a great tool made by Topper, that allows you to convert .jpng files into regular .png files, and back again.");
         ConsoleHandler.append_Force("Once it's opened, type     \'help\'     without quotes, to learn how to use the commands.");
     }
 }
コード例 #10
0
 private void SaveEditorToolStripMenuItem_MouseHover(object sender, EventArgs e)
 {
     if (!seMessageShown)
     {
         seMessageShown = true;
         ConsoleHandler.append_Force("This save editor was originally made by Vadmeme on github. They're allowing anyone to use it, so we added it to toolbox.");
         ConsoleHandler.append_Force("If you're interested, the link for it is here: https://github.com/Vadmeme/BTDSaveEditor");
     }
 }
コード例 #11
0
ファイル: AlwaysUseNKH.cs プロジェクト: yassin889/BTDToolbox
        private void No_Button_Click(object sender, EventArgs e)
        {
            CurrentProjectVariables.DontAskAboutNKH = Dont_Ask_Again_Checkbox.Checked;
            ProjectHandler.SaveProject();
            useNKHDefault = false;

            ConsoleHandler.append("You selected No. If you checked \"Dont Ask Me Again\" then BTD Toolbox won't ask you" +
                                  " for the rest of this session. You can always change this by going to Settings and checking Use NKHook");
            Submit();
        }
コード例 #12
0
ファイル: AlwaysUseNKH.cs プロジェクト: yassin889/BTDToolbox
        private void Yes_Button_Click(object sender, EventArgs e)
        {
            CurrentProjectVariables.UseNKHook = true;
            ProjectHandler.SaveProject();
            useNKHDefault = true;

            ConsoleHandler.append("You selected Yes. From now on when you quick launch this project BTD Toolbox " +
                                  "will use NKHook");
            Submit();
        }
コード例 #13
0
 private void Option1_CB_CheckedChanged(object sender, EventArgs e)
 {
     if (Option1_CB.Text == "Subtask")
     {
         if (Option1_CB.Checked)
         {
             ConsoleHandler.force_append_Notice("Please enter the subtask numbers you are looking for in the \"Find\" text box above.\n>> Example:    0,0,1");
         }
     }
 }
コード例 #14
0
        private void ResetUserSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ConsoleHandler.append("Resetting user settings...");
            if (File.Exists(Serializer.settingsPath))
            {
                File.Delete(Serializer.settingsPath);
            }

            ConsoleHandler.append("User settings have been reset.");
        }
コード例 #15
0
 private void ViewOriginalToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!filename.Contains(New_JsonEditor.readOnlyName))
     {
         JsonEditorHandler.OpenOriginalFile(path);
     }
     else
     {
         ConsoleHandler.append_Notice("You are already looking at the original " + filename.Replace(New_JsonEditor.readOnlyName, ""));
     }
 }
コード例 #16
0
        private void CreateProject_Button_Click(object sender, EventArgs e)
        {
            string projectJet = Environment.CurrentDirectory + "\\" + CurrentProjectVariables.GameName + "_Original.jet";

            bool result = GeneralMethods.Bad_JetPass(projectJet, Password_TextBox.Text);

            if (!result)
            {
                ConsoleHandler.append("Password correct");
                CurrentProjectVariables.JetPassword = Password_TextBox.Text;
                ProjectHandler.SaveProject();

                if (Dont_Ask_Again_Checkbox.Checked)
                {
                    ZipForm.rememberedPassword = Password_TextBox.Text;
                    Serializer.SaveSettings();
                }

                var zip = new ZipForm();
                zip.password = Password_TextBox.Text;
                zip.Show();

                if (isExtracting)
                {
                    zip.Extract();
                }
                else
                {
                    zip.launch = launch;
                    zip.Compile();
                }
                this.Close();
            }
            else
            {
                ConsoleHandler.append_Force("You entered a bad password. Please check your password and try again");
            }

            /*
             * string projectJet = CurrentProjectVariables.PathToProjectClassFile + "\\" + CurrentProjectVariables.ProjectName + ".jet";
             *
             * if (File.Exists(projectJet))
             * {
             *
             * }
             * else
             * {
             *  ConsoleHandler.append_Force("Your project file was not detected...");
             * }*/

            //GetPass();
        }
コード例 #17
0
ファイル: Console.cs プロジェクト: yassin889/BTDToolbox
        public void CreateLogFile()
        {
            if (DoesLogFileExist())
            {
                File.Delete(Environment.CurrentDirectory + "\\ConsoleLog.txt");
            }

            File.Create(Environment.CurrentDirectory + "\\ConsoleLog.txt").Close();
            if (console != null)
            {
                ConsoleHandler.append("New log file created.");
            }
        }
コード例 #18
0
ファイル: UpdateHandler.cs プロジェクト: yassin889/BTDToolbox
 private bool CheckForUpdates()
 {
     reader = new WebHandler();
     try
     {
         return(reader.CheckForUpdate(gitURL, "toolbox2019: ", 0, Main.version));
     }
     catch
     {
         ConsoleHandler.append_Notice("Something went wrong when checking for updates.. Failed to check for updates");
         return(false);
     }
 }
コード例 #19
0
 public static void DeleteFile(string fileName)
 {
     if (File.Exists(fileName))
     {
         ConsoleHandler.append("Deleting file...");
         File.Delete(fileName);
         ConsoleHandler.append("File deleted.");
     }
     else
     {
         ConsoleHandler.append("Error! Unable to delete the file:\r\n" + fileName);
     }
 }
コード例 #20
0
        private void GetSubtaskNum()
        {
            string subtaskNum = JSON_Reader.GetSubtaskNum(CharIndex_UnderMouse, Editor_TextBox.Text);

            if (subtaskNum != "" && subtaskNum != " " && subtaskNum != null)
            {
                ConsoleHandler.append_Force_CanRepeat("Subtask:  [" + subtaskNum + " ]");
            }
            else
            {
                ConsoleHandler.append_Force("Unable to detect subtask. Please try clicking somewhere else...");
            }
        }
コード例 #21
0
        private void GetBTDBPasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult diag = MessageBox.Show("You are trying to open the \"Get BTDB Password\" tool. It will take a couple of minutes to get the password. Do you wish to continue?", "Continue?", MessageBoxButtons.YesNo);

            if (diag == DialogResult.Yes)
            {
                var getPass = new CrackBTDB_Pass();
                getPass.Get_BTDB_Password();
            }
            else
            {
                ConsoleHandler.append_CanRepeat("User cancelled password tool...");
            }
        }
コード例 #22
0
ファイル: UpdateHandler.cs プロジェクト: yassin889/BTDToolbox
        private bool AskToUpdate()
        {
            ConsoleHandler.append("There is a new update availible for BTD Toolbox! Do you want to download it?");
            DialogResult result = MessageBox.Show("There is a new update availible for BTD Toolbox! Do you want to download it?", "Update BTD Toolbox?", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #23
0
        public static void CreateBackup(string game)
        {
            string backupDir      = Environment.CurrentDirectory + "\\Backups";
            string backupName     = game + "_Original.jet";
            string backupLocName  = game + "_Original_LOC.xml";
            string fullBackupPath = backupDir + "\\" + backupName;

            ConsoleHandler.append("One or more of the backup files failed to be aquired... Please wait while they are reaquired...");
            ConsoleHandler.append("Aquiring new backups..");
            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);
                CopyFile(steamJetPath, fullBackupPath);

                if (File.Exists(fullBackupPath))
                {
                    ConsoleHandler.append("Backup jet created!");
                }
                else
                {
                    ConsoleHandler.append("Backup jet failed...");
                }

                if (game == "BMC")
                {
                    string source      = Serializer.cfg.BMC_Directory + "\\AssetBundles";
                    string destination = backupDir + "\\AssetBundles_Original";
                    if (Directory.Exists(destination))
                    {
                        Directory.Delete(destination, true);
                    }

                    Directory.CreateDirectory(destination);
                    CopyDirectory(source, destination);
                }
            }
            else
            {
                ConsoleHandler.append("Unable to create backup for " + game + ".");
            }
        }
コード例 #24
0
 private void EZCard_Button_Click(object sender, EventArgs e)
 {
     if (JSON_Reader.IsValidJson(Editor_TextBox.Text))
     {
         var ezCard = new EZCard_Editor();
         ezCard.path = path;
         ezCard.Show();
     }
     else
     {
         ConsoleHandler.force_append_Notice("ERROR! This file doesn't have valid Json. Please fix the Json to continue");
         this.Focus();
     }
 }
コード例 #25
0
        public void OpenInFileExplorer()
        {
            string[] split      = path.Split('\\');
            string   foldername = path.Replace(split[split.Length - 1], "");

            if (!foldername.Contains("BackupProject"))
            {
                Process.Start(foldername);
            }
            else
            {
                ConsoleHandler.append_Notice("Operation cancelled. We don't want you to edit the backup on accident... If you really need to look at it, you can find it in the Backups folder");
            }
        }
コード例 #26
0
        private void UseNKH_CB_CheckedChanged(object sender, EventArgs e)
        {
            if (!NKHook.DoesNkhExist())
            {
                if (UseNKH_CB.Checked == true)
                {
                    UseNKH_CB.Checked = false;

                    ConsoleHandler.force_append_Notice("You need to have NKHook installed to do that!");
                    MessageBox.Show("You need to have NKHook installed to do that!");
                    NKHook_Message msg = new NKHook_Message();
                    msg.Show();
                }
            }
        }
コード例 #27
0
ファイル: UpdateHandler.cs プロジェクト: yassin889/BTDToolbox
        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...");
        }
コード例 #28
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;
        }
コード例 #29
0
        private void resetBMCexeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string g = "BMC";

            ConsoleHandler.append("Please browse for MonkeyCity-Win.exe");
            browseForExe(g);
            if (isGamePathValid(g) == true)
            {
                ConsoleHandler.append("Success! Selected exe at: " + Serializer.cfg.BTDB_Directory);
            }
            else
            {
                ConsoleHandler.append("Invalid game directory selected.");
            }
        }
コード例 #30
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();
 }