diff --git a/BTDToolbox/BTDToolbox.csproj b/BTDToolbox/BTDToolbox.csproj index 8e9e724..97c0aa2 100644 --- a/BTDToolbox/BTDToolbox.csproj +++ b/BTDToolbox/BTDToolbox.csproj @@ -33,18 +33,18 @@ 4 - - ..\packages\DotNetZip.1.13.5\lib\net40\DotNetZip.dll + + ..\packages\DotNetZip.1.13.7\lib\net40\DotNetZip.dll - - ..\packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll + + ..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll ..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll - ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll @@ -65,19 +65,29 @@ + + + + + + Form + + + BattlesPassManager.cs + Form @@ -90,6 +100,12 @@ CreditViewer.cs + + Form + + + EZ_Base.cs + Form @@ -132,15 +148,33 @@ UpdateChangelog.cs + + UserControl + + + JsonEditor_Instance.cs + + + Form + + + New_JsonEditor.cs + Form ZipForm.cs + + BattlesPassManager.cs + BGForm.cs + + EZ_Base.cs + EZCard_Editor.cs @@ -165,6 +199,12 @@ UpdateChangelog.cs + + JsonEditor_Instance.cs + + + New_JsonEditor.cs + ZipForm.cs diff --git a/BTDToolbox/Classes/BattlesPass_Class.cs b/BTDToolbox/Classes/BattlesPass_Class.cs new file mode 100644 index 0000000..13c0417 --- /dev/null +++ b/BTDToolbox/Classes/BattlesPass_Class.cs @@ -0,0 +1,57 @@ +// +// +// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do: +// +// using BTDToolbox.Classes; +// +// var battlesPassClass = BattlesPassClass.FromJson(jsonString); + +namespace BTDToolbox.Classes +{ + using System; + using System.Collections.Generic; + + using System.Globalization; + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + + public partial class BattlesPassClass + { + [JsonProperty("Versions")] + public VersionElement[] Versions { get; set; } + } + + public partial class VersionElement + { + [JsonProperty("Version")] + public VersionVersion Version { get; set; } + } + + public partial class VersionVersion + { + [JsonProperty("version number")] + public string VersionNumber { get; set; } + + [JsonProperty("Windows")] + public string Windows { get; set; } + + [JsonProperty("Mac")] + public string Mac { get; set; } + + [JsonProperty("Android")] + public string Android { get; set; } + + [JsonProperty("IOS")] + public string Ios { get; set; } + } + + public partial class BattlesPassClass + { + public static BattlesPassClass FromJson(string json) => JsonConvert.DeserializeObject(json, BTDToolbox.Classes.Converter.Settings); + } + + public static class Serialize + { + public static string ToJson(this BattlesPassClass self) => JsonConvert.SerializeObject(self, BTDToolbox.Classes.Converter.Settings); + } +} diff --git a/BTDToolbox/Classes/JsonEditorHandler.cs b/BTDToolbox/Classes/JsonEditorHandler.cs new file mode 100644 index 0000000..4c144c8 --- /dev/null +++ b/BTDToolbox/Classes/JsonEditorHandler.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BTDToolbox.Classes +{ + class JsonEditorHandler + { + public static New_JsonEditor jeditor; + + public static void ValidateEditor() + { + if (jeditor == null) + { + jeditor = new New_JsonEditor(); + jeditor.tabPages = new List(); + jeditor.tabFilePaths = new List(); + jeditor.userControls = new List(); + jeditor.Show(); + } + else if (jeditor.Visible == false) + { + jeditor.Show(); + } + } + public static void OpenFile(string path) + { + if (Serializer.Deserialize_Config().useExternalEditor == false) + { + ValidateEditor(); + if(jeditor.tabFilePaths.Contains(path)) + { + jeditor.tabControl1.SelectedIndex = jeditor.tabFilePaths.IndexOf(path); + } + else + { + jeditor.NewTab(path); + } + } + } + public static void OpenOriginalFile(string path) + { + string[] split = path.Split('\\'); + string filename = split[split.Length - 1]; + string backupProj = ""; + if (!path.Contains("\\Backups\\" + Main.gameName + "_BackupProject\\")) + backupProj = Environment.CurrentDirectory + "\\Backups\\" + Main.gameName + "_BackupProject\\" + path.Replace(Environment.CurrentDirectory, "").Replace(Serializer.Deserialize_Config().LastProject + "\\", ""); + else + { + backupProj = path; + if(jeditor.tabControl1.SelectedTab.Text == filename + New_JsonEditor.readOnlyName) + ConsoleHandler.appendNotice("You are already looking at the original " + filename.Replace(New_JsonEditor.readOnlyName, "")); + } + + if (File.Exists(backupProj)) + OpenFile(backupProj); + else + ConsoleHandler.appendLog_CanRepeat("Could not find file in backup project... Unable to view original file"); + } + public static void CloseFile(string path) + { + jeditor.CloseTab(path); + } + public static bool AreJsonErrors() + { + if(jeditor != null) + { + int i = 0; + bool isError = false; + foreach (var u in jeditor.userControls) + { + if (u.jsonError) + { + isError = true; + jeditor.tabControl1.SelectedIndex = i; + break; + } + i++; + } + if (isError) + return true; + } + return false; + } + } +} diff --git a/BTDToolbox/Classes/ProjectConfig.cs b/BTDToolbox/Classes/ProjectConfig.cs index 8d40a04..5f78bcd 100644 --- a/BTDToolbox/Classes/ProjectConfig.cs +++ b/BTDToolbox/Classes/ProjectConfig.cs @@ -15,6 +15,7 @@ public class ConfigFile public bool recentUpdate { get; set; } public bool useExternalEditor { get; set; } public string battlesPass { get; set; } + public bool disableUpdates { get; set; } //Project wide variables @@ -60,6 +61,7 @@ public class ConfigFile public int JSON_Editor_PosX { get; set; } public int JSON_Editor_PosY { get; set; } public float JSON_Editor_FontSize { get; set; } + public List JsonEditor_OpenedTabs { get; set; } } } } diff --git a/BTDToolbox/Classes/SerializeOps.cs b/BTDToolbox/Classes/SerializeOps.cs index 016bf6f..ec033ec 100644 --- a/BTDToolbox/Classes/SerializeOps.cs +++ b/BTDToolbox/Classes/SerializeOps.cs @@ -10,6 +10,7 @@ using static BTDToolbox.ProjectConfig; using static BTDToolbox.Main; using static BTDToolbox.JetForm; +using BTDToolbox.Classes; namespace BTDToolbox { @@ -35,19 +36,49 @@ public static void SaveSmallSettings(string formName, ConfigFile serialize_confi { cfg.battlesPass = ZipForm.rememberedPassword; } + if (formName == "disableUpdates") + { + cfg.disableUpdates = Main.disableUpdates; + } string output_Cfg = JsonConvert.SerializeObject(cfg, Formatting.Indented); StreamWriter serialize = new StreamWriter(Environment.CurrentDirectory + "\\settings.json", false); serialize.Write(output_Cfg); serialize.Close(); } + public static void SaveJSONEditor_Instance(JsonEditor_Instance jeditor, ConfigFile serialize_config) + { + var cfg = Serializer.Deserialize_Config(); + if(jeditor!= null) + { + cfg.JSON_Editor_FontSize = jeditor.Editor_TextBox.Font.Size; + string output_Cfg = JsonConvert.SerializeObject(cfg, Formatting.Indented); + StreamWriter serialize = new StreamWriter(Environment.CurrentDirectory + "\\settings.json", false); + serialize.Write(output_Cfg); + serialize.Close(); + } + } + public static void SaveJSONEditor_Tabs(ConfigFile cfg) + { + if (JsonEditorHandler.jeditor != null) + { + cfg.JsonEditor_OpenedTabs = JsonEditorHandler.jeditor.tabFilePaths; + } + else + cfg.JsonEditor_OpenedTabs = new List(); + + string output_Cfg = JsonConvert.SerializeObject(cfg, Formatting.Indented); + + StreamWriter serialize = new StreamWriter(Environment.CurrentDirectory + "\\settings.json", false); + serialize.Write(output_Cfg); + serialize.Close(); + } + public static void SaveConfig(Form frm, string formName, ConfigFile serialize_config) { var cfg = Serializer.Deserialize_Config(); - - if (formName == "game") { cfg.CurrentGame = gameName; @@ -108,7 +139,6 @@ public static void SaveConfig(Form frm, string formName, ConfigFile serialize_co cfg.JSON_Editor_SizeY = frm.Size.Height; cfg.JSON_Editor_PosX = frm.Location.X; cfg.JSON_Editor_PosY = frm.Location.Y; - cfg.JSON_Editor_FontSize = JsonEditor.jsonEditorFont;//frm.Font.Size; } if (formName == "updater") @@ -140,6 +170,9 @@ public static ConfigFile Deserialize_Config() programData.enableSplash = true; programData.recentUpdate = false; programData.useExternalEditor = false; + programData.disableUpdates = false; + + programData.JsonEditor_OpenedTabs = new List(); programData.BTD5_Directory = ""; diff --git a/BTDToolbox/Classes/Spritesheets/SpriteSheet_Handler.cs b/BTDToolbox/Classes/Spritesheets/SpriteSheet_Handler.cs new file mode 100644 index 0000000..f93b94c --- /dev/null +++ b/BTDToolbox/Classes/Spritesheets/SpriteSheet_Handler.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Xml.Linq; + +namespace BTDToolbox.Classes.Spritesheets +{ + class SpriteSheet_Handler + { + public void Extract(string filename, string elementName) + { + string[] split = filename.Split('\\'); + string[] fileSplit = split[split.Length - 1].Split('.'); + string file = fileSplit[0]; + string xmlPath = filename.Replace(split[split.Length-1], "") + "\\" + file + ".xml"; + + StreamReader str = new StreamReader(xmlPath); + //ConsoleHandler.appendLog_CanRepeat(str.ReadToEnd()); + XDocument xml = XDocument.Load(xmlPath); + //XDocument xml = XDocument.Parse(str.ReadToEnd()); + + var items = from item in xml.Descendants(elementName) + select new + { + Name = item.Attribute("name").Value, + Aw = Int32.Parse(item.Attribute("aw").Value), + Ah = Int32.Parse(item.Attribute("ah").Value), + Ax = Int32.Parse(item.Attribute("ax").Value), + Ay = Int32.Parse(item.Attribute("ay").Value), + W = Int32.Parse(item.Attribute("w").Value), + H = Int32.Parse(item.Attribute("h").Value), + X = Int32.Parse(item.Attribute("x").Value), + Y = Int32.Parse(item.Attribute("y").Value) + }; + + Bitmap spritesheet = new Bitmap(filename); + string extractpath = Environment.CurrentDirectory + "\\ExtractedSprites\\" + file; + if (!Directory.Exists(extractpath)) + Directory.CreateDirectory(extractpath); + foreach (var a in items) + { + if(a.Aw != 0 && a.Ah != 0) + { + Rectangle srcRect = new Rectangle(a.X, a.Y, a.W, a.H); + Bitmap sprite = (Bitmap)spritesheet.Clone(srcRect, spritesheet.PixelFormat); + + if (File.Exists(extractpath + "\\" + a.Name + ".png")) + File.Delete(extractpath + "\\" + a.Name + ".png"); + sprite.Save(extractpath + "\\" + a.Name + ".png"); + //Bitmap atlasImage = new Bitmap(filename); + //PixelFormat pixelFormat = atlasImage.PixelFormat; + //ExtractSprite2(atlasImage, pixelFormat, filename, file, a.Name, a.Aw, a.Ah, a.Ax, a.Ay, a.W, a.H, a.X, a.Y); + } + } + } + public Bitmap CropImage(Bitmap source, Rectangle section) + { + var bitmap = new Bitmap(section.Width, section.Height); + using (var g = Graphics.FromImage(bitmap)) + { + g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel); + return bitmap; + } + } + private void ExtractSprite2(Bitmap atlasImage, PixelFormat pixelFormat, string spritesheetPath, string filename, string name, int aw, int ah, int ax, int ay, int w, int h, int x, int y) + { + string extractpath = Environment.CurrentDirectory + "\\ExtractedSprites\\" + filename + "\\" + name + ".png"; + try + { + var CroppedImage = new Bitmap(w, h, pixelFormat); + // copy pixels over to avoid antialiasing or any other side effects of drawing + // the subimages to the output image using Graphics + for (int a = 0; a < w; a++) + for (int b = 0; b < h; b++) + CroppedImage.SetPixel(x, y, atlasImage.GetPixel(x + a, y + b)); + CroppedImage.Save(extractpath); + } + catch (Exception ex) + { + // handle the exception + } + } + private void ExtractSprite(string spritesheetPath, string filename, string name, int aw, int ah, int ax, int ay, int w, int h, int x, int y) + { + Bitmap source = new Bitmap(spritesheetPath.Replace(".xml", ".png")); + source.MakeTransparent(); + Rectangle section = new Rectangle(new Point(x, y), new Size(w, h)); + + /*MessageBox.Show(aw.ToString()); + MessageBox.Show(ah.ToString());*/ + System.Drawing.Bitmap finalImage = null; + finalImage = new System.Drawing.Bitmap(aw, ah); + + Bitmap image = null; + image = CropImage(source, section); + using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(finalImage)) + { + //set background color + g.Clear(System.Drawing.Color.Transparent); + g.DrawImage(image, + new System.Drawing.Rectangle(ax, ay, image.Width, image.Height)); + //offset += image.Width; + } + + if (!Directory.Exists(Environment.CurrentDirectory + "\\ExtractedSprites\\" + filename)) + Directory.CreateDirectory(Environment.CurrentDirectory + "\\ExtractedSprites\\" + filename); + string extractpath = Environment.CurrentDirectory + "\\ExtractedSprites\\" + filename + "\\" + name + ".png"; + if (File.Exists(extractpath)) + File.Delete(extractpath); + + image.Save(extractpath); + } + public void Compile() + { + + } + } +} diff --git a/BTDToolbox/Classes/SubTask_Reader.cs b/BTDToolbox/Classes/SubTask_Reader.cs new file mode 100644 index 0000000..03d515a --- /dev/null +++ b/BTDToolbox/Classes/SubTask_Reader.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BTDToolbox.Classes +{ + class SubTask_Reader + { + /*private void GetSubtaskNum() + { + string subtaskNum = JSON_Reader.GetSubtaskNum(CharIndex_UnderMouse, Editor_TextBox.Text); + if (subtaskNum != "" && subtaskNum != " " && subtaskNum != null) + { + ConsoleHandler.force_appendLog_CanRepeat("Subtask: [" + subtaskNum + " ]"); + } + else + { + ConsoleHandler.force_appendLog("Unable to detect subtask. Please try clicking somewhere else..."); + } + }*/ + } +} diff --git a/BTDToolbox/Classes/UpdateHandler.cs b/BTDToolbox/Classes/UpdateHandler.cs index 5be883a..d72a76a 100644 --- a/BTDToolbox/Classes/UpdateHandler.cs +++ b/BTDToolbox/Classes/UpdateHandler.cs @@ -55,7 +55,16 @@ public void HandleUpdates() private bool CheckForUpdates() { reader = new WebHandler(); - return reader.CheckForUpdate(gitURL, "toolbox2019: ", 0, Main.version); + try + { + return reader.CheckForUpdate(gitURL, "toolbox2019: ", 0, Main.version); + } + catch + { + ConsoleHandler.appendNotice("Something went wrong when checking for updates.. Failed to check for updates"); + return false; + } + } private void DownloadUpdate() { diff --git a/BTDToolbox/Console.cs b/BTDToolbox/Console.cs index 225d1a5..022b9eb 100644 --- a/BTDToolbox/Console.cs +++ b/BTDToolbox/Console.cs @@ -68,13 +68,20 @@ public void GetAnnouncement() { WebHandler web = new WebHandler(); string url = "https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/toolbox%20announcements"; - string answer = web.WaitOn_URL(url); - output_log.SelectionColor = Color.OrangeRed; + try + { + string answer = web.WaitOn_URL(url); + output_log.SelectionColor = Color.OrangeRed; - if (answer.Length > 0 && answer != null) - appendLog("Announcement: " + answer); - else - appendLog("Failed to read announcement..."); + if (answer.Length > 0 && answer != null) + appendLog("Announcement: " + answer); + else + appendLog("Failed to read announcement..."); + } + catch + { + appendNotice("Something went wrong.. Failed to read announcements..."); + } } public void appendNotice(string notice) { diff --git a/BTDToolbox/Extra Forms/BattlesPassManager.Designer.cs b/BTDToolbox/Extra Forms/BattlesPassManager.Designer.cs new file mode 100644 index 0000000..58fdf0a --- /dev/null +++ b/BTDToolbox/Extra Forms/BattlesPassManager.Designer.cs @@ -0,0 +1,277 @@ +namespace BTDToolbox.Extra_Forms +{ + partial class BattlesPassManager + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.Game_LB = new System.Windows.Forms.ListBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.Versions_CB = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.Password_TB = new System.Windows.Forms.RichTextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.Save_Button = new System.Windows.Forms.Button(); + this.Copy_Button = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.VersionNum_TB = new System.Windows.Forms.RichTextBox(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft YaHei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(179, 14); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(373, 35); + this.label1.TabIndex = 0; + this.label1.Text = "Battles Password Maganger"; + // + // Game_LB + // + this.Game_LB.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); + this.Game_LB.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.Game_LB.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Game_LB.ForeColor = System.Drawing.Color.White; + this.Game_LB.FormattingEnabled = true; + this.Game_LB.ItemHeight = 25; + this.Game_LB.Items.AddRange(new object[] { + "Windows", + "Android", + "IOS", + "Mac"}); + this.Game_LB.Location = new System.Drawing.Point(185, 124); + this.Game_LB.Name = "Game_LB"; + this.Game_LB.Size = new System.Drawing.Size(543, 175); + this.Game_LB.TabIndex = 1; + this.Game_LB.SelectedIndexChanged += new System.EventHandler(this.Game_LB_SelectedIndexChanged); + // + // panel1 + // + this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.panel1.Controls.Add(this.button2); + this.panel1.Controls.Add(this.button1); + this.panel1.Location = new System.Drawing.Point(-4, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(159, 465); + this.panel1.TabIndex = 2; + // + // button2 + // + this.button2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); + this.button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.button2.FlatAppearance.BorderSize = 0; + this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button2.Font = new System.Drawing.Font("Microsoft YaHei", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button2.ForeColor = System.Drawing.Color.White; + this.button2.Location = new System.Drawing.Point(3, 12); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(156, 46); + this.button2.TabIndex = 1; + this.button2.Text = "Passwords"; + this.button2.UseVisualStyleBackColor = false; + // + // button1 + // + this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); + this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.button1.FlatAppearance.BorderSize = 0; + this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button1.Font = new System.Drawing.Font("Microsoft YaHei", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.ForeColor = System.Drawing.Color.White; + this.button1.Location = new System.Drawing.Point(3, 12); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(156, 46); + this.button1.TabIndex = 0; + this.button1.Text = "New Pass"; + this.button1.UseVisualStyleBackColor = false; + this.button1.Visible = false; + // + // Versions_CB + // + this.Versions_CB.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Versions_CB.FormattingEnabled = true; + this.Versions_CB.ItemHeight = 20; + this.Versions_CB.Location = new System.Drawing.Point(185, 75); + this.Versions_CB.Name = "Versions_CB"; + this.Versions_CB.Size = new System.Drawing.Size(324, 28); + this.Versions_CB.TabIndex = 3; + this.Versions_CB.Text = "6.5.2"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft YaHei", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.ForeColor = System.Drawing.Color.White; + this.label2.Location = new System.Drawing.Point(181, 53); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(101, 19); + this.label2.TabIndex = 4; + this.label2.Text = "Battles version:"; + // + // Password_TB + // + this.Password_TB.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Password_TB.Location = new System.Drawing.Point(185, 339); + this.Password_TB.Multiline = false; + this.Password_TB.Name = "Password_TB"; + this.Password_TB.Size = new System.Drawing.Size(324, 35); + this.Password_TB.TabIndex = 5; + this.Password_TB.Text = ""; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft YaHei", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.ForeColor = System.Drawing.Color.White; + this.label3.Location = new System.Drawing.Point(181, 317); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(70, 19); + this.label3.TabIndex = 6; + this.label3.Text = "Password:"; + // + // Save_Button + // + this.Save_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); + this.Save_Button.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.Save_Button.FlatAppearance.BorderSize = 0; + this.Save_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.Save_Button.Font = new System.Drawing.Font("Microsoft YaHei", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Save_Button.ForeColor = System.Drawing.Color.White; + this.Save_Button.Location = new System.Drawing.Point(614, 339); + this.Save_Button.Name = "Save_Button"; + this.Save_Button.Size = new System.Drawing.Size(80, 35); + this.Save_Button.TabIndex = 7; + this.Save_Button.Text = "Save"; + this.Save_Button.UseVisualStyleBackColor = false; + this.Save_Button.Click += new System.EventHandler(this.Save_Button_Click); + // + // Copy_Button + // + this.Copy_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); + this.Copy_Button.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.Copy_Button.FlatAppearance.BorderSize = 0; + this.Copy_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.Copy_Button.Font = new System.Drawing.Font("Microsoft YaHei", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Copy_Button.ForeColor = System.Drawing.Color.White; + this.Copy_Button.Location = new System.Drawing.Point(528, 339); + this.Copy_Button.Name = "Copy_Button"; + this.Copy_Button.Size = new System.Drawing.Size(80, 35); + this.Copy_Button.TabIndex = 8; + this.Copy_Button.Text = "Copy"; + this.Copy_Button.UseVisualStyleBackColor = false; + // + // button5 + // + this.button5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); + this.button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.button5.FlatAppearance.BorderSize = 0; + this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button5.Font = new System.Drawing.Font("MingLiU-ExtB", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button5.ForeColor = System.Drawing.Color.White; + this.button5.Location = new System.Drawing.Point(515, 75); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(37, 30); + this.button5.TabIndex = 9; + this.button5.Text = "+"; + this.button5.UseVisualStyleBackColor = false; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft YaHei", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.ForeColor = System.Drawing.Color.White; + this.label4.Location = new System.Drawing.Point(596, 53); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(107, 19); + this.label4.TabIndex = 11; + this.label4.Text = "Version number"; + this.label4.Visible = false; + // + // VersionNum_TB + // + this.VersionNum_TB.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.VersionNum_TB.Location = new System.Drawing.Point(575, 74); + this.VersionNum_TB.Multiline = false; + this.VersionNum_TB.Name = "VersionNum_TB"; + this.VersionNum_TB.Size = new System.Drawing.Size(153, 35); + this.VersionNum_TB.TabIndex = 10; + this.VersionNum_TB.Text = ""; + this.VersionNum_TB.Visible = false; + // + // BattlesPassManager + // + 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(756, 406); + this.Controls.Add(this.label4); + this.Controls.Add(this.VersionNum_TB); + this.Controls.Add(this.button5); + this.Controls.Add(this.Copy_Button); + this.Controls.Add(this.Save_Button); + this.Controls.Add(this.label3); + this.Controls.Add(this.Password_TB); + this.Controls.Add(this.label2); + this.Controls.Add(this.Versions_CB); + this.Controls.Add(this.panel1); + this.Controls.Add(this.label1); + this.Controls.Add(this.Game_LB); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "BattlesPassManager"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "BTD Battles Password Manager"; + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ListBox Game_LB; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.ComboBox Versions_CB; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.RichTextBox Password_TB; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button Save_Button; + private System.Windows.Forms.Button Copy_Button; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.RichTextBox VersionNum_TB; + } +} \ No newline at end of file diff --git a/BTDToolbox/Extra Forms/BattlesPassManager.cs b/BTDToolbox/Extra Forms/BattlesPassManager.cs new file mode 100644 index 0000000..1a59f57 --- /dev/null +++ b/BTDToolbox/Extra Forms/BattlesPassManager.cs @@ -0,0 +1,71 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using BTDToolbox.Classes; + +namespace BTDToolbox.Extra_Forms +{ + public partial class BattlesPassManager : Form + { + string path = Environment.CurrentDirectory + "\\versions test.json"; + string json = ""; + public BattlesPassManager() + { + InitializeComponent(); + json = File.ReadAllText(path); + Game_LB.SelectedIndex = 0; + } + + private void Save_Button_Click(object sender, EventArgs e) + {/* + if(JSON_Reader.IsValidJson(json)) + { + var ver = BattlesPassClass.FromJson(json); + ver.Versions = new VersionElement[10]; + for (int i = 0; i < 10;i++) + { + ver.Versions[i].Version.VersionNumber = i.ToString(); + } + foreach (var a in ver.Versions) + { + ConsoleHandler.appendLog_CanRepeat(a.Version.VersionNumber); + } + } + else + { + ConsoleHandler.appendLog_CanRepeat("Invalid json"); + } + */ + } + + private void Game_LB_SelectedIndexChanged(object sender, EventArgs e) + { + if(Game_LB.SelectedIndex == 0) + { + Password_TB.Text = "EB9D43D2ECF10989"; + } + else if (Game_LB.SelectedIndex == 1) + { + Password_TB.Text = "EDB03D8CEE046D18"; + } + else if (Game_LB.SelectedIndex == 1) + { + Password_TB.Text = "913287551902D49F"; + } + else if (Game_LB.SelectedIndex == 1) + { + Password_TB.Text = "3A0620B4AB746982"; + } + } + } +} diff --git a/BTDToolbox/Extra Forms/BattlesPassManager.resx b/BTDToolbox/Extra Forms/BattlesPassManager.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BTDToolbox/Extra Forms/BattlesPassManager.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BTDToolbox/Extra Forms/CreditViewer.cs b/BTDToolbox/Extra Forms/CreditViewer.cs index 6b0ca42..4e59e40 100644 --- a/BTDToolbox/Extra Forms/CreditViewer.cs +++ b/BTDToolbox/Extra Forms/CreditViewer.cs @@ -33,6 +33,14 @@ public CreditViewer() : base() int height = 0; Label lbl = new Label(); lbl.Location = new Point(x, y); + if (line.StartsWith("#0")) + { + text = line.Substring(2); + size = 50; + height = 15; + x = 0; + lbl.Location = new Point(x, y + 10); + } if (line.StartsWith("#1")) { text = line.Substring(2); @@ -41,6 +49,14 @@ public CreditViewer() : base() x = 0; lbl.Location = new Point(x, y + 10); } + if (line.StartsWith("#2")) + { + text = line.Substring(2); + size = 20; + height = 10; + x = 0; + lbl.Location = new Point(x, y + 5); + } if (line.StartsWith("#L")) { text = line.Substring(2); diff --git a/BTDToolbox/Extra Forms/EZBloon_Editor.cs b/BTDToolbox/Extra Forms/EZBloon_Editor.cs index 0d1031f..61a8d5c 100644 --- a/BTDToolbox/Extra Forms/EZBloon_Editor.cs +++ b/BTDToolbox/Extra Forms/EZBloon_Editor.cs @@ -415,13 +415,8 @@ private CheckedListBox resetCheckedListBox(CheckedListBox checkedListBox) private void EasyTowerEditor_Shown(object sender, EventArgs e) { EZBloon_Opened = true; - string gameDir = ""; - if (game == "BTD5") - gameDir = Serializer.Deserialize_Config().BTD5_Directory; - else - gameDir = Serializer.Deserialize_Config().BTDB_Directory; - if (gameDir != null && gameDir != "") + if(Main.projName != "" && Main.projName != null) { string bloonPath = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BloonDefinitions"; var bloonFiles = Directory.GetFiles(bloonPath); @@ -470,7 +465,7 @@ private void EasyTowerEditor_Shown(object sender, EventArgs e) } else { - ConsoleHandler.force_appendNotice("You're game directory has not been set! You need to set your game Dir before continuing. You can do this by clicking the \"Help\" tab at the top, then clicking on \"Browse for game\""); + ConsoleHandler.force_appendNotice("You need to have a project opened to use this tool..."); this.Close(); } } @@ -606,18 +601,8 @@ private void EZBloon_Editor_KeyDown(object sender, KeyEventArgs e) private void OpenText_Button_Click(object sender, EventArgs e) { - if (Serializer.Deserialize_Config().useExternalEditor == false) - { - JsonEditor JsonWindow = new JsonEditor(path); - JsonWindow.MdiParent = Main.getInstance(); - JsonWindow.Show(); - this.Focus(); - } - else - { - string selectedFile = path; - Process.Start(selectedFile); - } + JsonEditorHandler.OpenFile(path); + this.Focus(); } private void EZBloon_Editor_FormClosed(object sender, FormClosedEventArgs e) diff --git a/BTDToolbox/Extra Forms/EZCard_Editor.Designer.cs b/BTDToolbox/Extra Forms/EZCard_Editor.Designer.cs index 2e32dff..6e66c7f 100644 --- a/BTDToolbox/Extra Forms/EZCard_Editor.Designer.cs +++ b/BTDToolbox/Extra Forms/EZCard_Editor.Designer.cs @@ -1533,9 +1533,9 @@ private void InitializeComponent() this.Controls.Add(this.CardFiles_ComboBox); this.Controls.Add(this.Save_Button); this.Controls.Add(this.Card_Label); - this.Controls.Add(this.TowerPanel); this.Controls.Add(this.Tower_Bloon_Panel); this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.TowerPanel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.KeyPreview = true; this.MaximizeBox = false; diff --git a/BTDToolbox/Extra Forms/EZCard_Editor.cs b/BTDToolbox/Extra Forms/EZCard_Editor.cs index 5841525..66408d6 100644 --- a/BTDToolbox/Extra Forms/EZCard_Editor.cs +++ b/BTDToolbox/Extra Forms/EZCard_Editor.cs @@ -416,8 +416,7 @@ private void EasyTowerEditor_Shown(object sender, EventArgs e) { if (game == "BTDB") { - string gameDir = Serializer.Deserialize_Config().BTDB_Directory; - if (gameDir != null && gameDir != "") + if (Main.projName != "" && Main.projName != null) { Game_Label.Text = "BTDB"; string cardPath = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BattleCardDefinitions"; @@ -455,7 +454,7 @@ private void EasyTowerEditor_Shown(object sender, EventArgs e) } else { - ConsoleHandler.force_appendNotice("You're game directory has not been set! You need to set your game Dir before continuing. You can do this by clicking the \"Help\" tab at the top, then clicking on \"Browse for game\""); + ConsoleHandler.force_appendNotice("You need to have a project opened to use this tool..."); this.Close(); } } @@ -536,49 +535,29 @@ private void OpenText_Button_Click(object sender, EventArgs e) } private void OpenInText() { - if (Serializer.Deserialize_Config().useExternalEditor == false) + string selectedCard = ""; + if (openStarterCard == true) + selectedCard = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BattleCardDefinitions\\" + StartingCards_LB.SelectedItem.ToString(); + + else if (openTower == true) { - string selectedCard = ""; - if (openStarterCard == true) - { - selectedCard = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BattleCardDefinitions\\" + StartingCards_LB.SelectedItem.ToString(); - } - else if (openTower == true) - { - if(card.Tower.TowerType != null) - { - selectedCard = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\TowerDefinitions\\" + card.Tower.TowerType + ".tower"; - } - else - { - ConsoleHandler.appendLog("This card doesn't have a specified tower type"); - } - } - else if (openBloon == true) - { - if (card.Bloon.BloonType != null) - { - selectedCard = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BloonDefinitions\\" + card.Bloon.BloonType + ".bloon"; - } - else - { - ConsoleHandler.appendLog("This card doesn't have a specified bloon type"); - } - } + if (card.Tower.TowerType != null) + selectedCard = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\TowerDefinitions\\" + card.Tower.TowerType + ".tower"; else - { - selectedCard = path; - } - JsonEditor JsonWindow = new JsonEditor(selectedCard); - JsonWindow.MdiParent = Main.getInstance(); - JsonWindow.Show(); - this.Focus(); + ConsoleHandler.appendLog("This card doesn't have a specified tower type"); } - else + else if (openBloon == true) { - string selectedFile = path; - Process.Start(selectedFile); + if (card.Bloon.BloonType != null) + selectedCard = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BloonDefinitions\\" + card.Bloon.BloonType + ".bloon"; + else + ConsoleHandler.appendLog("This card doesn't have a specified bloon type"); } + else + selectedCard = path; + + JsonEditorHandler.OpenFile(selectedCard); + this.Focus(); } private void EZBloon_Editor_FormClosed(object sender, FormClosedEventArgs e) { @@ -613,7 +592,7 @@ private void StartingCard_OpenText_Button_Click(object sender, EventArgs e) } Open_Panel.Visible = false; } - private void OpenInEZCard_Button_Click(object sender, EventArgs e) + private void OpenInEZCard_Button_Click(object sender, EventArgs e) { if (StartingCards_LB.SelectedIndices.Count == 1) { diff --git a/BTDToolbox/Extra Forms/EZ_Base.Designer.cs b/BTDToolbox/Extra Forms/EZ_Base.Designer.cs new file mode 100644 index 0000000..c531477 --- /dev/null +++ b/BTDToolbox/Extra Forms/EZ_Base.Designer.cs @@ -0,0 +1,295 @@ +namespace BTDToolbox.Extra_Forms +{ + partial class EZ_Base + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Type_Label = new System.Windows.Forms.Label(); + this.Save_Button = new System.Windows.Forms.Button(); + this.Files_ComboBox = new System.Windows.Forms.ComboBox(); + this.Panel1 = new System.Windows.Forms.Panel(); + this.OpenFile_Button = new System.Windows.Forms.Button(); + this.Game_Label = new System.Windows.Forms.Label(); + this.SwitchPanel_Button = new System.Windows.Forms.Button(); + this.GoToFile_Button = new System.Windows.Forms.Button(); + this.GoToFile_TB = new System.Windows.Forms.RichTextBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.PrevCard_Button = new System.Windows.Forms.Button(); + this.NextCard_Button = new System.Windows.Forms.Button(); + this.OpenFile_Panel = new System.Windows.Forms.Panel(); + this.OpenText_Button = new System.Windows.Forms.Button(); + this.OpenNewEZBase_Button = new System.Windows.Forms.Button(); + this.Panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.OpenFile_Panel.SuspendLayout(); + this.SuspendLayout(); + // + // Type_Label + // + this.Type_Label.AutoSize = true; + this.Type_Label.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.Type_Label.Font = new System.Drawing.Font("Microsoft YaHei UI", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Type_Label.ForeColor = System.Drawing.Color.White; + this.Type_Label.Location = new System.Drawing.Point(14, 18); + this.Type_Label.Name = "Type_Label"; + this.Type_Label.Size = new System.Drawing.Size(76, 35); + this.Type_Label.TabIndex = 3; + this.Type_Label.Text = "Type"; + // + // Save_Button + // + this.Save_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.Save_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.Save_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); + this.Save_Button.ForeColor = System.Drawing.Color.White; + this.Save_Button.Location = new System.Drawing.Point(890, 484); + this.Save_Button.Name = "Save_Button"; + this.Save_Button.Size = new System.Drawing.Size(164, 58); + this.Save_Button.TabIndex = 47; + this.Save_Button.Text = "Save"; + this.Save_Button.UseVisualStyleBackColor = false; + this.Save_Button.Click += new System.EventHandler(this.Save_Button_Click); + // + // Files_ComboBox + // + this.Files_ComboBox.DropDownHeight = 500; + this.Files_ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.Files_ComboBox.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Files_ComboBox.FormattingEnabled = true; + this.Files_ComboBox.IntegralHeight = false; + this.Files_ComboBox.ItemHeight = 19; + this.Files_ComboBox.Location = new System.Drawing.Point(24, 56); + this.Files_ComboBox.Name = "Files_ComboBox"; + this.Files_ComboBox.Size = new System.Drawing.Size(398, 27); + this.Files_ComboBox.TabIndex = 48; + this.Files_ComboBox.SelectedValueChanged += new System.EventHandler(this.Files_ComboBox_SelectedValueChanged); + // + // Panel1 + // + this.Panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.Panel1.Controls.Add(this.OpenFile_Button); + this.Panel1.Controls.Add(this.Game_Label); + this.Panel1.Location = new System.Drawing.Point(2, 50); + this.Panel1.Name = "Panel1"; + this.Panel1.Size = new System.Drawing.Size(1071, 413); + this.Panel1.TabIndex = 49; + // + // OpenFile_Button + // + this.OpenFile_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.OpenFile_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.OpenFile_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); + this.OpenFile_Button.ForeColor = System.Drawing.Color.White; + this.OpenFile_Button.Location = new System.Drawing.Point(426, 1); + this.OpenFile_Button.Name = "OpenFile_Button"; + this.OpenFile_Button.Size = new System.Drawing.Size(141, 34); + this.OpenFile_Button.TabIndex = 118; + this.OpenFile_Button.Text = "Open"; + this.OpenFile_Button.UseVisualStyleBackColor = false; + // + // Game_Label + // + this.Game_Label.AutoSize = true; + this.Game_Label.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.Game_Label.Font = new System.Drawing.Font("Microsoft YaHei UI", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Game_Label.ForeColor = System.Drawing.Color.White; + this.Game_Label.Location = new System.Drawing.Point(929, 4); + this.Game_Label.Name = "Game_Label"; + this.Game_Label.Size = new System.Drawing.Size(90, 35); + this.Game_Label.TabIndex = 117; + this.Game_Label.Text = "Game"; + // + // SwitchPanel_Button + // + this.SwitchPanel_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.SwitchPanel_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.SwitchPanel_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); + this.SwitchPanel_Button.ForeColor = System.Drawing.Color.White; + this.SwitchPanel_Button.Location = new System.Drawing.Point(720, 484); + this.SwitchPanel_Button.Name = "SwitchPanel_Button"; + this.SwitchPanel_Button.Size = new System.Drawing.Size(164, 58); + this.SwitchPanel_Button.TabIndex = 51; + this.SwitchPanel_Button.Text = "Page 2"; + this.SwitchPanel_Button.UseVisualStyleBackColor = false; + this.SwitchPanel_Button.Click += new System.EventHandler(this.SwitchPanel_Click); + // + // GoToFile_Button + // + this.GoToFile_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.GoToFile_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.GoToFile_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); + this.GoToFile_Button.ForeColor = System.Drawing.Color.White; + this.GoToFile_Button.Location = new System.Drawing.Point(937, 12); + this.GoToFile_Button.Name = "GoToFile_Button"; + this.GoToFile_Button.Size = new System.Drawing.Size(117, 32); + this.GoToFile_Button.TabIndex = 119; + this.GoToFile_Button.Text = "GoTo File"; + this.GoToFile_Button.UseVisualStyleBackColor = false; + // + // GoToFile_TB + // + this.GoToFile_TB.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); + this.GoToFile_TB.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.GoToFile_TB.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.GoToFile_TB.ForeColor = System.Drawing.Color.White; + this.GoToFile_TB.Location = new System.Drawing.Point(705, 17); + this.GoToFile_TB.Multiline = false; + this.GoToFile_TB.Name = "GoToFile_TB"; + this.GoToFile_TB.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; + this.GoToFile_TB.Size = new System.Drawing.Size(226, 24); + this.GoToFile_TB.TabIndex = 118; + this.GoToFile_TB.Text = ""; + // + // pictureBox1 + // + this.pictureBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.pictureBox1.Location = new System.Drawing.Point(-41, -26); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(1225, 74); + this.pictureBox1.TabIndex = 125; + this.pictureBox1.TabStop = false; + // + // PrevCard_Button + // + this.PrevCard_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.PrevCard_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.PrevCard_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.PrevCard_Button.ForeColor = System.Drawing.Color.White; + this.PrevCard_Button.Location = new System.Drawing.Point(306, 26); + this.PrevCard_Button.Name = "PrevCard_Button"; + this.PrevCard_Button.Size = new System.Drawing.Size(55, 28); + this.PrevCard_Button.TabIndex = 127; + this.PrevCard_Button.Text = "<<"; + this.PrevCard_Button.UseVisualStyleBackColor = false; + this.PrevCard_Button.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PrevCard_Button_MouseDown); + this.PrevCard_Button.MouseUp += new System.Windows.Forms.MouseEventHandler(this.PrevCard_Button_MouseUp); + // + // NextCard_Button + // + this.NextCard_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.NextCard_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.NextCard_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.NextCard_Button.ForeColor = System.Drawing.Color.White; + this.NextCard_Button.Location = new System.Drawing.Point(367, 26); + this.NextCard_Button.Name = "NextCard_Button"; + this.NextCard_Button.Size = new System.Drawing.Size(55, 28); + this.NextCard_Button.TabIndex = 126; + this.NextCard_Button.Text = ">>"; + this.NextCard_Button.UseVisualStyleBackColor = false; + this.NextCard_Button.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NextCard_Button_MouseDown); + this.NextCard_Button.MouseUp += new System.Windows.Forms.MouseEventHandler(this.NextCard_Button_MouseUp); + // + // OpenFile_Panel + // + this.OpenFile_Panel.Controls.Add(this.OpenText_Button); + this.OpenFile_Panel.Controls.Add(this.OpenNewEZBase_Button); + this.OpenFile_Panel.Location = new System.Drawing.Point(565, 37); + this.OpenFile_Panel.Name = "OpenFile_Panel"; + this.OpenFile_Panel.Size = new System.Drawing.Size(168, 70); + this.OpenFile_Panel.TabIndex = 119; + this.OpenFile_Panel.Visible = false; + // + // OpenText_Button + // + this.OpenText_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.OpenText_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.OpenText_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); + this.OpenText_Button.ForeColor = System.Drawing.Color.White; + this.OpenText_Button.Location = new System.Drawing.Point(3, 0); + this.OpenText_Button.Name = "OpenText_Button"; + this.OpenText_Button.Size = new System.Drawing.Size(164, 34); + this.OpenText_Button.TabIndex = 77; + this.OpenText_Button.Text = "Open in Text"; + this.OpenText_Button.UseVisualStyleBackColor = false; + this.OpenText_Button.Click += new System.EventHandler(this.OpenText_Button_Click); + // + // OpenNewEZBase_Button + // + this.OpenNewEZBase_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + this.OpenNewEZBase_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.OpenNewEZBase_Button.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F); + this.OpenNewEZBase_Button.ForeColor = System.Drawing.Color.White; + this.OpenNewEZBase_Button.Location = new System.Drawing.Point(3, 35); + this.OpenNewEZBase_Button.Name = "OpenNewEZBase_Button"; + this.OpenNewEZBase_Button.Size = new System.Drawing.Size(164, 35); + this.OpenNewEZBase_Button.TabIndex = 76; + this.OpenNewEZBase_Button.Text = "Open in EZ Base"; + this.OpenNewEZBase_Button.UseVisualStyleBackColor = false; + this.OpenNewEZBase_Button.Click += new System.EventHandler(this.OpenNewEZBase_Button_Click); + // + // EZ_Base + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(35)))), ((int)(((byte)(35)))), ((int)(((byte)(35))))); + this.ClientSize = new System.Drawing.Size(1066, 554); + this.Controls.Add(this.OpenFile_Panel); + this.Controls.Add(this.PrevCard_Button); + this.Controls.Add(this.NextCard_Button); + this.Controls.Add(this.GoToFile_Button); + this.Controls.Add(this.GoToFile_TB); + this.Controls.Add(this.SwitchPanel_Button); + this.Controls.Add(this.Files_ComboBox); + this.Controls.Add(this.Save_Button); + this.Controls.Add(this.Type_Label); + this.Controls.Add(this.Panel1); + this.Controls.Add(this.pictureBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "EZ_Base"; + this.Text = "EZ Base"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.EZ_Base_FormClosed); + this.Shown += new System.EventHandler(this.EZ_Base_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.EZ_Base_KeyDown); + this.Panel1.ResumeLayout(false); + this.Panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.OpenFile_Panel.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Label Type_Label; + private System.Windows.Forms.Button Save_Button; + private System.Windows.Forms.ComboBox Files_ComboBox; + private System.Windows.Forms.Panel Panel1; + private System.Windows.Forms.Button SwitchPanel_Button; + private System.Windows.Forms.Label Game_Label; + private System.Windows.Forms.Button GoToFile_Button; + private System.Windows.Forms.RichTextBox GoToFile_TB; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button PrevCard_Button; + private System.Windows.Forms.Button NextCard_Button; + private System.Windows.Forms.Button OpenFile_Button; + private System.Windows.Forms.Panel OpenFile_Panel; + private System.Windows.Forms.Button OpenText_Button; + private System.Windows.Forms.Button OpenNewEZBase_Button; + } +} \ No newline at end of file diff --git a/BTDToolbox/Extra Forms/EZ_Base.cs b/BTDToolbox/Extra Forms/EZ_Base.cs new file mode 100644 index 0000000..19ba606 --- /dev/null +++ b/BTDToolbox/Extra Forms/EZ_Base.cs @@ -0,0 +1,241 @@ +using BTDToolbox.Classes; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Documents; +using System.Windows.Forms; +using Tower_Class; + +namespace BTDToolbox.Extra_Forms +{ + public partial class EZ_Base : Form + { + public string json { get; set; } + public string path { get; set; } + + string gameDir = ""; + int autoscrollcount = 0; + bool mouseDown = false; + System.Threading.Thread thread; + string jetDir = ""; + public static bool EZTBase_Opened = false; + + + string game = Serializer.Deserialize_Config().CurrentGame; + + public EZ_Base() + { + InitializeComponent(); + Set_ClickEvents(); + + if (game == "BTD5") + { + Game_Label.Text = "BTD5"; + gameDir = Serializer.Deserialize_Config().BTD5_Directory; + } + else + { + Game_Label.Text = "BTDB"; + gameDir = Serializer.Deserialize_Config().BTDB_Directory; + } + + if (gameDir == null || gameDir == "") + { + ConsoleHandler.force_appendNotice("You're game directory has not been set! You need to set your game Dir before continuing. You can do this by clicking the \"Help\" tab at the top, then clicking on \"Browse for game\""); + this.Close(); + } + } + public void CreateJSONObject(string filepath) + { + string json = File.ReadAllText(filepath); + if (JSON_Reader.IsValidJson(json)) + { + ResetUI(); + //Populate UI + } + else + { + ConsoleHandler.force_appendLog_CanRepeat("The file you are trying to load has invalid JSON, and as a result, can't be loaded..."); + } + + } + private void PopulateUI() + { + //if json object not invalid + //{ + + //} + } + private void ResetUI() + { + + } + private void SaveFile() + { + bool error = false; + + /*try { newCard.DiscardCost = Int64.Parse(DiscardCost_TB.Text); } + catch (FormatException e) { ConsoleHandler.force_appendNotice("Your discard cost is not a valid number..."); error = true; }*/ + + /*if (!error) + { + var y = Tower_Class.Serialize.ToJson(artist); + File.WriteAllText(path, y); + }*/ + } + + private void CardAutoScroll(string direction) + { + Invoke((MethodInvoker)delegate { + if (direction == "back") + { + if (Files_ComboBox.SelectedIndex - 1 >= 0) + { + Files_ComboBox.SelectedIndex = Files_ComboBox.SelectedIndex - 1; + } + } + else + { + if (Files_ComboBox.SelectedIndex + 1 <= Files_ComboBox.Items.Count - 1) + { + Files_ComboBox.SelectedIndex = Files_ComboBox.SelectedIndex + 1; + } + } + + }); + int sleeptime = 125; + if (autoscrollcount < 3) + sleeptime = 125; + else if (autoscrollcount > 3 && autoscrollcount < 8) + sleeptime = 90; + else if (autoscrollcount > 8 && autoscrollcount < 15) + sleeptime = 75; + else if (autoscrollcount > 15 && autoscrollcount < 22) + sleeptime = 50; + else if (autoscrollcount > 22) + sleeptime = 30; + + System.Threading.Thread.Sleep(sleeptime); + if (mouseDown == true) + { + autoscrollcount++; + CardAutoScroll(direction); + } + } + private void Set_ClickEvents() + { + this.MouseClick += Close_Panels; + + Type_Label.MouseClick += Close_Panels; + Files_ComboBox.MouseClick += Close_Panels; + OpenText_Button.MouseClick += Close_Panels; + OpenNewEZBase_Button.MouseClick += Close_Panels; + GoToFile_Button.MouseClick += Close_Panels; + GoToFile_TB.MouseClick += Close_Panels; + Save_Button.MouseClick += Close_Panels; + Panel1.MouseClick += Close_Panels; + } + private void Close_Panels(object sender, EventArgs e) + { + OpenFile_Panel.Hide(); + } + // + // Handling UI changes + // + private void EZ_Base_Shown(object sender, EventArgs e) + { + EZTBase_Opened = true; + + string towersPath = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\TowerDefinitions"; + var towerFiles = Directory.GetFiles(towersPath); + foreach (string file in towerFiles) + { + string[] split = file.Split('\\'); + string filename = split[split.Length - 1].Replace("\\", ""); + + if (!Files_ComboBox.Items.Contains(filename)) + Files_ComboBox.Items.Add(filename); + + if (file == path) + Files_ComboBox.SelectedItem = Files_ComboBox.Items[Files_ComboBox.Items.Count - 1]; + } + } + private void Files_ComboBox_SelectedValueChanged(object sender, EventArgs e) + { + path = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + jetDir + "\\" + Files_ComboBox.SelectedItem; + CreateJSONObject(path); + } + private void Save_Button_Click(object sender, EventArgs e) + { + SaveFile(); + ConsoleHandler.appendLog_CanRepeat("Saved " + Files_ComboBox.SelectedItem.ToString()); + } + private void SwitchPanel_Click(object sender, EventArgs e) + { + if(Panel1.Visible) + { + Panel1.Visible = false; + SwitchPanel_Button.Text = "Tower"; + } + else if (!Panel1.Visible) + { + Panel1.Visible = true; + SwitchPanel_Button.Text = "Upgrades"; + } + } + private void OpenNewEZBase_Button_Click(object sender, EventArgs e) + { + + } + private void OpenText_Button_Click(object sender, EventArgs e) + { + JsonEditorHandler.OpenFile(path); + this.Focus(); + } + private void EZ_Base_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.F5) + { + SaveFile(); + ConsoleHandler.appendLog_CanRepeat("Saved " + Files_ComboBox.SelectedItem.ToString()); + GeneralMethods.CompileJet("launch"); + ConsoleHandler.appendLog_CanRepeat("Launching " + game); + } + } + private void EZ_Base_FormClosed(object sender, FormClosedEventArgs e) + { + EZTBase_Opened = false; + } + private void PrevCard_Button_MouseDown(object sender, MouseEventArgs e) + { + mouseDown = true; + thread = new System.Threading.Thread(delegate () { CardAutoScroll("back"); }); + thread.Start(); + } + private void PrevCard_Button_MouseUp(object sender, MouseEventArgs e) + { + mouseDown = false; + autoscrollcount = 0; + thread.Abort(); + } + private void NextCard_Button_MouseDown(object sender, MouseEventArgs e) + { + mouseDown = true; + thread = new System.Threading.Thread(delegate () { CardAutoScroll("forward"); }); + thread.Start(); + } + private void NextCard_Button_MouseUp(object sender, MouseEventArgs e) + { + mouseDown = false; + autoscrollcount = 0; + thread.Abort(); + } + } +} diff --git a/BTDToolbox/Extra Forms/EZ_Base.resx b/BTDToolbox/Extra Forms/EZ_Base.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BTDToolbox/Extra Forms/EZ_Base.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BTDToolbox/Extra Forms/EasyTowerEditor.cs b/BTDToolbox/Extra Forms/EasyTowerEditor.cs index def189f..bf35547 100644 --- a/BTDToolbox/Extra Forms/EasyTowerEditor.cs +++ b/BTDToolbox/Extra Forms/EasyTowerEditor.cs @@ -436,18 +436,15 @@ private void EasyTowerEditor_Shown(object sender, EventArgs e) { finishedLoading = true; firstLoad = true; - string gameDir = ""; if (game == "BTD5") { - gameDir = Serializer.Deserialize_Config().BTD5_Directory; - loc_Path = gameDir + "\\Assets\\Loc\\English.xml"; + loc_Path = Serializer.Deserialize_Config().BTD5_Directory + "\\Assets\\Loc\\English.xml"; } else { - gameDir = Serializer.Deserialize_Config().BTDB_Directory; + loc_Path = ""; } - - if (gameDir != null && gameDir != "") + if (Main.projName != "" && Main.projName != null) { string towersPath = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\TowerDefinitions"; var towerFiles = Directory.GetFiles(towersPath); @@ -468,7 +465,7 @@ private void EasyTowerEditor_Shown(object sender, EventArgs e) } else { - ConsoleHandler.force_appendNotice("You're game directory has not been set! You need to set your game Dir before continuing. You can do this by clicking the \"Help\" tab at the top, then clicking on \"Browse for game\""); + ConsoleHandler.force_appendNotice("You need to have a project opened to use this tool..."); this.Close(); } } @@ -879,18 +876,8 @@ private void UsePlacementRadius_Checkbox_CheckedChanged(object sender, EventArgs private void OpenText_Button_Click(object sender, EventArgs e) { - if (Serializer.Deserialize_Config().useExternalEditor == false) - { - JsonEditor JsonWindow = new JsonEditor(path); - JsonWindow.MdiParent = Main.getInstance(); - JsonWindow.Show(); - this.Focus(); - } - else - { - string selectedFile = path; - Process.Start(selectedFile); - } + JsonEditorHandler.OpenFile(path); + this.Focus(); } private void EasyTowerEditor_KeyDown(object sender, KeyEventArgs e) diff --git a/BTDToolbox/Extra Forms/SettingsWindow.Designer.cs b/BTDToolbox/Extra Forms/SettingsWindow.Designer.cs index 505fe0c..e8342b6 100644 --- a/BTDToolbox/Extra Forms/SettingsWindow.Designer.cs +++ b/BTDToolbox/Extra Forms/SettingsWindow.Designer.cs @@ -31,6 +31,7 @@ private new void InitializeComponent() this.EnableSplash = new System.Windows.Forms.CheckBox(); this.Save_Button = new System.Windows.Forms.Button(); this.useExternalEditor = new System.Windows.Forms.CheckBox(); + this.DisableUpdates_CB = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.titleSeperator)).BeginInit(); this.titleSeperator.Panel1.SuspendLayout(); this.titleSeperator.Panel2.SuspendLayout(); @@ -48,6 +49,7 @@ private new void InitializeComponent() // // contentPanel // + this.contentPanel.Controls.Add(this.DisableUpdates_CB); this.contentPanel.Controls.Add(this.useExternalEditor); this.contentPanel.Controls.Add(this.Save_Button); this.contentPanel.Controls.Add(this.EnableSplash); @@ -94,6 +96,18 @@ private new void InitializeComponent() this.useExternalEditor.Text = "Use External Text Editor"; this.useExternalEditor.UseVisualStyleBackColor = true; // + // DisableUpdates_CB + // + this.DisableUpdates_CB.AutoSize = true; + this.DisableUpdates_CB.Font = new System.Drawing.Font("Microsoft YaHei", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.DisableUpdates_CB.ForeColor = System.Drawing.Color.White; + this.DisableUpdates_CB.Location = new System.Drawing.Point(15, 82); + this.DisableUpdates_CB.Name = "DisableUpdates_CB"; + this.DisableUpdates_CB.Size = new System.Drawing.Size(315, 24); + this.DisableUpdates_CB.TabIndex = 4; + this.DisableUpdates_CB.Text = "Disable updates (NOT RECOMMENDED)"; + this.DisableUpdates_CB.UseVisualStyleBackColor = true; + // // SettingsWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -117,5 +131,6 @@ private new void InitializeComponent() private System.Windows.Forms.CheckBox EnableSplash; private System.Windows.Forms.Button Save_Button; private System.Windows.Forms.CheckBox useExternalEditor; + private System.Windows.Forms.CheckBox DisableUpdates_CB; } } \ No newline at end of file diff --git a/BTDToolbox/Extra Forms/SettingsWindow.cs b/BTDToolbox/Extra Forms/SettingsWindow.cs index e14c5c7..7d1890d 100644 --- a/BTDToolbox/Extra Forms/SettingsWindow.cs +++ b/BTDToolbox/Extra Forms/SettingsWindow.cs @@ -28,6 +28,8 @@ private void Setup() EnableSplash.CheckState = CheckState.Checked; if (projectData.useExternalEditor == true) useExternalEditor.CheckState = CheckState.Checked; + if (projectData.disableUpdates == true) + DisableUpdates_CB.CheckState = CheckState.Checked; } private void Save_Button_Click(object sender, EventArgs e) { @@ -48,11 +50,19 @@ private void Save_Button_Click(object sender, EventArgs e) { Program.enableSplash = false; } + if (DisableUpdates_CB.Checked) + { + Main.disableUpdates = true; + } + else + { + Main.disableUpdates = false; + } Serializer.SaveSmallSettings("splash", projectData); + Serializer.SaveSmallSettings("disableUpdates", projectData); Serializer.SaveSmallSettings("external editor", projectData); - - ConsoleHandler.appendLog("Settings saved!!!"); + ConsoleHandler.appendLog_CanRepeat("Settings saved!!!"); } } } diff --git a/BTDToolbox/JetForm.Designer.cs b/BTDToolbox/JetForm.Designer.cs index 9b5a9d8..e033a6c 100644 --- a/BTDToolbox/JetForm.Designer.cs +++ b/BTDToolbox/JetForm.Designer.cs @@ -60,6 +60,31 @@ private new void InitializeComponent() this.saveButton = new System.Windows.Forms.Button(); this.listView1 = new System.Windows.Forms.ListView(); this.name_column = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.OneSelected_CM = new System.Windows.Forms.ContextMenuStrip(this.components); + this.openFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ezTools_Seperator = new System.Windows.Forms.ToolStripSeparator(); + this.ezTower_CMButton = new System.Windows.Forms.ToolStripMenuItem(); + this.ezBloon_CMButton = new System.Windows.Forms.ToolStripMenuItem(); + this.ezCard_CMButton = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.viewOriginal_CMButton = new System.Windows.Forms.ToolStripMenuItem(); + this.RestoreToOriginal_CMButton = new System.Windows.Forms.ToolStripMenuItem(); + this.NoneSelected_CM = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.MultiSelected_CM = new System.Windows.Forms.ContextMenuStrip(this.components); + this.openFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); + this.viewOriginalToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.restoreToOriginalToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.titleSeperator)).BeginInit(); this.titleSeperator.Panel1.SuspendLayout(); this.titleSeperator.Panel2.SuspendLayout(); @@ -71,6 +96,9 @@ private new void InitializeComponent() this.fileViewContainer.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.findPanel.SuspendLayout(); + this.OneSelected_CM.SuspendLayout(); + this.NoneSelected_CM.SuspendLayout(); + this.MultiSelected_CM.SuspendLayout(); this.SuspendLayout(); // // titleSeperator @@ -161,39 +189,39 @@ private new void InitializeComponent() this.openToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.Open_Proj_Dir}); this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(158, 22); this.openToolStripMenuItem.Text = "Open"; // // Open_Proj_Dir // this.Open_Proj_Dir.Name = "Open_Proj_Dir"; - this.Open_Proj_Dir.Size = new System.Drawing.Size(180, 22); + this.Open_Proj_Dir.Size = new System.Drawing.Size(162, 22); this.Open_Proj_Dir.Text = "Project Directory"; this.Open_Proj_Dir.Click += new System.EventHandler(this.Open_Proj_Dir_Click); // // Save_ToolStrip // this.Save_ToolStrip.Name = "Save_ToolStrip"; - this.Save_ToolStrip.Size = new System.Drawing.Size(180, 22); + this.Save_ToolStrip.Size = new System.Drawing.Size(158, 22); this.Save_ToolStrip.Text = "Save"; this.Save_ToolStrip.Click += new System.EventHandler(this.Save_ToolStrip_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(155, 6); // // ValidateAllFiles // this.ValidateAllFiles.Name = "ValidateAllFiles"; - this.ValidateAllFiles.Size = new System.Drawing.Size(180, 22); + this.ValidateAllFiles.Size = new System.Drawing.Size(158, 22); this.ValidateAllFiles.Text = "Validate All Files"; this.ValidateAllFiles.Click += new System.EventHandler(this.ValidateAllFiles_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(155, 6); // // retToolStripMenuItem // @@ -201,7 +229,7 @@ private new void InitializeComponent() this.makeBackupOfProjectToolStripMenuItem, this.revertToBackupToolStripMenuItem1}); this.retToolStripMenuItem.Name = "retToolStripMenuItem"; - this.retToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.retToolStripMenuItem.Size = new System.Drawing.Size(158, 22); this.retToolStripMenuItem.Text = "Backup project"; this.retToolStripMenuItem.Visible = false; // @@ -220,26 +248,26 @@ private new void InitializeComponent() // revertToBackupToolStripMenuItem // this.revertToBackupToolStripMenuItem.Name = "revertToBackupToolStripMenuItem"; - this.revertToBackupToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.revertToBackupToolStripMenuItem.Size = new System.Drawing.Size(158, 22); this.revertToBackupToolStripMenuItem.Text = "Remake Project"; this.revertToBackupToolStripMenuItem.Visible = false; // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(155, 6); // // RenameProject_Button // this.RenameProject_Button.Name = "RenameProject_Button"; - this.RenameProject_Button.Size = new System.Drawing.Size(180, 22); + this.RenameProject_Button.Size = new System.Drawing.Size(158, 22); this.RenameProject_Button.Text = "Rename Project"; this.RenameProject_Button.Click += new System.EventHandler(this.RenameProject_Button_Click); // // DeleteProject_Button // this.DeleteProject_Button.Name = "DeleteProject_Button"; - this.DeleteProject_Button.Size = new System.Drawing.Size(180, 22); + this.DeleteProject_Button.Size = new System.Drawing.Size(158, 22); this.DeleteProject_Button.Text = "Delete Project"; this.DeleteProject_Button.Click += new System.EventHandler(this.DeleteProject_Button_Click); // @@ -342,7 +370,6 @@ private new void InitializeComponent() this.treeView1.SelectedImageIndex = 0; this.treeView1.Size = new System.Drawing.Size(251, 380); this.treeView1.TabIndex = 0; - this.treeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TreeView_CheckHotkey); // // lastSelectedLabel // @@ -384,6 +411,7 @@ private new void InitializeComponent() // // listView1 // + this.listView1.AllowDrop = true; this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); @@ -406,6 +434,180 @@ private new void InitializeComponent() this.name_column.Text = "Name"; this.name_column.Width = 517; // + // OneSelected_CM + // + this.OneSelected_CM.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.openFileToolStripMenuItem, + this.toolStripMenuItem4, + this.toolStripSeparator6, + this.copyToolStripMenuItem, + this.renameToolStripMenuItem, + this.deleteToolStripMenuItem, + this.ezTools_Seperator, + this.ezTower_CMButton, + this.ezBloon_CMButton, + this.ezCard_CMButton, + this.toolStripSeparator4, + this.viewOriginal_CMButton, + this.RestoreToOriginal_CMButton}); + this.OneSelected_CM.Name = "OneSelected_CM"; + this.OneSelected_CM.Size = new System.Drawing.Size(184, 242); + this.OneSelected_CM.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.OneSelected_CM_ItemClicked); + // + // openFileToolStripMenuItem + // + this.openFileToolStripMenuItem.Name = "openFileToolStripMenuItem"; + this.openFileToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.openFileToolStripMenuItem.Text = "Open File"; + // + // toolStripMenuItem4 + // + this.toolStripMenuItem4.Name = "toolStripMenuItem4"; + this.toolStripMenuItem4.Size = new System.Drawing.Size(183, 22); + this.toolStripMenuItem4.Text = "Open in File Explorer"; + // + // toolStripSeparator6 + // + this.toolStripSeparator6.Name = "toolStripSeparator6"; + this.toolStripSeparator6.Size = new System.Drawing.Size(180, 6); + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.copyToolStripMenuItem.Text = "Copy"; + // + // renameToolStripMenuItem + // + this.renameToolStripMenuItem.Name = "renameToolStripMenuItem"; + this.renameToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.renameToolStripMenuItem.Text = "Rename"; + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.deleteToolStripMenuItem.Text = "Delete"; + // + // ezTools_Seperator + // + this.ezTools_Seperator.Name = "ezTools_Seperator"; + this.ezTools_Seperator.Size = new System.Drawing.Size(180, 6); + // + // ezTower_CMButton + // + this.ezTower_CMButton.Name = "ezTower_CMButton"; + this.ezTower_CMButton.Size = new System.Drawing.Size(183, 22); + this.ezTower_CMButton.Text = "Open with EZ Tower"; + this.ezTower_CMButton.Visible = false; + // + // ezBloon_CMButton + // + this.ezBloon_CMButton.Name = "ezBloon_CMButton"; + this.ezBloon_CMButton.Size = new System.Drawing.Size(183, 22); + this.ezBloon_CMButton.Text = "Open with EZ Bloon"; + this.ezBloon_CMButton.Visible = false; + // + // ezCard_CMButton + // + this.ezCard_CMButton.Name = "ezCard_CMButton"; + this.ezCard_CMButton.Size = new System.Drawing.Size(183, 22); + this.ezCard_CMButton.Text = "Open with EZ Card"; + this.ezCard_CMButton.Visible = false; + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(180, 6); + // + // viewOriginal_CMButton + // + this.viewOriginal_CMButton.Name = "viewOriginal_CMButton"; + this.viewOriginal_CMButton.Size = new System.Drawing.Size(183, 22); + this.viewOriginal_CMButton.Text = "View original"; + // + // RestoreToOriginal_CMButton + // + this.RestoreToOriginal_CMButton.Name = "RestoreToOriginal_CMButton"; + this.RestoreToOriginal_CMButton.Size = new System.Drawing.Size(183, 22); + this.RestoreToOriginal_CMButton.Text = "Restore to original"; + // + // NoneSelected_CM + // + this.NoneSelected_CM.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addToolStripMenuItem, + this.pasteToolStripMenuItem, + this.selectAllToolStripMenuItem}); + this.NoneSelected_CM.Name = "NoneSelected_CM"; + this.NoneSelected_CM.Size = new System.Drawing.Size(121, 70); + this.NoneSelected_CM.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.NoneSelected_CM_ItemClicked); + // + // addToolStripMenuItem + // + this.addToolStripMenuItem.Name = "addToolStripMenuItem"; + this.addToolStripMenuItem.Size = new System.Drawing.Size(120, 22); + this.addToolStripMenuItem.Text = "Add"; + // + // pasteToolStripMenuItem + // + this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; + this.pasteToolStripMenuItem.Size = new System.Drawing.Size(120, 22); + this.pasteToolStripMenuItem.Text = "Paste"; + // + // selectAllToolStripMenuItem + // + this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; + this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(120, 22); + this.selectAllToolStripMenuItem.Text = "Select all"; + // + // MultiSelected_CM + // + this.MultiSelected_CM.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.openFilesToolStripMenuItem, + this.copyToolStripMenuItem1, + this.deleteToolStripMenuItem1, + this.toolStripSeparator7, + this.viewOriginalToolStripMenuItem1, + this.restoreToOriginalToolStripMenuItem1}); + this.MultiSelected_CM.Name = "MultiSelected_CM"; + this.MultiSelected_CM.Size = new System.Drawing.Size(171, 120); + this.MultiSelected_CM.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.MultiSelected_CM_ItemClicked); + // + // openFilesToolStripMenuItem + // + this.openFilesToolStripMenuItem.Name = "openFilesToolStripMenuItem"; + this.openFilesToolStripMenuItem.Size = new System.Drawing.Size(170, 22); + this.openFilesToolStripMenuItem.Text = "Open Files"; + // + // copyToolStripMenuItem1 + // + this.copyToolStripMenuItem1.Name = "copyToolStripMenuItem1"; + this.copyToolStripMenuItem1.Size = new System.Drawing.Size(170, 22); + this.copyToolStripMenuItem1.Text = "Copy"; + // + // deleteToolStripMenuItem1 + // + this.deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1"; + this.deleteToolStripMenuItem1.Size = new System.Drawing.Size(170, 22); + this.deleteToolStripMenuItem1.Text = "Delete"; + // + // toolStripSeparator7 + // + this.toolStripSeparator7.Name = "toolStripSeparator7"; + this.toolStripSeparator7.Size = new System.Drawing.Size(167, 6); + // + // viewOriginalToolStripMenuItem1 + // + this.viewOriginalToolStripMenuItem1.Name = "viewOriginalToolStripMenuItem1"; + this.viewOriginalToolStripMenuItem1.Size = new System.Drawing.Size(170, 22); + this.viewOriginalToolStripMenuItem1.Text = "View original"; + // + // restoreToOriginalToolStripMenuItem1 + // + this.restoreToOriginalToolStripMenuItem1.Name = "restoreToOriginalToolStripMenuItem1"; + this.restoreToOriginalToolStripMenuItem1.Size = new System.Drawing.Size(170, 22); + this.restoreToOriginalToolStripMenuItem1.Text = "Restore to original"; + // // JetForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -418,6 +620,7 @@ private new void InitializeComponent() this.Load += new System.EventHandler(this.JetForm_Load); this.Shown += new System.EventHandler(this.JetForm_Shown); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.JetForm_KeyDown); + this.Controls.SetChildIndex(this.titleSeperator, 0); this.titleSeperator.Panel1.ResumeLayout(false); this.titleSeperator.Panel1.PerformLayout(); this.titleSeperator.Panel2.ResumeLayout(false); @@ -434,6 +637,9 @@ private new void InitializeComponent() this.toolStrip1.PerformLayout(); this.findPanel.ResumeLayout(false); this.findPanel.PerformLayout(); + this.OneSelected_CM.ResumeLayout(false); + this.NoneSelected_CM.ResumeLayout(false); + this.MultiSelected_CM.ResumeLayout(false); this.ResumeLayout(false); } @@ -470,5 +676,30 @@ private new void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem DeleteProject_Button; private System.Windows.Forms.ToolStripMenuItem ValidateAllFiles; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ContextMenuStrip OneSelected_CM; + private System.Windows.Forms.ContextMenuStrip NoneSelected_CM; + private System.Windows.Forms.ContextMenuStrip MultiSelected_CM; + private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem renameToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator ezTools_Seperator; + private System.Windows.Forms.ToolStripMenuItem ezTower_CMButton; + private System.Windows.Forms.ToolStripMenuItem ezBloon_CMButton; + private System.Windows.Forms.ToolStripMenuItem ezCard_CMButton; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem viewOriginal_CMButton; + private System.Windows.Forms.ToolStripMenuItem RestoreToOriginal_CMButton; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; + private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openFilesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem1; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; + private System.Windows.Forms.ToolStripMenuItem viewOriginalToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem restoreToOriginalToolStripMenuItem1; } } \ No newline at end of file diff --git a/BTDToolbox/JetForm.cs b/BTDToolbox/JetForm.cs index dc8d17a..58d4727 100644 --- a/BTDToolbox/JetForm.cs +++ b/BTDToolbox/JetForm.cs @@ -27,9 +27,6 @@ public partial class JetForm : ThemedForm private string tempName; public string projName; private ContextMenuStrip treeMenu; - private ContextMenuStrip selMenu; - private ContextMenuStrip empMenu; - private ContextMenuStrip multiSelMenu; //Config values ConfigFile programData; @@ -41,30 +38,68 @@ public partial class JetForm : ThemedForm public JetForm(DirectoryInfo dirInfo, Main Form, string projName) { InitializeComponent(); + programData = DeserializeConfig(); StartUp(); + + if (projName == Serializer.Deserialize_Config().LastProject) + { + if (Serializer.Deserialize_Config().JsonEditor_OpenedTabs.Count > 0) + { + DialogResult dialogResult = MessageBox.Show("Do you want to re-open your previous files?", "Reopen previous files?", MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + { + foreach (string tab in Serializer.Deserialize_Config().JsonEditor_OpenedTabs) + JsonEditorHandler.OpenFile(tab); + } + else + { + programData.JsonEditor_OpenedTabs = new List(); + Serializer.SaveJSONEditor_Tabs(programData); + } + } + } + else + { + programData.JsonEditor_OpenedTabs = new List(); + Serializer.SaveJSONEditor_Tabs(programData); + } + goUpButton.Font = new Font("Microsoft Sans Serif", 9); this.dirInfo = dirInfo; this.Form = Form; this.projName = projName; Main.projName = projName; this.DoubleBuffered = true; + string gamedir = ""; - initMultiContextMenu(); - initSelContextMenu(); - initEmpContextMenu(); initTreeMenu(); if (projName.Contains("BTD5")) { Main.gameName = "BTD5"; + gamedir = Serializer.Deserialize_Config().BTD5_Directory; + } else if (projName.Contains("BTDB")) { Main.gameName = "BTDB"; + gamedir = Serializer.Deserialize_Config().BTDB_Directory; + } + if (gamedir == "" || gamedir == null) + { + Main.getInstance().Launch_Program_ToolStrip.Visible = false; + } + else + { + Main.getInstance().Launch_Program_ToolStrip.Visible = true; } ConsoleHandler.appendLog("Game: " + Main.gameName); ConsoleHandler.appendLog("Loading Project: " + projName.ToString()); + + + + Serializer.SaveConfig(this, "game", programData); Serializer.SaveConfig(this, "jet explorer", programData); @@ -77,15 +112,9 @@ public JetForm(DirectoryInfo dirInfo, Main Form, string projName) if (EZCard_Editor.EZCard_Opened == true) ConsoleHandler.force_appendNotice("The EZ Card tool is currently opened for a different project. Please close it to avoid errors..."); } - private void Deserialize_Config() - { - programData = DeserializeConfig(); - //programData = Serializer.Deserialize_Config(); - } private void StartUp() { //config stuff - Deserialize_Config(); this.Size = new Size(programData.JetExplorer_SizeX, programData.JetExplorer_SizeY); this.Location = new Point(programData.JetExplorer_PosX, programData.JetExplorer_PosY); @@ -107,38 +136,12 @@ private void StartUp() this.FormClosed += exitHandling; this.FormClosing += this.JetForm_Closed; } - private void initSelContextMenu() - { - selMenu = new ContextMenuStrip(); - selMenu.Items.Add("Rename"); - selMenu.Items.Add("Delete"); - selMenu.Items.Add("Copy"); - selMenu.Items.Add("Restore original"); - - selMenu.ItemClicked += jsonContextClicked; - } - - private void initMultiContextMenu() - { - multiSelMenu = new ContextMenuStrip(); - multiSelMenu.Items.Add("Delete"); - multiSelMenu.Items.Add("Copy"); - multiSelMenu.ItemClicked += multiJsonContextClicked; - } - private void initEmpContextMenu() - { - empMenu = new ContextMenuStrip(); - empMenu.Items.Add("Add"); - empMenu.Items.Add("Paste"); - empMenu.ItemClicked += listContextClicked; - } private void initTreeMenu() { treeMenu = new ContextMenuStrip(); treeMenu.Items.Add("Open in File Explorer"); treeMenu.ItemClicked += treeContextClicked; } - private void JetForm_Load(object sender, EventArgs e) { openDirWindow(); @@ -248,283 +251,80 @@ private void goUpButton_Click(object sender, EventArgs e) { } } - private void ListView1_DoubleClicked(object sender, EventArgs e) + private void OpenFile() { - ListView.SelectedListViewItemCollection Selected = listView1.SelectedItems; - if (Selected.Count == 1) + if(listView1.SelectedItems.Count <= 0) + ConsoleHandler.appendLog("You need to select at least one file to open"); + else { - if (useExternalEditor == false) + int i = 0; + foreach (var a in listView1.SelectedItems) { - try - { - JsonEditor JsonWindow = new JsonEditor(this.Text + "\\" + Selected[0].Text); - JsonWindow.MdiParent = Form; - JsonWindow.Show(); - } - catch (Exception) + var Selected = listView1.SelectedItems[i]; + if (!Selected.Text.Contains(".")) { - try + foreach (TreeNode node in treeView1.SelectedNode.Nodes) { - if (!Selected[0].Text.Contains(".")) + if (node.Text == Selected.Text) { - foreach (TreeNode node in treeView1.SelectedNode.Nodes) - { - if (node.Text == Selected[0].Text) - { - node.Expand(); - treeView1.SelectedNode = node; - } - } + node.Expand(); + treeView1.SelectedNode = node; + break; } } - catch (Exception) - { - } + break; } - } - else - { - try + else { - string selectedFile = this.Text + "\\" + Selected[0].Text; - Process.Start(selectedFile); - } - catch - { - + JsonEditorHandler.OpenFile(this.Text + "\\" + Selected.Text); } + i++; } - } } + private void ListView1_DoubleClicked(object sender, EventArgs e) + { + OpenFile(); + } //Context caller private void ListView1_RightClicked(object sender, MouseEventArgs e) { - try + if (e.Button == MouseButtons.Right) { - if (e.Button == MouseButtons.Right) + if(listView1.SelectedItems.Count <= 0) + NoneSelected_CM.Show(listView1, e.Location); + else if (listView1.SelectedItems.Count == 1) { - ListView.SelectedListViewItemCollection Selected = listView1.SelectedItems; - if (Selected.Count == 1) - { - selMenu.Show(listView1, e.Location); + OneSelected_CM.Show(listView1, e.Location); + string filename = listView1.SelectedItems[0].Text; - string filename = listView1.SelectedItems[0].ToString().Replace("ListViewItem: {", "").Replace("}", ""); - if (filename.Contains(".bloon")) - { - int i = 0; - bool ezBloonExists = false; - foreach(var item in selMenu.Items) - { - if (item.ToString() == "Open with EZ Bloon Tool") - { - ezBloonExists = true; - if (selMenu.Items[i].Visible == false) - { - selMenu.Items[i].Visible = true; - } - } - i++; - } - if(!ezBloonExists) - { - selMenu.Items.Add("Open with EZ Bloon Tool"); - } - } - else - { - int i = 0; - foreach(var item in selMenu.Items) - { - if (item.ToString() == "Open with EZ Bloon Tool") - { - selMenu.Items[i].Visible = false; - } - i++; - } - } + ezTower_CMButton.Visible = false; + ezBloon_CMButton.Visible = false; + ezCard_CMButton.Visible = false; + ezTools_Seperator.Visible = true; - //Handle towers - if (filename.Contains(".tower")) - { - int i = 0; - bool ezTowerExists = false; - foreach (var item in selMenu.Items) - { - if (item.ToString() == "Open with EZ Tower Tool") - { - ezTowerExists = true; - if (selMenu.Items[i].Visible == false) - { - selMenu.Items[i].Visible = true; - } - } - i++; - } - if (!ezTowerExists) - { - selMenu.Items.Add("Open with EZ Tower Tool"); - } - } - else - { - int i = 0; - foreach (var item in selMenu.Items) - { - if (item.ToString() == "Open with EZ Tower Tool") - { - selMenu.Items[i].Visible = false; - } - i++; - } - } - } - else if (Selected.Count == 0 || Selected == null) - { - empMenu.Show(listView1, e.Location); - } - else if (Selected.Count > 1) - { - multiSelMenu.Show(listView1, e.Location); - } + if (filename.EndsWith(".tower")) + ezTower_CMButton.Visible = true; + else if (filename.EndsWith(".bloon")) + ezTower_CMButton.Visible = false; + else if ((this.Text).Contains("BattleCardDefinitions")) + ezCard_CMButton.Visible = true; + else + ezTools_Seperator.Visible = false; } - } - catch (Exception) - { + else + MultiSelected_CM.Show(listView1, e.Location); } } private void TreeView_RightClicked(object sender, MouseEventArgs e) { - try - { - if (e.Button == MouseButtons.Right) - { - treeMenu.Show(treeView1, e.Location); - } - } - catch - { - - } - - } - - //Context caller - private void jsonContextClicked(object sender, ToolStripItemClickedEventArgs e) - { - if (e.ClickedItem.Text == "Rename") - { - try - { - rename(); - } - catch (Exception) - { - } - } - if (e.ClickedItem.Text == "Delete") - { - try - { - delete(); - } - catch (Exception) - { - } - } - if (e.ClickedItem.Text == "Copy") - { - try - { - copy(); - } - catch (Exception) - { - } - } - if (e.ClickedItem.Text == "Open with EZ Bloon Tool") + if (e.Button == MouseButtons.Right) { - try - { - Open_EZBloon(); - } - catch (Exception) - { - } - } - if (e.ClickedItem.Text == "Open with EZ Tower Tool") - { - try - { - Open_EZTower(); - } - catch (Exception) - { - } + treeMenu.Show(treeView1, e.Location); } } - private void treeContextClicked(object sender, ToolStripItemClickedEventArgs e) - { - try - { - if (e.ClickedItem.Text == "Open in File Explorer") - { - ConsoleHandler.appendLog("Opening folder in File Explorer.."); - Process.Start(this.Text); - } - } - catch - { - } - } - private void listContextClicked(object sender, ToolStripItemClickedEventArgs e) - { - if (e.ClickedItem.Text == "Add") - { - try - { - add(); - } - catch (Exception) - { - } - } - if (e.ClickedItem.Text == "Paste") - { - try - { - paste(); - } - catch (Exception) - { - } - } - } - private void multiJsonContextClicked(object sender, ToolStripItemClickedEventArgs e) - { - if (e.ClickedItem.Text == "Delete") - { - try - { - delete(); - } - catch (Exception) - { - } - } - if (e.ClickedItem.Text == "Copy") - { - try - { - copy(); - } - catch (Exception) - { - } - } - } //Context menu methods private void add() @@ -645,6 +445,64 @@ private void paste() listView1.Items.Add(item); } } + private void selectAll() + { + if (listView1.Focused) + { + int i = 0; + foreach (var a in listView1.Items) + { + listView1.Items[i].Selected = true; + i++; + } + } + } + private void openInFileExplorer() + { + if (!listView1.SelectedItems[0].Text.Contains(".")) + Process.Start(this.Text + "\\" + listView1.SelectedItems[0].Text); + else + Process.Start(this.Text); + } + private void restoreSingleFile(string filepath, string filename) + { + if (File.Exists(filepath)) + { + File.Delete(filepath); + } + File.Copy(Environment.CurrentDirectory + "\\Backups\\" + Main.gameName + "_BackupProject\\" + filepath.Replace(Environment.CurrentDirectory, "").Replace("\\" + projName + "\\", ""), filepath); + + if (JsonEditorHandler.jeditor.tabFilePaths.Contains(filepath)) + { + JsonEditorHandler.CloseFile(filepath); + JsonEditorHandler.OpenFile(filepath); + } + ConsoleHandler.appendLog_CanRepeat(filename + "has been restored"); + } + private void restoreOriginal() + { + int i = 0; + foreach(var x in listView1.SelectedItems) + { + string filepath = this.Text + "\\" + listView1.SelectedItems[i].Text; + if (listView1.SelectedItems[i].Text.Contains(".")) + { + restoreSingleFile(filepath, listView1.SelectedItems[i].Text); + } + else + { + foreach (var a in Directory.GetFiles(filepath)) + { + string[] split = a.Split('\\'); + string filename = split[split.Length - 1]; + string sourcefile = Environment.CurrentDirectory + "\\Backups\\" + Main.gameName + "_BackupProject\\" + filepath.Replace(Environment.CurrentDirectory, "").Replace("\\" + projName + "\\", "") + "\\" + filename; + + restoreSingleFile(a, filename); + } + } + i++; + } + } private void Open_EZBloon() { string filename = listView1.SelectedItems[0].ToString().Replace("ListViewItem: {", "").Replace("}", ""); @@ -661,6 +519,23 @@ private void Open_EZTower() ezTower.path = path; ezTower.Show(); } + private void Open_EZCard() + { + string filename = listView1.SelectedItems[0].ToString().Replace("ListViewItem: {", "").Replace("}", ""); + var ezCard = new EZCard_Editor(); + string path = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BattleCardDefinitions\\" + filename; + ezCard.path = path; + ezCard.Show(); + } + private void ViewOriginal() + { + int i = 0; + foreach (var a in listView1.SelectedItems) + { + JsonEditorHandler.OpenOriginalFile(this.Text + "\\" + listView1.SelectedItems[i].Text); + i++; + } + } private void SplitContainer_SplitterMoved(object sender, SplitterEventArgs e) { jetExplorer_SplitterWidth = fileViewContainer.SplitterDistance; @@ -717,14 +592,11 @@ private void JetForm_KeyDown(object sender, KeyEventArgs e) findBox.Select(); } } + if (e.Control && e.KeyCode == Keys.A) + { + selectAll(); + } } - - private void TreeView_CheckHotkey(object sender, KeyEventArgs e) - { - - } - - private void JetForm_Activated(object sender, EventArgs e) { Serializer.SaveConfig(this, "jet explorer", programData); @@ -914,5 +786,73 @@ private void ValidateAllFiles_Click(object sender, EventArgs e) Thread bg = new Thread(JSON_Reader.ValidateAllJsonFiles); bg.Start(); } + + + //Context caller + private void treeContextClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Text == "Open in File Explorer") + { + ConsoleHandler.appendLog("Opening folder in File Explorer.."); + Process.Start(this.Text); + } + } + private void NoneSelected_CM_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Text == "Add") + add(); + else if (e.ClickedItem.Text == "Paste") + paste(); + else if (e.ClickedItem.Text == "Select all") + selectAll(); + } + private void OneSelected_CM_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Text == "Open File") + OpenFile(); + else if (e.ClickedItem.Text == "Rename") + rename(); + else if (e.ClickedItem.Text == "Delete") + delete(); + else if (e.ClickedItem.Text == "Copy") + copy(); + else if (e.ClickedItem.Text == "Open with EZ Bloon Tool") + Open_EZBloon(); + else if (e.ClickedItem.Text == "Open with EZ Tower Tool") + Open_EZTower(); + else if (e.ClickedItem.Text == "Open with EZ Card Tool") + Open_EZCard(); + else if (e.ClickedItem.Text == "Open in File Explorer") + openInFileExplorer(); + else if (e.ClickedItem.Text == "View original") + ViewOriginal(); + else if (e.ClickedItem.Text == "Restore to original") + { + DialogResult diag = MessageBox.Show("Are you sure you want to restore this file to the original unmodded version?", "Restore to original?", MessageBoxButtons.YesNo); + if (diag == DialogResult.Yes) + restoreOriginal(); + else + ConsoleHandler.appendLog_CanRepeat("restore cancelled..."); + } + } + private void MultiSelected_CM_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Text == "Open Files") + OpenFile(); + if (e.ClickedItem.Text == "Delete") + delete(); + if (e.ClickedItem.Text == "Copy") + copy(); + if (e.ClickedItem.Text == "View original") + ViewOriginal(); + if (e.ClickedItem.Text == "Restore to original") + { + DialogResult diag = MessageBox.Show("Are you sure you want to restore this file to the original unmodded version?", "Restore to original?", MessageBoxButtons.YesNo); + if (diag == DialogResult.Yes) + restoreOriginal(); + else + ConsoleHandler.appendLog_CanRepeat("restore cancelled..."); + } + } } } diff --git a/BTDToolbox/JetForm.resx b/BTDToolbox/JetForm.resx index 359cdf4..e24b8bb 100644 --- a/BTDToolbox/JetForm.resx +++ b/BTDToolbox/JetForm.resx @@ -117,40 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 127, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG - YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 - 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw - bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc - VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 - c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 - Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo - mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ - kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D - TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG - YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 - 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw - bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc - VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 - c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 - Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo - mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ - kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D - TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - 17, 17 @@ -159,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACk - DAAAAk1TRnQBSQFMAgEBAgEAATABAQEwAQEBIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + DAAAAk1TRnQBSQFMAgEBAgEAAVgBAQFYAQEBIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABgAMAASADAAEBAQABCAYAARAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -216,6 +182,49 @@ Cw== + + 127, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + 365, 23 + + + 222, 20 + + + 521, 17 + AAABAAEAIEAQAAEABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAABMLAAATCwAAEAAAABAA diff --git a/BTDToolbox/JsonEditor.cs b/BTDToolbox/JsonEditor.cs index 21ed33f..492eabf 100644 --- a/BTDToolbox/JsonEditor.cs +++ b/BTDToolbox/JsonEditor.cs @@ -267,7 +267,6 @@ private void FindText() } } } - } private void HideFindButton() { @@ -400,11 +399,11 @@ private void JsonEditor_Load(object sender, EventArgs e) { Serializer.SaveConfig(this, "json editor", programData); } - private void ShowReplaceMenu_Button_Click(object sender, EventArgs e) { ShowReplaceMenu(); } + public int getWidth() { int w = 25; @@ -443,7 +442,6 @@ public void AddLineNumbers() tB_line.Text += i + 1 + "\n"; } } - private void Editor_TextBox_SelectionChanged(object sender, EventArgs e) { Point pt = Editor_TextBox.GetPositionFromCharIndex(Editor_TextBox.SelectionStart); @@ -452,27 +450,23 @@ private void Editor_TextBox_SelectionChanged(object sender, EventArgs e) AddLineNumbers(); } } - private void Editor_TextBox_VScroll(object sender, EventArgs e) { tB_line.Text = ""; AddLineNumbers(); tB_line.Invalidate(); } - private void Editor_TextBox_FontChanged(object sender, EventArgs e) { tB_line.Font = Editor_TextBox.Font; Editor_TextBox.Select(); AddLineNumbers(); } - private void TB_line_MouseDown(object sender, MouseEventArgs e) { Editor_TextBox.Select(); tB_line.DeselectAll(); } - private void Editor_TextBox_MouseClick(object sender, MouseEventArgs e) { //SearchForPairs(); @@ -844,7 +838,6 @@ private void RemoveEmptySpaces() } } } - private void EZBoon_Button_Click(object sender, EventArgs e) { var ezBloon = new EZBloon_Editor(); diff --git a/BTDToolbox/JsonEditor_Instance.Designer.cs b/BTDToolbox/JsonEditor_Instance.Designer.cs new file mode 100644 index 0000000..9d79d37 --- /dev/null +++ b/BTDToolbox/JsonEditor_Instance.Designer.cs @@ -0,0 +1,572 @@ +namespace BTDToolbox +{ + partial class JsonEditor_Instance + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(JsonEditor_Instance)); + this.Editor_TextBox = new System.Windows.Forms.RichTextBox(); + this.tB_line = new System.Windows.Forms.RichTextBox(); + this.JsonToolstrip = new System.Windows.Forms.ToolStrip(); + this.File_DropDown = new System.Windows.Forms.ToolStripDropDownButton(); + this.Undo_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.Redo_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.ShowFindMenu_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.ShowReplaceMenu_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.FindSubtask_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.EZCard_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.EZBoon_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.EZTowerEditor_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.ChangeFontSize_MenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.FontSize_TextBox = new System.Windows.Forms.ToolStripTextBox(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.viewOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openInFileExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.RestoreToOriginal_Button = new System.Windows.Forms.ToolStripMenuItem(); + this.Help_DropDown = new System.Windows.Forms.ToolStripDropDownButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.lintPanel = new System.Windows.Forms.Panel(); + this.CloseFile_Button = new System.Windows.Forms.Button(); + this.JsonError_Label = new System.Windows.Forms.Label(); + this.Find_Panel = new System.Windows.Forms.Panel(); + this.SearchOptions_Button = new System.Windows.Forms.Button(); + this.Find_Button = new System.Windows.Forms.Button(); + this.Find_TB = new System.Windows.Forms.RichTextBox(); + this.Replace_Button = new System.Windows.Forms.Button(); + this.Replace_TB = new System.Windows.Forms.RichTextBox(); + this.SearchOptions_Panel = new System.Windows.Forms.Panel(); + this.Option1_CB = new System.Windows.Forms.CheckBox(); + this.NoItem_CM = new System.Windows.Forms.ContextMenuStrip(this.components); + this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ItemHighlighted_CM = new System.Windows.Forms.ContextMenuStrip(this.components); + this.findSubtaskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.getCurrentSubtaskNumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.findSubtaskToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.getThisSubtaskNumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.JsonToolstrip.SuspendLayout(); + this.Find_Panel.SuspendLayout(); + this.SearchOptions_Panel.SuspendLayout(); + this.NoItem_CM.SuspendLayout(); + this.ItemHighlighted_CM.SuspendLayout(); + this.SuspendLayout(); + // + // Editor_TextBox + // + this.Editor_TextBox.AcceptsTab = true; + this.Editor_TextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25))))); + this.Editor_TextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.Editor_TextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Editor_TextBox.ForeColor = System.Drawing.Color.White; + this.Editor_TextBox.Location = new System.Drawing.Point(32, 24); + this.Editor_TextBox.Name = "Editor_TextBox"; + this.Editor_TextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical; + this.Editor_TextBox.Size = new System.Drawing.Size(719, 313); + this.Editor_TextBox.TabIndex = 26; + this.Editor_TextBox.Text = ""; + this.Editor_TextBox.SelectionChanged += new System.EventHandler(this.Editor_TextBox_SelectionChanged); + this.Editor_TextBox.VScroll += new System.EventHandler(this.Editor_TextBox_VScroll); + this.Editor_TextBox.FontChanged += new System.EventHandler(this.Editor_TextBox_FontChanged); + this.Editor_TextBox.TextChanged += new System.EventHandler(this.Editor_TextBox_TextChanged); + this.Editor_TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Editor_TextBox_KeyDown); + // + // tB_line + // + this.tB_line.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.tB_line.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(35)))), ((int)(((byte)(35)))), ((int)(((byte)(35))))); + this.tB_line.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.tB_line.Font = new System.Drawing.Font("Consolas", 12.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tB_line.ForeColor = System.Drawing.Color.DarkGray; + this.tB_line.Location = new System.Drawing.Point(0, 24); + this.tB_line.Name = "tB_line"; + this.tB_line.ReadOnly = true; + this.tB_line.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; + this.tB_line.Size = new System.Drawing.Size(53, 313); + this.tB_line.TabIndex = 27; + this.tB_line.TabStop = false; + this.tB_line.Text = ""; + this.tB_line.WordWrap = false; + this.tB_line.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TB_line_MouseDown); + // + // JsonToolstrip + // + this.JsonToolstrip.BackColor = System.Drawing.SystemColors.ControlDarkDark; + this.JsonToolstrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.JsonToolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.File_DropDown, + this.Help_DropDown, + this.toolStripSeparator1}); + this.JsonToolstrip.Location = new System.Drawing.Point(0, 0); + this.JsonToolstrip.Name = "JsonToolstrip"; + this.JsonToolstrip.Padding = new System.Windows.Forms.Padding(0, 0, 1, 5); + this.JsonToolstrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; + this.JsonToolstrip.Size = new System.Drawing.Size(754, 28); + this.JsonToolstrip.TabIndex = 28; + this.JsonToolstrip.Text = "toolStrip1"; + // + // File_DropDown + // + this.File_DropDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.File_DropDown.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.File_DropDown.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.Undo_Button, + this.Redo_Button, + this.ShowFindMenu_Button, + this.ShowReplaceMenu_Button, + this.FindSubtask_Button, + this.EZCard_Button, + this.EZBoon_Button, + this.EZTowerEditor_Button, + this.toolStripSeparator3, + this.ChangeFontSize_MenuItem, + this.toolStripSeparator2, + this.viewOriginalToolStripMenuItem, + this.openInFileExplorerToolStripMenuItem, + this.RestoreToOriginal_Button}); + this.File_DropDown.Font = new System.Drawing.Font("Segoe UI", 9F); + this.File_DropDown.ForeColor = System.Drawing.Color.White; + this.File_DropDown.Image = ((System.Drawing.Image)(resources.GetObject("File_DropDown.Image"))); + this.File_DropDown.ImageTransparentColor = System.Drawing.Color.Magenta; + this.File_DropDown.Name = "File_DropDown"; + this.File_DropDown.Size = new System.Drawing.Size(38, 20); + this.File_DropDown.Text = "File"; + // + // Undo_Button + // + this.Undo_Button.Name = "Undo_Button"; + this.Undo_Button.Size = new System.Drawing.Size(201, 22); + this.Undo_Button.Text = "Undo (Ctrl + Z)"; + // + // Redo_Button + // + this.Redo_Button.Name = "Redo_Button"; + this.Redo_Button.Size = new System.Drawing.Size(201, 22); + this.Redo_Button.Text = "Redo (Ctrl + R)"; + // + // ShowFindMenu_Button + // + this.ShowFindMenu_Button.Name = "ShowFindMenu_Button"; + this.ShowFindMenu_Button.Size = new System.Drawing.Size(201, 22); + this.ShowFindMenu_Button.Text = "Find (Ctrl + F)"; + this.ShowFindMenu_Button.Click += new System.EventHandler(this.ShowFindMenu_Button_Click); + // + // ShowReplaceMenu_Button + // + this.ShowReplaceMenu_Button.Name = "ShowReplaceMenu_Button"; + this.ShowReplaceMenu_Button.Size = new System.Drawing.Size(201, 22); + this.ShowReplaceMenu_Button.Text = "Replace (Ctrl + H)"; + this.ShowReplaceMenu_Button.Click += new System.EventHandler(this.ShowReplaceMenu_Button_Click); + // + // FindSubtask_Button + // + this.FindSubtask_Button.Name = "FindSubtask_Button"; + this.FindSubtask_Button.Size = new System.Drawing.Size(201, 22); + this.FindSubtask_Button.Text = "Find Subtask"; + // + // EZCard_Button + // + this.EZCard_Button.Name = "EZCard_Button"; + this.EZCard_Button.Size = new System.Drawing.Size(201, 22); + this.EZCard_Button.Text = "Open in EZ Card tool"; + this.EZCard_Button.Visible = false; + this.EZCard_Button.Click += new System.EventHandler(this.EZCard_Button_Click); + // + // EZBoon_Button + // + this.EZBoon_Button.Name = "EZBoon_Button"; + this.EZBoon_Button.Size = new System.Drawing.Size(201, 22); + this.EZBoon_Button.Text = "Open in EZ Bloon tool"; + this.EZBoon_Button.Visible = false; + this.EZBoon_Button.Click += new System.EventHandler(this.EZBoon_Button_Click); + // + // EZTowerEditor_Button + // + this.EZTowerEditor_Button.Name = "EZTowerEditor_Button"; + this.EZTowerEditor_Button.Size = new System.Drawing.Size(201, 22); + this.EZTowerEditor_Button.Text = "Open in EZ Tower tool"; + this.EZTowerEditor_Button.Visible = false; + this.EZTowerEditor_Button.Click += new System.EventHandler(this.EZTowerEditor_Button_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(198, 6); + // + // ChangeFontSize_MenuItem + // + this.ChangeFontSize_MenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.FontSize_TextBox}); + this.ChangeFontSize_MenuItem.Name = "ChangeFontSize_MenuItem"; + this.ChangeFontSize_MenuItem.Size = new System.Drawing.Size(201, 22); + this.ChangeFontSize_MenuItem.Text = "Change Font Size"; + // + // FontSize_TextBox + // + this.FontSize_TextBox.Font = new System.Drawing.Font("Segoe UI", 9F); + this.FontSize_TextBox.Name = "FontSize_TextBox"; + this.FontSize_TextBox.Size = new System.Drawing.Size(100, 23); + this.FontSize_TextBox.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.FontSize_TextBox.TextChanged += new System.EventHandler(this.FontSize_TextBox_TextChanged); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(198, 6); + // + // viewOriginalToolStripMenuItem + // + this.viewOriginalToolStripMenuItem.Name = "viewOriginalToolStripMenuItem"; + this.viewOriginalToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + this.viewOriginalToolStripMenuItem.Text = "View Original"; + this.viewOriginalToolStripMenuItem.Click += new System.EventHandler(this.ViewOriginalToolStripMenuItem_Click); + // + // openInFileExplorerToolStripMenuItem + // + this.openInFileExplorerToolStripMenuItem.Name = "openInFileExplorerToolStripMenuItem"; + this.openInFileExplorerToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + this.openInFileExplorerToolStripMenuItem.Text = "Open in File Explorer"; + this.openInFileExplorerToolStripMenuItem.Click += new System.EventHandler(this.OpenInFileExplorerToolStripMenuItem_Click); + // + // RestoreToOriginal_Button + // + this.RestoreToOriginal_Button.Name = "RestoreToOriginal_Button"; + this.RestoreToOriginal_Button.Size = new System.Drawing.Size(201, 22); + this.RestoreToOriginal_Button.Text = "Restore File to Original"; + this.RestoreToOriginal_Button.Click += new System.EventHandler(this.RestoreToOriginal_Button_Click); + // + // Help_DropDown + // + this.Help_DropDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.Help_DropDown.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.Help_DropDown.Font = new System.Drawing.Font("Segoe UI", 9F); + this.Help_DropDown.ForeColor = System.Drawing.Color.White; + this.Help_DropDown.Image = ((System.Drawing.Image)(resources.GetObject("Help_DropDown.Image"))); + this.Help_DropDown.ImageTransparentColor = System.Drawing.Color.Magenta; + this.Help_DropDown.Name = "Help_DropDown"; + this.Help_DropDown.Size = new System.Drawing.Size(45, 20); + this.Help_DropDown.Text = "Help"; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.toolStripSeparator1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 23); + // + // lintPanel + // + this.lintPanel.BackColor = System.Drawing.SystemColors.ControlDarkDark; + this.lintPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.lintPanel.ForeColor = System.Drawing.Color.Black; + this.lintPanel.Location = new System.Drawing.Point(110, 0); + this.lintPanel.Name = "lintPanel"; + this.lintPanel.Size = new System.Drawing.Size(60, 20); + this.lintPanel.TabIndex = 29; + this.lintPanel.MouseClick += new System.Windows.Forms.MouseEventHandler(this.LintPanel_MouseClick); + // + // CloseFile_Button + // + this.CloseFile_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.CloseFile_Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128))))); + this.CloseFile_Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CloseFile_Button.Location = new System.Drawing.Point(527, 0); + this.CloseFile_Button.Name = "CloseFile_Button"; + this.CloseFile_Button.Size = new System.Drawing.Size(36, 20); + this.CloseFile_Button.TabIndex = 30; + this.CloseFile_Button.Text = "X"; + this.CloseFile_Button.UseVisualStyleBackColor = false; + this.CloseFile_Button.Click += new System.EventHandler(this.CloseFile_Button_Click); + // + // JsonError_Label + // + this.JsonError_Label.AutoSize = true; + this.JsonError_Label.Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.JsonError_Label.ForeColor = System.Drawing.Color.Orange; + this.JsonError_Label.Location = new System.Drawing.Point(176, 4); + this.JsonError_Label.Name = "JsonError_Label"; + this.JsonError_Label.Size = new System.Drawing.Size(178, 20); + this.JsonError_Label.TabIndex = 31; + this.JsonError_Label.Text = "<< Click to go to error"; + this.JsonError_Label.Visible = false; + // + // Find_Panel + // + this.Find_Panel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Find_Panel.Controls.Add(this.SearchOptions_Button); + this.Find_Panel.Controls.Add(this.Find_Button); + this.Find_Panel.Controls.Add(this.Find_TB); + this.Find_Panel.Controls.Add(this.Replace_Button); + this.Find_Panel.Controls.Add(this.Replace_TB); + this.Find_Panel.Location = new System.Drawing.Point(3, 213); + this.Find_Panel.Name = "Find_Panel"; + this.Find_Panel.Size = new System.Drawing.Size(748, 124); + this.Find_Panel.TabIndex = 32; + this.Find_Panel.Visible = false; + // + // SearchOptions_Button + // + this.SearchOptions_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.SearchOptions_Button.Font = new System.Drawing.Font("Candara Light", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SearchOptions_Button.Location = new System.Drawing.Point(270, 6); + this.SearchOptions_Button.Name = "SearchOptions_Button"; + this.SearchOptions_Button.Size = new System.Drawing.Size(25, 21); + this.SearchOptions_Button.TabIndex = 5; + this.SearchOptions_Button.Text = "^"; + this.SearchOptions_Button.UseVisualStyleBackColor = true; + this.SearchOptions_Button.Visible = false; + this.SearchOptions_Button.Click += new System.EventHandler(this.FindOptions_Button_Click); + // + // Find_Button + // + this.Find_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.Find_Button.Location = new System.Drawing.Point(30, 4); + this.Find_Button.Name = "Find_Button"; + this.Find_Button.Size = new System.Drawing.Size(59, 24); + this.Find_Button.TabIndex = 4; + this.Find_Button.Text = "Find"; + this.Find_Button.UseVisualStyleBackColor = true; + this.Find_Button.Visible = false; + this.Find_Button.Click += new System.EventHandler(this.Find_Button_Click); + // + // Find_TB + // + this.Find_TB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.Find_TB.Font = new System.Drawing.Font("Microsoft YaHei", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Find_TB.Location = new System.Drawing.Point(90, 5); + this.Find_TB.Multiline = false; + this.Find_TB.Name = "Find_TB"; + this.Find_TB.Size = new System.Drawing.Size(181, 23); + this.Find_TB.TabIndex = 3; + this.Find_TB.Text = ""; + this.Find_TB.Visible = false; + this.Find_TB.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Find_TB_KeyDown); + // + // Replace_Button + // + this.Replace_Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.Replace_Button.Location = new System.Drawing.Point(301, 4); + this.Replace_Button.Name = "Replace_Button"; + this.Replace_Button.Size = new System.Drawing.Size(59, 24); + this.Replace_Button.TabIndex = 2; + this.Replace_Button.Text = "Replace"; + this.Replace_Button.UseVisualStyleBackColor = true; + this.Replace_Button.Visible = false; + this.Replace_Button.Click += new System.EventHandler(this.Replace_Button_Click); + // + // Replace_TB + // + this.Replace_TB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.Replace_TB.Font = new System.Drawing.Font("Microsoft YaHei", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Replace_TB.Location = new System.Drawing.Point(361, 5); + this.Replace_TB.Multiline = false; + this.Replace_TB.Name = "Replace_TB"; + this.Replace_TB.Size = new System.Drawing.Size(181, 23); + this.Replace_TB.TabIndex = 0; + this.Replace_TB.Text = ""; + this.Replace_TB.Visible = false; + // + // SearchOptions_Panel + // + this.SearchOptions_Panel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.SearchOptions_Panel.Controls.Add(this.Option1_CB); + this.SearchOptions_Panel.Location = new System.Drawing.Point(473, 188); + this.SearchOptions_Panel.Name = "SearchOptions_Panel"; + this.SearchOptions_Panel.Size = new System.Drawing.Size(104, 25); + this.SearchOptions_Panel.TabIndex = 33; + this.SearchOptions_Panel.Visible = false; + // + // Option1_CB + // + this.Option1_CB.AutoSize = true; + this.Option1_CB.Font = new System.Drawing.Font("Microsoft YaHei", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Option1_CB.ForeColor = System.Drawing.Color.White; + this.Option1_CB.Location = new System.Drawing.Point(15, 7); + this.Option1_CB.Name = "Option1_CB"; + this.Option1_CB.Size = new System.Drawing.Size(89, 25); + this.Option1_CB.TabIndex = 0; + this.Option1_CB.Text = "Subtask"; + this.Option1_CB.UseVisualStyleBackColor = true; + this.Option1_CB.CheckedChanged += new System.EventHandler(this.Option1_CB_CheckedChanged); + // + // NoItem_CM + // + this.NoItem_CM.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.testToolStripMenuItem, + this.findSubtaskToolStripMenuItem, + this.getCurrentSubtaskNumberToolStripMenuItem}); + this.NoItem_CM.Name = "NoItem_CM"; + this.NoItem_CM.Size = new System.Drawing.Size(203, 70); + this.NoItem_CM.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.NoItem_CM_ItemClicked); + // + // testToolStripMenuItem + // + this.testToolStripMenuItem.Name = "testToolStripMenuItem"; + this.testToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.testToolStripMenuItem.Text = "Paste"; + // + // ItemHighlighted_CM + // + this.ItemHighlighted_CM.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.copyToolStripMenuItem, + this.pasteToolStripMenuItem, + this.findToolStripMenuItem, + this.replaceToolStripMenuItem, + this.findSubtaskToolStripMenuItem1, + this.getThisSubtaskNumberToolStripMenuItem}); + this.ItemHighlighted_CM.Name = "ItemHighlighted_CM"; + this.ItemHighlighted_CM.Size = new System.Drawing.Size(203, 158); + this.ItemHighlighted_CM.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.ItemHighlighted_CM_ItemClicked); + // + // findSubtaskToolStripMenuItem + // + this.findSubtaskToolStripMenuItem.Name = "findSubtaskToolStripMenuItem"; + this.findSubtaskToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.findSubtaskToolStripMenuItem.Text = "Find Subtask"; + // + // getCurrentSubtaskNumberToolStripMenuItem + // + this.getCurrentSubtaskNumberToolStripMenuItem.Name = "getCurrentSubtaskNumberToolStripMenuItem"; + this.getCurrentSubtaskNumberToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.getCurrentSubtaskNumberToolStripMenuItem.Text = "Get this subtask number"; + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.copyToolStripMenuItem.Text = "Copy"; + // + // pasteToolStripMenuItem + // + this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; + this.pasteToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.pasteToolStripMenuItem.Text = "Paste"; + // + // findToolStripMenuItem + // + this.findToolStripMenuItem.Name = "findToolStripMenuItem"; + this.findToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.findToolStripMenuItem.Text = "Find"; + // + // replaceToolStripMenuItem + // + this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem"; + this.replaceToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.replaceToolStripMenuItem.Text = "Replace"; + // + // findSubtaskToolStripMenuItem1 + // + this.findSubtaskToolStripMenuItem1.Name = "findSubtaskToolStripMenuItem1"; + this.findSubtaskToolStripMenuItem1.Size = new System.Drawing.Size(202, 22); + this.findSubtaskToolStripMenuItem1.Text = "Find Subtask"; + // + // getThisSubtaskNumberToolStripMenuItem + // + this.getThisSubtaskNumberToolStripMenuItem.Name = "getThisSubtaskNumberToolStripMenuItem"; + this.getThisSubtaskNumberToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.getThisSubtaskNumberToolStripMenuItem.Text = "Get this subtask number"; + // + // JsonEditor_Instance + // + 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.Controls.Add(this.SearchOptions_Panel); + this.Controls.Add(this.Find_Panel); + this.Controls.Add(this.JsonError_Label); + this.Controls.Add(this.CloseFile_Button); + this.Controls.Add(this.lintPanel); + this.Controls.Add(this.JsonToolstrip); + this.Controls.Add(this.Editor_TextBox); + this.Controls.Add(this.tB_line); + this.Name = "JsonEditor_Instance"; + this.Size = new System.Drawing.Size(754, 337); + this.Resize += new System.EventHandler(this.JsonEditor_UserControl_Resize); + this.JsonToolstrip.ResumeLayout(false); + this.JsonToolstrip.PerformLayout(); + this.Find_Panel.ResumeLayout(false); + this.SearchOptions_Panel.ResumeLayout(false); + this.SearchOptions_Panel.PerformLayout(); + this.NoItem_CM.ResumeLayout(false); + this.ItemHighlighted_CM.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.ToolStrip JsonToolstrip; + private System.Windows.Forms.ToolStripDropDownButton File_DropDown; + private System.Windows.Forms.ToolStripMenuItem Undo_Button; + private System.Windows.Forms.ToolStripMenuItem Redo_Button; + private System.Windows.Forms.ToolStripMenuItem ShowFindMenu_Button; + private System.Windows.Forms.ToolStripMenuItem ShowReplaceMenu_Button; + private System.Windows.Forms.ToolStripMenuItem FindSubtask_Button; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem ChangeFontSize_MenuItem; + private System.Windows.Forms.ToolStripTextBox FontSize_TextBox; + private System.Windows.Forms.ToolStripMenuItem EZTowerEditor_Button; + private System.Windows.Forms.ToolStripMenuItem EZBoon_Button; + private System.Windows.Forms.ToolStripDropDownButton Help_DropDown; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.Panel lintPanel; + public System.Windows.Forms.RichTextBox Editor_TextBox; + public System.Windows.Forms.RichTextBox tB_line; + private System.Windows.Forms.Button CloseFile_Button; + private System.Windows.Forms.Label JsonError_Label; + private System.Windows.Forms.Panel Find_Panel; + private System.Windows.Forms.RichTextBox Replace_TB; + private System.Windows.Forms.Button Replace_Button; + private System.Windows.Forms.Button Find_Button; + private System.Windows.Forms.RichTextBox Find_TB; + private System.Windows.Forms.Button SearchOptions_Button; + private System.Windows.Forms.Panel SearchOptions_Panel; + private System.Windows.Forms.CheckBox Option1_CB; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripMenuItem viewOriginalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openInFileExplorerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem RestoreToOriginal_Button; + private System.Windows.Forms.ToolStripMenuItem EZCard_Button; + private System.Windows.Forms.ContextMenuStrip NoItem_CM; + private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip ItemHighlighted_CM; + private System.Windows.Forms.ToolStripMenuItem findSubtaskToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem getCurrentSubtaskNumberToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem findToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem findSubtaskToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem getThisSubtaskNumberToolStripMenuItem; + } +} diff --git a/BTDToolbox/JsonEditor_Instance.cs b/BTDToolbox/JsonEditor_Instance.cs new file mode 100644 index 0000000..88529e9 --- /dev/null +++ b/BTDToolbox/JsonEditor_Instance.cs @@ -0,0 +1,770 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using BTDToolbox.Classes; +using System.IO; +using BTDToolbox.Extra_Forms; +using static BTDToolbox.ProjectConfig; +using System.Diagnostics; + +namespace BTDToolbox +{ + public partial class JsonEditor_Instance : UserControl + { + Font font; + ConfigFile programData; + public bool jsonError; + public string path = ""; + public string filename = ""; + + //Tab new line vars + string tab; + bool tabLine = false; + + //Find vars + int endEditor = 0; + int endPosition = 0; + int startPosition = 0; + int numPhrasesFound = 0; + int CharIndex_UnderMouse = 0; + string previousSearchPhrase = ""; + bool searchPhrase_selected = false; + + public JsonEditor_Instance() + { + InitializeComponent(); + SetHideEvents(); + + Editor_TextBox.Select(); + AddLineNumbers(); + + Find_Button.KeyDown += Find_TB_KeyDown; + Replace_TB.KeyDown += Find_TB_KeyDown; + SearchOptions_Panel.KeyDown += Find_TB_KeyDown; + SearchOptions_Button.KeyDown += Find_TB_KeyDown; + Editor_TextBox.MouseUp += Editor_TextBox_RightClicked; + } + public void FinishedLoading() + { + HandleTools(); + if (Serializer.Deserialize_Config().JSON_Editor_FontSize > 0) + Editor_TextBox.Font = new Font("Consolas", Serializer.Deserialize_Config().JSON_Editor_FontSize); + else + Editor_TextBox.Font = new Font("Consolas", 14); + tB_line.Font = Editor_TextBox.Font; + FontSize_TextBox.Text = Editor_TextBox.Font.Size.ToString(); + } + // + //JSON + // + private void Editor_TextBox_TextChanged(object sender, EventArgs e) + { + CheckJSON(Editor_TextBox.Text); + File.WriteAllText(path, Editor_TextBox.Text); + + if (tabLine) + { + Editor_TextBox.SelectedText = tab; + tabLine = false; + } + } + private void CheckJSON(string text) + { + if (JSON_Reader.IsValidJson(text) == true) + { + this.lintPanel.BackgroundImage = Properties.Resources.JSON_valid; + JsonError_Label.Visible = false; + + jsonError = false; + New_JsonEditor.isJsonError = false; + } + else + { + this.lintPanel.BackgroundImage = Properties.Resources.JSON_Invalid; + JsonError_Label.Visible = true; + + jsonError = true; + New_JsonEditor.isJsonError = true; + } + } + private void LintPanel_MouseClick(object sender, MouseEventArgs e) + { + if (jsonError) + { + try + { + string error = JSON_Reader.GetJSON_Error(Editor_TextBox.Text); + ConsoleHandler.force_appendNotice(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.appendLog_CanRepeat("Something went wrong... Unable to find the bad json"); + } + } + } + private void CloseFile_Button_Click(object sender, EventArgs e) + { + if(!jsonError) + { + JsonEditorHandler.CloseFile(path); + if(programData == null) + programData = Serializer.Deserialize_Config(); + Serializer.SaveJSONEditor_Instance(this, programData); + Serializer.SaveJSONEditor_Tabs(programData); + } + else + { + + DialogResult dialogResult = MessageBox.Show("This file has a JSON error! Are you sure you want to close and save it?", "ARE YOU SURE!!!!!", MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + { + if (programData == null) + programData = Serializer.Deserialize_Config(); + JsonEditorHandler.CloseFile(path); + Serializer.SaveJSONEditor_Instance(this, programData); + } + } + } + + // + //EZ Tools and text formatting + // + private int IndentNewLines() + { + int index = Editor_TextBox.GetFirstCharIndexOfCurrentLine(); + string text = Editor_TextBox.Text.Remove(0, index); + + int numSpace = 0; + foreach (char c in text) + { + if (c != ' ') + break; + else + numSpace++; + } + return numSpace; + } + private void HandleTools() + { + if (path.EndsWith("tower")) + EZTowerEditor_Button.Visible = true; + else + EZTowerEditor_Button.Visible = false; + + if (path.EndsWith("bloon")) + EZBoon_Button.Visible = true; + else + EZBoon_Button.Visible = false; + + if (path.Contains("BattleCardDefinitions")) + EZCard_Button.Visible = true; + else + EZCard_Button.Visible = false; + } + + // + //Add line numbers + // + public int getWidth() + { + int w = 25; + // get total lines of richTextBox1 + int line = Editor_TextBox.Lines.Length; + if (line <= 99) + { + w = 20 + (int)Editor_TextBox.Font.Size; + } + else if (line <= 999) + { + w = 30 + (int)Editor_TextBox.Font.Size; + } + else + { + w = 50 + (int)Editor_TextBox.Font.Size; + } + + return w; + } + public void AddLineNumbers() + { + Point pt = new Point(0, 0); + int First_Index = Editor_TextBox.GetCharIndexFromPosition(pt); + int First_Line = Editor_TextBox.GetLineFromCharIndex(First_Index); + pt.X = ClientRectangle.Width; + pt.Y = ClientRectangle.Height; + + int Last_Index = Editor_TextBox.GetCharIndexFromPosition(pt); + int Last_Line = Editor_TextBox.GetLineFromCharIndex(Last_Index); + tB_line.SelectionAlignment = HorizontalAlignment.Center; + tB_line.Text = ""; + tB_line.Width = getWidth(); + for (int i = First_Line; i <= Last_Line + 2; i++) + { + tB_line.Text += i + 1 + "\n"; + } + } + private void Editor_TextBox_SelectionChanged(object sender, EventArgs e) + { + Point pt = Editor_TextBox.GetPositionFromCharIndex(Editor_TextBox.SelectionStart); + if (pt.X == 1) + { + AddLineNumbers(); + } + } + private void Editor_TextBox_FontChanged(object sender, EventArgs e) + { + tB_line.Font = Editor_TextBox.Font; + Editor_TextBox.Select(); + AddLineNumbers(); + } + private void Editor_TextBox_VScroll(object sender, EventArgs e) + { + tB_line.Text = ""; + AddLineNumbers(); + tB_line.Invalidate(); + } + private void TB_line_MouseDown(object sender, MouseEventArgs e) + { + Editor_TextBox.Select(); + tB_line.DeselectAll(); + } + private void JsonEditor_UserControl_Resize(object sender, EventArgs e) + { + Editor_TextBox.Size = new Size(this.Width - 43, this.Height-38); + tB_line.Size = new Size(tB_line.Width, this.Height - 38); + + Point pt = Editor_TextBox.GetPositionFromCharIndex(Editor_TextBox.SelectionStart); + if (pt.X == 1) + { + AddLineNumbers(); + } + } + + // + //Find and replace stuff + // + private void ShowSearchMenu(string op) + { + Editor_TextBox.Size = new Size(Editor_TextBox.Size.Width, Editor_TextBox.Size.Height - 40); + tB_line.Size = new Size(tB_line.Size.Width, tB_line.Size.Height - 40); + + if(op == "find") + { + Find_TB.Location = new Point(Editor_TextBox.Width- 241, 5); + Find_Button.Location = new Point(Editor_TextBox.Width - 321, 4); + SearchOptions_Button.Location = new Point(Editor_TextBox.Width, 4); + Find_TB.Visible = !Find_TB.Visible; + Find_Button.Visible = !Find_Button.Visible; + SearchOptions_Button.Visible = !SearchOptions_Button.Visible; + + if(Option1_CB.Text == "Replace all") + { + if (Option1_CB.Checked) + Option1_CB.Checked = false; + } + Option1_CB.Text = "Subtask"; + Option1_CB.Location = new Point(15, Option1_CB.Location.Y); + Find_Panel.Visible = !Find_Panel.Visible; + } + if (op == "replace") + { + Find_TB.Visible = !Find_TB.Visible; + Find_Button.Visible = !Find_Button.Visible; + SearchOptions_Button.Visible = !SearchOptions_Button.Visible; + Replace_TB.Visible = !Replace_TB.Visible; + Replace_Button.Visible = !ShowReplaceMenu_Button.Visible; + + Replace_TB.Location = new Point(Editor_TextBox.Width - 241, 5); + Replace_Button.Location = new Point(Editor_TextBox.Width - 321, 4); + Find_TB.Location = new Point(Editor_TextBox.Width - 591, 5); + Find_Button.Location = new Point(Editor_TextBox.Width - 671, 4); + SearchOptions_Button.Location = new Point(Editor_TextBox.Width, 4); + + if (Option1_CB.Text == "Subtask") + { + if (Option1_CB.Checked) + Option1_CB.Checked = false; + } + Option1_CB.Text = "Replace all"; + Option1_CB.Location = new Point(10, Option1_CB.Location.Y); + Find_Panel.Visible = !Find_Panel.Visible; + } + if (Find_TB.Visible) + Find_TB.Focus(); + else + Editor_TextBox.Focus(); + + if (!Find_Panel.Visible) + { + Find_TB.Text = ""; + Replace_TB.Text = ""; + SearchOptions_Panel.Visible = false; + Editor_TextBox.Size = new Size(Editor_TextBox.Size.Width, Editor_TextBox.Size.Height + 80); + tB_line.Size = new Size(tB_line.Size.Width, tB_line.Size.Height + 80); + } + } + private void Find_Button_Click(object sender, EventArgs e) + { + if (Find_TB.Text.Length > 0) + { + Editor_TextBox.Focus(); + if (Option1_CB.Checked) + SearchForSubtask(); + else + FindText(); + } + else + { + ConsoleHandler.appendLog("You didn't enter anything to search"); + } + } + private void FindOptions_Button_Click(object sender, EventArgs e) + { + SearchOptions_Panel.Visible = !SearchOptions_Panel.Visible; + } + private void FindText() + { + endEditor = Editor_TextBox.Text.Length; + startPosition = Editor_TextBox.SelectionStart + 1; + + if (previousSearchPhrase != Find_TB.Text) + { + startPosition = 0; + endPosition = Find_TB.Text.Length; + numPhrasesFound = 0; + } + for (int i = 0; i < endEditor; i = startPosition) + { + searchPhrase_selected = false; + if (i == -1) + { + MessageBox.Show("Reached the end of the file"); + break; + } + if (startPosition >= endEditor) + { + startPosition = 0; + break; + } + startPosition = Editor_TextBox.Find(Find_TB.Text, startPosition, endEditor, RichTextBoxFinds.None); + if (startPosition >= 0) + { + numPhrasesFound++; + searchPhrase_selected = true; + + endPosition = this.Find_TB.Text.Length; + startPosition = startPosition + endPosition; + previousSearchPhrase = this.Find_TB.Text; + break; + } + if (numPhrasesFound == 0) + { + MessageBox.Show("No Match Found!!!"); + break; + } + } + } + private void Replace_Button_Click(object sender, EventArgs e) + { + if (Find_TB.Text.Length <= 0) + { + MessageBox.Show("You didn't enter anything to search for. Please Try Again"); + } + if (Replace_TB.Text.Length <= 0) + { + MessageBox.Show("You didn't enter anything to replace with. Please Try Again"); + } + if (Option1_CB.Checked) + { + Editor_TextBox.Text = Editor_TextBox.Text.Replace(Find_TB.Text, Replace_TB.Text); + } + else + { + if (!searchPhrase_selected) + { + MessageBox.Show("You need to find something before you can try replacing it..."); + } + else + { + Editor_TextBox.Focus(); + ReplaceText(); + } + } + + } + private void ReplaceText() + { + Editor_TextBox.Text = Editor_TextBox.Text.Remove(startPosition - endPosition, Find_TB.Text.Length); + Editor_TextBox.Text = Editor_TextBox.Text.Insert(startPosition - endPosition, Replace_TB.Text); + endPosition = this.Replace_TB.Text.Length; + startPosition = startPosition + endPosition + Editor_TextBox.SelectionStart + 1; + FindText(); + } + + // + //Right-Click menu + // + private void Editor_TextBox_RightClicked(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + CharIndex_UnderMouse = GeneralMethods.CharIndex_UnderMouse(Editor_TextBox, e.X, e.Y); + + if (Editor_TextBox.SelectedText.Length == 0) + { + NoItem_CM.Show(Editor_TextBox, e.Location); + } + else if (Editor_TextBox.SelectedText.Length > 0) + { + ItemHighlighted_CM.Show(Editor_TextBox, e.Location); + } + } + } + private void NoItem_CM_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Text == "Paste") + { + Editor_TextBox.SelectionStart = CharIndex_UnderMouse; + Editor_TextBox.Paste(); + } + if (e.ClickedItem.Text == "Find subtask") + { + FindSubtask_Button_Event(); + } + if (e.ClickedItem.Text == "Get current subtask number") + { + GetSubtaskNum(); + } + } + private void ItemHighlighted_CM_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Text == "Copy") + { + if (Editor_TextBox.SelectedText.Length > 0) + Clipboard.SetText(Editor_TextBox.SelectedText); + } + if (e.ClickedItem.Text == "Paste") + { + Editor_TextBox.Paste(); + } + if (e.ClickedItem.Text == "Find") + { + Find_TB.Text = Editor_TextBox.SelectedText; + if (!Find_Panel.Visible) + ShowSearchMenu("find"); + + Option1_CB.Checked = false; + } + if (e.ClickedItem.Text == "Replace") + { + ShowSearchMenu("replace"); + if (!Replace_TB.Visible) + ShowSearchMenu("replace"); + + Find_TB.Text = Editor_TextBox.SelectedText; + Option1_CB.Checked = false; + } + if (e.ClickedItem.Text == "Find subtask") + { + FindSubtask_Button_Event(); + } + if (e.ClickedItem.Text == "Get current subtask number") + { + GetSubtaskNum(); + } + } + + + // + //Subtask stuff + // + private void FindSubtask_Button_Event() + { + if (!Find_Panel.Visible) + ShowSearchMenu("find"); + Option1_CB.Checked = true; + ConsoleHandler.force_appendNotice("Please enter the subtask numbers you are looking for in the \"Find\" text box above.\n>> Example: 0,0,1"); + } + private void GetSubtaskNum() + { + if(jsonError == false) + { + string subtaskNum = JSON_Reader.GetSubtaskNum(CharIndex_UnderMouse, Editor_TextBox.Text); + if (subtaskNum != "" && subtaskNum != " " && subtaskNum != null) + { + ConsoleHandler.force_appendLog_CanRepeat("Subtask: [" + subtaskNum + " ]"); + } + else + { + ConsoleHandler.force_appendLog_CanRepeat("Unable to detect subtask. Please try clicking somewhere else..."); + this.Focus(); + } + } + else + { + ConsoleHandler.force_appendLog("JSON error detected... You need to fix the JSON error before you can get the subtask"); + } + } + private void SearchForSubtask() + { + int i = 0; + bool found = false; + foreach (char c in Editor_TextBox.Text) + { + if (c == ':') + { + string subtaskNum = JSON_Reader.GetSubtaskNum(i, Editor_TextBox.Text); + if (subtaskNum.Replace(" ", "").Replace(",", "") == Find_TB.Text.Replace(" ", "").Replace(",", "")) + { + found = true; + + int startHighlighht = Editor_TextBox.Text.LastIndexOf("\"", i - 2); + Editor_TextBox.SelectionStart = i; + Editor_TextBox.Select(i, -(i - startHighlighht)); + Editor_TextBox.ScrollToCaret(); + break; + } + } + i++; + } + if (!found) + { + ConsoleHandler.force_appendLog_CanRepeat("That subtask was not found"); + } + } + private void Option1_CB_CheckedChanged(object sender, EventArgs e) + { + if (Option1_CB.Text == "Subtask") + { + if (Option1_CB.Checked) + ConsoleHandler.force_appendNotice("Please enter the subtask numbers you are looking for in the \"Find\" text box above.\n>> Example: 0,0,1"); + } + } + + // + //UI Events + // + private void SetHideEvents() + { + MouseClick += HideExtraPanels; + Editor_TextBox.Click += HideExtraPanels; + this.Click += HideExtraPanels; + Find_TB.Click += HideExtraPanels; + Replace_TB.Click += HideExtraPanels; + Replace_Button.Click += HideExtraPanels; + Find_Button.Click += HideExtraPanels; + ShowReplaceMenu_Button.Click += HideExtraPanels; + } + private void HideExtraPanels(object sender, EventArgs e) + { + if (SearchOptions_Panel.Visible) + { + SearchOptions_Panel.Visible = false; + } + } + private void Find_TB_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control && e.KeyCode == Keys.F) + { + ShowSearchMenu("find"); + } + if (e.Control && e.KeyCode == Keys.H) + { + ShowSearchMenu("replace"); + } + } + private void Editor_TextBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + tab = string.Concat(Enumerable.Repeat(" ", IndentNewLines())); + tabLine = true; + } + if (e.Control && e.KeyCode == Keys.F) + { + if (Find_Panel.Visible == false && Editor_TextBox.SelectedText.Length > 0) + { + Find_TB.Text = Editor_TextBox.SelectedText; + } + ShowSearchMenu("find"); + } + if (e.Control && e.KeyCode == Keys.H) + { + if (Find_Panel.Visible == false && Editor_TextBox.SelectedText.Length > 0) + { + Find_TB.Text = Editor_TextBox.SelectedText; + } + ShowSearchMenu("replace"); + } + } + private void FontSize_TextBox_TextChanged(object sender, EventArgs e) + { + float FontSize = 0; + float.TryParse(FontSize_TextBox.Text, out FontSize); + if (FontSize < 3) + FontSize = 3; + + Editor_TextBox.Font = new Font("Consolas", FontSize); + tB_line.Font = new Font("Consolas", FontSize); + Serializer.SaveJSONEditor_Instance(this, programData); + } + private void EZTowerEditor_Button_Click(object sender, EventArgs e) + { + if (JSON_Reader.IsValidJson(Editor_TextBox.Text)) + { + var easyTower = new EasyTowerEditor(); + easyTower.path = path; + easyTower.Show(); + } + else + { + ConsoleHandler.force_appendNotice("ERROR! This file doesn't have valid Json. Please fix the Json to continue"); + this.Focus(); + } + } + private void EZBoon_Button_Click(object sender, EventArgs e) + { + if(JSON_Reader.IsValidJson(Editor_TextBox.Text)) + { + var ezBloon = new EZBloon_Editor(); + ezBloon.path = path; + ezBloon.Show(); + } + else + { + ConsoleHandler.force_appendNotice("ERROR! This file doesn't have valid Json. Please fix the Json to continue"); + this.Focus(); + } + } + private void ShowFindMenu_Button_Click(object sender, EventArgs e) + { + if (Find_Panel.Visible == false) + { + if(Find_Panel.Visible == false && Editor_TextBox.SelectedText.Length > 0) + { + Find_TB.Text = Editor_TextBox.SelectedText; + } + ShowSearchMenu("find"); + } + else if (Find_Panel.Visible && Find_TB.Text.Length > 0) + FindText(); + + } + private void ShowReplaceMenu_Button_Click(object sender, EventArgs e) + { + if (Find_Panel.Visible == false) + { + if (Find_Panel.Visible == false && Editor_TextBox.SelectedText.Length > 0) + { + Find_TB.Text = Editor_TextBox.SelectedText; + } + ShowSearchMenu("replace"); + } + else if (Find_Panel.Visible && Find_TB.Text.Length > 0 && Replace_TB.Text.Length > 0) + ReplaceText(); + } + 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_appendNotice("ERROR! This file doesn't have valid Json. Please fix the Json to continue"); + this.Focus(); + } + } + private void RestoreToOriginal_Button_Click(object sender, EventArgs e) + { + RestoreToOriginal(); + } + public void RestoreToOriginal() + { + if (!filename.Contains(New_JsonEditor.readOnlyName)) + { + DialogResult diag = MessageBox.Show("You are trying to restore this file to the original unmodded version. Are you sure you want to do this?", "Restore to original?", MessageBoxButtons.YesNo); + if (diag == DialogResult.Yes) + { + string backupProj = Environment.CurrentDirectory + "\\Backups\\" + Main.gameName + "_BackupProject\\" + path.Replace(Environment.CurrentDirectory, "").Replace("\\" + Serializer.Deserialize_Config().LastProject + "\\", ""); + if (File.Exists(backupProj)) + { + if (path.Contains(".")) + { + if (File.Exists(path)) + { + JsonEditorHandler.CloseFile(path); + File.Delete(path); + } + File.Copy(backupProj, path); + JsonEditorHandler.OpenFile(path); + ConsoleHandler.appendLog_CanRepeat(filename + "has been restored"); + } + } + else + { + ConsoleHandler.appendLog_CanRepeat("Could not find file in backup project... Unable to restore file"); + } + } + else + { + ConsoleHandler.appendLog_CanRepeat("User cancelled restore"); + } + } + else + ConsoleHandler.appendNotice("You can't restore this file because it IS the original " + filename.Replace(New_JsonEditor.readOnlyName, "") + " and it is read only"); + } + private void OpenInFileExplorerToolStripMenuItem_Click(object sender, EventArgs e) + { + OpenInFileExplorer(); + } + public void OpenInFileExplorer() + { + string[] split = path.Split('\\'); + string foldername = path.Replace(split[split.Length - 1], ""); + if(!foldername.Contains("BackupProject")) + { + Process.Start(foldername); + } + else + { + ConsoleHandler.appendNotice("Operation cancelled. We don't want you to edit the backup on accident... If you really need to look at it, you can find it in the Backups folder"); + } + } + private void ViewOriginalToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!filename.Contains(New_JsonEditor.readOnlyName)) + JsonEditorHandler.OpenOriginalFile(path); + else + ConsoleHandler.appendNotice("You are already looking at the original " + filename.Replace(New_JsonEditor.readOnlyName, "")); + } + } +} diff --git a/BTDToolbox/JsonEditor_Instance.resx b/BTDToolbox/JsonEditor_Instance.resx new file mode 100644 index 0000000..7fe40b2 --- /dev/null +++ b/BTDToolbox/JsonEditor_Instance.resx @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + 140, 17 + + + 256, 17 + + \ No newline at end of file diff --git a/BTDToolbox/Main.Designer.cs b/BTDToolbox/Main.Designer.cs index 45487d3..bb8c45f 100644 --- a/BTDToolbox/Main.Designer.cs +++ b/BTDToolbox/Main.Designer.cs @@ -34,6 +34,7 @@ private void InitializeComponent() this.New_ToolStrip = new System.Windows.Forms.ToolStripMenuItem(); this.New_BTD5_Proj = new System.Windows.Forms.ToolStripMenuItem(); this.New_BTDB_Proj = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); this.NewProject_From_Backup = new System.Windows.Forms.ToolStripMenuItem(); this.btdpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); @@ -46,16 +47,6 @@ private void InitializeComponent() this.Find_Button = new System.Windows.Forms.ToolStripMenuItem(); this.Replace_Button = new System.Windows.Forms.ToolStripMenuItem(); this.Launch_Program_ToolStrip = new System.Windows.Forms.ToolStripMenuItem(); - this.viewToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.ToggleConsole = new System.Windows.Forms.ToolStripMenuItem(); - this.OpenJetExplorer = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.ShowBTD5_Pass = new System.Windows.Forms.ToolStripMenuItem(); - this.ShowLastBattlesPass = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.bTD5DirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.bTDBDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.NKHook_Github = new System.Windows.Forms.ToolStripMenuItem(); @@ -67,11 +58,24 @@ private void InitializeComponent() this.spriteEditingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.spriteSheetDecompilerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.spriteAnimationVisualizerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolboxSpriteDecompilerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.getBTDBPasswordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.FlashReader = new System.Windows.Forms.ToolStripMenuItem(); this.bTD5FlashMapEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.ToggleConsole = new System.Windows.Forms.ToolStripMenuItem(); + this.OpenJetExplorer = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); + this.ShowBTD5_Pass = new System.Windows.Forms.ToolStripMenuItem(); + this.ShowLastBattlesPass = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.bTD5DirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.bTDBDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); + this.bTDBPasswordManagerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.EZ_Tools = new System.Windows.Forms.ToolStripMenuItem(); this.EZ_TowerEditor = new System.Windows.Forms.ToolStripMenuItem(); this.EZ_BloonEditor = new System.Windows.Forms.ToolStripMenuItem(); @@ -123,8 +127,8 @@ private void InitializeComponent() this.File_ToolStrip, this.viewToolStripMenuItem, this.Launch_Program_ToolStrip, - this.viewToolStripMenuItem1, this.toolStripMenuItem1, + this.viewToolStripMenuItem1, this.EZ_Tools, this.helpToolStripMenuItem, this.debugToolStripMenuItem}); @@ -152,6 +156,7 @@ private void InitializeComponent() this.New_ToolStrip.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.New_BTD5_Proj, this.New_BTDB_Proj, + this.toolStripSeparator8, this.NewProject_From_Backup, this.btdpToolStripMenuItem}); this.New_ToolStrip.Name = "New_ToolStrip"; @@ -161,29 +166,35 @@ private void InitializeComponent() // New_BTD5_Proj // this.New_BTD5_Proj.Name = "New_BTD5_Proj"; - this.New_BTD5_Proj.Size = new System.Drawing.Size(172, 22); + this.New_BTD5_Proj.Size = new System.Drawing.Size(220, 22); this.New_BTD5_Proj.Text = "BTD5 Project"; this.New_BTD5_Proj.Click += new System.EventHandler(this.New_BTD5_Proj_Click); // // New_BTDB_Proj // this.New_BTDB_Proj.Name = "New_BTDB_Proj"; - this.New_BTDB_Proj.Size = new System.Drawing.Size(172, 22); + this.New_BTDB_Proj.Size = new System.Drawing.Size(220, 22); this.New_BTDB_Proj.Text = "BTD Battles Project"; this.New_BTDB_Proj.Click += new System.EventHandler(this.New_BTDB_Proj_Click); // + // toolStripSeparator8 + // + this.toolStripSeparator8.Name = "toolStripSeparator8"; + this.toolStripSeparator8.Size = new System.Drawing.Size(217, 6); + // // NewProject_From_Backup // this.NewProject_From_Backup.Name = "NewProject_From_Backup"; - this.NewProject_From_Backup.Size = new System.Drawing.Size(172, 22); - this.NewProject_From_Backup.Text = "Project from .jet"; + this.NewProject_From_Backup.Size = new System.Drawing.Size(220, 22); + this.NewProject_From_Backup.Text = "Project from .jet (No Game)"; this.NewProject_From_Backup.Click += new System.EventHandler(this.NewProject_From_Backup_Click); // // btdpToolStripMenuItem // this.btdpToolStripMenuItem.Name = "btdpToolStripMenuItem"; - this.btdpToolStripMenuItem.Size = new System.Drawing.Size(172, 22); + this.btdpToolStripMenuItem.Size = new System.Drawing.Size(220, 22); this.btdpToolStripMenuItem.Text = "Project from .btdp"; + this.btdpToolStripMenuItem.Visible = false; // // openToolStripMenuItem1 // @@ -415,7 +426,8 @@ private void InitializeComponent() // this.spriteEditingToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.spriteSheetDecompilerToolStripMenuItem, - this.spriteAnimationVisualizerToolStripMenuItem}); + this.spriteAnimationVisualizerToolStripMenuItem, + this.toolboxSpriteDecompilerToolStripMenuItem}); this.spriteEditingToolStripMenuItem.Name = "spriteEditingToolStripMenuItem"; this.spriteEditingToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.spriteEditingToolStripMenuItem.Text = "Sprite Editing"; @@ -434,6 +446,12 @@ private void InitializeComponent() this.spriteAnimationVisualizerToolStripMenuItem.Text = "Sprite/Animation Visualizer"; this.spriteAnimationVisualizerToolStripMenuItem.Visible = false; // + // toolboxSpriteDecompilerToolStripMenuItem + // + this.toolboxSpriteDecompilerToolStripMenuItem.Name = "toolboxSpriteDecompilerToolStripMenuItem"; + this.toolboxSpriteDecompilerToolStripMenuItem.Size = new System.Drawing.Size(217, 22); + this.toolboxSpriteDecompilerToolStripMenuItem.Text = "Toolbox Sprite Decompiler"; + // // toolStripSeparator7 // this.toolStripSeparator7.Name = "toolStripSeparator7"; @@ -465,6 +483,96 @@ private void InitializeComponent() this.bTD5FlashMapEditorToolStripMenuItem.Text = "BTD5 Flash Map Editor"; this.bTD5FlashMapEditorToolStripMenuItem.Visible = false; // + // viewToolStripMenuItem1 + // + this.viewToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToggleConsole, + this.OpenJetExplorer, + this.toolStripSeparator6, + this.ShowBTD5_Pass, + this.ShowLastBattlesPass, + this.toolStripSeparator5, + this.bTD5DirectoryToolStripMenuItem, + this.bTDBDirectoryToolStripMenuItem, + this.toolStripMenuItem4, + this.toolStripSeparator9, + this.bTDBPasswordManagerToolStripMenuItem}); + this.viewToolStripMenuItem1.ForeColor = System.Drawing.Color.White; + this.viewToolStripMenuItem1.Name = "viewToolStripMenuItem1"; + this.viewToolStripMenuItem1.Size = new System.Drawing.Size(44, 20); + this.viewToolStripMenuItem1.Text = "View"; + // + // ToggleConsole + // + this.ToggleConsole.Name = "ToggleConsole"; + this.ToggleConsole.Size = new System.Drawing.Size(204, 22); + this.ToggleConsole.Text = "Console"; + this.ToggleConsole.Click += new System.EventHandler(this.ToggleConsole_Click); + // + // OpenJetExplorer + // + this.OpenJetExplorer.Name = "OpenJetExplorer"; + this.OpenJetExplorer.Size = new System.Drawing.Size(204, 22); + this.OpenJetExplorer.Text = "Jet Explorer"; + this.OpenJetExplorer.Click += new System.EventHandler(this.OpenJetExplorer_Click); + // + // toolStripSeparator6 + // + this.toolStripSeparator6.Name = "toolStripSeparator6"; + this.toolStripSeparator6.Size = new System.Drawing.Size(201, 6); + // + // ShowBTD5_Pass + // + this.ShowBTD5_Pass.Name = "ShowBTD5_Pass"; + this.ShowBTD5_Pass.Size = new System.Drawing.Size(204, 22); + this.ShowBTD5_Pass.Text = "BTD5 Password"; + this.ShowBTD5_Pass.Click += new System.EventHandler(this.ShowBTD5_Pass_Click); + // + // ShowLastBattlesPass + // + this.ShowLastBattlesPass.Name = "ShowLastBattlesPass"; + this.ShowLastBattlesPass.Size = new System.Drawing.Size(204, 22); + this.ShowLastBattlesPass.Text = "BTDB Password"; + this.ShowLastBattlesPass.Click += new System.EventHandler(this.ShowLastBattlesPass_Click); + // + // toolStripSeparator5 + // + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(201, 6); + // + // bTD5DirectoryToolStripMenuItem + // + this.bTD5DirectoryToolStripMenuItem.Name = "bTD5DirectoryToolStripMenuItem"; + this.bTD5DirectoryToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.bTD5DirectoryToolStripMenuItem.Text = "BTD5 Directory"; + this.bTD5DirectoryToolStripMenuItem.Click += new System.EventHandler(this.BTD5DirectoryToolStripMenuItem_Click_1); + // + // bTDBDirectoryToolStripMenuItem + // + this.bTDBDirectoryToolStripMenuItem.Name = "bTDBDirectoryToolStripMenuItem"; + this.bTDBDirectoryToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.bTDBDirectoryToolStripMenuItem.Text = "BTDB Directory"; + this.bTDBDirectoryToolStripMenuItem.Click += new System.EventHandler(this.BTDBDirectoryToolStripMenuItem_Click_1); + // + // toolStripMenuItem4 + // + this.toolStripMenuItem4.Name = "toolStripMenuItem4"; + this.toolStripMenuItem4.Size = new System.Drawing.Size(204, 22); + this.toolStripMenuItem4.Text = "Toolbox Directory"; + this.toolStripMenuItem4.Click += new System.EventHandler(this.ToolStripMenuItem4_Click); + // + // toolStripSeparator9 + // + this.toolStripSeparator9.Name = "toolStripSeparator9"; + this.toolStripSeparator9.Size = new System.Drawing.Size(201, 6); + // + // bTDBPasswordManagerToolStripMenuItem + // + this.bTDBPasswordManagerToolStripMenuItem.Name = "bTDBPasswordManagerToolStripMenuItem"; + this.bTDBPasswordManagerToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.bTDBPasswordManagerToolStripMenuItem.Text = "BTDB Password manager"; + this.bTDBPasswordManagerToolStripMenuItem.Click += new System.EventHandler(this.BTDBPasswordManagerToolStripMenuItem_Click); + // // EZ_Tools // this.EZ_Tools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -479,21 +587,21 @@ private void InitializeComponent() // EZ_TowerEditor // this.EZ_TowerEditor.Name = "EZ_TowerEditor"; - this.EZ_TowerEditor.Size = new System.Drawing.Size(180, 22); + this.EZ_TowerEditor.Size = new System.Drawing.Size(155, 22); this.EZ_TowerEditor.Text = "EZ Tower editor"; this.EZ_TowerEditor.Click += new System.EventHandler(this.EZ_TowerEditor_Click); // // EZ_BloonEditor // this.EZ_BloonEditor.Name = "EZ_BloonEditor"; - this.EZ_BloonEditor.Size = new System.Drawing.Size(180, 22); + this.EZ_BloonEditor.Size = new System.Drawing.Size(155, 22); this.EZ_BloonEditor.Text = "EZ Bloon editor"; this.EZ_BloonEditor.Click += new System.EventHandler(this.EZ_BloonEditor_Click); // // EZCard_Editor // this.EZCard_Editor.Name = "EZCard_Editor"; - this.EZCard_Editor.Size = new System.Drawing.Size(180, 22); + this.EZCard_Editor.Size = new System.Drawing.Size(155, 22); this.EZCard_Editor.Text = "EZ Card editor"; this.EZCard_Editor.Click += new System.EventHandler(this.EZCard_Editor_Click); // @@ -806,7 +914,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem New_ToolStrip; private System.Windows.Forms.ToolStripMenuItem btdpToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem Launch_Program_ToolStrip; private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem ToggleConsole; private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; @@ -882,6 +989,11 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem EZ_TowerEditor; private System.Windows.Forms.ToolStripMenuItem EZ_BloonEditor; private System.Windows.Forms.ToolStripMenuItem EZCard_Editor; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator8; + public System.Windows.Forms.ToolStripMenuItem Launch_Program_ToolStrip; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; + private System.Windows.Forms.ToolStripMenuItem bTDBPasswordManagerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolboxSpriteDecompilerToolStripMenuItem; } } diff --git a/BTDToolbox/Main.cs b/BTDToolbox/Main.cs index dd8b59a..180b913 100644 --- a/BTDToolbox/Main.cs +++ b/BTDToolbox/Main.cs @@ -1,4 +1,5 @@ using BTDToolbox.Classes; +using BTDToolbox.Classes.Spritesheets; using BTDToolbox.Extra_Forms; using System; using System.Diagnostics; @@ -16,7 +17,8 @@ namespace BTDToolbox public partial class Main : Form { //Form variables - public static string version = "Alpha 0.0.8"; + public static string version = "Alpha 0.1.0"; + public static bool disableUpdates = false; private static Main toolbox; private static UpdateHandler update; string livePath = Environment.CurrentDirectory; @@ -36,6 +38,7 @@ public partial class Main : Form public static string BTD5_Dir; public static string BTDB_Dir; public static bool enableConsole; + bool projNoGame = false; // Win32 Constants private const int SB_HORZ = 0; @@ -89,11 +92,7 @@ private void Startup() enableConsole = cfgFile.EnableConsole; lastProject = cfgFile.LastProject; - - if (lastProject != null) - { - - } + disableUpdates = cfgFile.disableUpdates; } private void FirstTimeUse() { @@ -141,9 +140,12 @@ private void Main_Load(object sender, EventArgs e) if (programData.recentUpdate == true) ConsoleHandler.appendLog("BTD Toolbox has successfully updated."); - ConsoleHandler.announcement(); - var isUpdate = new UpdateHandler(); - isUpdate.HandleUpdates(); + if(!disableUpdates) + { + ConsoleHandler.announcement(); + var isUpdate = new UpdateHandler(); + isUpdate.HandleUpdates(); + } foreach (Control con in Controls) if (con is MdiClient) @@ -193,9 +195,10 @@ private void Main_KeyDown(object sender, KeyEventArgs e) } private void Main_FormClosed(object sender, FormClosedEventArgs e) { + 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(); } - private void Main_Shown(object sender, EventArgs e) { ConsoleHandler.appendLog("Searching for existing projects..."); @@ -384,19 +387,27 @@ private void Open_Existing_JetFile_Click(object sender, EventArgs e) } private void NewProject(string gameName) { - if (isGamePathValid(gameName) == false) + if (projNoGame == false) { - ConsoleHandler.appendLog("Please browse for " + Get_EXE_Name(gameName)); - browseForExe(gameName); if (isGamePathValid(gameName) == false) { - ConsoleHandler.appendLog("Theres been an error identifying your game"); + ConsoleHandler.appendLog("Please browse for " + Get_EXE_Name(gameName)); + browseForExe(gameName); + if (isGamePathValid(gameName) == false) + { + ConsoleHandler.appendLog("Theres been an error identifying your game"); + } + else + { + if (!Validate_Backup(gameName)) + CreateBackup(gameName); + Serializer.SaveConfig(this, "directories", cfgFile); + var setProjName = new SetProjectName(); + setProjName.Show(); + } } else { - if (!Validate_Backup(gameName)) - CreateBackup(gameName); - Serializer.SaveConfig(this, "directories", cfgFile); var setProjName = new SetProjectName(); setProjName.Show(); } @@ -429,10 +440,7 @@ private void Replace_BTD5_Backup_Click(object sender, EventArgs e) } private void TestForm_Click(object sender, EventArgs e) { - var splash = new SplashScreen(); - splash.Show(); - /*var editor = new JsonEditor(lastProject + "\\Assets\\JSON\\TowerDefinitions\\DartMonkey.tower"); - editor.Show();*/ + JsonEditorHandler.OpenFile(Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\TowerDefinitions\\DartMonkey.tower"); } private void ResetBTD5exeToolStripMenuItem_Click(object sender, EventArgs e) { @@ -505,16 +513,46 @@ private void OpenBTDToolboxGithubToolStripMenuItem_Click(object sender, EventArg private void TestingToolStripMenuItem_Click(object sender, EventArgs e) { - /*string path = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\TowerSprites\\DartMonkey.json"; - var spriteVisualizer = new SpriteVisualizer(); - spriteVisualizer.path = path; - spriteVisualizer.Show();*/ - - var ezBloon = new EZBloon_Editor(); - string path = Environment.CurrentDirectory + "\\" + Serializer.Deserialize_Config().LastProject + "\\Assets\\JSON\\BloonDefinitions\\Red.bloon"; - ezBloon.path = path; - ezBloon.Show(); - + string startDir = ""; + if (gameName != "") + { + MessageBox.Show("Please select the sprite file you want to decompile"); + if (gameName == "BTD5") + { + if(Serializer.Deserialize_Config().BTD5_Directory != "") + { + startDir = Serializer.Deserialize_Config().BTD5_Directory + "\\Assets\\Textures"; + } + } + else + { + if (Serializer.Deserialize_Config().BTDB_Directory != "") + { + startDir = Serializer.Deserialize_Config().BTDB_Directory + "\\Assets\\Textures"; + } + } + } + OpenFileDialog ofd = new OpenFileDialog(); + ofd.InitialDirectory = startDir; + ofd.Title = "Browse for sprite sheet"; + ofd.Filter = "Image files (*.png, *.jpng, *.jpg, *.jpeg) | *.png; *.jpng; *.jpg; *.jpeg"; + ofd.Multiselect = true; + if(ofd.ShowDialog() == DialogResult.OK) + { + if(ofd.FileName.EndsWith(".png") || ofd.FileName.EndsWith(".jpng") || ofd.FileName.EndsWith(".jpg") || ofd.FileName.EndsWith(".jpeg")) + { + SpriteSheet_Handler handler = new SpriteSheet_Handler(); + Thread thread = new Thread(delegate () { handler.Extract(ofd.FileName, "Cell"); }); + thread.Start(); + + } + else + { + MessageBox.Show("You selected an invalid filetype. Please contact the TD Toolbox team if you think we should add this to the list"); + } + } + /*BattlesPassManager mgr = new BattlesPassManager(); + mgr.Show();*/ } private void ToolStripMenuItem2_Click(object sender, EventArgs e) @@ -731,5 +769,11 @@ private void EZCard_Editor_Click(object sender, EventArgs e) ConsoleHandler.force_appendNotice("This tool only works for BTD Battles projects. To use it, please open a BTDB project"); } } + + private void BTDBPasswordManagerToolStripMenuItem_Click(object sender, EventArgs e) + { + BattlesPassManager mgr = new BattlesPassManager(); + mgr.Show(); + } } } \ No newline at end of file diff --git a/BTDToolbox/New_JsonEditor.Designer.cs b/BTDToolbox/New_JsonEditor.Designer.cs new file mode 100644 index 0000000..ed8853b --- /dev/null +++ b/BTDToolbox/New_JsonEditor.Designer.cs @@ -0,0 +1,148 @@ +namespace BTDToolbox +{ + partial class New_JsonEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.ContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.restoreToOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openInFileExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.titleSeperator)).BeginInit(); + this.titleSeperator.Panel1.SuspendLayout(); + this.titleSeperator.Panel2.SuspendLayout(); + this.titleSeperator.SuspendLayout(); + this.contentPanel.SuspendLayout(); + this.ContextMenu.SuspendLayout(); + this.SuspendLayout(); + // + // titleSeperator + // + // + // TitleLabel + // + this.TitleLabel.Size = new System.Drawing.Size(75, 16); + this.TitleLabel.Text = "Json Editor"; + // + // contentPanel + // + this.contentPanel.BackColor = System.Drawing.SystemColors.ControlDarkDark; + this.contentPanel.Controls.Add(this.tabControl1); + // + // close_button + // + this.close_button.FlatAppearance.BorderColor = System.Drawing.Color.Black; + this.close_button.FlatAppearance.BorderSize = 0; + this.close_button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Indigo; + this.close_button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Purple; + this.close_button.Click += new System.EventHandler(this.Close_button_Click); + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed; + this.tabControl1.Location = new System.Drawing.Point(4, 3); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(769, 397); + this.tabControl1.TabIndex = 0; + this.tabControl1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.TabControl1_DrawItem); + this.tabControl1.SizeChanged += new System.EventHandler(this.TabControl1_SizeChanged); + // + // ContextMenu + // + this.ContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.closeToolStripMenuItem, + this.viewOriginalToolStripMenuItem, + this.restoreToOriginalToolStripMenuItem, + this.openInFileExplorerToolStripMenuItem}); + this.ContextMenu.Name = "ContextMenu"; + this.ContextMenu.Size = new System.Drawing.Size(184, 114); + this.ContextMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.ContextClicked); + // + // closeToolStripMenuItem + // + this.closeToolStripMenuItem.Name = "closeToolStripMenuItem"; + this.closeToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.closeToolStripMenuItem.Text = "Close"; + // + // viewOriginalToolStripMenuItem + // + this.viewOriginalToolStripMenuItem.Name = "viewOriginalToolStripMenuItem"; + this.viewOriginalToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.viewOriginalToolStripMenuItem.Text = "View original"; + // + // restoreToOriginalToolStripMenuItem + // + this.restoreToOriginalToolStripMenuItem.Name = "restoreToOriginalToolStripMenuItem"; + this.restoreToOriginalToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.restoreToOriginalToolStripMenuItem.Text = "Restore to original"; + // + // openInFileExplorerToolStripMenuItem + // + this.openInFileExplorerToolStripMenuItem.Name = "openInFileExplorerToolStripMenuItem"; + this.openInFileExplorerToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.openInFileExplorerToolStripMenuItem.Text = "Open in File Explorer"; + // + // New_JsonEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); + this.ClientSize = new System.Drawing.Size(800, 450); + this.KeyPreview = true; + this.Name = "New_JsonEditor"; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "New_JsonEditor"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.New_JsonEditor_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.New_JsonEditor_KeyDown); + this.Controls.SetChildIndex(this.titleSeperator, 0); + this.titleSeperator.Panel1.ResumeLayout(false); + this.titleSeperator.Panel1.PerformLayout(); + this.titleSeperator.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.titleSeperator)).EndInit(); + this.titleSeperator.ResumeLayout(false); + this.contentPanel.ResumeLayout(false); + this.ContextMenu.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + public System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.ContextMenuStrip ContextMenu; + private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem viewOriginalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem restoreToOriginalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openInFileExplorerToolStripMenuItem; + } +} \ No newline at end of file diff --git a/BTDToolbox/New_JsonEditor.cs b/BTDToolbox/New_JsonEditor.cs new file mode 100644 index 0000000..4542060 --- /dev/null +++ b/BTDToolbox/New_JsonEditor.cs @@ -0,0 +1,244 @@ +using BTDToolbox.Classes; +using BTDToolbox.Extra_Forms; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static BTDToolbox.ProjectConfig; + +namespace BTDToolbox +{ + public partial class New_JsonEditor : ThemedForm + { + public static int JsonEditor_Width = 0; + public static int JsonEditor_Height = 0; + public static string selectedPath = ""; + public static bool isJsonError = false; + public static string readOnlyName = "_original (READ-ONLY)"; + public Point mouseClickPos; + + public List tabPages; + public List tabFilePaths; + public List userControls; + + ConfigFile programData; + public New_JsonEditor() + { + InitializeComponent(); + //initSelContextMenu(); + tabControl1.MouseUp += Mouse_RightClick; + + this.MdiParent = Main.getInstance(); + this.Font = new Font("Consolas", 11); + JsonEditor_Width = tabControl1.Width; + JsonEditor_Height = tabControl1.Height; + + programData = Serializer.Deserialize_Config(); + this.Size = new Size(programData.JSON_Editor_SizeX, programData.JSON_Editor_SizeY); + this.Location = new Point(programData.JSON_Editor_PosX, programData.JSON_Editor_PosY); + } + + + // + //Open stuff + // + private void ContextClicked(object sender, ToolStripItemClickedEventArgs e) + { + int i = GetTabUnderMouse(mouseClickPos.X, mouseClickPos.Y); + if (i != 9999) + { + if (e.ClickedItem.Text == "Close") + { + CloseTab(tabFilePaths[i]); + } + else if (e.ClickedItem.Text == "View original") + { + JsonEditorHandler.OpenOriginalFile(tabFilePaths[i]); + } + else if (e.ClickedItem.Text == "Restore to original") + { + userControls[i].RestoreToOriginal(); + } + else if (e.ClickedItem.Text == "Open in File Explorer") + { + userControls[i].OpenInFileExplorer(); + } + } + + } + private void Mouse_RightClick(object sender, MouseEventArgs e) + { + mouseClickPos = new Point(e.X, e.Y); + if (e.Button == MouseButtons.Right) + { + ContextMenu.Show(tabControl1, e.Location); + } + else if (e.Button == MouseButtons.Middle) + { + int i = GetTabUnderMouse(mouseClickPos.X, mouseClickPos.Y); + if (i != 9999) + CloseTab(tabFilePaths[i]); + } + } + public void NewTab(string path) + { + if (path != "" && path != null) + { + tabFilePaths.Add(path); + tabPages.Add(new TabPage()); + userControls.Add(new JsonEditor_Instance()); + + //create the tab and do required processing + + string[] split = path.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; + + AddText(path); + + tabControl1.TabPages.Add(tabPages[tabPages.Count - 1]); + + OpenTab(path); + ConsoleHandler.appendLog_CanRepeat("Opened " + filename); + userControls[userControls.Count - 1].FinishedLoading(); + + } + else + { + ConsoleHandler.appendLog_CanRepeat("Something went wrong when trying to read the files path..."); + } + } + private void AddText(string path) + { + string unformattedText = File.ReadAllText(path); + try + { + JToken jt = JToken.Parse(unformattedText); + string formattedText = jt.ToString(Formatting.Indented); + userControls[userControls.Count - 1].Editor_TextBox.Text = formattedText; + } + catch (Exception) + { + userControls[userControls.Count - 1].Editor_TextBox.Text = unformattedText; + } + } + public void OpenTab(string path) + { + int i = 0; + foreach (string t in tabFilePaths) + { + if (t == path) + { + tabControl1.SelectedTab = tabPages[i]; + userControls[i].Size = new Size(tabControl1.SelectedTab.Width, tabControl1.SelectedTab.Height); + } + i++; + } + } + + // + //Methods + // + public int GetTabUnderMouse(int mouseX, int mouseY) + { + for (int i = 0; i < tabControl1.TabCount; i++) + { + if (tabControl1.GetTabRect(i).Contains(mouseX, mouseY)) + { + return i; + } + } + return 9999; + } + // + //Closing stuff + // + public void CloseTab(string path) + { + int i = tabFilePaths.IndexOf(path); + int indexBeforeDelete = tabControl1.SelectedIndex; + + tabControl1.TabPages.Remove(tabPages[i]); + if (indexBeforeDelete + 1 <= tabControl1.TabPages.Count) + tabControl1.SelectedIndex = indexBeforeDelete; + else + tabControl1.SelectedIndex = indexBeforeDelete - 1; + + tabFilePaths.RemoveAt(i); + tabPages.RemoveAt(i); + userControls.RemoveAt(i); + + if (tabControl1.TabPages.Count <= 0) + this.Close(); + } + private void New_JsonEditor_FormClosing(object sender, FormClosingEventArgs e) + { + Serializer.SaveConfig(this, "json editor", programData); + Serializer.SaveJSONEditor_Tabs(programData); + if(userControls.Count >0) + Serializer.SaveJSONEditor_Instance(userControls[tabControl1.SelectedIndex], programData); + JsonEditorHandler.jeditor = null; + } + private void Close_button_Click(object sender, EventArgs e) + { + Serializer.SaveConfig(this, "json editor", programData); + 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(); + } + } + + // + //Other stuff + // + private void New_JsonEditor_KeyDown(object sender, KeyEventArgs e) + { + /*if (e.Control && e.KeyCode == Keys.F) + { + FindReplace_Panel.Visible = !FindReplace_Panel.Visible; + FindReplace_Panel.BringToFront(); + }*/ + } + private void TabControl1_SizeChanged(object sender, EventArgs e) + { + if (userControls != null) + { + foreach (var x in userControls) + { + x.Size = new Size(tabControl1.SelectedTab.Width, tabControl1.SelectedTab.Height); + } + } + } + private void TabControl1_DrawItem(object sender, DrawItemEventArgs e) + { + TabPage page = tabControl1.TabPages[e.Index]; + //e.Graphics.FillRectangle(new SolidBrush(page.BackColor), e.Bounds); + e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(40, 40, 40)), e.Bounds); + + Rectangle paddedBounds = e.Bounds; + int yOffset = (e.State == DrawItemState.Selected) ? -2 : 1; + paddedBounds.Offset(1, yOffset); + //TextRenderer.DrawText(e.Graphics, page.Text, e.Font, paddedBounds, page.ForeColor); + TextRenderer.DrawText(e.Graphics, page.Text, e.Font, paddedBounds, Color.White); + } + } +} diff --git a/BTDToolbox/New_JsonEditor.resx b/BTDToolbox/New_JsonEditor.resx new file mode 100644 index 0000000..69b2acb --- /dev/null +++ b/BTDToolbox/New_JsonEditor.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/BTDToolbox/ThemedForm.cs b/BTDToolbox/ThemedForm.cs index 33c36f1..010fda1 100644 --- a/BTDToolbox/ThemedForm.cs +++ b/BTDToolbox/ThemedForm.cs @@ -1,4 +1,5 @@ -using System; +using BTDToolbox.Classes; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -88,7 +89,7 @@ private void CheckInBounds() } public virtual void close_button_Click(object sender, EventArgs e) { - if (JsonEditor.jsonError != true) + if (!JsonEditorHandler.AreJsonErrors()) this.Close(); } diff --git a/BTDToolbox/ZipForm.cs b/BTDToolbox/ZipForm.cs index d034760..e101829 100644 --- a/BTDToolbox/ZipForm.cs +++ b/BTDToolbox/ZipForm.cs @@ -71,7 +71,6 @@ private void StartUp() } gameName = std; steamJetPath = gameDir + "\\Assets\\" + jetName; - ValidateEXE(gameName); } public void Extract() { @@ -177,6 +176,36 @@ private void Extract_OnThread() archive.ExtractAll(destPath); archive.Dispose(); + if(!Directory.Exists(Environment.CurrentDirectory + "\\Backups\\" + gameName + "_BackupProject")) + { + string gamed = ""; + if(gameName == "BTD5") + gamed = Serializer.Deserialize_Config().BTD5_Directory; + else + gamed = Serializer.Deserialize_Config().BTDB_Directory; + + //they should have a backup jet of gamed not invalid. create backup proj + if(gamed != "" && gamed != null) + { + ConsoleHandler.force_appendNotice("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; + archive.ExtractAll(destPath); + archive.Dispose(); + }); + } + else + { + ConsoleHandler.force_appendNotice("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.appendLog("Project files created at: " + projName); Invoke((MethodInvoker)delegate { jf = new JetForm(dinfo, Main.getInstance(), dinfo.Name); diff --git a/BTDToolbox/packages.config b/BTDToolbox/packages.config index 0b6b456..07870c6 100644 --- a/BTDToolbox/packages.config +++ b/BTDToolbox/packages.config @@ -1,7 +1,7 @@  - - - + + + \ No newline at end of file