Example #1
0
        void menuText_Click(object sender, EventArgs e)
        {
            if (_config.ConfirmTest)
            {
                DialogResult res = new TestDialog(_config).ShowDialog();
                if (res == DialogResult.Cancel) return;
            }
            // prep stuff
            menuSave_Click("menuTest_Click", new EventArgs());
            if (_config.VerifyTest && !_config.Verify) Common.RunVerify(_mission.MissionPath, _config.VerifyLocation);
            int index = 0;
            while (File.Exists(_config.XwaPath + "\\test" + index + "0.plt")) index++;
            string pilot = "\\test" + index + "0.plt";
            string lst = "\\MISSIONS\\MISSION.LST";
            string backup = "\\MISSIONS\\MISSION_" + index + ".bak";

            // pilot file edit
            File.Copy(Application.StartupPath + "\\xwatest0.plt", _config.XwaPath + pilot);
            FileStream pilotFile = File.OpenWrite(_config.XwaPath + pilot);
            pilotFile.Position = 4;
            char[] indexBytes = index.ToString().ToCharArray();
            BinaryWriter bw = new BinaryWriter(pilotFile);
            bw.Write(indexBytes);
            for (int i = (int)pilotFile.Position; i < 0xC; i++) pilotFile.WriteByte(0);
            pilotFile.Position = 0x010F54;
            bw.Write(indexBytes);
            for (int i = (int)pilotFile.Position; i < 0x010F50 + 0xC; i++) pilotFile.WriteByte(0);
            pilotFile.Close();

            // configure XWA
            System.Diagnostics.Process xwa = new System.Diagnostics.Process();
            xwa.StartInfo.FileName = _config.XwaPath + "\\XWINGALLIANCE.exe";
            xwa.StartInfo.Arguments = "/skipintro";
            xwa.StartInfo.UseShellExecute = false;
            xwa.StartInfo.WorkingDirectory = _config.XwaPath;
            File.Copy(_config.XwaPath + lst, _config.XwaPath + backup, true);
            StreamReader sr = File.OpenText(_config.XwaPath + "\\CONFIG.CFG");
            string contents = sr.ReadToEnd();
            sr.Close();
            int lastpilot = contents.IndexOf("lastpilot ") + 10;
            int nextline = contents.IndexOf("\r\n", lastpilot);
            string modified = contents.Substring(0, lastpilot) + "test" + index + contents.Substring(nextline);
            StreamWriter sw = new FileInfo(_config.XwaPath + "\\CONFIG.CFG").CreateText();
            sw.Write(modified);
            sw.Close();
            sr = File.OpenText(_config.XwaPath + lst);
            contents = sr.ReadToEnd();
            sr.Close();
            string[] expanded = contents.Replace("\r\n", "\0").Split('\0');
            expanded[3] = "7";
            expanded[4] = _mission.MissionFileName;
            expanded[5] = "!MISSION_7_DESC!YOGEME: " + expanded[4];
            modified = String.Join("\r\n", expanded);
            sw = new FileInfo(_config.XwaPath + lst).CreateText();
            sw.Write(modified);
            sw.Close();

            xwa.Start();
            System.Threading.Thread.Sleep(1000);
            System.Diagnostics.Process[] runningXwas = System.Diagnostics.Process.GetProcessesByName("XWINGALLIANCE");
            while (runningXwas.Length > 0)
            {
                Application.DoEvents();
                System.Diagnostics.Debug.WriteLine("sleeping...");
                System.Threading.Thread.Sleep(1000);
                runningXwas = System.Diagnostics.Process.GetProcessesByName("XWINGALLIANCE");
            }

            if (_config.DeleteTestPilots) File.Delete(_config.XwaPath + pilot);
            File.Copy(_config.XwaPath + backup, _config.XwaPath + lst, true);
            File.Delete(_config.XwaPath + backup);
        }
