Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
        public static void MoveSolution(string location, string projectname)
        {
            if (String.IsNullOrWhiteSpace(location))
            {
                location = System.IO.Directory.GetCurrentDirectory();
            }

            var ph = new ProjectHandler().Initialize();

            ph.SaveProject(Path.Combine(location, projectname));
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        private void Close_button_Click(object sender, EventArgs e)
        {
            ProjectHandler.SaveProject();
            Serializer.SaveSettings();

            if (JsonEditorHandler.AreJsonErrors())
            {
                DialogResult diag = MessageBox.Show(tabControl1.SelectedTab.Text + " has a Json Error! Your mod will break if you don't fix it.\nClose anyways?", "WARNING!!", MessageBoxButtons.YesNo);
                if (diag == DialogResult.Yes)
                {
                    this.Close();
                }
            }
        }
Exemplo n.º 6
0
        private void StartUp()
        {
            //string std = DeserializeConfig().CurrentGame;

            gameName = CurrentProjectVariables.GameName;
            jetName  = ReturnJetName(gameName);
            gameDir  = CurrentProjectVariables.GamePath;
            if (gameName != "BTDB" && gameName != "" && gameName != null)
            {
                password = "******";
                CurrentProjectVariables.JetPassword = password;
                ProjectHandler.SaveProject();
            }
            steamJetPath = gameDir + "\\Assets\\" + jetName;
        }
Exemplo n.º 7
0
        private void New_JsonEditor_FormClosing(object sender, FormClosingEventArgs e)
        {
            ProjectHandler.SaveProject();
            Serializer.SaveSettings();


            foreach (string t in tabFilePaths)
            {
                if (!t.Contains("Backups"))
                {
                    CheckIfModified(t);
                }
            }
            JsonEditorHandler.jeditor = null;
        }
Exemplo n.º 8
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            Serializer.cfg.useExternalEditor = useExternalEditor.Checked;
            Serializer.cfg.enableSplash      = EnableSplash.Checked;
            Serializer.cfg.disableUpdates    = DisableUpdates_CB.Checked;
            Serializer.cfg.autoFormatJSON    = AutoFormatJSON_CB.Checked;
            Serializer.cfg.UseDeveloperMode  = UseDeveloperMode.Checked;

            CurrentProjectVariables.UseNKHook = UseNKH_CB.Checked;

            Serializer.SaveSettings();
            ProjectHandler.SaveProject();
            ConsoleHandler.append_CanRepeat("Settings saved!!!");
            DeveloperMode.ControlDeveloperMode();
            this.Close();
        }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
0
        //
        //Closing stuff
        //
        public void CloseTab(string path)
        {
            /*if(jet != null)
             *  ProjectHandler.SaveZipFile(jet);*/
            int i = tabFilePaths.IndexOf(path);
            int indexBeforeDelete = tabControl1.SelectedIndex;

            tabControl1.TabPages.Remove(tabPages[i]);

            tabControl1.TabPages.Remove(tabPages[i]);
            if (indexBeforeDelete + 1 <= tabControl1.TabPages.Count)
            {
                tabControl1.SelectedIndex = indexBeforeDelete;
            }
            else
            {
                tabControl1.SelectedIndex = indexBeforeDelete - 1;
            }

            if (!path.Contains("Backups"))
            {
                CheckIfModified(path);
            }

            if (!saveOpenFileList)
            {
                tabFilePaths.RemoveAt(i);
                CurrentProjectVariables.JsonEditor_OpenedTabs.RemoveAt(i);
                ProjectHandler.SaveProject();

                tabPages.RemoveAt(i);
                userControls.RemoveAt(i);
            }

            if (tabControl1.TabPages.Count <= 0)
            {
                this.Close();
            }
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
0
        private void CheckIfModified(string pathToFile)
        {
            string backupfile = Environment.CurrentDirectory + "\\Backups\\" + CurrentProjectVariables.GameName + "_Original.jet";

            if (!File.Exists(pathToFile) || !File.Exists(backupfile))
            {
                if (JetProps.get().Count <= 0)
                {
                    return;
                }

                if (!File.Exists(pathToFile))
                {
                    ConsoleHandler.append_Force("Can't check if file is modified because the file itself was not found. Was it deleted?");
                }
                else if (!File.Exists(backupfile))
                {
                    ConsoleHandler.append_Force("Can't check if file is modified because the backup was not found");
                }

                return;
            }


            ZipFile backup = new ZipFile(backupfile);

            backup.Password = CurrentProjectVariables.JetPassword;

            string modText      = RemoveWhitespace(File.ReadAllText(pathToFile));
            string pathInZip    = pathToFile.Replace(CurrentProjectVariables.PathToProjectFiles + "\\", "");
            string originalText = RemoveWhitespace(ProjectHandler.ReadTextFromZipFile(backup, pathInZip));

            try
            {
                if (modText == originalText)
                {
                    //file not modded
                    if (CurrentProjectVariables.ModifiedFiles.Contains(pathToFile))
                    {
                        CurrentProjectVariables.ModifiedFiles.Remove(pathToFile);
                    }
                }
                else
                {
                    //file modded
                    if (!CurrentProjectVariables.ModifiedFiles.Contains(pathToFile))
                    {
                        CurrentProjectVariables.ModifiedFiles.Add(pathToFile);
                    }
                }
            }
            catch
            {
                //exception occurred. file probably modded
                if (!CurrentProjectVariables.ModifiedFiles.Contains(pathToFile))
                {
                    CurrentProjectVariables.ModifiedFiles.Add(pathToFile);
                }
            }

            ProjectHandler.SaveProject();
        }
Exemplo n.º 14
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...");
                    }
                }
            }
        }
