Example #1
0
        private void Login(object sender, EventArgs e)
        {
            if (!XIVGame.GetGateStatus())
            {
                MessageBox.Show(
                    "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");

                return;
            }

            if (saveCheckBox.Checked)
            {
                Properties.Settings.Default["savedid"] = IDTextBox.Text;
                Properties.Settings.Default["savedpw"] = PWTextBox.Text;
                if (autoLoginCheckBox.Checked)
                {
                    DialogResult result = MessageBox.Show("This option will log you in automatically with the credentials you entered.\nTo reset it again, launch this application as administrator once.\n\nDo you really want to enable it?", "Enabling Autologin", MessageBoxButtons.YesNo);

                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        autoLoginCheckBox.Checked = false;
                    }
                    else
                    {
                        Properties.Settings.Default["autologin"] = true;
                    }
                }
                else
                {
                    Properties.Settings.Default["autologin"] = false;
                }
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default["savedid"] = "";
                Properties.Settings.Default["savedpw"] = "";
                Properties.Settings.Default.Save();
            }

            StatusLabel.Text = "Logging in...";
            try
            {
                XIVGame.LaunchGame(XIVGame.GetRealSid(IDTextBox.Text, PWTextBox.Text, OTPTextBox.Text), Settings.GetLanguage(), Settings.IsDX11(), Settings.GetExpansionLevel());
                Environment.Exit(0);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Logging in failed, check your login information or try again.\n\n" + exc, "Login failed", MessageBoxButtons.OK);
                StatusLabel.Text = "";
                return;
            }
        }