Example #2
0
        void menuTest_Click(object sender, EventArgs e)
        {
            if (_config.ConfirmTest)
            {
                DialogResult res = new TestDialog(_config).ShowDialog();
                if (res == DialogResult.Cancel) return;
            }
            // prep stuff
            menuSave_Click("menuTest_Click", new EventArgs());
            if (_config.VerifyTest && !_config.Verify) Common.RunVerify(_mission.MissionPath, _config.VerifyLocation);
            /*Version os = Environment.OSVersion.Version;
            bool isWin7 = (os.Major == 6 && os.Minor == 1);
            System.Diagnostics.Process explorer = null;
            int restart = 1;
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true);*/

            // configure XvT/BoP
            int index = 0;
            string path = (_mission.IsBop ? _config.BopPath : _config.XvtPath);
            while (File.Exists(path + "\\test" + index + "0.plt")) index++;
            string pilot = "\\test" + index + "0.plt";
            string bopPilot = "\\test" + index + "0.pl2";
            string lst = "\\Train\\IMPERIAL.LST";
            string backup = "\\Train\\IMPERIAL_" + index + ".bak";

            File.Copy(Application.StartupPath + "\\xvttest0.plt", _config.XvtPath + pilot);
            if (_config.BopInstalled) File.Copy(Application.StartupPath + "\\xvttest0.pl2", _config.BopPath + bopPilot, true);
            // XvT pilot edit
            FileStream pilotFile = File.OpenWrite(_config.XvtPath + pilot);
            pilotFile.Position = 4;
            char[] indexBytes = index.ToString().ToCharArray();
            new BinaryWriter(pilotFile).Write(indexBytes);
            for (int i = (int)pilotFile.Position; i < 0xC; i++) pilotFile.WriteByte(0);
            pilotFile.Close();
            // BoP pilot edit
            if (_config.BopInstalled)
            {
                pilotFile = File.OpenWrite(_config.BopPath + bopPilot);
                pilotFile.Position = 4;
                indexBytes = index.ToString().ToCharArray();
                new BinaryWriter(pilotFile).Write(indexBytes);
                for (int i = (int)pilotFile.Position; i < 0xC; i++) pilotFile.WriteByte(0);
                pilotFile.Close();
            }

            // configure XvT
            System.Diagnostics.Process xvt = new System.Diagnostics.Process();
            xvt.StartInfo.FileName = path + "\\Z_XVT__.exe";
            xvt.StartInfo.Arguments = "/skipintro";
            xvt.StartInfo.UseShellExecute = false;
            xvt.StartInfo.WorkingDirectory = path;
            File.Copy(path + lst, path + backup, true);
            StreamReader sr = File.OpenText(_config.XvtPath + "\\Config.cfg");
            string contents = sr.ReadToEnd();
            sr.Close();
            int lastpilot = contents.IndexOf("lastpilot ") + 10;
            int nextline = contents.IndexOf("\r\n", lastpilot);
            string modified = contents.Substring(0, lastpilot) + "test" + index + contents.Substring(nextline);
            StreamWriter sw = new FileInfo(_config.XvtPath + "\\Config.cfg").CreateText();
            sw.Write(modified);
            sw.Close();
            if (_config.BopInstalled)
            {
                sr = File.OpenText(_config.BopPath + "\\config2.cfg");
                contents = sr.ReadToEnd();
                sr.Close();
                lastpilot = contents.IndexOf("lastpilot ") + 10;
                nextline = contents.IndexOf("\r\n", lastpilot);
                modified = contents.Substring(0, lastpilot) + "test" + index + contents.Substring(nextline);
                sw = new FileInfo(_config.BopPath + "\\config2.cfg").CreateText();
                sw.Write(modified);
                sw.Close();
            }
            sr = File.OpenText(path + lst);
            contents = sr.ReadToEnd();
            sr.Close();
            string[] expanded = contents.Replace("\r\n", "\0").Split('\0');
            expanded[4] = _mission.MissionFileName;
            expanded[5] = "YOGEME: " + expanded[4];
            modified = String.Join("\r\n", expanded);
            sw = new FileInfo(path + lst).CreateText();
            sw.Write(modified);
            sw.Close();

            /*if (isWin7)	// explorer kill so colors work right
            {
                restart = (int)key.GetValue("AutoRestartShell", 1);
                key.SetValue("AutoRestartShell", 0, Microsoft.Win32.RegistryValueKind.DWord);
                explorer = System.Diagnostics.Process.GetProcessesByName("explorer")[0];
                explorer.Kill();
                explorer.WaitForExit();
            }*/

            xvt.Start();
            System.Threading.Thread.Sleep(1000);
            System.Diagnostics.Process[] runningXvts = System.Diagnostics.Process.GetProcessesByName("Z_XVT__");
            while (runningXvts.Length > 0)
            {
                Application.DoEvents();
                System.Diagnostics.Debug.WriteLine("sleeping...");
                System.Threading.Thread.Sleep(1000);
                runningXvts = System.Diagnostics.Process.GetProcessesByName("Z_XVT__");
            }

            /*if (isWin7)	// restart
            {
                key.SetValue("AutoRestartShell", restart, Microsoft.Win32.RegistryValueKind.DWord);
                explorer.StartInfo.UseShellExecute = false;
                explorer.StartInfo.FileName = "explorer.exe";
                explorer.Start();
            }*/
            if (_config.DeleteTestPilots)
            {
                File.Delete(_config.XvtPath + pilot);
                File.Delete(_config.BopPath + bopPilot);
            }
            File.Copy(path + backup, path + lst, true);
            File.Delete(path + backup);
        }