Exemplo n.º 15
0
        public void NewTab(string path, bool isFromZip)
        {
            if (!Guard.IsStringValid(path))
            {
                ConsoleHandler.append_CanRepeat("Something went wrong when trying to read the files path...");
                return;
            }

            string filepath = "";

            if (isFromZip)
            {
                filepath = path.Replace(Environment.CurrentDirectory + "\\", "").Replace("\\", "/");
                path     = filepath;
            }
            else
            {
                filepath = path;
            }


            tabFilePaths.Add(path);

            if (!CurrentProjectVariables.JsonEditor_OpenedTabs.Contains(path))
            {
                CurrentProjectVariables.JsonEditor_OpenedTabs.Add(path);
                ProjectHandler.SaveProject();
            }

            tabPages.Add(new TabPage());
            userControls.Add(new JsonEditor_Instance());

            //create the tab and do required processing

            string[] split    = path.Replace("/", "\\").Split('\\');
            string   filename = split[split.Length - 1];

            if (path.Contains("BackupProject"))
            {
                filename = filename + readOnlyName;
                userControls[userControls.Count - 1].Editor_TextBox.ReadOnly = true;
            }

            tabPages[tabPages.Count - 1].Text = filename;
            tabPages[tabPages.Count - 1].Controls.Add(userControls[userControls.Count - 1]);
            userControls[userControls.Count - 1].path     = path;
            userControls[userControls.Count - 1].filename = filename;

            if (isFromZip == false)
            {
                AddText(path, false);
            }
            else
            {
                AddText(path, true);
            }

            if ((tabPages.Count - 1) < 0 || tabPages[tabPages.Count - 1] == null)
            {
                return;
            }

            tabControl1.TabPages.Add(tabPages[tabPages.Count - 1]);

            OpenTab(path);
            userControls[userControls.Count - 1].FinishedLoading();
        }
Exemplo n.º 16
0
        public void Setup()
        {
            SalesforceMigrationsProject project = new SalesforceMigrationsProject
            {
                ContextTypes = new[]
                {
                    "ApexClass", "ApexComponent", "ApexPage", "ApexTrigger", "Workflow", "RemoteSiteSetting",
                    "PermissionSet", "CustomObject", "StaticResource", "Profile"
                }.ToList(),
                                        Environments = new List <SalesForceEnvionment>
                {
                    new SalesForceEnvionment
                    {
                        Name = "Dev54 SandBox",
                        AuthorizationCredential = new Credential
                        {
                            UserName        = "******",
                            Password        = "******",
                            Token           = "UBB2jcTNepy81bfDhy1duZt4I",
                            EnvironmentType = SalesforceEnvironmentType.Sandbox
                        }
                    },
                    new SalesForceEnvionment
                    {
                        Name = "Dev49 SandBox",
                        AuthorizationCredential = new Credential
                        {
                            UserName        = "******",
                            Password        = "******",
                            Token           = "Up5Iauh1187WdUDLB519PVoN9",
                            EnvironmentType = SalesforceEnvironmentType.Sandbox
                        }
                    },
                    new SalesForceEnvionment
                    {
                        Name = "Dev58 SandBox",
                        AuthorizationCredential = new Credential
                        {
                            UserName        = "******",
                            Password        = "******",
                            Token           = "68CsU07xwwEcgUbC6guo1Oix",
                            EnvironmentType = SalesforceEnvironmentType.Sandbox
                        }
                    },
                    new SalesForceEnvionment
                    {
                        Name = "Dev56 SandBox",
                        AuthorizationCredential = new Credential
                        {
                            UserName        = "******",
                            Password        = "******",
                            Token           = "YBm64kT2z18rGOnTUuTJmAf1",
                            EnvironmentType = SalesforceEnvironmentType.Sandbox
                        }
                    },
                    new SalesForceEnvionment
                    {
                        Name = "Dev43 SandBox",
                        AuthorizationCredential = new Credential
                        {
                            UserName        = "******",
                            Password        = "******",
                            Token           = "Dcv65G0PfeMbDnVCYKsz50OZf",
                            EnvironmentType = SalesforceEnvironmentType.Sandbox
                        }
                    },
                },
                                        PullEnvironments = new List <string>
                {
                    "Dev54 SandBox",
                    "Dev49 SandBox",
                    "Dev58 SandBox",
                    "Dev56 SandBox",
                    "Dev43 SandBox"
                },
                                        PushEnvironments = new List <string>
                {
                    "Dev58 SandBox"
                }
            };

            ProjectHandler projectHandler = new ProjectHandler()
                                            .Initialize(project);

            projectHandler.SaveProject();
        }
