public MainWindow()
        {
            InitializeComponent();

            _isDuringStartup = true;

            _settingManager = new SettingManager();

            EnvironmentHelper.Initialize();

            EnvironmentHelper.CheckDuplicateStartup();

            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            CustomRes.Visibility  = Visibility.Hidden;
            if (!EnvironmentHelper.KKmanExist)
            {
                gridUpdate.Visibility = Visibility.Hidden;
            }

            switch (EnvironmentHelper.DeveloperModeEnabled)
            {
            case null:
                toggleConsole.IsEnabled = false;
                break;

            case false:
                toggleConsole.IsChecked = false;
                break;

            case true:
                toggleConsole.IsChecked = true;
                break;
            }

            // Mod settings
            if (File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\DHH_AI4.dll"))
            {
                toggleDHH.IsChecked = true;
            }
            if (!File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\DHH_AI4.dl_") && !File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\DHH_AI4.dll"))
            {
                toggleDHH.IsEnabled = false;
            }
            if (File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\AIGraphics\\AI_Graphics.dll"))
            {
                toggleAIGraphics.IsChecked = true;
            }
            if (!File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\AIGraphics\\AI_Graphics.dl_") && !File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\AIGraphics\\AI_Graphics.dll"))
            {
                toggleAIGraphics.IsEnabled = false;
            }
            if (File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\AIGraphics\\AI_Graphics.dll") && File.Exists($"{EnvironmentHelper.GameRootDirectory}\\BepInEx\\Plugins\\DHH_AI4.dll"))
            {
                toggleDHH.IsChecked        = false;
                toggleAIGraphics.IsChecked = false;
            }

            _isDuringStartup = false;

            SetupUiLanguage();

            // Launcher Customization: Defining Warning, background and character

            if (!string.IsNullOrEmpty(EnvironmentHelper.VersionString))
            {
                labelDist.Content = EnvironmentHelper.VersionString;
            }

            _isStudio   = File.Exists(EnvironmentHelper.GameRootDirectory + MStrStudioExe);
            _isMainGame = File.Exists(EnvironmentHelper.GameRootDirectory + MStrGameExe);

            if (!string.IsNullOrEmpty(EnvironmentHelper.WarningString))
            {
                warningText.Text = EnvironmentHelper.WarningString;
            }

            if (EnvironmentHelper.CustomCharacterImage != null)
            {
                PackChara.Source = EnvironmentHelper.CustomCharacterImage;
            }
            if (EnvironmentHelper.CustomBgImage != null)
            {
                appBG.ImageSource = EnvironmentHelper.CustomBgImage;
            }

            if (string.IsNullOrEmpty(EnvironmentHelper.PatreonUrl))
            {
                linkPatreon.Visibility   = Visibility.Collapsed;
                patreonBorder.Visibility = Visibility.Collapsed;
                patreonIMG.Visibility    = Visibility.Collapsed;
            }

            var num = Screen.AllScreens.Length;

            if (num == 2)
            {
                dropDisplay.Items.Add(_sPrimarydisplay);
                dropDisplay.Items.Add($"{_sSubdisplay} : 1");
            }
            else
            {
                for (var i = 0; i < num; i++)
                {
                    var newItem = i == 0 ? _sPrimarydisplay : ($"{_sSubdisplay} : " + i);
                    dropDisplay.Items.Add(newItem);
                }
            }
            foreach (var newItem2 in _mAstrQuality)
            {
                dropQual.Items.Add(newItem2);
            }

            var configFilePath = EnvironmentHelper.GetConfigFilePath();

CheckConfigFile:
            if (File.Exists(configFilePath))
            {
                try
                {
                    _settingManager.LoadSettings(configFilePath);

                    _settingManager.CurrentSettings.Display = Math.Min(_settingManager.CurrentSettings.Display, num - 1);
                    SetDisplayComboBox(_settingManager.CurrentSettings.FullScreen);
                    var flag = false;
                    foreach (var resItem in dropRes.Items)
                    {
                        if (resItem.ToString() == _settingManager.CurrentSettings.Size)
                        {
                            flag = true;
                        }
                    }
                    dropRes.Text = flag ? _settingManager.CurrentSettings.Size : "1280 x 720 (16 : 9)";
                    toggleFullscreen.IsChecked = _settingManager.CurrentSettings.FullScreen;
                    dropQual.Text = _mAstrQuality[_settingManager.CurrentSettings.Quality];
                    var text = _settingManager.CurrentSettings.Display == 0 ? _sPrimarydisplay : $"{_sSubdisplay} : " + _settingManager.CurrentSettings.Display;
                    if (num == 2)
                    {
                        text = new[]
                        {
                            _sPrimarydisplay,
                            $"{_sSubdisplay} : 1"
                        }[_settingManager.CurrentSettings.Display];
                    }
                    if (dropDisplay.Items.Contains(text))
                    {
                        dropDisplay.Text = text;
                    }
                    else
                    {
                        dropDisplay.Text = _sPrimarydisplay;
                        _settingManager.CurrentSettings.Display = 0;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("/UserData/setup.xml file was corrupted, settings will be reset.");
                    File.Delete(configFilePath);
                    goto CheckConfigFile;
                }
            }
            else
            {
                SetDisplayComboBox(false);
                dropRes.Text     = _settingManager.CurrentSettings.Size;
                dropQual.Text    = _mAstrQuality[_settingManager.CurrentSettings.Quality];
                dropDisplay.Text = _sPrimarydisplay;
            }
        }