Example #3
0
        void menuTest_Click(object sender, EventArgs e)
        {
            if (_config.ConfirmTest)
            {
                DialogResult res = new TestDialog(_config).ShowDialog();
                if (res == DialogResult.Cancel) return;
            }
            // prep stuff
            menuSave_Click("menuTest_Click", new EventArgs());
            if (_config.VerifyTest && !_config.Verify) Common.RunVerify(_mission.MissionPath, _config.VerifyLocation);
            Version os = Environment.OSVersion.Version;
            bool isWin7 = (os.Major == 6 && os.Minor == 1);
            System.Diagnostics.Process explorer = null;
            int restart = 1;
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", false);

            // configure TIE
            int index = 0;
            while (File.Exists(_config.TiePath + "\\TEST" + index + ".tfr")) index++;
            System.Diagnostics.Debug.WriteLine("pilot index: " + index);
            string pilot = "\\TEST" + index + ".tfr";
            string battle = "\\RESOURCE\\BATTLE1.LFD";
            string backup = "\\RESOURCE\\BATTLE1_" + index + ".bak";
            File.Copy(Application.StartupPath + "\\TEST.tfr", _config.TiePath + pilot);
            System.Diagnostics.Process tie = new System.Diagnostics.Process();
            tie.StartInfo.FileName = _config.TiePath + "\\TIE95.exe";
            tie.StartInfo.UseShellExecute = false;
            tie.StartInfo.WorkingDirectory = _config.TiePath;
            File.Copy(_config.TiePath + battle, _config.TiePath + backup, true);
            LfdReader.LfdFile battleLfd = new LfdReader.LfdFile(_config.TiePath + battle);
            LfdReader.Text txt = (LfdReader.Text)battleLfd.Resources[0];
            string[] missions = txt.Strings[3].Split('\0');
            missions[0] = _mission.MissionFileName.Replace(".tie", "");
            txt.Strings[3] = String.Join("\0", missions);
            battleLfd.Write();

            if (isWin7 && !_config.TiePath.ToUpper().Contains("STEAM"))	// explorer kill so colors work right
            {
                key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true);
                restart = (int)key.GetValue("AutoRestartShell", 1);
                key.SetValue("AutoRestartShell", 0, Microsoft.Win32.RegistryValueKind.DWord);
                explorer = System.Diagnostics.Process.GetProcessesByName("explorer")[0];
                explorer.Kill();
                explorer.WaitForExit();
            }

            tie.Start();
            System.Threading.Thread.Sleep(1000);
            System.Diagnostics.Process[] runningTies = System.Diagnostics.Process.GetProcessesByName("tie95");
            while(runningTies.Length > 0)
            {
                Application.DoEvents();
                System.Diagnostics.Debug.WriteLine("sleeping...");
                System.Threading.Thread.Sleep(1000);
                runningTies = System.Diagnostics.Process.GetProcessesByName("tie95");
            }

            if (isWin7 && !_config.TiePath.ToUpper().Contains("STEAM"))	// restart
            {
                key.SetValue("AutoRestartShell", restart, Microsoft.Win32.RegistryValueKind.DWord);
                explorer.StartInfo.UseShellExecute = false;
                explorer.StartInfo.FileName = "explorer.exe";
                explorer.Start();
            }
            if (_config.DeleteTestPilots) File.Delete(_config.TiePath + pilot);
            File.Copy(_config.TiePath + backup, _config.TiePath + battle, true);
            File.Delete(_config.TiePath + backup);
        }