Esempio n. 1
0
        private void LintPanel_MouseClick(object sender, MouseEventArgs e)
        {
            if (jsonError)
            {
                try
                {
                    string error = JSON_Reader.GetJSON_Error(Editor_TextBox.Text);
                    ConsoleHandler.force_append_Notice(error);
                    //Line number
                    string[] split      = error.Split(',');
                    string[] line       = split[split.Length - 2].Split(' ');
                    int      lineNumber = Int32.Parse(line[line.Length - 1].Replace(".", "").Replace(",", ""));

                    //Position in line
                    string[] pos     = split[split.Length - 1].Split(' ');
                    int      linePos = Int32.Parse(pos[pos.Length - 1].Replace(".", "").Replace(",", ""));

                    //Scroll to the line above error
                    int index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 3) + linePos;
                    Editor_TextBox.Select(index, 1);
                    Editor_TextBox.ScrollToCaret();

                    int numChars = (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 1)) - (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2));

                    //highlight line with error
                    index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2) + linePos;
                    Editor_TextBox.Focus();
                    Editor_TextBox.Select(index, numChars - 2);
                }
                catch
                {
                    ConsoleHandler.append_CanRepeat("Something went wrong... Unable to find the bad json");
                }
            }
        }
Esempio n. 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);
     }
 }
Esempio n. 3
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();
 }
Esempio n. 4
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");
 }
Esempio n. 5
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");
         }
     }
 }
Esempio n. 6
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();
     }
 }
Esempio n. 7
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();
                }
            }
        }
Esempio n. 8
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.");
     }
 }
Esempio n. 9
0
        public void Compile()
        {
            if (!IsGameRunning(gameName))
            {
                this.Text        = "Compiling " + CurrentProjectVariables.ProjectName;
                Filename_TB.Text = ReturnJetName(gameName);

                if (gameName == "BTDB")
                {
                    if (rememberedPassword != null && rememberedPassword != "")
                    {
                        password = rememberedPassword;
                        Serializer.SaveSettings();
                        CurrentProjectVariables.JetPassword = password;
                        ProjectHandler.SaveProject();
                    }

                    if (password == null || password.Length <= 0)
                    {
                        var getpas = new Get_BTDB_Password();
                        getpas.launch       = launch;
                        getpas.isExtracting = false;
                        getpas.projName     = projName;
                        getpas.destPath     = destPath;
                        getpas.Show();
                        this.Close();
                    }
                    else
                    {
                        backgroundThread = new Thread(Compile_OnThread);
                        backgroundThread.Start();
                    }
                }
                else
                {
                    backgroundThread = new Thread(Compile_OnThread);
                    backgroundThread.Start();
                }
            }
            else
            {
                ConsoleHandler.force_append_Notice("Game is currently running. Please close the game and try again...");
                this.Close();
            }
        }
Esempio n. 10
0
 private void jsonContextClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     if (e.ClickedItem.Text == "Paste")
     {
         try
         {
             Editor_TextBox.SelectionStart = CharIndex_UnderMouse;
             Editor_TextBox.Paste();
         }
         catch (Exception)
         {
         }
     }
     if (e.ClickedItem.Text == "Find subtask")
     {
         try
         {
             ConsoleHandler.force_append_Notice("Please enter the subtask numbers you are looking for in the \"Find\" text box above.\n>> Example:    0,0,1");
             searchSubtask = true;
             ShowFindMenu();
         }
         catch (Exception)
         {
         }
     }
     if (e.ClickedItem.Text == "Get current subtask number")
     {
         if (jsonError == false)
         {
             try
             {
                 //func here
                 GetSubtaskNum();
             }
             catch (Exception)
             {
             }
         }
         else
         {
             ConsoleHandler.append_Force("JSON error detected... You need to fix the JSON error before you can get the subtask");
         }
     }
 }
