private void StartGame(string strExe)
 {
     SettingManager.SaveSettings();
     if (EnvironmentHelper.StartGame(strExe))
     {
         Close();
     }
 }
        public static void SetLanguage(string language)
        {
            try
            {
                using (var writetext = new StreamWriter(GameRootDirectory + _mCustomDir + _decideLang, false))
                    writetext.WriteLine(language);

                string LangQ_a = "Do you want to set the ingame language to the selected language as well?";
                string LangQ_b = "Question";

                switch (language)
                {
                case "ja-JP":
                    LangQ_a = "ゲームにこの言語の選択を反映させたいですか?";
                    LangQ_b = "質問";
                    break;

                case "zh-CN":
                    LangQ_a = "您是否希望游戏中的语言反映这项语言选择?";
                    LangQ_b = "问题";
                    break;

                case "zh-TW":
                    LangQ_a = "您是否希望遊戲中的語言反映這項語言選擇?";
                    LangQ_b = "問題";
                    break;

                case "ko-KR":
                    LangQ_a = "게임 언어를 선택한 언어로 설정 하시겠습니까?";
                    LangQ_b = "질문";
                    break;

                case "es-ES":
                    LangQ_a = "¿Desea configurar el idioma del juego al idioma seleccionado también?";
                    LangQ_b = "Pregunta";
                    break;

                case "pt-PT":
                    LangQ_a = "Deseja também definir o idioma do jogo para o idioma selecionado?";
                    LangQ_b = "Questão";
                    break;

                case "fr-FR":
                    LangQ_a = "Voulez-vous également définir la langue du jeu sur la langue sélectionnée?";
                    LangQ_b = "Question";
                    break;

                case "de-DE":
                    LangQ_a = "Möchten Sie die Spielsprache auch auf die ausgewählte Sprache einstellen?";
                    LangQ_b = "Frage";
                    break;

                case "no-NB":
                    LangQ_a = "Ønsker du å endre språket i spillet også?";
                    LangQ_b = "Spørsmål";
                    break;

                default:
                    LangQ_a = "Do you want to set the ingame language to the selected language as well?";
                    LangQ_b = "Question";
                    break;
                }

                if (System.Windows.MessageBox.Show(LangQ_a,
                                                   LangQ_b, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    var builtinIndex = _builtinLanguages.ToList()
                                       .FindIndex(x => language.Equals(x, StringComparison.OrdinalIgnoreCase));

                    // Set built-in game language if supported
                    if (builtinIndex >= 0)
                    {
                        SettingManager.CurrentSettings.Language = builtinIndex;
                        SettingManager.SaveSettings();
                    }
                    else
                    {
                        MessageBox.Show(Localizable.InstructDecideLang);
                    }

                    WriteAutoTranslatorLangIni(language);
                }

                Application.Restart();
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong when changing language: " + e);
            }
        }
        public MainWindow()
        {
            try
            {
                _suppressEvents = true;

                // Initialize code -------------------------------------
                EnvironmentHelper.Initialize(_builtinLanguages);

                _mainGameExists = File.Exists(EnvironmentHelper.GameRootDirectory + ExecutableGame);
                _studioExists   = File.Exists(EnvironmentHelper.GameRootDirectory + ExecutableStudio);

                if (_studioExists)
                {
                    SettingManager.Initialize(EnvironmentHelper.GetConfigFilePath(), RegistryKeyGame,
                                              RegistryKeyStudio, RegistryKeyVR);
                }
                else
                {
                    SettingManager.Initialize(EnvironmentHelper.GetConfigFilePath(), RegistryKeyGame);
                }

                SettingManager.LoadSettings();


                // Initialize interface --------------------------------
                InitializeComponent();

                var tooltip = new System.Windows.Controls.ToolTip
                {
                    Content = Localizable.TooltipBoneMod
                };

                toggleBoneMod.ToolTip = tooltip;

                WindowStartupLocation = WindowStartupLocation.CenterScreen;
                CustomRes.Visibility  = Visibility.Hidden;

                if (string.IsNullOrEmpty((string)labelTranslated.Content))
                {
                    labelTranslated.Visibility       = Visibility.Hidden;
                    labelTranslatedBorder.Visibility = Visibility.Hidden;
                }

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

                // Launcher Customization: Defining Warning, background and character
                if (!string.IsNullOrEmpty(EnvironmentHelper.VersionString))
                {
                    labelDist.Content = EnvironmentHelper.VersionString;
                }

                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 primaryDisplay = Localizable.PrimaryDisplay;
                var subDisplay     = Localizable.SubDisplay;
                for (var i = 0; i < Screen.AllScreens.Length; i++)
                {
                    // 0 is primary
                    var newItem = i == 0 ? primaryDisplay : $"{subDisplay} : " + i;
                    dropDisplay.Items.Add(newItem);
                }

                PlayHomeStartup();

                PluginToggleManager.CreatePluginToggles(Toggleables);

                _suppressEvents = false;

                UpdateDisplaySettings(SettingManager.CurrentSettings.FullScreen);

                Closed    += (sender, args) => SettingManager.SaveSettings();
                MouseDown += (sender, args) =>
                {
                    if (args.ChangedButton == MouseButton.Left)
                    {
                        DragMove();
                    }
                };
                buttonClose.Click += (sender, args) => Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    "Failed to start the launcher, please consider reporting this error to the developers.\n\nError that caused the crash: " +
                    e, "Launcher crash", MessageBoxButtons.OK, MessageBoxIcon.Error);
                File.WriteAllText(Path.Combine(EnvironmentHelper.GameRootDirectory, "launcher_crash.log"),
                                  e.ToString());
                Close();
            }
        }
