private void Logo_OnMouseUp(object sender, MouseButtonEventArgs e)
        {
#if DEBUG
            var result = MessageBox.Show("Yes: FTS\nNo: Save troubleshooting\nCancel: Cancel", "XIVLauncher Expert Debugging Interface", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
            switch (result)
            {
            case MessageBoxResult.Yes:
                var fts = new FirstTimeSetup();
                fts.ShowDialog();

                Log.Debug($"WasCompleted: {fts.WasCompleted}");

                this.ReloadSettings();
                break;

            case MessageBoxResult.No:
                MessageBox.Show(PackGenerator.SavePack());
                break;

            case MessageBoxResult.Cancel:
                return;
            }
#else
            if (_hasTriggeredLogo)
            {
                return;
            }

            Process.Start("explorer.exe", $"/select, \"{PackGenerator.SavePack()}\"");
            _hasTriggeredLogo = true;
#endif
        }
        private void Logo_OnMouseUp(object sender, MouseButtonEventArgs e)
        {
#if DEBUG
            var fts = new FirstTimeSetup();
            fts.ShowDialog();

            Log.Debug($"WasCompleted: {fts.WasCompleted}");

            this.ReloadSettings();
#endif
        }
Пример #3
0
        public void Initialize()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Log.Information("Settings upgrade required...");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            // Clean up invalid addons
            if (App.Settings.AddonList != null)
            {
                App.Settings.AddonList = App.Settings.AddonList.Where(x => !string.IsNullOrEmpty(x.Addon.Path)).ToList();
            }

            App.Settings.EncryptArguments ??= true;
            App.Settings.AskBeforePatchInstall ??= true;

            var gateStatus = false;

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

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

            var version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                new ChangelogWindow().ShowDialog();

                Properties.Settings.Default.LastVersion = version;

                Properties.Settings.Default.Save();
            }

            _accountManager = new AccountManager(App.Settings);

            var savedAccount = _accountManager.CurrentAccount;

            if (savedAccount != null)
            {
                SwitchAccount(savedAccount, false);
            }

            AutoLoginCheckBox.IsChecked = App.Settings.AutologinEnabled;

            if (App.Settings.AutologinEnabled && savedAccount != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Log.Information("Engaging Autologin...");

                try
                {
                    HandleLogin(true);
                    return;
                }
                catch (Exception ex)
                {
                    new ErrorWindow(ex, Loc.Localize("CheckLoginInfo", "Additionally, please check your login information or try again."), "AutoLogin")
                    .ShowDialog();
                    App.Settings.AutologinEnabled = false;
                    _isLoggingIn = false;
                }
            }
            else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) || bool.Parse(Environment.GetEnvironmentVariable("XL_NOAUTOLOGIN") ?? "false"))
            {
                App.Settings.AutologinEnabled = false;
                AutoLoginCheckBox.IsChecked   = false;
            }

            if (App.Settings.GamePath?.Exists != true)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();

                SettingsControl.ReloadSettings();
            }

            Task.Run(SetupHeadlines);

            ProblemCheck.RunCheck();

            Log.Information("MainWindow initialized.");

            HandleBootCheck(() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    Show();
                    Activate();
                });
            });
        }