Esempio n. 11
0
 //
 //Save editor stuff
 //
 #region Save editor stuff
 private void Encrypt_Button_Click(object sender, EventArgs e)
 {
     if (!jsonError)
     {
         if (filename.StartsWith("BTD5"))
         {
             SaveEditor.SaveEditor.EncryptSave("BTD5");
         }
         else if (filename.StartsWith("BTDB"))
         {
             SaveEditor.SaveEditor.EncryptSave("BTDB");
         }
         else if (filename.StartsWith("UnknownGame"))
         {
             SaveEditor.SaveEditor.EncryptSave("UnknownGame");
         }
     }
     else
     {
         ConsoleHandler.force_append_Notice("You need to fix your JSON error before continuing...");
     }
 }
Esempio n. 12
0
        private void Launch_Program_ToolStrip_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (!NKHook.CanUseNKH())
            {
                return;
            }

            if (e.ClickedItem.Text == "With NKHook")
            {
                if (NKHook.DoesNkhExist())
                {
                    if (CurrentProjectVariables.UseNKHook == false && CurrentProjectVariables.DontAskAboutNKH == false)
                    {
                        AlwaysUseNKH ask = new AlwaysUseNKH(true);
                        ask.Show();
                    }
                    else
                    {
                        CompileJet("launch nkh");
                    }
                }
                else
                {
                    ConsoleHandler.force_append_Notice("Unable to locate NKHook5-Injector.exe. Opening Get NKHook message... You need to launch without it until you download NKHook.");
                    NKHook_Message msg = new NKHook_Message();
                    msg.Show();
                }
            }
            if (e.ClickedItem.Text == "Without NKHook")
            {
                CompileJet("launch");
            }
            if (e.ClickedItem.Text == "NKHook Plugin Manager")
            {
                NKHPluginMgr mgr = new NKHPluginMgr();
            }
        }
Esempio n. 13
0
 private void FindSubtask_Button_Click(object sender, EventArgs e)
 {
     ConsoleHandler.force_append_Notice("Please enter the subtask numbers you are looking for in the \"Find\" text box above.\n>> Example:    0,0,1");
     searchSubtask = true;
     ShowFindMenu();
 }