Exemple #4
0
        public MainWindow()
        {
            try
            {
                _suppressEvents = true;

                if (!File.Exists(EnvironmentHelper.GameRootDirectory + ExecutableGame))
                {
                    ExecutableGame = "AI-Syoujyo.exe";
                }

                // Initialize code -------------------------------------
                string tempgamedir =
                    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                bool isGameConverted = File.Exists($"{tempgamedir}/abdata/BRConvert/OK.txt");

                if (isGameConverted)
                {
                    RegistryKeyGame   = "Software\\illusion\\AI-Syoujyo\\AI-Syoujyo\\";
                    RegistryKeyStudio = "Software\\illusion\\AI-Syoujyo\\StudioNEOV2";
                    ExecutableGame    = "AI-Syoujyo.exe";
                }

                EnvironmentHelper.Initialize(!isGameConverted ? _builtinLanguages : _builtinLanguagesConvert);

                _mainGameExists = File.Exists(EnvironmentHelper.GameRootDirectory + ExecutableGame);
                _studioExists   = File.Exists(EnvironmentHelper.GameRootDirectory + ExecutableStudio);

                if (_studioExists)
                {
                    SettingManager.Initialize(EnvironmentHelper.GetConfigFilePath(), RegistryKeyGame, RegistryKeyStudio);
                }
                else
                {
                    SettingManager.Initialize(EnvironmentHelper.GetConfigFilePath(), RegistryKeyGame);
                }

                SettingManager.LoadSettings();

                // Initialize interface --------------------------------
                InitializeComponent();

                WindowStartupLocation = WindowStartupLocation.CenterScreen;
                CustomRes.Visibility  = Visibility.Hidden;

                if (string.IsNullOrEmpty((string)labelTranslated.Content))
                {
                    labelTranslated.Visibility       = Visibility.Hidden;
                    labelTranslatedBorder.Visibility = Visibility.Hidden;
                }

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

                /*
                 * // Launcher Customization: Defining Warning, background and character
                 * if (!string.IsNullOrEmpty(EnvironmentHelper.VersionString))
                 *  labelDist.Content = EnvironmentHelper.VersionString;
                 */
                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;
                }


                var primaryDisplay = Localizable.PrimaryDisplay;
                var subDisplay     = Localizable.SubDisplay;
                for (var i = 0; i < Screen.AllScreens.Length; i++)
                {
                    // 0 is primary
                    var newItem = i == 0 ? primaryDisplay : $"{subDisplay} : " + i;
                    dropDisplay.Items.Add(newItem);
                }

                PluginToggleManager.CreatePluginToggles(Toggleables);

                _suppressEvents = false;

                UpdateDisplaySettings(SettingManager.CurrentSettings.FullScreen);

                Closed    += (sender, args) => SettingManager.SaveSettings();
                MouseDown += (sender, args) => { if (args.ChangedButton == MouseButton.Left)
                                                 {
                                                     DragMove();
                                                 }
                };
                buttonClose.Click += (sender, args) => Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to start the launcher, please consider reporting this error to the developers.\n\nError that caused the crash: " + e, "Launcher crash", MessageBoxButtons.OK, MessageBoxIcon.Error);
                File.WriteAllText(Path.Combine(EnvironmentHelper.GameRootDirectory, "launcher_crash.log"), e.ToString());
                Close();
            }
        }