/* * private void CboxDebug_Changed(object sender, RoutedEventArgs e) * { * if (!IsLoaded) //Don't update cfg while the control loads * return; * * // Bools convert "nicely" to 0s and 1s :) * Cfg.SetVariable("debug =", Convert.ToString(Convert.ToInt32(CboxDebug.IsChecked)), ref Cfg.ConfigFile); * Cfg.SaveConfigFile(Cfg.InstallPath + "xlive.ini", Cfg.ConfigFile); * } */ private void GameArguments_TextChanged(object sender, TextChangedEventArgs e) { if (!IsLoaded) //Don't update cfg while the control loads { return; } Cfg.SetVariable("arguments =", GameArguments.Text, ref Cfg.ConfigFile); Cfg.SaveConfigFile(Cfg.InstallPath + "xlive.ini", Cfg.ConfigFile); }
private void PlayerName_TextChanged(object sender, TextChangedEventArgs e) { if (!IsLoaded) // Makes sure that we don't update cfg while the control loads { return; } Cfg.SetVariable("profile name 1 =", PlayerName.Text, ref Cfg.ConfigFile); Cfg.SaveConfigFile("xlive.ini", Cfg.ConfigFile); }
private void GetLatestVersions() { var versionLines = new WebClient().DownloadString(UpdateServer + "version.txt") .Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); //Grab version number from the URL constant // Grab latest (line 1) or dev build (line 2) if (Cfg.GetConfigVariable("dev_build =", null, false) != "1") { _latestVersion = versionLines[0]; } else { _latestVersion = versionLines[2] + "-Beta"; } _latestLauncherVersion = versionLines[1]; //Latest launcher version from line 2 of version.txt //if (versionLines.Length == 3) // _disableHalo2Download = true; //else // _halo2DownloadUrl = versionLines[3]; //Halo 2 download url from line 3 of version.txt //Grab xlive.dll file version number. File doesn't exist? 0.0.0.0 _localVersion = File.Exists(Cfg.InstallPath + @"\xlive.dll") ? FileVersionInfo.GetVersionInfo(Cfg.InstallPath + @"\xlive.dll").FileVersion : "0.0.0.0"; //Grab halo2.exe file version number. _halo2Version = File.Exists(Cfg.InstallPath + @"\" + ProcessName + ".exe") ? FileVersionInfo.GetVersionInfo(Cfg.InstallPath + @"\" + ProcessName + ".exe").FileVersion : "0.0.0.0"; _localLauncherVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); //Grab launcher version Trace.WriteLine("Latest h2vonline: " + _latestVersion); Trace.WriteLine("Latest launcher: " + _latestLauncherVersion); Trace.WriteLine("Local h2vonline: " + _localVersion); Trace.WriteLine("Local launcher: " + _localLauncherVersion); Trace.WriteLine("Halo 2: " + _halo2Version); Trace.WriteLine(Cfg.InstallPath + @"\" + ProcessName + ".exe"); if (_localLauncherVersion != null) { LauncherVersion.Foreground = _localLauncherVersion == _latestLauncherVersion ? new SolidColorBrush(Colors.Lime) : new SolidColorBrush(Colors.OrangeRed); LauncherVersion.Content = _localLauncherVersion; } if (_localVersion != null) { PcVersion.Foreground = _localVersion == _latestVersion ? new SolidColorBrush(Colors.Lime) : new SolidColorBrush(Colors.OrangeRed); PcVersion.Content = _localVersion; } }
private void CboxDebug_Changed(object sender, RoutedEventArgs e) { if (!IsLoaded) // Don't update cfg while the control loads { return; } // Bools convert "nicely" to 0s and 1s :) Cfg.SetVariable("debug =", Convert.ToString(Convert.ToInt32(CboxDebug.IsChecked)), ref Cfg.ConfigFile); Cfg.SaveConfigFile("xlive.ini", Cfg.ConfigFile); }
private void PlayerName_TextChanged(object sender, TextChangedEventArgs e) { if (!IsLoaded || ButtonAction.Content == "Play") // Makes sure that we don't update cfg while the control loads { return; } StartTimer(); Cfg.SetVariable("name =", UsernameBox.Text, ref Cfg.ConfigFile); Cfg.SaveConfigFile(Cfg.InstallPath + "xlive.ini", Cfg.ConfigFile); }
private bool Load() //TODO: Databind this { try { UsernameBox.Text = Cfg.GetConfigVariable("name =", null); GameArguments.Text = Cfg.GetConfigVariable("arguments =", ""); //CboxDebug.IsChecked = Convert.ToBoolean(Convert.ToInt32(Cfg.GetConfigVariable("debug_log =", "0"))); Trace.WriteLine("Name: " + UsernameBox.Text); //Write Name //Trace.WriteLine("Debug: " + CboxDebug.IsChecked); //Write debug selection return(true); } catch { return(false); } }
private void ButtonAction_Click(object sender, RoutedEventArgs e) { if ((string)ButtonAction.Content == "Play") { try { if (Cfg.CheckIfProcessIsRunning(ProcessName)) // Kill halo2 if its running (Should help with black screens) { KillProcess(ProcessName); } Process.Start(ProcessName + ".exe"); // Good to go! (may need target parameters later) } catch { Trace.WriteLine("Could not find or launch Halo 2 application."); TextboxOutput.Text = "Could not find or launch Halo 2 application."; } } else if ((string)ButtonAction.Content == "Close Game") // Game is open { if (Cfg.CheckIfProcessIsRunning(ProcessName)) // Might be redundant but we don't want crashes { KillProcess(ProcessName); } ButtonAction.Content = "Play"; } else if ((string)ButtonAction.Content == "Update") { KillProcess(ProcessName); // Kills Halo 2 before updating TODO: add dialog before closing ButtonAction.Content = "Updating..."; // Button is still enabled if download is long it might look strange // TODO: Implement a filelist.txt on server so we can grab needed files (append build number to only grab latest) if (!File.Exists("MF.dll")) // If we don't find mf.dll { DownloadFile(UpdateServer + "MF.dll", "MF.dll"); } if (!File.Exists("h2Update.exe") && _halo2Version != LatestHalo2Version) // If halo2 needs an update { DownloadFile(UpdateServer + "h2Update.exe", "h2Update.exe"); } if (!File.Exists("gungame.ini")) // If we don't find gungame.ini { DownloadFile(UpdateServer + "gungame.ini", "gungame.ini"); } if (_localVersion != _latestVersion) // If our xlive.dll is old { DownloadFile(UpdateServer + "xlive.dll", "xlive.dll"); } //Never update the launcher. //if (_latestLauncherVersion != _localLauncherVersion) // If our launcher is old update //DownloadFile(UpdateServer + "h2online.exe", "h2online.exe"); //Trace.WriteLine("Files Needed: " + _fileCount); } else if ((string)ButtonAction.Content == "Restart") // Restart { Trace.WriteLine("Application restarting"); Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); } }
private async void DownloadButton_Click(object sender, RoutedEventArgs e) { if (_disableHalo2Download) { TextboxOutput.Text = "Halo 2 download is currently disabled please check back later"; return; } DownloadConfirmGrid.Visibility = Visibility.Hidden; CancelButton.Visibility = Visibility.Visible; TextboxOutput.Text = "Decrypting Url..."; using (var folderBrowser = new FolderBrowserDialog()) //Creates a file dialog window { folderBrowser.RootFolder = Environment.SpecialFolder.Desktop; // Sets starting location in dialog window folderBrowser.Description = @"Select where you want to install Halo 2"; // Gives it a title folderBrowser.ShowNewFolderButton = true; if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Cfg.InstallPath = folderBrowser.SelectedPath; Trace.WriteLine("Halo 2 install path selected: " + Cfg.InstallPath); //writes to debug file Cfg.SetVariable("install_path =", Cfg.InstallPath, ref Cfg.ConfigFile); //sets variable in config Cfg.SaveConfigFile(Cfg.InstallPath + "xlive.ini", Cfg.ConfigFile); //saves config } else { return; } } // Downloading try { await MegaDownload(GetRedirectUrl(_halo2DownloadUrl)); } catch { TextboxOutput.Text = "Error Downloading Halo 2. Please Restart."; DownloadConfirmGrid.Visibility = Visibility.Hidden; CancelButton.Visibility = Visibility.Hidden; ButtonAction.Visibility = Visibility.Visible; ButtonAction.Content = "Restart"; return; } // Extracting var compressed = ArchiveFactory.Open(Cfg.InstallPath + Halo2DownloadName); TextboxOutput.Text = "Extracting..."; foreach (var entry in compressed.Entries) { if (!entry.IsDirectory) { entry.WriteToDirectory(Cfg.InstallPath, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite); } } ButtonAction.Content = !CheckVersion() ? "Update" : "Play"; //Check version and change main button depending Trace.WriteLine("Halo 2 game installation complete"); //writes to debug file TextboxOutput.Text = "Halo 2 downloaded and installed"; //displays what happened DownloadConfirmGrid.Visibility = Visibility.Hidden; ButtonAction.Visibility = Visibility.Visible; }
private void ButtonAction_Click(object sender, RoutedEventArgs e) { if ((string)ButtonAction.Content == "Play") { try { if (Cfg.CheckIfProcessIsRunning(ProcessName) || Cfg.CheckIfProcessIsRunning(ProcessStartup)) //Kill halo2 or startup if its running (Should help with black screens) { KillProcess(ProcessName); KillProcess(ProcessStartup); } StartProcess(ProcessStartup); } catch { Trace.WriteLine("Could not find or launch Halo 2 application."); TextboxOutput.Text = "Could not find or launch Halo 2 application."; DownloadConfirmGrid.Visibility = Visibility.Visible; // Show download confirm ButtonAction.Visibility = Visibility.Hidden; // Hide action button TextboxOutput.Text = "Halo 2 could not be found. Locate or download?"; } } else if ((string)ButtonAction.Content == "Close Game") //Game is open { if (Cfg.CheckIfProcessIsRunning(ProcessName) || Cfg.CheckIfProcessIsRunning(ProcessStartup)) //Might be redundant but we don't want crashes { KillProcess(ProcessName); KillProcess(ProcessStartup); } ButtonAction.Content = "Play"; } else if ((string)ButtonAction.Content == "Update") { if (Cfg.CheckIfProcessIsRunning(ProcessName) || Cfg.CheckIfProcessIsRunning(ProcessStartup)) { KillProcess(ProcessName); KillProcess(ProcessStartup); } ButtonAction.Content = "Updating..."; // Button is still enabled if download is long it might look strange DownloadUpdate(); } else if ((string)ButtonAction.Content == "Login") { // User Is logging in if (PasswordPanel.Visibility == Visibility.Visible) { var loginResponse = Api.Login(UsernameBox.Text, PasswordBox.Password); if (loginResponse != "0") // Correct login { Cfg.SetVariable("login_token =", loginResponse, ref Cfg.ConfigFile); Cfg.SaveConfigFile(Cfg.InstallPath + "xlive.ini", Cfg.ConfigFile); Setup(); } else // Incorrect login { TextboxOutput.Text = "Incorrect Login"; PasswordBox.Password = ""; } } } else if ((string)ButtonAction.Content == "Register") { if (Api.IsValidEmail(EmailBox.Text)) { var registerResponse = Api.Register(UsernameBox.Text, PasswordBox.Password, EmailBox.Text); if (registerResponse != "0") { var loginResponse = Api.Login(UsernameBox.Text, PasswordBox.Password); PasswordPanel.Visibility = Visibility.Collapsed; EmailPanel.Visibility = Visibility.Collapsed; Application.Current.MainWindow.Height = 200; if (loginResponse != "0") { Cfg.SetVariable("login_token =", loginResponse, ref Cfg.ConfigFile); Cfg.SaveConfigFile(Cfg.InstallPath + "xlive.ini", Cfg.ConfigFile); Setup(); } } else { TextboxOutput.Text = "Error Registering. Please try again shortly."; } } else { TextboxOutput.Text = "Invalid Email"; EmailBox.Text = ""; } } else if ((string)ButtonAction.Content == "Verify") { PathFinder(); } else if ((string)ButtonAction.Content == "Restart") // Restart { //DO NOT TOUCH THIS //THIS UPDATES THE LAUNCHER //LEAVE THIS CODE ALONE Task.Delay(5000); ProcessStartInfo file_overwrite = new ProcessStartInfo(); file_overwrite.CreateNoWindow = true; file_overwrite.WindowStyle = ProcessWindowStyle.Hidden; file_overwrite.WorkingDirectory = LauncherDirectory; file_overwrite.FileName = "cmd.exe"; file_overwrite.Arguments = "/C ping 127.0.0.1 -n 1 -w 5000 > Nul & Del h2online.exe & ping 127.0.0.1 -n 1 -w 2000 > Nul & rename h2online_temp.exe h2online.exe & ping 127.0.0.1 -n 1 -w 2000 > Nul & start h2online.exe"; Process.Start(file_overwrite); Process.GetCurrentProcess().Kill(); //DO NOT TOUCH THIS //THIS UPDATES THE LAUNCHER //LEAVE THIS CODE ALONE } }