diff --git a/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.Designer.cs b/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.Designer.cs index 1ac5b57..ac93d25 100644 --- a/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.Designer.cs +++ b/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.Designer.cs @@ -43,7 +43,7 @@ private void InitializeComponent() // unpackButton // this.unpackButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.unpackButton.Location = new System.Drawing.Point(96, 618); + this.unpackButton.Location = new System.Drawing.Point(96, 620); this.unpackButton.Name = "unpackButton"; this.unpackButton.Size = new System.Drawing.Size(229, 50); this.unpackButton.TabIndex = 2; @@ -54,7 +54,7 @@ private void InitializeComponent() // repackButton // this.repackButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.repackButton.Location = new System.Drawing.Point(96, 674); + this.repackButton.Location = new System.Drawing.Point(96, 676); this.repackButton.Name = "repackButton"; this.repackButton.Size = new System.Drawing.Size(229, 50); this.repackButton.TabIndex = 3; @@ -65,7 +65,7 @@ private void InitializeComponent() // resetTrees // this.resetTrees.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.resetTrees.Location = new System.Drawing.Point(653, 618); + this.resetTrees.Location = new System.Drawing.Point(653, 620); this.resetTrees.Name = "resetTrees"; this.resetTrees.Size = new System.Drawing.Size(229, 50); this.resetTrees.TabIndex = 4; @@ -110,7 +110,7 @@ private void InitializeComponent() // this.Title4.AutoSize = true; this.Title4.Font = new System.Drawing.Font("Isolation", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Title4.Location = new System.Drawing.Point(90, 582); + this.Title4.Location = new System.Drawing.Point(90, 580); this.Title4.Name = "Title4"; this.Title4.Size = new System.Drawing.Size(278, 33); this.Title4.TabIndex = 50; @@ -120,7 +120,7 @@ private void InitializeComponent() // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Isolation", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(647, 582); + this.label1.Location = new System.Drawing.Point(647, 580); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(169, 33); this.label1.TabIndex = 51; diff --git a/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.cs b/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.cs index b90b550..d4974b0 100644 --- a/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.cs +++ b/BehaviourTreeTool/BehaviourTreeTool/BehaviourPacker.cs @@ -10,6 +10,7 @@ using System.IO; using System.Text.RegularExpressions; using System.Diagnostics; +using System.Collections.Generic; namespace BehaviourTreeTool { @@ -26,29 +27,27 @@ private void BehaviourPacker_Load(object sender, EventArgs e) HeaderText.Font = FontManager.GetFont(1, 80); HeaderText.Parent = HeaderImage; Title4.Font = FontManager.GetFont(0, 20); + label1.Font = FontManager.GetFont(0, 20); } /* UNPACK */ private void unpackButton_Click(object sender, EventArgs e) { + if (!Directory.Exists(SharedData.pathToBehaviourTrees)) Directory.CreateDirectory(SharedData.pathToBehaviourTrees); if (!File.Exists(SharedData.pathToBehaviourTrees + "alien_all_search_variants.xml")) { - /* STARTING */ unpackButton.Enabled = false; repackButton.Enabled = false; resetTrees.Enabled = false; Cursor.Current = Cursors.WaitCursor; - /* COPY _BINARY_BEHAVIOUR TO WORKING DIRECTORY */ + //Convert BML to XML File.Copy(SharedData.pathToAI + @"\DATA\BINARY_BEHAVIOR\_DIRECTORY_CONTENTS.BML", SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.BML"); - - /* CONVERT _BINARY_BEHAVIOUR TO XML */ new AlienConverter(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.BML", SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.xml").Run(); - /* EXTRACT XML TO SEPARATE FILES */ + //Extract XML to separate files string directoryContentsXML = File.ReadAllText(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.xml"); //Get contents from newly converted _DIRECTORY_CONTENTS string fileHeader = "\n"; //Premade file header int count = 0; - foreach (string currentFile in Regex.Split(directoryContentsXML, ""); //Split filename and contents string[] extractedContentsMain = Regex.Split(extractedContents[1], ""); //Split contents and footer string[] fileContents = { fileHeader, extractedContentsMain[0] }; //Write preset header and newly grabbed contents - string fileName = ""; - if (File.Exists(SharedData.pathToAI + @"\DATA\BINARY_BEHAVIOR\gameismodded.txt") || //legacy - File.Exists(SharedData.pathToAI + @"\DATA\BINARY_BEHAVIOR\packagingtool_hasmodded.ayz")) - { - fileName = extractedContents[0].Substring(1, extractedContents[0].Length - 9); //Grab filename - } - else - { - fileName = extractedContents[0].Substring(1, extractedContents[0].Length - 11); //Grab filename UNMODDED FILE - } + string fileName = extractedContents[0].Substring(1).Split(new string[] { ".bml" }, StringSplitOptions.None)[0]; //Grab filename File.WriteAllLines(SharedData.pathToBehaviourTrees + fileName + ".xml", fileContents); //Write new file } } - /* DELETE EXCESS FILES */ File.Delete(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.BML"); File.Delete(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.xml"); - /* DONE */ Cursor.Current = Cursors.Default; unpackButton.Enabled = true; repackButton.Enabled = true; resetTrees.Enabled = true; } - /* OPEN BRAINIAC */ + //Open Brainiac Designer ProcessStartInfo brainiacProcess = new ProcessStartInfo(); brainiacProcess.WorkingDirectory = Environment.CurrentDirectory; brainiacProcess.FileName = Environment.CurrentDirectory + "/Brainiac Designer.exe"; - Process myProcess = Process.Start(brainiacProcess); + Process.Start(brainiacProcess); } /* REPACK */ private void repackButton_Click(object sender, EventArgs e) { - if (File.Exists(SharedData.pathToBehaviourTrees + "alien_all_search_variants.xml")) + if (!Directory.Exists(SharedData.pathToBehaviourTrees)) Directory.CreateDirectory(SharedData.pathToBehaviourTrees); + if (!File.Exists(SharedData.pathToBehaviourTrees + "alien_all_search_variants.xml")) + { + MessageBox.Show("No modifications have been made! Nothing to import."); + } + else { - /* STARTING */ unpackButton.Enabled = false; repackButton.Enabled = false; resetTrees.Enabled = false; Cursor.Current = Cursors.WaitCursor; - /* WRITE NEW _DIRECTORY_CONTENTS XML AND DELETE FILES */ + //Create new XML to write string compiledBinaryBehaviourContents = ""; //Start file - DirectoryInfo workingDirectoryInfo = new DirectoryInfo(SharedData.pathToBehaviourTrees); //Get all files in directory foreach (FileInfo currentFile in workingDirectoryInfo.GetFiles()) { @@ -114,54 +105,52 @@ private void repackButton_Click(object sender, EventArgs e) compiledBinaryBehaviourContents += customFileHeader + fileContents.Substring(38) + customFileFooter; //Add to file string } - compiledBinaryBehaviourContents += ""; //Finish off file string - string[] compiledContentsAsArray = { compiledBinaryBehaviourContents }; - File.WriteAllLines(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.xml", compiledContentsAsArray); //Write new file - - /* CONVERT _BINARY_BEHAVIOUR TO BML */ + //Write and convert to BML + File.WriteAllText(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.xml", compiledBinaryBehaviourContents); new AlienConverter(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.xml", SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.bml").Run(); - /* COPY _BINARY_BEHAVIOUR TO GAME AND DELETE FILES */ File.Delete(SharedData.pathToAI + @"\DATA\BINARY_BEHAVIOR\_DIRECTORY_CONTENTS.BML"); File.Copy(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.bml", SharedData.pathToAI + @"\DATA\BINARY_BEHAVIOR\_DIRECTORY_CONTENTS.BML"); - string[] moddedGameText = { "DO NOT DELETE THIS FILE" }; - File.WriteAllLines(SharedData.pathToAI + @"\DATA\BINARY_BEHAVIOR\packagingtool_hasmodded.ayz", moddedGameText); //Write modded game text File.Delete(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.bml"); File.Delete(SharedData.pathToBehaviourTrees + "_DIRECTORY_CONTENTS.xml"); - /* DONE */ Cursor.Current = Cursors.Default; - MessageBox.Show("Modifications have been imported."); unpackButton.Enabled = true; repackButton.Enabled = true; resetTrees.Enabled = true; - } - else - { - MessageBox.Show("No modifications have been made! Nothing to import."); + + MessageBox.Show("Modifications have been imported."); } } /* RESET */ private void resetTrees_Click(object sender, EventArgs e) { - /* STARTING */ unpackButton.Enabled = false; repackButton.Enabled = false; resetTrees.Enabled = false; Cursor.Current = Cursors.WaitCursor; - /* RESET FILE */ + //Kill Brainiac + List allProcesses = new List(Process.GetProcessesByName("Brainiac Designer")); + for (int i = 0; i < allProcesses.Count; i++) allProcesses[i].Kill(); + + //Reset files File.WriteAllBytes(SharedData.pathToAI + @"\DATA\BINARY_BEHAVIOR\_DIRECTORY_CONTENTS.BML", Properties.Resources._DIRECTORY_CONTENTS); + if (Directory.Exists(SharedData.pathToBehaviourTrees)) + { + string[] trees = Directory.GetFiles(SharedData.pathToBehaviourTrees, "*.xml", SearchOption.TopDirectoryOnly); + for (int i = 0; i < trees.Length; i++) File.Delete(trees[i]); + } - /* DONE */ Cursor.Current = Cursors.Default; - MessageBox.Show("Changes reset to vanilla.\nIf you have the editor open, close it and re-open through this window.", "Please relaunch the editor if open!", MessageBoxButtons.OK, MessageBoxIcon.Information); unpackButton.Enabled = true; repackButton.Enabled = true; resetTrees.Enabled = true; + + MessageBox.Show("Behaviour trees have been reset to defaults!", "Reset complete.", MessageBoxButtons.OK, MessageBoxIcon.Information); } //Close diff --git a/BehaviourTreeTool/BehaviourTreeTool/BehaviourTreeTool.csproj b/BehaviourTreeTool/BehaviourTreeTool/BehaviourTreeTool.csproj index 4341b12..07a1dc2 100644 --- a/BehaviourTreeTool/BehaviourTreeTool/BehaviourTreeTool.csproj +++ b/BehaviourTreeTool/BehaviourTreeTool/BehaviourTreeTool.csproj @@ -45,7 +45,9 @@ ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll + diff --git a/BehaviourTreeTool/LegendPlugin/Action/ActionAssert.cs b/BehaviourTreeTool/LegendPlugin/Action/ActionAssert.cs index 455ad18..1f8d177 100644 --- a/BehaviourTreeTool/LegendPlugin/Action/ActionAssert.cs +++ b/BehaviourTreeTool/LegendPlugin/Action/ActionAssert.cs @@ -47,7 +47,7 @@ public string AssertInfo set { _AssertInfo = value; } } - public ActionAssert() : base("Asset", "ASSERT AN ERROR - USED FOR DEBUGGING.") + public ActionAssert() : base("Assert", "ASSERT AN ERROR - USED FOR DEBUGGING.") { } diff --git a/BehaviourTreeTool/LegendPlugin/Sequence/SequenceLinear.cs b/BehaviourTreeTool/LegendPlugin/Sequence/SequenceLinear.cs index 689186a..f8759df 100644 --- a/BehaviourTreeTool/LegendPlugin/Sequence/SequenceLinear.cs +++ b/BehaviourTreeTool/LegendPlugin/Sequence/SequenceLinear.cs @@ -38,24 +38,22 @@ public class SequenceLinear : Sequence { //All parameters added - protected ChildStateType _stateType; - //private string _Name = ""; + protected ChildStateType _childStateType; + private string _Name = ""; [DesignerEnum("Child state type", "ChildStateType", "CategoryBasic", DesignerProperty.DisplayMode.Parameter, 0, DesignerProperty.DesignerFlags.NoFlags, null)] - public ChildStateType stateType + public ChildStateType ChildStateType { - get { return _stateType; } - set { _stateType = value; } + get { return _childStateType; } + set { _childStateType = value; } } - /* [DesignerString("Name", "Name", "CategoryBasic", DesignerProperty.DisplayMode.Parameter, 0, DesignerProperty.DesignerFlags.NoFlags)] public string Name { get { return _Name; } set { _Name = value; } } - */ public SequenceLinear() : base("Linear", "A LINEAR SEQUENCE.") @@ -67,8 +65,8 @@ protected override void CloneProperties(Node newnode) base.CloneProperties(newnode); SequenceLinear cond = (SequenceLinear)newnode; - cond._stateType = _stateType; - //cond._Name = _Name; + cond._childStateType = _childStateType; + cond._Name = _Name; } } } diff --git a/BehaviourTreeTool/LegendPlugin/Sequence/SequenceStateless.cs b/BehaviourTreeTool/LegendPlugin/Sequence/SequenceStateless.cs index c40797c..380bebc 100644 --- a/BehaviourTreeTool/LegendPlugin/Sequence/SequenceStateless.cs +++ b/BehaviourTreeTool/LegendPlugin/Sequence/SequenceStateless.cs @@ -38,24 +38,22 @@ public class SequenceStateless : Sequence { //All parameters added - protected ChildStateType _stateType; - //private string _Name = ""; + protected ChildStateType _childStateType; + private string _Name = ""; [DesignerEnum("Child state type", "ChildStateType", "CategoryBasic", DesignerProperty.DisplayMode.Parameter, 0, DesignerProperty.DesignerFlags.NoFlags, null)] - public ChildStateType stateType + public ChildStateType ChildStateType { - get { return _stateType; } - set { _stateType = value; } + get { return _childStateType; } + set { _childStateType = value; } } - /* [DesignerString("Name", "Name", "CategoryBasic", DesignerProperty.DisplayMode.Parameter, 0, DesignerProperty.DesignerFlags.NoFlags)] public string Name { get { return _Name; } set { _Name = value; } } - */ public SequenceStateless() : base("Stateless", "A SEQUENCE THAT IS STATELESS.") @@ -67,8 +65,8 @@ protected override void CloneProperties(Node newnode) base.CloneProperties(newnode); SequenceStateless cond = (SequenceStateless)newnode; - cond._stateType = _stateType; - //cond._Name = _Name; + cond._childStateType = _childStateType; + cond._Name = _Name; } } } diff --git a/Build/BehaviourTreeTool.exe b/Build/BehaviourTreeTool.exe index c82c7d3..998e38d 100644 Binary files a/Build/BehaviourTreeTool.exe and b/Build/BehaviourTreeTool.exe differ diff --git a/Build/plugins/LegendPlugin.dll b/Build/plugins/LegendPlugin.dll index c7c41a0..2d78014 100644 Binary files a/Build/plugins/LegendPlugin.dll and b/Build/plugins/LegendPlugin.dll differ