Example #2
0
        public MainForm()
        {
            InitializeComponent();

            if (Properties.Settings.Default.savedid != "")
            {
                IDTextBox.Text       = Properties.Settings.Default.savedid;
                PWTextBox.Text       = Properties.Settings.Default.savedpw;
                saveCheckBox.Checked = true;
            }

            if (Properties.Settings.Default.setupcomplete != true)
            {
                InitialSetup();
            }

            if (Properties.Settings.Default.autologin && !Settings.IsAdministrator())
            {
                try
                {
                    this.Enabled = false;

                    if (!XIVGame.GetGateStatus())
                    {
                        this.Enabled = true;
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");

                        Properties.Settings.Default["autologin"] = false;
                        Properties.Settings.Default.Save();
                    }
                    else
                    {
                        XIVGame.LaunchGame(XIVGame.GetRealSid(IDTextBox.Text, PWTextBox.Text, OTPTextBox.Text), Settings.GetLanguage(), Settings.IsDX11(), Settings.GetExpansionLevel());
                        Environment.Exit(0);
                    }
                }
                catch (Exception e)
                {
                    this.Enabled = true;
                    MessageBox.Show("Logging in failed, check your login information or try again.\n\n" + e, "Login failed", MessageBoxButtons.OK);
                }
            }
            else
            {
                Properties.Settings.Default["autologin"] = false;
                Properties.Settings.Default.Save();
            }
        }
        public MainForm()
        {
            InitializeComponent();

            if (Settings.Instance.SavedID != "")
            {
                IDTextBox.Text       = Settings.Instance.SavedID;
                PWTextBox.Text       = Settings.Instance.SavedPW;
                saveCheckBox.Checked = true;
            }

            if (Settings.Instance.SetupComplete != true)
            {
                InitialSetup();
            }

            if (Settings.Instance.AutoLogin == true && !SettingsHelper.IsAdministrator())
            {
                try
                {
                    this.Enabled = false;

                    if (!XIVGame.GetGateStatus())
                    {
                        this.Enabled = true;
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");

                        Settings.Instance.AutoLogin = false;
                        Settings.Instance.Save();
                    }
                    else
                    {
                        XIVGame.LaunchGame(XIVGame.GetRealSid(IDTextBox.Text, PWTextBox.Text, OTPTextBox.Text), SettingsHelper.GetLanguage(), SettingsHelper.IsDX11(), SettingsHelper.UseSteam(), SettingsHelper.GetExpansionLevel());
                        Environment.Exit(0);
                    }
                }
                catch (Exception e)
                {
                    this.Enabled = true;
                    MessageBox.Show("Logging in failed, check your login information or try again.\n\n" + e, "Login failed", MessageBoxButtons.OK);
                }
            }
            else
            {
                Settings.Instance.AutoLogin = false;
                Settings.Instance.Save();
            }
        }
        private void StartGame()
        {
            if (!XIVGame.GetGateStatus())
            {
                MessageBox.Show(
                    "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);

                return;
            }

            try
            {
                XIVGame.Login(LoginUsername.Text, LoginPassword.Password, OtpTextBox.Text);
                Environment.Exit(0);
            }
            catch (Exception exc)
            {
                Util.ShowError("Logging in failed, check your login information or try again.\n\n" + exc, "Login failed");
            }
        }
        private void QueueButton_OnClick(object sender, RoutedEventArgs e)
        {
            _maintenanceQueueTimer = new System.Timers.Timer
            {
                Interval = 5000
            };

            _maintenanceQueueTimer.Elapsed += (o, args) =>
            {
                if (XIVGame.GetGateStatus())
                {
                    Console.Beep(529, 130);
                    System.Threading.Thread.Sleep(200);
                    Console.Beep(529, 100);
                    System.Threading.Thread.Sleep(30);
                    Console.Beep(529, 100);
                    System.Threading.Thread.Sleep(300);
                    Console.Beep(420, 140);
                    System.Threading.Thread.Sleep(300);
                    Console.Beep(466, 100);
                    System.Threading.Thread.Sleep(300);
                    Console.Beep(529, 160);
                    System.Threading.Thread.Sleep(200);
                    Console.Beep(466, 100);
                    System.Threading.Thread.Sleep(30);
                    Console.Beep(529, 900);

                    this.Dispatcher.BeginInvoke(new Action(() => LoginButton_Click(null, null)));
                    return;
                }

                _maintenanceQueueTimer.Start();
            };

            DialogHost.OpenDialogCommand.Execute(null, MaintenanceQueueDialogHost);
            _maintenanceQueueTimer.Start();
        }
Example #6
0
        private void QueueButton_Click(object sender, EventArgs e) //TODO: please do this in a thread when you care enough at some point
        {
            DialogResult result = MessageBox.Show("This will be querying the maintenance status server, until the maintenance is over and then launch the game. Make sure the login information you entered is correct." +
                                                  "\n\n!!!The application will be unresponsive!!!\n\nDo you want to continue?", "Maintenance Queue", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                this.BringToFront();

                while (true)
                {
                    if (XIVGame.GetGateStatus())
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(5000);
                }

                Console.Beep(529, 130);
                System.Threading.Thread.Sleep(200);
                Console.Beep(529, 100);
                System.Threading.Thread.Sleep(30);
                Console.Beep(529, 100);
                System.Threading.Thread.Sleep(300);
                Console.Beep(420, 140);
                System.Threading.Thread.Sleep(300);
                Console.Beep(466, 100);
                System.Threading.Thread.Sleep(300);
                Console.Beep(529, 160);
                System.Threading.Thread.Sleep(200);
                Console.Beep(466, 100);
                System.Threading.Thread.Sleep(30);
                Console.Beep(529, 900);

                Login(null, null);
            }
        }
Example #7
0
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Serilog.Log.Information("Settings upgrade required...");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            var gateStatus = false;

            try
            {
                gateStatus = _game.GetGateStatus();
            }
            catch
            {
                // ignored
            }

            if (!gateStatus)
            {
                WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(242, 24, 24));
            }

            var savedCredentials = CredentialManager.GetCredentials(AppName);

            if (savedCredentials != null)
            {
                LoginUsername.Text          = savedCredentials.UserName;
                LoginPassword.Password      = savedCredentials.Password;
                OtpCheckBox.IsChecked       = Settings.NeedsOtp();
                AutoLoginCheckBox.IsChecked = Settings.IsAutologin();
                SaveLoginCheckBox.IsChecked = true;
            }

            if (Settings.IsAutologin() && savedCredentials != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Serilog.Log.Information("Engaging Autologin");

                try
                {
                    if (!gateStatus)
                    {
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");
                        Settings.SetAutologin(false);
                    }
                    else
                    {
                        HandleLogin(true);
                        Settings.Save();
                        return;
                    }
                }
                catch (Exception exc)
                {
                    new ErrorWindow(exc, "Additionally, please check your login information or try again.", "AutoLogin").ShowDialog();
                    Settings.SetAutologin(false);
                }

                Settings.Save();
            }

            if (Settings.GetGamePath() == string.Empty)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();
            }

            Task.Run(() => SetupHeadlines());

            Settings.LanguageChanged += SetupHeadlines;

            var version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                MessageBox.Show($"XIVLauncher was updated to version {version}. This release features some new features and fixes:\r\n\r\n* Added an integrity check: This will check your game files for validity and offer you to patch your game again to restore them, in case they are modified or corrupted\r\n* Fixed an issue wherein choosing any language other than English during First Time Setup would cause a crash\r\n* Changed oauth login errors to not pop up the generic error message\r\n* Removed expansion from Settings and First Time Setup - the newest expansion will now always be chosen\r\n* Additional Shadowbringers compatibility fixes", "XIVLauncher updated!", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                Properties.Settings.Default.LastVersion = version;
                Properties.Settings.Default.Save();
            }

            Show();
            Activate();

            Serilog.Log.Information("MainWindow initialized.");
        }
        private void InitializeWindow()
        {
            var gateStatus = XIVGame.GetGateStatus();

            if (!gateStatus)
            {
                WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(242, 24, 24));
            }

            var savedCredentials = CredentialManager.GetCredentials(AppName);

            if (savedCredentials != null)
            {
                LoginUsername.Text          = savedCredentials.UserName;
                LoginPassword.Password      = savedCredentials.Password;
                OtpCheckBox.IsChecked       = Settings.NeedsOtp();
                AutoLoginCheckBox.IsChecked = Settings.IsAutologin();
                SaveLoginCheckBox.IsChecked = true;
            }

            if (Settings.IsAutologin() && !Settings.IsAdministrator() && savedCredentials != null)
            {
                try
                {
                    if (!gateStatus)
                    {
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");
                        Settings.SetAutologin(false);
                    }
                    else
                    {
                        HandleLogin(true);
                    }
                }
                catch (Exception exc)
                {
                    Util.ShowError("Logging in failed, check your login information or try again.\n\n" + exc, "Login failed");
                    Settings.SetAutologin(false);
                }

                Settings.Save();
            }

            if (Settings.GetGamePath() == string.Empty)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();
            }

            try
            {
                _headlines = Headlines.Get();

                _bannerBitmaps = new BitmapImage[_headlines.Banner.Length];
                for (int i = 0; i < _headlines.Banner.Length; i++)
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = _headlines.Banner[i].LsbBanner;
                    bitmap.EndInit();

                    _bannerBitmaps[i] = bitmap;
                }

                _bannerChangeTimer = new System.Timers.Timer
                {
                    Interval = 5000
                };

                _bannerChangeTimer.Elapsed += (o, args) =>
                {
                    if (_currentBannerIndex + 1 > _headlines.Banner.Length - 1)
                    {
                        _currentBannerIndex = 0;
                    }
                    else
                    {
                        _currentBannerIndex++;
                    }

                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        BannerImage.Source = _bannerBitmaps[_currentBannerIndex];
                    }));

                    _bannerChangeTimer.Start();
                };

                _bannerChangeTimer.Start();

                NewsListView.ItemsSource = _headlines.News;
            }
            catch (Exception)
            {
                NewsListView.Items.Add(new News()
                {
                    Title = "Could not download news data.",
                    Tag   = "DlError"
                });
            }

            this.Visibility = Visibility.Visible;
        }
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Serilog.Log.Information("Settings upgrade required...");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            var gateStatus = false;

            try
            {
                gateStatus = _game.GetGateStatus();
            }
            catch
            {
                // ignored
            }

            if (!gateStatus)
            {
                WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(242, 24, 24));
            }

            var savedCredentials = CredentialManager.GetCredentials(AppName);

            if (savedCredentials != null)
            {
                LoginUsername.Text          = savedCredentials.UserName;
                LoginPassword.Password      = savedCredentials.Password;
                OtpCheckBox.IsChecked       = Settings.NeedsOtp();
                AutoLoginCheckBox.IsChecked = Settings.IsAutologin();
                SaveLoginCheckBox.IsChecked = true;
            }

            if (Settings.IsAutologin() && savedCredentials != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Serilog.Log.Information("Engaging Autologin");

                try
                {
                    if (!gateStatus)
                    {
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");
                        Settings.SetAutologin(false);
                    }
                    else
                    {
                        HandleLogin(true);
                        Settings.Save();
                        return;
                    }
                }
                catch (Exception exc)
                {
                    new ErrorWindow(exc, "Additionally, please check your login information or try again.", "AutoLogin").ShowDialog();
                    Settings.SetAutologin(false);
                }

                Settings.Save();
            }

            if (Settings.GetGamePath() == string.Empty)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();
            }

            Task.Run(() => SetupHeadlines());

            Settings.LanguageChanged += SetupHeadlines;

            var version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                MessageBox.Show($"XIVLauncher was updated to version {version}. This version features some changes and improvements:\n\n* Batch and PowerShell scripts can now be launched as generic addons\n* Fixed an issue wherein custom plugins would be deleted on launch\n* Fixed an issue wherein gate status would not be recognized correctly", "XIVLauncher updated!", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                Properties.Settings.Default.LastVersion = version;
                Properties.Settings.Default.Save();
            }

            Show();
            Activate();

            Serilog.Log.Information("MainWindow initialized.");
        }