Пример #4
0
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                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 version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                new ChangelogWindow().ShowDialog();

                Properties.Settings.Default.LastVersion = version;

                Properties.Settings.Default.Save();
            }

            _accountManager = new AccountManager(_setting);

            var savedAccount = _accountManager.CurrentAccount;

            if (savedAccount != null)
            {
                SwitchAccount(savedAccount, false);
            }

            AutoLoginCheckBox.IsChecked = _setting.AutologinEnabled;

            if (_setting.AutologinEnabled && savedAccount != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Log.Information("Engaging Autologin...");

                try
                {
#if DEBUG
                    HandleLogin(true);
                    _setting.Save();
                    return;
#else
                    if (!gateStatus)
                    {
                        var startLauncher = MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched. Do you want to start the official launcher to check for patches?", "XIVLauncherLite", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;

                        if (startLauncher)
                        {
                            _setting.StartOfficialLauncher(SteamCheckBox.IsChecked == true);
                        }

                        _setting.AutologinEnabled = false;
                        _isLoggingIn = false;
                    }
                    else
                    {
                        HandleLogin(true);
                        _setting.Save();
                        return;
                    }
#endif
                }
                catch (Exception exc)
                {
                    new ErrorWindow(exc, "Additionally, please check your login information or try again.", "AutoLogin")
                    .ShowDialog();
                    _setting.AutologinEnabled = false;
                    _isLoggingIn = false;
                }

                _setting.Save();
            }
            else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                _setting.AutologinEnabled   = false;
                AutoLoginCheckBox.IsChecked = false;
            }

            if (_setting.GamePath?.Exists != true)
            {
                var setup = new FirstTimeSetup(_setting);
                setup.ShowDialog();
                _setting = setup.Result;
            }

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

            Show();
            Activate();

            Log.Information("MainWindow initialized.");
        }
Пример #5
0
        public void Initialize()
        {
#if DEBUG
            var fakeStartMenuItem = new MenuItem
            {
                Header = "Fake start"
            };
            fakeStartMenuItem.Click += FakeStart_OnClick;

            LoginContextMenu.Items.Add(fakeStartMenuItem);
#endif

            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Log.Information("Settings upgrade required...");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            // Clean up invalid addons
            if (App.Settings.AddonList != null)
            {
                App.Settings.AddonList = App.Settings.AddonList.Where(x => !string.IsNullOrEmpty(x.Addon.Path)).ToList();
            }

            App.Settings.EncryptArguments ??= true;
            App.Settings.AskBeforePatchInstall ??= true;

            var gateStatus = false;
            try
            {
                gateStatus = _launcher.GetGateStatus();
            }
            catch
            {
                // ignored
            }

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

            var version = Util.GetAssemblyVersion();
            if (Properties.Settings.Default.LastVersion != version)
            {
                new ChangelogWindow().ShowDialog();

                Properties.Settings.Default.LastVersion = version;

                Properties.Settings.Default.Save();
            }

            _accountManager = new AccountManager(App.Settings);

            var savedAccount = _accountManager.CurrentAccount;

            if (savedAccount != null)
            {
                SwitchAccount(savedAccount, false);
            }

            AutoLoginCheckBox.IsChecked = App.Settings.AutologinEnabled;

            if (App.Settings.UniqueIdCacheEnabled && Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                UniqueIdCache.Instance.Reset();
                Console.Beep(523, 150); // Feedback without popup
            }

            if (App.GlobalIsDisableAutologin)
            {
                Log.Information("Autologin was disabled globally, saving into settings...");
                App.Settings.AutologinEnabled = false;
            }

            if (App.Settings.AutologinEnabled && savedAccount != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Log.Information("Engaging Autologin...");

                try
                {
                    this.Kickoff(true);
                    return;
                }
                catch (Exception ex)
                {
                    new ErrorWindow(ex, Loc.Localize("CheckLoginInfo", "Additionally, please check your login information or try again."), "AutoLogin")
                    .ShowDialog();
                    App.Settings.AutologinEnabled = false;
                    _isLoggingIn = false;
                }
            }
            else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) || bool.Parse(Environment.GetEnvironmentVariable("XL_NOAUTOLOGIN") ?? "false"))
            {
                App.Settings.AutologinEnabled = false;
                AutoLoginCheckBox.IsChecked   = false;
            }

            if (App.Settings.GamePath?.Exists != true)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();

                // If the user didn't reach the end of the setup, we should quit
                if (!setup.WasCompleted)
                {
                    Environment.Exit(0);
                    return;
                }

                SettingsControl.ReloadSettings();
            }

            Task.Run(SetupHeadlines);

            ProblemCheck.RunCheck();

            Log.Information("MainWindow initialized.");

            Show();
            Activate();
        }
