private void btnLogin_Click(object sender, EventArgs e) { try { suppressFetching = true; LoginResults results = new LoginResults(txtUsername.Text, txtPassword.Text, launcherData); cbWorlds.DataSource = launcherData.Worlds.Values.ToList(); cbWorlds.DisplayMember = "Name"; cbWorlds.Enabled = true; cbSubs.DataSource = results.Subscriptions.ToList(); cbSubs.DisplayMember = "Description"; cbSubs.ValueMember = "Name"; cbSubs.Enabled = true; btnCreateShortcut.Enabled = true; if (!string.IsNullOrEmpty(Settings.DefaultWorld)) { cbWorlds.FindStringExact(Settings.DefaultWorld); } if (!string.IsNullOrEmpty(Settings.DefaultSubscription)) { cbSubs.FindStringExact(Settings.DefaultSubscription); } suppressFetching = false; PopulateCharacters(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnLogin_Click(object sender, EventArgs e) { bool fail = false; if (string.IsNullOrEmpty(txtUsername.Text)) { fail = true; txtUsername.BackColor = Color.Yellow; txtUsername.Focus(); } if (string.IsNullOrEmpty(txtPassword.Text)) { fail = true; txtPassword.BackColor = Color.Yellow; txtPassword.Focus(); } if (fail) { return; } if (chkSaveUsername.Checked) { Settings.Username = txtUsername.Text; Settings.SaveUsername = true; } else { Settings.Username = ""; Settings.SaveUsername = false; } if (chkSavePassword.Checked) { Settings.Password = txtPassword.Text; Settings.SavePassword = true; } else { Settings.Password = ""; Settings.SavePassword = false; } try { results = new LoginResults(txtUsername.Text, txtPassword.Text, launcherData); cbWorlds.DataSource = launcherData.Worlds.Values.ToList(); cbWorlds.DisplayMember = "Name"; cbWorlds.ValueMember = "Name"; cbSubscriptions.DataSource = results.Subscriptions.ToList(); cbSubscriptions.DisplayMember = "Description"; cbSubscriptions.ValueMember = "Name"; if (!string.IsNullOrEmpty(Settings.DefaultWorld)) { cbWorlds.SelectedValue = Settings.DefaultWorld; } if (!string.IsNullOrEmpty(Settings.DefaultSubscription)) { cbSubscriptions.SelectedValue = Settings.DefaultSubscription; } pnlLogin.Visible = false; pnlPlay.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
static void Main(string[] args) { string worldName = ""; string subscriptionName = ""; string language = System.Globalization.CultureInfo.CurrentCulture.Parent.EnglishName; string username = Settings.Username; string password = Settings.Password; string clientDir = null; string character = null; ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; if (args.Length > 0) { foreach (string arg in args) { if (arg.Length > 3 && arg[0] == '/' && arg[2] == ':') { switch (arg[1]) { case 'w': worldName = arg.Substring(3); break; case 's': subscriptionName = arg.Substring(3); break; case 'l': language = arg.Substring(3); break; case 'u': username = Util.DecryptString(arg.Substring(3)); break; case 'p': password = Util.DecryptString(arg.Substring(3)); break; case 'd': clientDir = arg.Substring(3).Replace("\"", ""); break; case 'c': character = arg.Substring(3); break; } } } } if (!string.IsNullOrEmpty(clientDir) && System.IO.Directory.Exists(clientDir)) { System.IO.Directory.SetCurrentDirectory(clientDir); } // validate the config file is found if (System.IO.File.Exists("TurbineLauncher.exe.config")) { // load launcher configuration LauncherData launcherData = new LauncherData(); if (string.IsNullOrEmpty(worldName)) { worldName = Settings.DefaultWorld; } if (string.IsNullOrEmpty(subscriptionName)) { subscriptionName = Settings.DefaultSubscription; } if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { LoginResults lr = new LoginResults(username, password, launcherData); if (!string.IsNullOrEmpty(worldName) && lr.Subscriptions.Count > 0) { if (lr.Subscriptions.Count == 1) { lr.Launch(lr.Subscriptions[0].Name, worldName, language, character); return; } else if (!string.IsNullOrEmpty(subscriptionName)) { lr.Launch(subscriptionName, worldName, language, character); return; } } } } // if we made it this far, we didn't launch yet Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new LaunchForm()); }