Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
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();
            }
        }