Пример #6
0
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                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))
            {
                Log.Information("Engaging Autologin");

                try
                {
                    #if DEBUG
                    HandleLogin(true);
                    Settings.Save();
                    return;
                    #else
                    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;
                    }
                    #endif
                }
                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.GamePath == null)
            {
                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 fixes:\r\n\r\n* Added compatibility for SE's new Steam service account policy. If your FFXIV service account is tied to Steam, you must now check the Steam integration checkbox in Settings->Game.\r\n* Fixed some more bugs related to the rewritten addon system.",
                    "XIVLauncher updated!", MessageBoxButton.OK, MessageBoxImage.Asterisk);

                Properties.Settings.Default.LastVersion = version;
                Settings.UniqueIdCache = new List <UniqueIdCacheEntry>();
                Properties.Settings.Default.Save();
            }

            Show();
            Activate();

            Log.Information("MainWindow initialized.");
        }
Пример #7
0
        public void Initialize()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Log.Information("Settings upgrade required...");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            // Clean up invalid addons
            if (App.Settings.AddonList != null)
            {
                App.Settings.AddonList = App.Settings.AddonList.Where(x => !string.IsNullOrEmpty(x.Addon.Path)).ToList();
            }

            if (!App.Settings.EncryptArguments.HasValue)
            {
                App.Settings.EncryptArguments = true;
            }

            var gateStatus = false;

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

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

            var version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                new ChangelogWindow().ShowDialog();

                Properties.Settings.Default.LastVersion = version;

                Properties.Settings.Default.Save();
            }

            _accountManager = new AccountManager(App.Settings);

            var savedAccount = _accountManager.CurrentAccount;

            if (savedAccount != null)
            {
                SwitchAccount(savedAccount, false);
            }

            AutoLoginCheckBox.IsChecked = App.Settings.AutologinEnabled;

            if (App.Settings.AutologinEnabled && savedAccount != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Log.Information("Engaging Autologin...");

                try
                {
#if DEBUG
                    HandleLogin(true);
                    return;
#else
                    if (!gateStatus)
                    {
                        var startLauncher = MessageBox.Show(Loc.Localize("MaintenanceAskOfficial", "Square Enix seems to be running maintenance work right now. The game shouldn't be launched. Do you want to start the official launcher to check for patches?")
                                                            , "XIVLauncher", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;

                        if (startLauncher)
                        {
                            Util.StartOfficialLauncher(App.Settings.GamePath, SteamCheckBox.IsChecked == true);
                        }

                        App.Settings.AutologinEnabled = false;
                        _isLoggingIn = false;
                    }
                    else
                    {
                        HandleLogin(true);
                        return;
                    }
#endif
                }
                catch (Exception ex)
                {
                    new ErrorWindow(ex, Loc.Localize("CheckLoginInfo", "Additionally, please check your login information or try again."), "AutoLogin")
                    .ShowDialog();
                    App.Settings.AutologinEnabled = false;
                    _isLoggingIn = false;
                }
            }
            else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                App.Settings.AutologinEnabled = false;
                AutoLoginCheckBox.IsChecked   = false;
            }

            if (App.Settings.GamePath?.Exists != true)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();

                SettingsControl.ReloadSettings();
            }

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

            ProblemCheck.RunCheck();

            Show();
            Activate();

            Log.Information("MainWindow initialized.");
        }
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                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 version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                new ChangelogWindow().ShowDialog();

                Properties.Settings.Default.LastVersion = version;
                Settings.UniqueIdCache = new List <UniqueIdCacheEntry>();

                if (version == "3.4.0.0")
                {
                    var savedCredentials = CredentialManager.GetCredentials("FINAL FANTASY XIV");

                    if (savedCredentials != null)
                    {
                        _accountManager.AddAccount(new XivAccount(savedCredentials.UserName)
                        {
                            Password               = savedCredentials.Password,
                            SavePassword           = true,
                            UseOtp                 = Settings.NeedsOtp(),
                            UseSteamServiceAccount = Settings.SteamIntegrationEnabled
                        });

                        Properties.Settings.Default.CurrentAccount = $"{savedCredentials.UserName}-{Settings.NeedsOtp()}-{Settings.SteamIntegrationEnabled}";;
                    }
                }

                Properties.Settings.Default.Save();
            }

            _accountManager = new AccountManager();

            var savedAccount = _accountManager.CurrentAccount;

            if (savedAccount != null)
            {
                SwitchAccount(savedAccount, false);
            }

            AutoLoginCheckBox.IsChecked = Settings.IsAutologin();

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

                try
                {
                    #if DEBUG
                    HandleLogin(true);
                    Settings.Save();
                    return;
                    #else
                    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;
                    }
                    #endif
                }
                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.GamePath == null)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();
            }

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

            Settings.LanguageChanged += SetupHeadlines;

            Show();
            Activate();

            Log.Information("MainWindow initialized.");
        }
        public void Initialize()
        {
#if DEBUG
            var fakeStartMenuItem = new MenuItem
            {
                Header = "Fake start"
            };
            fakeStartMenuItem.Click += FakeStart_OnClick;

            LoginContextMenu.Items.Add(fakeStartMenuItem);
#endif

            this.SetDefaults();

            var worldStatusBrushOk = WorldStatusPackIcon.Foreground;
            // grey out world status icon while deferred check is running
            WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(38, 38, 38));

            _launcher.GetGateStatus(App.Settings.Language.GetValueOrDefault(ClientLanguage.English)).ContinueWith((resultTask) =>
            {
                try
                {
                    var brushToSet = resultTask.Result.Status ? worldStatusBrushOk : null;
                    Dispatcher.InvokeAsync(() => WorldStatusPackIcon.Foreground = brushToSet ?? new SolidColorBrush(Color.FromRgb(242, 24, 24)));
                }
                catch
                {
                    // ignored
                }
            });

            _accountManager = new AccountManager(App.Settings);

            var savedAccount = _accountManager.CurrentAccount;

            if (savedAccount != null)
            {
                SwitchAccount(savedAccount, false);
            }

            Model.IsAutoLogin = App.Settings.AutologinEnabled;

            if (App.Settings.UniqueIdCacheEnabled && Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                App.UniqueIdCache.Reset();
                Console.Beep(523, 150); // Feedback without popup
            }

            if (App.GlobalIsDisableAutologin)
            {
                Log.Information("Autologin was disabled globally, saving into settings...");
                App.Settings.AutologinEnabled = false;
            }

            if (App.Settings.AutologinEnabled && savedAccount != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Log.Information("Engaging Autologin...");
                Model.TryLogin(savedAccount.UserName, savedAccount.Password,
                               savedAccount.UseOtp,
                               savedAccount.UseSteamServiceAccount, true, MainWindowViewModel.AfterLoginAction.Start);

                return;
            }
            else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) || bool.Parse(Environment.GetEnvironmentVariable("XL_NOAUTOLOGIN") ?? "false"))
            {
                App.Settings.AutologinEnabled = false;
                AutoLoginCheckBox.IsChecked   = false;
            }

            if (App.Settings.GamePath?.Exists != true)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();

                // If the user didn't reach the end of the setup, we should quit
                if (!setup.WasCompleted)
                {
                    Environment.Exit(0);
                    return;
                }

                SettingsControl.ReloadSettings();
            }

            Task.Run(async() =>
            {
                await SetupHeadlines();
                Troubleshooting.LogTroubleshooting();
            });

            Log.Information("MainWindow initialized.");

            Show();
            Activate();
        }