Exemplo n.º 1
0
        //Delete Mod
        private void DeleteMod_Click_1(object sender, EventArgs e)
        {
            Filemanager_ResetMod loadForm = new Filemanager_ResetMod();

            loadForm.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        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 { }
        }