Exemple #1
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            // Set SecurityProtocol to prevent crash with TLS
            System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            if (ModAssistant.Properties.Settings.Default.UpgradeRequired)
            {
                ModAssistant.Properties.Settings.Default.Upgrade();
                ModAssistant.Properties.Settings.Default.UpgradeRequired = false;
                ModAssistant.Properties.Settings.Default.Save();
            }

            Version   = Version.Substring(0, Version.Length - 2);
            OCIWindow = ModAssistant.Properties.Settings.Default.OCIWindow;
            if (string.IsNullOrEmpty(OCIWindow))
            {
                OCIWindow = "Yes";
            }
            Pages.Options options = Pages.Options.Instance;
            options.InstallDirectory      =
                BeatSaberInstallDirectory = Utils.GetInstallDir();

            Languages.LoadLanguages();

            Options.Instance.DownloadServerSelectComboBox.ItemsSource   = Options.serverList.ToList();
            Options.Instance.DownloadServerSelectComboBox.SelectedIndex = Options.serverList.ToList().FindIndex((string server) => server == ModAssistant.Properties.Settings.Default.DownloadServer);

            while (string.IsNullOrEmpty(App.BeatSaberInstallDirectory))
            {
                string title = (string)Current.FindResource("App:InstallDirDialog:Title");
                string body  = (string)Current.FindResource("App:InstallDirDialog:OkCancel");

                if (System.Windows.Forms.MessageBox.Show(body, title, System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    App.BeatSaberInstallDirectory = Utils.GetManualDir();
                }
                else
                {
                    Environment.Exit(0);
                }
            }

            options.InstallType            =
                BeatSaberInstallType       = ModAssistant.Properties.Settings.Default.StoreType;
            options.SaveSelection          =
                SaveModSelection           = ModAssistant.Properties.Settings.Default.SaveSelected;
            options.CheckInstalledMods     =
                CheckInstalledMods         = ModAssistant.Properties.Settings.Default.CheckInstalled;
            options.SelectInstalledMods    =
                SelectInstalledMods        = ModAssistant.Properties.Settings.Default.SelectInstalled;
            options.ReinstallInstalledMods =
                ReinstallInstalledMods     = ModAssistant.Properties.Settings.Default.ReinstallInstalled;
            options.CloseWindowOnFinish    =
                CloseWindowOnFinish        = ModAssistant.Properties.Settings.Default.CloseWindowOnFinish;

            await ArgumentHandler(e.Args);
            await Init();

            options.UpdateOCIWindow(OCIWindow);
        }
Exemple #2
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            // Set SecurityProtocol to prevent crash with TLS
            System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
            Languages.LoadLanguages();

            if (ModAssistant.Properties.Settings.Default.UpgradeRequired)
            {
                ModAssistant.Properties.Settings.Default.Upgrade();
                ModAssistant.Properties.Settings.Default.UpgradeRequired = false;
                ModAssistant.Properties.Settings.Default.Save();
            }

            Version = Version.Substring(0, Version.Length - 2);
            BeatSaberInstallDirectory = Utils.GetInstallDir();

            while (string.IsNullOrEmpty(App.BeatSaberInstallDirectory))
            {
                string title = (string)Current.FindResource("App:InstallDirDialog:Title");
                string body  = (string)Current.FindResource("App:InstallDirDialog:OkCancel");

                if (System.Windows.Forms.MessageBox.Show(body, title, System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    App.BeatSaberInstallDirectory = Utils.GetManualDir();
                }
                else
                {
                    Environment.Exit(0);
                }
            }

            BeatSaberInstallType   = ModAssistant.Properties.Settings.Default.StoreType;
            SaveModSelection       = ModAssistant.Properties.Settings.Default.SaveSelected;
            CheckInstalledMods     = ModAssistant.Properties.Settings.Default.CheckInstalled;
            SelectInstalledMods    = ModAssistant.Properties.Settings.Default.SelectInstalled;
            ReinstallInstalledMods = ModAssistant.Properties.Settings.Default.ReinstallInstalled;
            CloseWindowOnFinish    = ModAssistant.Properties.Settings.Default.CloseWindowOnFinish;

            await ArgumentHandler(e.Args);
            await Init();
        }
Exemple #3
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            const int ContentWidth  = 1280;
            const int ContentHeight = 720;

            double ChromeWidth  = SystemParameters.WindowNonClientFrameThickness.Left + SystemParameters.WindowNonClientFrameThickness.Right;
            double ChromeHeight = SystemParameters.WindowNonClientFrameThickness.Top + SystemParameters.WindowNonClientFrameThickness.Bottom;
            double ResizeBorder = SystemParameters.ResizeFrameVerticalBorderWidth;

            Width  = ChromeWidth + ContentWidth + 2 * ResizeBorder;
            Height = ChromeHeight + ContentHeight + 2 * ResizeBorder;

            VersionText.Text = App.Version;

            if (Utils.IsVoid())
            {
                Main.Content = Invalid.Instance;
                MainWindow.Instance.ModsButton.IsEnabled      = false;
                MainWindow.Instance.OptionsButton.IsEnabled   = false;
                MainWindow.Instance.IntroButton.IsEnabled     = false;
                MainWindow.Instance.AboutButton.IsEnabled     = false;
                MainWindow.Instance.GameVersionsBox.IsEnabled = false;
                return;
            }

            Themes.LoadThemes();
            Themes.FirstLoad(Properties.Settings.Default.SelectedTheme);

            Languages.LoadLanguages();

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

            if (!Properties.Settings.Default.Agreed || string.IsNullOrEmpty(Properties.Settings.Default.LastTab))
            {
                Main.Content = Intro.Instance;
            }
            else
            {
                switch (Properties.Settings.Default.LastTab)
                {
                case "Intro":
                    Main.Content = Intro.Instance;
                    break;

                case "Mods":
                    _ = ShowModsPage();
                    break;

                case "About":
                    Main.Content = About.Instance;
                    break;

                case "Options":
                    Main.Content = Options.Instance;
                    Themes.LoadThemes();
                    break;

                default:
                    Main.Content = Intro.Instance;
                    break;
                }
            }
        }