Esempio n. 14
0
        private void Compile_OnThread()
        {
            bool cont = true;

            if (launch)
            {
                if (gameDir == null || gameDir == "")
                {
                    cont = false;
                    this.Invoke(new Action(() => this.Close()));
                    ConsoleHandler.append("There was an issue reading your game directory. Go to the \"Help\" tab at the top, browse for your game again, and then try again...");
                    backgroundThread.Abort();
                }
            }

            if (cont)
            {
                string dir = "";
                if (destPath == null || destPath == "")
                {
                    dir = steamJetPath;
                }
                else
                {
                    dir = destPath;
                }

                if (dir != "\\Assets\\" + jetName)
                {
                    if (!Guard.IsStringValid(Serializer.cfg.LastProject))
                    {
                        Serializer.SaveSettings();
                    }

                    DirectoryInfo projDir = new DirectoryInfo(CurrentProjectVariables.PathToProjectFiles);
                    if (Directory.Exists(projDir.ToString()))
                    {
                        ConsoleHandler.append("Compiling jet...");
                        int numFiles   = Directory.GetFiles((projDir.ToString()), "*", SearchOption.AllDirectories).Length;
                        int numFolders = Directory.GetDirectories(projDir.ToString(), "*", SearchOption.AllDirectories).Count();
                        totalFiles      = numFiles + numFolders;
                        filesTransfered = 0;

                        ZipFile toExport = new ZipFile();
                        toExport.Password     = password;
                        toExport.AddProgress += ZipCompileProgress;
                        toExport.AddDirectory(projDir.FullName);
                        toExport.Encryption       = EncryptionAlgorithm.PkzipWeak;
                        toExport.Name             = dir;
                        toExport.CompressionLevel = CompressionLevel.Level6;

                        try
                        {
                            toExport.Save();
                            toExport.Dispose();
                        }
                        catch (System.IO.IOException)
                        {
                            ConsoleHandler.force_append_Notice("Something went wrong... Is your jet file opened?");
                            this.Invoke(new Action(() => this.Close()));
                        }

                        //Commented this out for now

                        /*if (CurrentProjectVariables.GameName == "BMC")
                         * {
                         *  var d = new DirectoryInfo(CurrentProjectVariables.PathToProjectFiles).GetDirectories();
                         *  foreach(var a in d)
                         *  {
                         *      if (a.Name.Contains("AssetBundles"))
                         *      {
                         *          Invoke((MethodInvoker)delegate { Filename_TB.Text = "AssetBundles"; });
                         *          CompileAssetBundles();
                         *          break;
                         *      }
                         *  }
                         * }*/

                        ConsoleHandler.append("Jet was successfully exported to: " + dir);

                        if (launch == true)
                        {
                            if (!launchNKH)
                            {
                                LaunchGame(gameName);
                            }
                            else
                            {
                                NKHook.LaunchNKH();
                            }
                        }
                        try
                        {
                            this.Invoke(new Action(() => this.Close()));
                        }
                        catch (Exception ex)
                        {
                            PrintError(ex.Message);
                            backgroundThread.Abort();
                        }
                        backgroundThread.Abort();
                    }
                    else
                    {
                        ConsoleHandler.append("Output directory not found... Failed to compile...");
                    }
                }
                else
                {
                    ConsoleHandler.append("Something went wrong with the export. The export path might have been invalid, or it might have been cancelled...");
                    try
                    {
                        this.Invoke(new Action(() => this.Close()));
                    }
                    catch (Exception ex)
                    {
                        PrintError(ex.Message);
                    }
                    backgroundThread.Abort();
                }
            }
        }
