/* * Access Level: Private * Description: Convert the requested BML file to a readable XML * Return value: null */ private void convertBMLtoXML(string fileName, string filePath) { //Required filepaths string filepath_GameBML = AlienDirectories.GameDirectoryRoot() + filePath + fileName + ".BML"; //Game BML file string filepath_WorkingBML = AlienDirectories.ToolWorkingDirectory() + fileName + ".BML"; //Working BML file string filepath_WorkingXML = AlienDirectories.ToolWorkingDirectory() + fileName + ".xml"; //Working XML file //Copy correct BML to working directory File.Copy(filepath_GameBML, filepath_WorkingBML); //Convert BML to XML new AlienConverter(filepath_WorkingBML, filepath_WorkingXML).Run(); //Delete BML File.Delete(filepath_WorkingBML); }
public LoadMovieEditor() { InitializeComponent(); this.WindowState = FormWindowState.Minimized; this.Show(); this.WindowState = FormWindowState.Normal; //Update cursor and begin Cursor.Current = Cursors.WaitCursor; //Set common file paths pathToWorkingBML = AlienDirectories.ToolWorkingDirectory() + "GBL_ITEM.BML"; pathToGameBML = AlienDirectories.GameDirectoryRoot() + @"\DATA\GBL_ITEM.BML"; pathToGameXML = AlienDirectories.GameDirectoryRoot() + @"\DATA\GBL_ITEM.XML"; pathToWorkingXML = AlienDirectories.ToolWorkingDirectory() + "GBL_ITEM.xml"; //Copy correct XML to working directory and fix bug StreamWriter updateXmlContents = new StreamWriter(pathToWorkingXML); updateXmlContents.WriteLine(File.ReadAllText(pathToGameXML).Replace(" xmlns=\"http://www.w3schools.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3schools.com gbl_item.xsd\"", "")); updateXmlContents.Close(); //Load-in XML data var ChrAttributeXML = XDocument.Load(pathToWorkingXML); //Get playlists moviePlaylists.Items.Clear(); IEnumerable <XElement> elements = ChrAttributeXML.XPathSelectElements("//item_database/movie_playlists/movie_playlist"); foreach (XElement el in elements) { moviePlaylists.Items.Add(el.Attribute("playlist_name").Value.ToString()); moviePlaylists.Enabled = true; btnSelectClass.Enabled = true; } //Update cursor and finish Cursor.Current = Cursors.Default; }
public HackingEditor() { InitializeComponent(); this.WindowState = FormWindowState.Minimized; this.Show(); this.WindowState = FormWindowState.Normal; //Update cursor and begin Cursor.Current = Cursors.WaitCursor; //Set common file paths pathToWorkingBML = AlienDirectories.ToolWorkingDirectory() + "GBL_ITEM.BML"; pathToGameBML = AlienDirectories.GameDirectoryRoot() + @"\DATA\GBL_ITEM.BML"; pathToGameXML = AlienDirectories.GameDirectoryRoot() + @"\DATA\GBL_ITEM.XML"; pathToWorkingXML = AlienDirectories.ToolWorkingDirectory() + "GBL_ITEM.xml"; //Copy correct XML to working directory and fix bug StreamWriter updateXmlContents = new StreamWriter(pathToWorkingXML); updateXmlContents.WriteLine(File.ReadAllText(pathToGameXML).Replace(" xmlns=\"http://www.w3schools.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3schools.com gbl_item.xsd\"", "")); updateXmlContents.Close(); //Load-in XML data var ChrAttributeXML = XDocument.Load(pathToWorkingXML); //Get difficulty ranges IEnumerable <XElement> diffsMaxMin = ChrAttributeXML.XPathSelectElements("//item_database/hacking_gating_levels/hack_max_difficulty"); foreach (XElement el in diffsMaxMin) { if (el.Attribute("tool_level").Value.ToString() == "0") { max_difficulty_0.Enabled = true; max_difficulty_0.Text = el.Attribute("max_difficulty").Value.ToString(); } if (el.Attribute("tool_level").Value.ToString() == "1") { max_difficulty_1.Enabled = true; max_difficulty_1.Text = el.Attribute("max_difficulty").Value.ToString(); } if (el.Attribute("tool_level").Value.ToString() == "2") { max_difficulty_2.Enabled = true; max_difficulty_2.Text = el.Attribute("max_difficulty").Value.ToString(); } if (el.Attribute("tool_level").Value.ToString() == "3") { max_difficulty_3.Enabled = true; max_difficulty_3.Text = el.Attribute("max_difficulty").Value.ToString(); } if (el.Attribute("tool_level").Value.ToString() == "99") { min_difficulty_99.Enabled = true; min_difficulty_99.Text = el.Attribute("min_difficulty").Value.ToString(); max_difficulty_99.Enabled = true; max_difficulty_99.Text = el.Attribute("max_difficulty").Value.ToString(); } } //Get difficulties hackDifficulties.Items.Clear(); IEnumerable <XElement> elements = ChrAttributeXML.XPathSelectElements("//item_database/hacking_game_difficulties/hack_difficulty"); foreach (XElement el in elements) { hackDifficulties.Items.Add(el.Attribute("difficulty").Value.ToString()); hackDifficulties.Enabled = true; btnSelectClass.Enabled = true; } //Update cursor and finish Cursor.Current = Cursors.Default; }
public InventoryLoot() { InitializeComponent(); this.WindowState = FormWindowState.Minimized; this.Show(); this.WindowState = FormWindowState.Normal; //Update cursor and begin Cursor.Current = Cursors.WaitCursor; //Set common file paths pathToWorkingBML = AlienDirectories.ToolWorkingDirectory() + "GBL_ITEM.BML"; pathToGameBML = AlienDirectories.GameDirectoryRoot() + @"\DATA\GBL_ITEM.BML"; pathToGameXML = AlienDirectories.GameDirectoryRoot() + @"\DATA\GBL_ITEM.XML"; pathToWorkingXML = AlienDirectories.ToolWorkingDirectory() + "GBL_ITEM.xml"; //Copy correct XML to working directory and fix bug StreamWriter updateXmlContents = new StreamWriter(pathToWorkingXML); updateXmlContents.WriteLine(File.ReadAllText(pathToGameXML).Replace(" xmlns=\"http://www.w3schools.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3schools.com gbl_item.xsd\"", "")); updateXmlContents.Close(); //Load-in XML data var ChrAttributeXML = XDocument.Load(pathToWorkingXML); //Update object lists Inv_Ammo.Items.Clear(); keyframe.Items.Clear(); target_weapon.Items.Clear(); thrown_object_name.Items.Clear(); held_object_name.Items.Clear(); IEnumerable <XElement> ammos = ChrAttributeXML.XPathSelectElements("//item_database/objects/ammo"); foreach (XElement el in ammos) { Inv_Ammo.Items.Add(el.Attribute("name").Value.ToString()); keyframe.Items.Add(el.Attribute("name").Value.ToString()); try { held_object_name.Items.Add(el.Attribute("held_object_name").Value.ToString()); } catch { } try { thrown_object_name.Items.Add(el.Attribute("thrown_object_name").Value.ToString()); } catch { } } Inv_IED.Items.Clear(); IEnumerable <XElement> ieds = ChrAttributeXML.XPathSelectElements("//item_database/objects/ied"); foreach (XElement el in ieds) { Inv_IED.Items.Add(el.Attribute("name").Value.ToString()); keyframe.Items.Add(el.Attribute("name").Value.ToString()); try { held_object_name.Items.Add(el.Attribute("held_object_name").Value.ToString()); } catch { } try { thrown_object_name.Items.Add(el.Attribute("thrown_object_name").Value.ToString()); } catch { } } Inv_Lights.Items.Clear(); IEnumerable <XElement> lights = ChrAttributeXML.XPathSelectElements("//item_database/objects/light"); foreach (XElement el in lights) { Inv_Lights.Items.Add(el.Attribute("name").Value.ToString()); keyframe.Items.Add(el.Attribute("name").Value.ToString()); try { held_object_name.Items.Add(el.Attribute("held_object_name").Value.ToString()); } catch { } try { thrown_object_name.Items.Add(el.Attribute("thrown_object_name").Value.ToString()); } catch { } } Inv_MedKit.Items.Clear(); IEnumerable <XElement> medkits = ChrAttributeXML.XPathSelectElements("//item_database/objects/medikit"); foreach (XElement el in medkits) { Inv_MedKit.Items.Add(el.Attribute("name").Value.ToString()); keyframe.Items.Add(el.Attribute("name").Value.ToString()); try { held_object_name.Items.Add(el.Attribute("held_object_name").Value.ToString()); } catch { } try { thrown_object_name.Items.Add(el.Attribute("thrown_object_name").Value.ToString()); } catch { } } Inv_Objects.Items.Clear(); IEnumerable <XElement> objects = ChrAttributeXML.XPathSelectElements("//item_database/objects/object"); foreach (XElement el in objects) { Inv_Objects.Items.Add(el.Attribute("name").Value.ToString()); keyframe.Items.Add(el.Attribute("name").Value.ToString()); try { held_object_name.Items.Add(el.Attribute("held_object_name").Value.ToString()); } catch { } try { thrown_object_name.Items.Add(el.Attribute("thrown_object_name").Value.ToString()); } catch { } } Inv_Weapons.Items.Clear(); IEnumerable <XElement> weapons = ChrAttributeXML.XPathSelectElements("//item_database/objects/weapon"); foreach (XElement el in weapons) { Inv_Weapons.Items.Add(el.Attribute("name").Value.ToString()); keyframe.Items.Add(el.Attribute("name").Value.ToString()); target_weapon.Items.Add(el.Attribute("name").Value.ToString()); try { held_object_name.Items.Add(el.Attribute("held_object_name").Value.ToString()); } catch { } try { thrown_object_name.Items.Add(el.Attribute("thrown_object_name").Value.ToString()); } catch { } } special_slot.Items.Clear(); IEnumerable <XElement> slots = ChrAttributeXML.XPathSelectElements("//item_database/special_slots/slot"); foreach (XElement el in slots) { special_slot.Items.Add(el.Attribute("name").Value.ToString()); } //Update cursor and finish Cursor.Current = Cursors.Default; }
private void Landing_Main_Load(object sender, EventArgs e) { //Get mod tool version VersionText.Text = "Alien: Isolation Mod Tools" + Environment.NewLine + "Version " + ProductVersion; //Directories string GameDirectory = ""; string BrainiacDirectory = ""; /* CREATE SETTINGS FILE */ if (!File.Exists(Directory.GetCurrentDirectory() + @"\modtools_settings.ayz")) { File.WriteAllText(Directory.GetCurrentDirectory() + @"\modtools_settings.ayz", "1\n0\n1"); //Write default settings } /* SET DIRECTORY LOCATIONS */ bool hasThrownError = false; if (!File.Exists(Directory.GetCurrentDirectory() + @"\modtools_locales.ayz")) { //Check if user has followed tutorial if (File.Exists(Directory.GetCurrentDirectory() + @"\AI.exe")) { GameDirectory = Directory.GetCurrentDirectory(); //Game directory is current directory } else { if (File.Exists(@"C:\Program Files\Steam\steamapps\common\Alien Isolation\AI.exe")) { GameDirectory = @"C:\Program Files\Steam\steamapps\common\Alien Isolation\AI.exe"; //Game directory is default steam directory } else { MessageBox.Show("Please locate your Alien: Isolation executable (AI.exe).", "Mod Tools Setup", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenFileDialog selectGameFile = new OpenFileDialog(); selectGameFile.Filter = "Applications (*.exe)|AI.exe"; if (selectGameFile.ShowDialog() == DialogResult.OK) { GameDirectory = Path.GetDirectoryName(selectGameFile.FileName); //Selected directory is game directory } else { hasThrownError = true; } } } if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\Brainiac Designer\Brainiac Designer.exe")) { BrainiacDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\Brainiac Designer"; //Brainiac designer is default directory } else { MessageBox.Show("Please locate your Brainiac Designer executable (Brainiac Designer.exe).", "Mod Tools Setup", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenFileDialog selectBrainiacFile = new OpenFileDialog(); selectBrainiacFile.Filter = "Applications (*.exe)|Brainiac Designer.exe"; if (selectBrainiacFile.ShowDialog() == DialogResult.OK) { BrainiacDirectory = Path.GetDirectoryName(selectBrainiacFile.FileName); //Selected directory is brainiac directory } else { hasThrownError = true; } } //Save to file string[] ModToolsLocales = { GameDirectory, BrainiacDirectory }; File.WriteAllLines(Directory.GetCurrentDirectory() + @"\modtools_locales.ayz", ModToolsLocales); } //Get directory info again AlienDirectories = new Directories(); /* VALIDATE GAME DIRECTORY */ if (!File.Exists(AlienDirectories.GameDirectoryRoot() + @"\DATA\BINARY_BEHAVIOR\_DIRECTORY_CONTENTS.BML") || hasThrownError) { MessageBox.Show("Please ensure you have selected the correct game install location.", "Missing files!", MessageBoxButtons.OK, MessageBoxIcon.Error); File.Delete(Directory.GetCurrentDirectory() + @"\modtools_locales.ayz"); Environment.Exit(0); } /* CREATE REQUIRED FOLDERS */ Directory.CreateDirectory(AlienDirectories.ToolTreeDirectory()); Directory.CreateDirectory(AlienDirectories.ToolWorkingDirectory()); Directory.CreateDirectory(AlienDirectories.ToolModInstallDirectory()); //Copy LegendPlugin to Brainiac Designer folder if it doesn't exist - if it does, make sure its updated if (!File.Exists(AlienDirectories.BrainiacDirectoryRoot() + "/plugins/LegendPlugin.dll")) { File.WriteAllBytes(AlienDirectories.BrainiacDirectoryRoot() + "/plugins/LegendPlugin.dll", Properties.Resources.LegendPlugin); } else { try { byte[] LegendPluginInstalled = File.ReadAllBytes(AlienDirectories.BrainiacDirectoryRoot() + "/plugins/LegendPlugin.dll"); if (LegendPluginInstalled.Count() != Properties.Resources.LegendPlugin.Count()) { //Legendplugin exists but is out of date - update from resources File.Delete(AlienDirectories.BrainiacDirectoryRoot() + "/plugins/LegendPlugin.dll"); File.WriteAllBytes(AlienDirectories.BrainiacDirectoryRoot() + "/plugins/LegendPlugin.dll", Properties.Resources.LegendPlugin); MessageBox.Show("LegendPlugin has been updated to a new version." + Environment.NewLine + "These changes will be seen within Brainiac Designer.", "Alien: Isolation Mod Tools Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { } } //Initialise resources for mod tools if (!Directory.Exists(AlienDirectories.ToolResourceDirectory())) { Directory.CreateDirectory(AlienDirectories.ToolResourceDirectory()); File.WriteAllBytes(AlienDirectories.ToolResourceDirectory() + "Isolation.ttf", Properties.Resources.Isolation_Isolation); File.WriteAllBytes(AlienDirectories.ToolResourceDirectory() + "Jixellation.ttf", Properties.Resources.JixellationBold_Jixellation); File.WriteAllBytes(AlienDirectories.ToolResourceDirectory() + "Nostromo.ttf", Properties.Resources.NostromoBoldCond_Nostromo_Cond); } //Load fonts PrivateFontCollection ModToolFont = new PrivateFontCollection(); ModToolFont.AddFontFile(AlienDirectories.ToolResourceDirectory() + "Isolation.ttf"); ModToolFont.AddFontFile(AlienDirectories.ToolResourceDirectory() + "Jixellation.ttf"); ModToolFont.AddFontFile(AlienDirectories.ToolResourceDirectory() + "Nostromo.ttf"); //Set fonts & parents MakeMod.Font = new Font(ModToolFont.Families[0], 40); MakeMod.Parent = LandingBackground; SaveMod.Font = new Font(ModToolFont.Families[0], 40); SaveMod.Parent = LandingBackground; LoadMod.Font = new Font(ModToolFont.Families[0], 40); LoadMod.Parent = LandingBackground; DeleteMod.Font = new Font(ModToolFont.Families[0], 40); DeleteMod.Parent = LandingBackground; LaunchGame.Font = new Font(ModToolFont.Families[0], 40); LaunchGame.Parent = LandingBackground; VersionText.Font = new Font(ModToolFont.Families[1], 15); VersionText.Parent = LandingBackground; Title2.Font = new Font(ModToolFont.Families[1], 20); Title2.Parent = LandingBackground; Title3.Font = new Font(ModToolFont.Families[1], 20); Title3.Parent = LandingBackground; this.WindowState = FormWindowState.Minimized; this.Show(); this.WindowState = FormWindowState.Normal; //Try free some resources try { GC.Collect(); GC.WaitForPendingFinalizers(); } catch { } try { Landing CreateModScreen = (Landing)Application.OpenForms["Landing"]; CreateModScreen.Close(); } catch { } try { Filemanager_ExportMod ExportModScreen = (Filemanager_ExportMod)Application.OpenForms["Filemanager_ExportMod"]; ExportModScreen.Close(); } catch { } try { Filemanager_ImportMod ImportModScreen = (Filemanager_ImportMod)Application.OpenForms["Filemanager_ImportMod"]; ImportModScreen.Close(); } catch { } try { Filemanager_ResetMod ResetModScreen = (Filemanager_ResetMod)Application.OpenForms["Filemanager_ResetMod"]; ResetModScreen.Close(); } catch { } }
private void VersionCheck_Load(object sender, EventArgs e) { try { //Get current Github version WebClient webClient = new WebClient(); //Stream webStream = webClient.OpenRead("https://raw.githubusercontent.com/MattFiler/LegendPlugin/master/Source/version.txt?random=" + random.Next(5000).ToString()); Stream webStream = webClient.OpenRead("https://raw.githubusercontent.com/MattFiler/LegendPlugin/master/Source/PackagingTool/Properties/AssemblyInfo.cs?v=" + ProductVersion + "&r = " + random.Next(5000).ToString()); StreamReader webRead = new StreamReader(webStream); string[] LatestVersionArray = webRead.ReadToEnd().Split(new[] { "AssemblyFileVersion(\"" }, StringSplitOptions.None); string LatestVersionNumber = LatestVersionArray[1].Substring(0, LatestVersionArray[1].Length - 4); //Check against current version if (ProductVersion != LatestVersionNumber) { //Out of date if (AlienDirectories.GameDirectoryRoot() == "") { throw new System.InvalidOperationException("The path is not of a legal form."); } string NewEXE = AlienDirectories.GameDirectoryRoot() + "/Mod Tools V" + LatestVersionNumber + ".exe"; if (File.Exists(NewEXE)) { //Start new exe Process.Start(NewEXE); //Close app Application.Exit(); Environment.Exit(0); } else { //New update needs to be downloaded MessageBox.Show("A new version of the Alien: Isolation Mod Tools is available." + Environment.NewLine + "The latest version will be downloaded to your game directory.", "Alien: Isolation Mod Tools Updater", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.TopMost = true; webClient.DownloadProgressChanged += (s, clientprogress) => { UpdateProgress.Value = clientprogress.ProgressPercentage; }; webClient.DownloadFileCompleted += (s, clientprogress) => { //Finish progress bar UpdateProgress.Value = 100; //Start new exe Process.Start(NewEXE); //Close app Application.Exit(); Environment.Exit(0); }; webClient.DownloadFileAsync(new Uri("https://raw.githubusercontent.com/MattFiler/LegendPlugin/master/Mod%20Tools/Mod%20Tools.exe"), NewEXE); } } else { //Clean up from previous updates DeleteOldEXE(); //Close version checker Landing_Main MainLander = new Landing_Main(); MainLander.Show(); this.Close(); } } catch (Exception errormessage) { if (errormessage.Message.ToString() != "The path is not of a legal form.") { //Probably no internet connection MessageBox.Show("Failed to check for updates." + Environment.NewLine + "Continuing with version " + ProductVersion, "Alien: Isolation Mod Tools Updater", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //File error - means we're loading for the first time ... but have to have a messagebox here else we'll crash if (File.Exists("modtools_locales.ayz")) { MessageBox.Show("Alien: Isolation Mod Tools running version " + ProductVersion, "Alien: Isolation Mod Tools Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Welcome to the Alien: Isolation Mod Tools!", "Mod Tools Setup", MessageBoxButtons.OK, MessageBoxIcon.Information); } } Landing_Main MainLander = new Landing_Main(); MainLander.Show(); this.Close(); } }