Exemplo n.º 1
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;
        }
Exemplo n.º 3
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);
                    }
                    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.");
        }
        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.");
        }