Esempio n. 15
0
        private void Extract_OnThread()
        {
            destPath = CurrentProjectVariables.PathToProjectFiles;
            DirectoryInfo dinfo = new DirectoryInfo(destPath);

            if (!dinfo.Exists)
            {
                ConsoleHandler.append("Creating project files for: " + projName);

                ZipFile archive = new ZipFile(sourcePath);
                archive.Password = password;
                totalFiles       = archive.Count();
                filesTransfered  = 0;

                try
                {
                    archive.ExtractProgress += ZipExtractProgress;
                    archive.ExtractAll(destPath);
                    archive.Dispose();
                }
                catch (Exception ex)
                {
                    error = true;
                    PrintError(ex.Message);
                }

                //Commented this out for now

                /*
                 * if (CurrentProjectVariables.GameName == "BMC")
                 * {
                 *  DialogResult diag = MessageBox.Show("Would you like to extract the Asset Bundles as well? " +
                 *      "They mostly have to do with textures and maps, and" +
                 *      " while you can mod those as well as anything else from data.jet, they are not necessary." +
                 *      "\nNote: Your project will take up more space", "Extract Asset Bundles as well?", MessageBoxButtons.YesNo);
                 *  if(diag == DialogResult.Yes)
                 *  {
                 *      Invoke((MethodInvoker)delegate {
                 *          Filename_TB.Text = "AssetBundles";
                 *      });
                 *      ExtractAssetBundleJet();
                 *  }
                 * }*/
                if (error == false)
                {
                    if (!Directory.Exists(Environment.CurrentDirectory + "\\Backups\\" + gameName + "_BackupProject"))
                    {
                        string gamed = "";
                        if (gameName == "BTD5")
                        {
                            gamed = Serializer.cfg.BTD5_Directory;
                        }
                        else if (gameName == "BTDB")
                        {
                            gamed = Serializer.cfg.BTDB_Directory;
                        }
                        else if (gameName == "BMC")
                        {
                            gamed = Serializer.cfg.BMC_Directory;
                        }

                        //they should have a backup jet of gamed not invalid. create backup proj
                        if (error == false && gamed != "" && gamed != null)
                        {
                            ConsoleHandler.force_append_Notice("Backup project not detected.... Creating one now..");
                            Invoke((MethodInvoker) delegate {
                                this.Focus();

                                destPath                 = Environment.CurrentDirectory + "\\Backups\\" + gameName + "_BackupProject";
                                archive                  = new ZipFile(sourcePath);
                                archive.Password         = password;
                                totalFiles               = archive.Count();
                                filesTransfered          = 0;
                                archive.ExtractProgress += ZipExtractProgress;

                                try
                                {
                                    archive.ExtractAll(destPath);
                                    archive.Dispose();
                                }
                                catch (Exception ex)
                                {
                                    error = true;
                                    PrintError(ex.Message);
                                }


                                //Commented this out for now

                                /*if (gameName == "BMC")
                                 * {
                                 *  DialogResult diag = MessageBox.Show("Would you like to extract the Asset Bundles as well? " +
                                 * "They mostly have to do with textures and maps, and" +
                                 * " while you can mod those as well as anything else from data.jet, they are not necessary." +
                                 * "\nNote: Your project will take up more space", "Extract Asset Bundles as well?", MessageBoxButtons.YesNo);
                                 *  if (diag == DialogResult.Yes)
                                 *  {
                                 *      Invoke((MethodInvoker)delegate {
                                 *          Filename_TB.Text = "AssetBundles";
                                 *      });
                                 *      ExtractAssetBundleJet();
                                 *  }
                                 * }*/
                            });
                        }
                        else
                        {
                            ConsoleHandler.force_append_Notice("Unable to find backup project or the game directory. Backup project WILL NOT be made, and you will NOT be able to use \"Restore to original\" until you browse for your game..");
                        }
                    }
                    ConsoleHandler.append("Project files created at: " + CurrentProjectVariables.PathToProjectFiles);
                    Invoke((MethodInvoker) delegate {
                        jf           = new JetForm(dinfo, dinfo.Name);
                        jf.MdiParent = Main.getInstance();
                        jf.Show();
                    });
                }
                else
                {
                    try
                    { this.Invoke(new Action(() => this.Close())); }
                    catch (Exception ex)
                    {
                        error = true;
                        PrintError(ex.Message);
                    }
                }
            }
            else
            {
                DialogResult varr = MessageBox.Show("A project with this name already exists. Do you want to replace it?", "", MessageBoxButtons.OKCancel);
                if (varr == DialogResult.OK)
                {
                    MessageBox.Show("Please close the Jet viewer for the old project...");
                    ConsoleHandler.append("Deleting existing project....");
                    MessageBox.Show(dinfo.ToString());
                    DeleteDirectory(dinfo.ToString());
                    ConsoleHandler.append("Project Deleted. Creating new project...");
                    Extract_OnThread();
                    return;
                }
                if (varr == DialogResult.Cancel)
                {
                    try
                    { this.Invoke(new Action(() => this.Close())); }
                    catch (Exception ex)
                    {
                        error = true;
                        PrintError(ex.Message);
                    }
                }
            }
            try
            { this.Invoke(new Action(() => this.Close())); }
            catch (Exception ex)
            {
                error = true;
                PrintError(ex.Message);
            }
        }
Esempio n. 16
0
 private void Reset_EXE_MouseHover(object sender, EventArgs e)
 {
     ConsoleHandler.force_append_Notice("This will reset your game path...");
 }