Example #10
0
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            // Check if dark mode is enabled on windows, if yes, load the dark theme
            var themeUri = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml", UriKind.RelativeOrAbsolute);

            if (Util.IsWindowsDarkModeEnabled())
            {
                themeUri = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml", UriKind.RelativeOrAbsolute);
            }

            Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = themeUri
            });

            var gateStatus = false;

            try
            {
                gateStatus = _game.GetGateStatus();
            }
            catch
            {
                // ignored
            }

            if (!gateStatus)
            {
                WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(242, 24, 24));
            }

            var savedCredentials = CredentialManager.GetCredentials(AppName);

            if (savedCredentials != null)
            {
                LoginUsername.Text          = savedCredentials.UserName;
                LoginPassword.Password      = savedCredentials.Password;
                OtpCheckBox.IsChecked       = Settings.NeedsOtp();
                AutoLoginCheckBox.IsChecked = Settings.IsAutologin();
                SaveLoginCheckBox.IsChecked = true;
            }

            if (Settings.IsAutologin() && !Settings.IsAdministrator() && savedCredentials != null)
            {
                try
                {
                    if (!gateStatus)
                    {
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");
                        Settings.SetAutologin(false);
                    }
                    else
                    {
                        HandleLogin(true);
                    }
                }
                catch (Exception exc)
                {
                    Util.ShowError("Logging in failed, check your login information or try again.\n\n" + exc, "Login failed");
                    Settings.SetAutologin(false);
                }

                Settings.Save();
            }

            if (Settings.GetGamePath() == string.Empty)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();
            }

            try
            {
                _headlines = Headlines.Get();

                _bannerBitmaps = new BitmapImage[_headlines.Banner.Length];
                for (int i = 0; i < _headlines.Banner.Length; i++)
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = _headlines.Banner[i].LsbBanner;
                    bitmap.EndInit();

                    _bannerBitmaps[i] = bitmap;
                }

                BannerImage.Source = _bannerBitmaps[0];

                _bannerChangeTimer = new System.Timers.Timer
                {
                    Interval = 5000
                };

                _bannerChangeTimer.Elapsed += (o, args) =>
                {
                    if (_currentBannerIndex + 1 > _headlines.Banner.Length - 1)
                    {
                        _currentBannerIndex = 0;
                    }
                    else
                    {
                        _currentBannerIndex++;
                    }

                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        BannerImage.Source = _bannerBitmaps[_currentBannerIndex];
                    }));

                    _bannerChangeTimer.Start();
                };

                _bannerChangeTimer.Start();

                NewsListView.ItemsSource = _headlines.News;
            }
            catch (Exception)
            {
                NewsListView.Items.Add(new News()
                {
                    Title = "Could not download news data.",
                    Tag   = "DlError"
                });
            }

            this.Visibility = Visibility.Visible;
        }
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Serilog.Log.Information("Settings upgrade required...");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            var gateStatus = false;

            try
            {
                gateStatus = _game.GetGateStatus();
            }
            catch
            {
                // ignored
            }

            if (!gateStatus)
            {
                WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(242, 24, 24));
            }

            var savedCredentials = CredentialManager.GetCredentials(AppName);

            if (savedCredentials != null)
            {
                LoginUsername.Text          = savedCredentials.UserName;
                LoginPassword.Password      = savedCredentials.Password;
                OtpCheckBox.IsChecked       = Settings.NeedsOtp();
                AutoLoginCheckBox.IsChecked = Settings.IsAutologin();
                SaveLoginCheckBox.IsChecked = true;
            }

            if (Settings.IsAutologin() && savedCredentials != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Serilog.Log.Information("Engaging Autologin");

                try
                {
                    if (!gateStatus)
                    {
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");
                        Settings.SetAutologin(false);
                        _isLoggingIn = false;
                    }
                    else
                    {
                        HandleLogin(true);
                        Settings.Save();
                        return;
                    }
                }
                catch (Exception exc)
                {
                    new ErrorWindow(exc, "Additionally, please check your login information or try again.", "AutoLogin").ShowDialog();
                    Settings.SetAutologin(false);
                    _isLoggingIn = false;
                }

                Settings.Save();
            }

            if (Settings.GetGamePath() == string.Empty)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();
            }

            Task.Run(() => SetupHeadlines());

            Settings.LanguageChanged += SetupHeadlines;

            var version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                MessageBox.Show($"XIVLauncher was updated to version {version}. This release features some new features and fixes:\r\n\r\n* Added Steam integration for play time, overlay, streaming (Settings -> Game -> Enable Steam integration)\r\n* Updated to .NET Framework 4.7.1\r\n* UID cache will now save expansion level\r\n* Some changes to addon handling, hopefully resolving some of the issues people are having with RP and in-game addon\r\n* Improve startup time by not embedding references\r\n* Various fixes\r\n\r\n* Outgoing Tell messages will now be posted under the Tell category\r\n* Added Cross World linkshells to the chat type selector\r\n* Fixed FATE and retainer notifications\r\n* Fixed a bug that was causing sporadic error messages in chat\r\n* Fixed a bug that was causing the game to crash when changing characters\r\n* The icon and name of the XIVLauncher discord bot will not be changed automatically anymore", "XIVLauncher updated!", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                Properties.Settings.Default.LastVersion = version;
                Properties.Settings.Default.Save();
            }

            Show();
            Activate();

            Serilog.Log.Information("MainWindow initialized.");
        }