From 92ae5ce7699deacca14d70613284b655e77524f6 Mon Sep 17 00:00:00 2001 From: Gurrenm3 Date: Mon, 30 Mar 2020 19:37:35 -0700 Subject: [PATCH 1/7] More support for users with no game; Can use last saved btdb pass --- BTDToolbox/Classes/GeneralMethods.cs | 56 +++++++++++++++++++++-- BTDToolbox/Extra Forms/EasyTowerEditor.cs | 46 +++++++++++++++++-- BTDToolbox/Get_BTDB_Password.Designer.cs | 16 +++++++ BTDToolbox/Get_BTDB_Password.cs | 23 +++++++++- BTDToolbox/Main.cs | 4 +- BTDToolbox/ZipForm.cs | 29 ++++++------ 6 files changed, 148 insertions(+), 26 deletions(-) diff --git a/BTDToolbox/Classes/GeneralMethods.cs b/BTDToolbox/Classes/GeneralMethods.cs index 1491145..1544b80 100644 --- a/BTDToolbox/Classes/GeneralMethods.cs +++ b/BTDToolbox/Classes/GeneralMethods.cs @@ -318,6 +318,37 @@ public static void CreateBackup(string game) ConsoleHandler.appendLog("Unable to create backup for " + game + "."); } } + public static void SteamValidateBTD5() + { + Process.Start("steam://validate/306020"); + } + public static void SteamValidateBTDB() + { + Process.Start("steam://validate/444640"); + } + public static void BackupLOC(string game) + { + string backupDir = Environment.CurrentDirectory + "\\Backups"; + string backupLocName = game + "_Original_LOC.xml"; + + if (!Directory.Exists(backupDir)) + { + ConsoleHandler.appendLog("Backup directory does not exist. Creating directory..."); + Directory.CreateDirectory(backupDir); + } + + string gameDir = ""; + if (game == "BTD5") + gameDir = DeserializeConfig().BTD5_Directory; + else + gameDir = DeserializeConfig().BTDB_Directory; + + string steamJetPath = GetJetPath(game); + if (steamJetPath != null) + CopyFile(gameDir + "\\Assets\\Loc\\English.xml", backupDir + "\\" + backupLocName); + else + ConsoleHandler.appendLog("Unable to create backup for " + game + "."); + } public static void RestoreGame_ToBackup(string game) { string gameDir = ""; @@ -516,8 +547,14 @@ public static string OutputJet() } public static void CompileJet(string switchCase) { - if (JsonEditor.jsonError != true) + if (New_JsonEditor.isJsonError != true) { + string gameDir = ""; + if(Main.gameName == "BTD5") + gameDir = Serializer.Deserialize_Config().BTD5_Directory; + else + gameDir = Serializer.Deserialize_Config().BTDB_Directory; + if (JetProps.get().Count == 1) { string dest = ""; @@ -532,9 +569,22 @@ public static void CompileJet(string switchCase) dest = OutputJet(); zip.destPath = dest; } - if (switchCase.Contains("launch")) + else if (switchCase.Contains("launch")) { - zip.launch = true; + if (gameDir != null && gameDir != "") + zip.launch = true; + else + { + ConsoleHandler.force_appendNotice("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?"); + DialogResult diag = MessageBox.Show("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?", "Game Dir not found", MessageBoxButtons.YesNo); + if (diag == DialogResult.Yes) + { + isOutputting = true; + ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); + dest = OutputJet(); + zip.destPath = dest; + } + } } if (isOutputting) { diff --git a/BTDToolbox/Extra Forms/EasyTowerEditor.cs b/BTDToolbox/Extra Forms/EasyTowerEditor.cs index bf35547..a71ef02 100644 --- a/BTDToolbox/Extra Forms/EasyTowerEditor.cs +++ b/BTDToolbox/Extra Forms/EasyTowerEditor.cs @@ -35,7 +35,7 @@ public partial class EasyTowerEditor : Form string[] loc_upgradeDescs = new string[] { }; string game = Serializer.Deserialize_Config().CurrentGame; - + string gameDir = ""; string[] loc_Text = new string[] { }; string loc_Path = ""; string loc_towerName = ""; @@ -199,7 +199,31 @@ private void PopulateUI() TowerDesc_TextBox.Text = loc_towerDesc; } } - ReadLoc(); + if(game == "BTD5") + { + if(File.Exists(loc_Path)) + ReadLoc(); + else + { + if(Serializer.Deserialize_Config().BTD5_Directory == null || Serializer.Deserialize_Config().BTD5_Directory == "") + { + ConsoleHandler.force_appendNotice("You haven't browsed for your BTD5 Game so you will not be able to edit the tower and upgrade descriptions"); + this.Focus(); + } + else + { + ConsoleHandler.force_appendNotice("Unable to find your LOC file..."); + DialogResult diag = MessageBox.Show("Unable to find BTD5's LOC file. Do you want toolbox to make Steam validate BTD5 so it can reaquire it? If you have any mods applied to btd5 steam, they will be lost. Do you want to continue?", "Continue?", MessageBoxButtons.YesNo); + if (diag == DialogResult.Yes) + GeneralMethods.SteamValidateBTD5(); + else + { + ConsoleHandler.force_appendNotice("Valdation cancelled. You will not be able to mod the tower or upgrade descriptions..."); + this.Focus(); + } + } + } + } if (upgradenames != null) { @@ -397,7 +421,14 @@ private void PopulateUpgrades() RankToUnlockUpgrade_TextBox.Text = upgradeRanks[Upgrades_ListBox.SelectedIndex].ToString(); XpToUnlockUpgrade_TextBox.Text = upgradeXPs[Upgrades_ListBox.SelectedIndex].ToString(); - UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString(); + if(game == "BTD5") + { + if (File.Exists(loc_Path)) + UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString(); + } + else + UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString(); + } } private void ResetUI() @@ -601,7 +632,7 @@ private void SaveLoc() } private void ReadLoc() { - if (Serializer.Deserialize_Config().CurrentGame == "BTD5") + if(File.Exists(loc_Path)) { loc_Text = File.ReadAllLines(loc_Path); string towerName = "LOC_" + TowerType_Label.Text + "_TOWER"; @@ -669,6 +700,10 @@ private void ReadLoc() } } } + else + { + + } } @@ -722,7 +757,8 @@ private void UpgradeName_TextBox_TextChanged(object sender, EventArgs e) private void Save_Button_Click(object sender, EventArgs e) { SaveFile(); - SaveLoc(); + if (File.Exists(loc_Path)) + SaveLoc(); ConsoleHandler.appendLog_CanRepeat("Saved " + AllTowerFiles_ComboBox.SelectedItem.ToString()); } private void UpgradeIcon_TextBox_TextChanged(object sender, EventArgs e) diff --git a/BTDToolbox/Get_BTDB_Password.Designer.cs b/BTDToolbox/Get_BTDB_Password.Designer.cs index c2f6613..9e47e71 100644 --- a/BTDToolbox/Get_BTDB_Password.Designer.cs +++ b/BTDToolbox/Get_BTDB_Password.Designer.cs @@ -34,6 +34,7 @@ private void InitializeComponent() this.Password_TextBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.Dont_Ask_Again_Checkbox = new System.Windows.Forms.CheckBox(); + this.UseLastPass_CB = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -101,12 +102,26 @@ private void InitializeComponent() this.Dont_Ask_Again_Checkbox.Text = "Don\'t ask me again"; this.Dont_Ask_Again_Checkbox.UseVisualStyleBackColor = true; // + // UseLastPass_CB + // + this.UseLastPass_CB.AutoSize = true; + this.UseLastPass_CB.Font = new System.Drawing.Font("Yu Gothic UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.UseLastPass_CB.ForeColor = System.Drawing.Color.Snow; + this.UseLastPass_CB.Location = new System.Drawing.Point(257, 158); + this.UseLastPass_CB.Name = "UseLastPass_CB"; + this.UseLastPass_CB.Size = new System.Drawing.Size(140, 21); + this.UseLastPass_CB.TabIndex = 15; + this.UseLastPass_CB.Text = "Use last password?"; + this.UseLastPass_CB.UseVisualStyleBackColor = true; + this.UseLastPass_CB.CheckedChanged += new System.EventHandler(this.UseLastPass_CB_CheckedChanged); + // // Get_BTDB_Password // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); this.ClientSize = new System.Drawing.Size(409, 191); + this.Controls.Add(this.UseLastPass_CB); this.Controls.Add(this.Dont_Ask_Again_Checkbox); this.Controls.Add(this.label2); this.Controls.Add(this.CreateProject_Button); @@ -133,5 +148,6 @@ private void InitializeComponent() private System.Windows.Forms.TextBox Password_TextBox; private System.Windows.Forms.Label label2; private System.Windows.Forms.CheckBox Dont_Ask_Again_Checkbox; + private System.Windows.Forms.CheckBox UseLastPass_CB; } } \ No newline at end of file diff --git a/BTDToolbox/Get_BTDB_Password.cs b/BTDToolbox/Get_BTDB_Password.cs index 236affb..93e841b 100644 --- a/BTDToolbox/Get_BTDB_Password.cs +++ b/BTDToolbox/Get_BTDB_Password.cs @@ -18,16 +18,21 @@ public partial class Get_BTDB_Password : Form public string destPath { get; set; } public bool isExtracting { get; set; } public bool launch { get; set; } - + string savedPass = Serializer.Deserialize_Config().battlesPass; public Get_BTDB_Password() { InitializeComponent(); this.AcceptButton = CreateProject_Button; + + if (savedPass == null) + UseLastPass_CB.Visible = false; + else + UseLastPass_CB.Visible = true; + if (rememberPass == true) Dont_Ask_Again_Checkbox.Checked = true; else Dont_Ask_Again_Checkbox.Checked = false; - } public void GetPass() { @@ -75,5 +80,19 @@ private void CreateProject_Button_Click(object sender, EventArgs e) { GetPass(); } + + private void UseLastPass_CB_CheckedChanged(object sender, EventArgs e) + { + if (UseLastPass_CB.Checked) + { + Password_TextBox.Text = savedPass; + Password_TextBox.ReadOnly = true; + } + else + { + Password_TextBox.Text = ""; + Password_TextBox.ReadOnly = false; + } + } } } diff --git a/BTDToolbox/Main.cs b/BTDToolbox/Main.cs index 180b913..e50700e 100644 --- a/BTDToolbox/Main.cs +++ b/BTDToolbox/Main.cs @@ -709,12 +709,12 @@ private void Reset_EXE_MouseHover(object sender, EventArgs e) private void ValidateBTD5_Click(object sender, EventArgs e) { - Process.Start("steam://validate/306020"); + GeneralMethods.SteamValidateBTD5(); } private void ValidateBTDB_Click(object sender, EventArgs e) { - Process.Start("steam://validate/444640"); + GeneralMethods.SteamValidateBTDB(); } private void FontForPCToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BTDToolbox/ZipForm.cs b/BTDToolbox/ZipForm.cs index e101829..705a17a 100644 --- a/BTDToolbox/ZipForm.cs +++ b/BTDToolbox/ZipForm.cs @@ -289,7 +289,19 @@ public void Compile() } private void Compile_OnThread() { - if (gameDir != null && gameDir != "") + bool cont = true; + if(launch) + { + if (gameDir == null && gameDir == "") + { + cont = false; + this.Invoke(new Action(() => this.Close())); + ConsoleHandler.appendLog("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 == "") @@ -298,13 +310,11 @@ private void Compile_OnThread() dir = destPath; if (DeserializeConfig().LastProject == null) - { Serializer.SaveConfig(jf, "jet explorer", programData); - } + DirectoryInfo projDir = new DirectoryInfo(DeserializeConfig().LastProject); if (Directory.Exists(projDir.ToString())) { - ConsoleHandler.appendLog("Compiling jet..."); int numFiles = Directory.GetFiles((projDir.ToString()), "*", SearchOption.AllDirectories).Length; int numFolders = Directory.GetDirectories(projDir.ToString(), "*", SearchOption.AllDirectories).Count(); @@ -321,12 +331,10 @@ private void Compile_OnThread() toExport.CompressionLevel = CompressionLevel.Level6; toExport.Save(); toExport.Dispose(); - ConsoleHandler.appendLog("Jet was successfully exported to: " + projDir.FullName); + ConsoleHandler.appendLog("Jet was successfully exported to: " + destPath); if (launch == true) - { LaunchGame(gameName); - } try { this.Invoke(new Action(() => this.Close())); @@ -338,13 +346,6 @@ private void Compile_OnThread() backgroundThread.Abort(); } } - else - { - this.Invoke(new Action(() => this.Close())); - ConsoleHandler.appendLog("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(); - } - } private void ExtractJet_Window_Load(object sender, EventArgs e) { From 717aeb307a82b7d29ac745e0c89973feac0c29a1 Mon Sep 17 00:00:00 2001 From: Gurrenm3 Date: Mon, 30 Mar 2020 19:39:36 -0700 Subject: [PATCH 2/7] Update Get_BTDB_Password.cs --- BTDToolbox/Get_BTDB_Password.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BTDToolbox/Get_BTDB_Password.cs b/BTDToolbox/Get_BTDB_Password.cs index 93e841b..e71943f 100644 --- a/BTDToolbox/Get_BTDB_Password.cs +++ b/BTDToolbox/Get_BTDB_Password.cs @@ -24,7 +24,7 @@ public Get_BTDB_Password() InitializeComponent(); this.AcceptButton = CreateProject_Button; - if (savedPass == null) + if (savedPass == "" || savedPass == null) UseLastPass_CB.Visible = false; else UseLastPass_CB.Visible = true; From d5bc9d5c3eca714ff4613b65b9689501ac6abd91 Mon Sep 17 00:00:00 2001 From: Gurrenm3 Date: Mon, 30 Mar 2020 20:20:07 -0700 Subject: [PATCH 3/7] Added save export path, use last password, more "no game" support, bug fixes, etc --- BTDToolbox/Classes/GeneralMethods.cs | 118 ++++++++++++++-------- BTDToolbox/Classes/SerializeOps.cs | 5 + BTDToolbox/Extra Forms/EasyTowerEditor.cs | 6 +- BTDToolbox/ZipForm.cs | 9 ++ 4 files changed, 92 insertions(+), 46 deletions(-) diff --git a/BTDToolbox/Classes/GeneralMethods.cs b/BTDToolbox/Classes/GeneralMethods.cs index 1544b80..d16c756 100644 --- a/BTDToolbox/Classes/GeneralMethods.cs +++ b/BTDToolbox/Classes/GeneralMethods.cs @@ -550,72 +550,102 @@ public static void CompileJet(string switchCase) if (New_JsonEditor.isJsonError != true) { string gameDir = ""; - if(Main.gameName == "BTD5") - gameDir = Serializer.Deserialize_Config().BTD5_Directory; - else - gameDir = Serializer.Deserialize_Config().BTDB_Directory; + string gameNameTemp = ""; - if (JetProps.get().Count == 1) + if (Serializer.Deserialize_Config().CurrentGame != "" && Serializer.Deserialize_Config() != null) + gameNameTemp = Serializer.Deserialize_Config().CurrentGame; + else if (Main.gameName != "" && Main.gameName != null) { - string dest = ""; - bool isOutputting = false; - - var zip = new ZipForm(); + Serializer.SaveConfig(Main.getInstance(), "main", Serializer.Deserialize_Config()); + } + + if(gameNameTemp != "" && Main.gameName != null) + { + if (Main.gameName == "BTD5") + gameDir = Serializer.Deserialize_Config().BTD5_Directory; + else + gameDir = Serializer.Deserialize_Config().BTDB_Directory; - if (switchCase.Contains("output")) + if (JetProps.get().Count == 1) { - isOutputting = true; - ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); - dest = OutputJet(); - zip.destPath = dest; - } - else if (switchCase.Contains("launch")) - { - if (gameDir != null && gameDir != "") - zip.launch = true; - else + string dest = ""; + bool isOutputting = false; + + var zip = new ZipForm(); + + if (switchCase.Contains("output")) { - ConsoleHandler.force_appendNotice("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?"); - DialogResult diag = MessageBox.Show("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?", "Game Dir not found", MessageBoxButtons.YesNo); - if (diag == DialogResult.Yes) + isOutputting = true; + string exPath = programData.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) { - isOutputting = true; ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); dest = OutputJet(); - zip.destPath = dest; + ZipForm.savedExportPath = dest; + Serializer.SaveSmallSettings("export path", Serializer.Deserialize_Config()); } + zip.destPath = dest; } - } - if (isOutputting) - { - if (dest != null && dest != "") + else if (switchCase.Contains("launch")) { - zip.Show(); - zip.Compile(); + if (gameDir != null && gameDir != "") + zip.launch = true; + else + { + ConsoleHandler.force_appendNotice("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?"); + DialogResult diag = MessageBox.Show("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?", "Game Dir not found", MessageBoxButtons.YesNo); + if (diag == DialogResult.Yes) + { + isOutputting = true; + ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); + dest = OutputJet(); + zip.destPath = dest; + } + } + } + if (isOutputting) + { + if (dest != null && dest != "") + { + zip.Show(); + zip.Compile(); + } + else + { + ConsoleHandler.appendLog("Export cancelled..."); + } } else { - ConsoleHandler.appendLog("Export cancelled..."); + zip.Show(); + zip.Compile(); } } else { - zip.Show(); - zip.Compile(); + if (JetProps.get().Count < 1) + { + MessageBox.Show("You have no .jets or projects open, you need one to launch."); + ConsoleHandler.appendLog("You need to open a project to continue..."); + } + else + { + MessageBox.Show("You have multiple .jets or projects open, only one can be launched."); + ConsoleHandler.appendLog("You need to close projects to continue..."); + } } } else { - if (JetProps.get().Count < 1) - { - MessageBox.Show("You have no .jets or projects open, you need one to launch."); - ConsoleHandler.appendLog("You need to open a project to continue..."); - } - else - { - MessageBox.Show("You have multiple .jets or projects open, only one can be launched."); - ConsoleHandler.appendLog("You need to close projects to continue..."); - } + ConsoleHandler.force_appendNotice("There was an issue detecting your current game! Please restart toolbox and try again..."); } } } diff --git a/BTDToolbox/Classes/SerializeOps.cs b/BTDToolbox/Classes/SerializeOps.cs index ec033ec..87cd7b4 100644 --- a/BTDToolbox/Classes/SerializeOps.cs +++ b/BTDToolbox/Classes/SerializeOps.cs @@ -20,6 +20,10 @@ public static void SaveSmallSettings(string formName, ConfigFile serialize_confi { var cfg = Serializer.Deserialize_Config(); + if (formName == "export path") + { + cfg.ExportPath = ZipForm.savedExportPath; + } if (formName == "updater") { cfg.recentUpdate = UpdateChangelog.recentUpdate; @@ -174,6 +178,7 @@ public static ConfigFile Deserialize_Config() programData.JsonEditor_OpenedTabs = new List(); + programData.ExportPath = ""; programData.BTD5_Directory = ""; programData.BTDB_Directory = ""; diff --git a/BTDToolbox/Extra Forms/EasyTowerEditor.cs b/BTDToolbox/Extra Forms/EasyTowerEditor.cs index a71ef02..eb9eb71 100644 --- a/BTDToolbox/Extra Forms/EasyTowerEditor.cs +++ b/BTDToolbox/Extra Forms/EasyTowerEditor.cs @@ -421,13 +421,15 @@ private void PopulateUpgrades() RankToUnlockUpgrade_TextBox.Text = upgradeRanks[Upgrades_ListBox.SelectedIndex].ToString(); XpToUnlockUpgrade_TextBox.Text = upgradeXPs[Upgrades_ListBox.SelectedIndex].ToString(); - if(game == "BTD5") + if (game == "BTD5") { if (File.Exists(loc_Path)) UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString(); } - else + else if (game != "" && game != null) UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString(); + else + ConsoleHandler.force_appendNotice("Something went wrong and your current game was not detected. Please reload BTD Toolbox, otherwise you may encounter errors"); } } diff --git a/BTDToolbox/ZipForm.cs b/BTDToolbox/ZipForm.cs index 705a17a..f685e38 100644 --- a/BTDToolbox/ZipForm.cs +++ b/BTDToolbox/ZipForm.cs @@ -21,6 +21,7 @@ public partial class ZipForm : Form public int filesTransfered = 0; public static string rememberedPassword = ""; public static string existingJetFile = ""; + public static string savedExportPath = ""; //Config variables ConfigFile programData; @@ -40,6 +41,7 @@ public partial class ZipForm : Form public string projName { get; set; } public string password { get; set; } public bool launch { get; set; } + public bool isExporting { get; set; } //Threads Thread backgroundThread; @@ -257,6 +259,7 @@ public void Compile() if (rememberedPassword != null && rememberedPassword != "") { password = rememberedPassword; + Serializer.SaveSmallSettings("battlesPass", programData); } if (password == null || password.Length <= 0) @@ -331,6 +334,12 @@ private void Compile_OnThread() toExport.CompressionLevel = CompressionLevel.Level6; toExport.Save(); toExport.Dispose(); + + /*if (isExporting == true) + { + savedExportPath = destPath; + Serializer.SaveSmallSettings("export path", programData); + }*/ ConsoleHandler.appendLog("Jet was successfully exported to: " + destPath); if (launch == true) From 6342138ee355eddcf37a176f830d7905de6e9ad2 Mon Sep 17 00:00:00 2001 From: Gurrenm3 Date: Mon, 30 Mar 2020 20:24:43 -0700 Subject: [PATCH 4/7] bugfix with save export path --- BTDToolbox/Classes/GeneralMethods.cs | 18 ++++++++++++++++-- BTDToolbox/Classes/SerializeOps.cs | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/BTDToolbox/Classes/GeneralMethods.cs b/BTDToolbox/Classes/GeneralMethods.cs index d16c756..fdaacaa 100644 --- a/BTDToolbox/Classes/GeneralMethods.cs +++ b/BTDToolbox/Classes/GeneralMethods.cs @@ -605,8 +605,22 @@ public static void CompileJet(string switchCase) if (diag == DialogResult.Yes) { isOutputting = true; - ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); - dest = OutputJet(); + string exPath = programData.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.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); + dest = OutputJet(); + ZipForm.savedExportPath = dest; + Serializer.SaveSmallSettings("export path", Serializer.Deserialize_Config()); + } zip.destPath = dest; } } diff --git a/BTDToolbox/Classes/SerializeOps.cs b/BTDToolbox/Classes/SerializeOps.cs index 87cd7b4..94330ed 100644 --- a/BTDToolbox/Classes/SerializeOps.cs +++ b/BTDToolbox/Classes/SerializeOps.cs @@ -179,6 +179,7 @@ public static ConfigFile Deserialize_Config() programData.JsonEditor_OpenedTabs = new List(); programData.ExportPath = ""; + programData.battlesPass = ""; programData.BTD5_Directory = ""; programData.BTDB_Directory = ""; From a00a325c538955c2cc9fa489fab6b399b8c69c0e Mon Sep 17 00:00:00 2001 From: Gurrenm3 Date: Mon, 30 Mar 2020 21:12:09 -0700 Subject: [PATCH 5/7] bugfix with bad path --- BTDToolbox/Classes/GeneralMethods.cs | 75 +++++++++++++++++----------- BTDToolbox/ZipForm.cs | 69 ++++++++++++++----------- 2 files changed, 86 insertions(+), 58 deletions(-) diff --git a/BTDToolbox/Classes/GeneralMethods.cs b/BTDToolbox/Classes/GeneralMethods.cs index fdaacaa..d7a14ff 100644 --- a/BTDToolbox/Classes/GeneralMethods.cs +++ b/BTDToolbox/Classes/GeneralMethods.cs @@ -556,10 +556,11 @@ public static void CompileJet(string switchCase) gameNameTemp = Serializer.Deserialize_Config().CurrentGame; else if (Main.gameName != "" && Main.gameName != null) { + gameNameTemp = Main.gameName; Serializer.SaveConfig(Main.getInstance(), "main", Serializer.Deserialize_Config()); } - if(gameNameTemp != "" && Main.gameName != null) + if(gameNameTemp != "" && gameNameTemp != null) { if (Main.gameName == "BTD5") gameDir = Serializer.Deserialize_Config().BTD5_Directory; @@ -570,6 +571,7 @@ public static void CompileJet(string switchCase) { string dest = ""; bool isOutputting = false; + bool abort = false; var zip = new ZipForm(); @@ -600,48 +602,63 @@ public static void CompileJet(string switchCase) zip.launch = true; else { - ConsoleHandler.force_appendNotice("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?"); - DialogResult diag = MessageBox.Show("Unable to find your game directory, and therefore, unable to launch. Do you want to just save your jet file instead?", "Game Dir not found", MessageBoxButtons.YesNo); + ConsoleHandler.force_appendNotice("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) { - isOutputting = true; - string exPath = programData.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) + browseForExe(gameNameTemp); + } + if (diag == DialogResult.No) + { + DialogResult diag2 = MessageBox.Show("Do you want to just save your jet file instead?", "Save jet instead?", MessageBoxButtons.YesNo); { - ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); - dest = OutputJet(); - ZipForm.savedExportPath = dest; - Serializer.SaveSmallSettings("export path", Serializer.Deserialize_Config()); + if (diag2 == DialogResult.Yes) + { + isOutputting = true; + string exPath = programData.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.appendLog("Select where you want to export your jet file. Make sure to give it a name.."); + dest = OutputJet(); + ZipForm.savedExportPath = dest; + Serializer.SaveSmallSettings("export path", Serializer.Deserialize_Config()); + } + zip.destPath = dest; + } } - zip.destPath = dest; } + else + abort = true; } } - if (isOutputting) + if(!abort) { - if (dest != null && dest != "") + if (isOutputting) { - zip.Show(); - zip.Compile(); + if (dest != null && dest != "") + { + zip.Show(); + zip.Compile(); + } + else + { + ConsoleHandler.appendLog("Export cancelled..."); + } } else { - ConsoleHandler.appendLog("Export cancelled..."); + zip.Show(); + zip.Compile(); } } - else - { - zip.Show(); - zip.Compile(); - } } else { diff --git a/BTDToolbox/ZipForm.cs b/BTDToolbox/ZipForm.cs index f685e38..b34538a 100644 --- a/BTDToolbox/ZipForm.cs +++ b/BTDToolbox/ZipForm.cs @@ -25,6 +25,7 @@ public partial class ZipForm : Form //Config variables ConfigFile programData; + string jetName = ""; public string gameDir; public string gameName; public string steamJetPath; @@ -58,7 +59,6 @@ private void StartUp() { programData = DeserializeConfig(); string std = DeserializeConfig().CurrentGame; - string jetName = ""; if (std == "BTDB") { @@ -295,7 +295,7 @@ private void Compile_OnThread() bool cont = true; if(launch) { - if (gameDir == null && gameDir == "") + if (gameDir == null || gameDir == "") { cont = false; this.Invoke(new Action(() => this.Close())); @@ -312,38 +312,49 @@ private void Compile_OnThread() else dir = destPath; - if (DeserializeConfig().LastProject == null) - Serializer.SaveConfig(jf, "jet explorer", programData); - - DirectoryInfo projDir = new DirectoryInfo(DeserializeConfig().LastProject); - if (Directory.Exists(projDir.ToString())) + if (dir != "\\Assets\\" + jetName) { - ConsoleHandler.appendLog("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; + if (DeserializeConfig().LastProject == null) + Serializer.SaveConfig(jf, "jet explorer", programData); - ZipFile toExport = new ZipFile(); + DirectoryInfo projDir = new DirectoryInfo(DeserializeConfig().LastProject); + if (Directory.Exists(projDir.ToString())) + { + ConsoleHandler.appendLog("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; - toExport.Password = password; - toExport.AddProgress += ZipCompileProgress; - toExport.AddDirectory(projDir.FullName); - toExport.Encryption = EncryptionAlgorithm.PkzipWeak; - toExport.Name = dir; - toExport.CompressionLevel = CompressionLevel.Level6; - toExport.Save(); - toExport.Dispose(); + ZipFile toExport = new ZipFile(); + MessageBox.Show(dir); + toExport.Password = password; + toExport.AddProgress += ZipCompileProgress; + toExport.AddDirectory(projDir.FullName); + toExport.Encryption = EncryptionAlgorithm.PkzipWeak; + toExport.Name = dir; + toExport.CompressionLevel = CompressionLevel.Level6; + toExport.Save(); + toExport.Dispose(); - /*if (isExporting == true) - { - savedExportPath = destPath; - Serializer.SaveSmallSettings("export path", programData); - }*/ - ConsoleHandler.appendLog("Jet was successfully exported to: " + destPath); + ConsoleHandler.appendLog("Jet was successfully exported to: " + dir); - if (launch == true) - LaunchGame(gameName); + if (launch == true) + LaunchGame(gameName); + try + { + this.Invoke(new Action(() => this.Close())); + } + catch (Exception ex) + { + PrintError(ex.Message); + } + backgroundThread.Abort(); + } + } + else + { + ConsoleHandler.appendLog("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())); From 01ff432c15ed71fde98e7e6550af1e3a4eee0bca Mon Sep 17 00:00:00 2001 From: Gurrenm3 Date: Mon, 30 Mar 2020 21:20:27 -0700 Subject: [PATCH 6/7] Removed resize bars on first startup --- BTDToolbox/ThemedForm.cs | 1 + BTDToolbox/ZipForm.cs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/BTDToolbox/ThemedForm.cs b/BTDToolbox/ThemedForm.cs index 010fda1..92e4faa 100644 --- a/BTDToolbox/ThemedForm.cs +++ b/BTDToolbox/ThemedForm.cs @@ -59,6 +59,7 @@ public ThemedForm() public void onThemedLoad(object sender, EventArgs e) { titleSeperator.SplitterDistance = 25; + CheckInBounds(); } private void CheckInBounds() { diff --git a/BTDToolbox/ZipForm.cs b/BTDToolbox/ZipForm.cs index b34538a..05c1d5f 100644 --- a/BTDToolbox/ZipForm.cs +++ b/BTDToolbox/ZipForm.cs @@ -327,7 +327,6 @@ private void Compile_OnThread() filesTransfered = 0; ZipFile toExport = new ZipFile(); - MessageBox.Show(dir); toExport.Password = password; toExport.AddProgress += ZipCompileProgress; toExport.AddDirectory(projDir.FullName); From 52e85767523542bc8d43dfa693bdd8f7452c6758 Mon Sep 17 00:00:00 2001 From: Gurrenm3 Date: Mon, 30 Mar 2020 21:23:00 -0700 Subject: [PATCH 7/7] Changed version num to alpha 0.1.1 --- BTDToolbox/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BTDToolbox/Main.cs b/BTDToolbox/Main.cs index e50700e..c3dd0b9 100644 --- a/BTDToolbox/Main.cs +++ b/BTDToolbox/Main.cs @@ -17,7 +17,7 @@ namespace BTDToolbox public partial class Main : Form { //Form variables - public static string version = "Alpha 0.1.0"; + public static string version = "Alpha 0.1.1"; public static bool disableUpdates = false; private static Main toolbox; private static UpdateHandler update;