Esempio n. 17
0
        public static void CompileJet(string switchCase)
        {
            if (New_JsonEditor.isJsonError != true)
            {
                if (JetProps.get().Count == 1)
                {
                    string dest         = "";
                    bool   isOutputting = false;
                    bool   abort        = false;

                    var zip = new ZipForm();

                    if (switchCase.Contains("output"))
                    {
                        isOutputting = true;
                        string exPath = CurrentProjectVariables.ExportPath;
                        if (exPath != "" && exPath != null)
                        {
                            DialogResult diag = MessageBox.Show("Do you want export to the same place as last time?", "Export to the same place?", MessageBoxButtons.YesNo);
                            if (diag == DialogResult.Yes)
                            {
                                dest = exPath;
                            }
                            else
                            {
                                exPath = "";
                            }
                        }
                        if (exPath == "" || exPath == null)
                        {
                            ConsoleHandler.append("Select where you want to export your jet file. Make sure to give it a name..");
                            dest = OutputJet();

                            CurrentProjectVariables.ExportPath = dest;
                            ProjectHandler.SaveProject();

                            //ZipForm.savedExportPath = dest;
                            //Serializer.SaveSmallSettings("export path");
                        }
                        zip.destPath = dest;
                    }


                    else if (switchCase.Contains("launch"))
                    {
                        if (switchCase.Contains("nkh"))
                        {
                            zip.launchNKH = true;
                        }

                        if (CurrentProjectVariables.GamePath != null && CurrentProjectVariables.GamePath != "")
                        {
                            zip.launch   = true;
                            zip.destPath = CurrentProjectVariables.GamePath + "\\Assets\\" + ReturnJetName(CurrentProjectVariables.GameName);
                        }
                        else
                        {
                            ConsoleHandler.force_append_Notice("Unable to find your game directory, and therefore, unable to launch. Do you want to try browsing for your game?");
                            DialogResult diag = MessageBox.Show("Unable to find your game directory, and therefore, unable to launch. Do you want to try browsing for your game?", "Browse for game?", MessageBoxButtons.YesNoCancel);
                            if (diag == DialogResult.Yes)
                            {
                                browseForExe(CurrentProjectVariables.GameName);
                            }
                            if (diag == DialogResult.No)
                            {
                                DialogResult diag2 = MessageBox.Show("Do you want to just save your jet file instead?", "Save jet instead?", MessageBoxButtons.YesNo);
                                {
                                    if (diag2 == DialogResult.Yes)
                                    {
                                        isOutputting = true;
                                        string exPath = CurrentProjectVariables.ExportPath;
                                        if (exPath != "" && exPath != null)
                                        {
                                            DialogResult diagz = MessageBox.Show("Do you want export to the same place as last time?", "Export to the same place?", MessageBoxButtons.YesNo);
                                            if (diagz == DialogResult.Yes)
                                            {
                                                dest = exPath;
                                            }
                                            else
                                            {
                                                exPath = "";
                                            }
                                        }
                                        if (exPath == "" || exPath == null)
                                        {
                                            ConsoleHandler.append("Select where you want to export your jet file. Make sure to give it a name..");
                                            dest = OutputJet();
                                            CurrentProjectVariables.ExportPath = dest;
                                            ProjectHandler.SaveProject();

                                            /*ZipForm.savedExportPath = dest;
                                             * Serializer.SaveSmallSettings("export path");*/
                                        }
                                        zip.destPath = dest;
                                    }
                                }
                            }
                            else
                            {
                                abort = true;
                            }
                        }
                    }
                    if (!abort)
                    {
                        if (isOutputting)
                        {
                            if (dest != null && dest != "")
                            {
                                zip.destPath = dest;
                                zip.Show();
                                zip.Compile();
                            }
                            else
                            {
                                ConsoleHandler.append("Export cancelled...");
                            }
                        }
                        else
                        {
                            zip.Show();
                            zip.Compile();
                        }
                    }
                }
                else
                {
                    if (JetProps.get().Count < 1)
                    {
                        MessageBox.Show("You have no .jets or projects open, you need one to launch.");
                        ConsoleHandler.append("You need to open a project to continue...");
                    }
                    else
                    {
                        MessageBox.Show("You have multiple .jets or projects open, only one can be launched.");
                        ConsoleHandler.append("You need to close projects to continue...");
                    }
                }
            }
        }