Exemplo n.º 17
0
        private void SubmitModName()
        {
            if (CustomName_RadioButton.Checked)
            {
                ConsoleHandler.append("You chose the project name: " + ProjectName_TextBox.Text);
            }
            else
            {
                ConsoleHandler.append("You chose a random project name");
            }
            if (isRenaming == true)
            {
                this.Hide();
                RenameProject();
                this.Close();
                return;
            }

            bool   writeProj = true;
            string projName  = ReturnName(ProjectName_TextBox.Text, gameName);
            string projdir   = "";

            if (Guard.IsStringValid(customFolder))
            {
                projdir = customFolder + "\\" + projName;
            }
            else
            {
                projdir = Environment.CurrentDirectory + "\\Projects\\" + projName;
            }

            if (Directory.Exists(projdir))
            {
                var result = MessageBox.Show("A project with this name already exists, do you want to replace it with a new one?", "Replace Existing Project?", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Cancel)
                {
                    writeProj = false;
                    this.Close();
                }
                else
                {
                    if (result == DialogResult.Yes)
                    {
                        ConsoleHandler.append("Deleting original project");
                        try
                        {
                            Directory.Delete(projdir, true);
                        }
                        catch { ConsoleHandler.append("Directory is currently open in windows file explorer..."); }
                        writeProj = true;
                    }
                    else
                    {
                        writeProj = false;
                        ProjectName_TextBox.Text = "";
                    }
                }
            }

            if (writeProj == true)
            {
                if (!Directory.Exists(projdir))
                {
                    Directory.CreateDirectory(projdir);
                }

                string backupPath = Environment.CurrentDirectory + "\\Backups\\" + CurrentProjectVariables.GameName + "_Original.jet";
                if (!GeneralMethods.Validate_Backup(gameName))
                {
                    GeneralMethods.CreateBackup(gameName);
                }

                if (File.Exists(backupPath))
                {
                    if (!Directory.Exists(projdir))
                    {
                        Directory.CreateDirectory(projdir);
                    }

                    CurrentProjectVariables.ProjectName            = projName;
                    CurrentProjectVariables.PathToProjectClassFile = projdir;
                    CurrentProjectVariables.PathToProjectFiles     = projdir + "\\" + projName;
                    CurrentProjectVariables.UseNKHook = UseNKH_CB.Checked;
                    ProjectHandler.SaveProject();

                    if (gameName == "BTDB")
                    {
                        var getPasss = new Get_BTDB_Password();
                        getPasss.Show();
                        getPasss.isExtracting = true;
                        this.Close();
                    }
                    else
                    {
                        var zip = new ZipForm();
                        zip.Show();
                        zip.Extract();
                        this.Close();
                    }
                }
                else
                {
                    ConsoleHandler.append_Force("Unable to locate or create backup... Cancelling project creation...");
                    if (Directory.Exists(projdir))
                    {
                        Directory.Delete(projdir);
                    }
                    this.Close();
                }
            }

            //This stuff is for zip projects

            /*if (gameName != "BTDB")
             * {
             *  CurrentProjectVariables.JetPassword = "******";
             *  ProjectHandler.SaveProject();
             *
             *  DirectoryInfo dinfo = new DirectoryInfo(projdir);
             *  jetf = new JetForm(dinfo, Main.getInstance(), dinfo.Name);
             *  jetf.MdiParent = Main.getInstance();
             *  jetf.Show();
             *  jetf.PopulateTreeview();
             * }
             * else
             * {
             *  var getPasss = new Get_BTDB_Password();
             *  getPasss.Show();
             * }
             * this.Close();*/
        }