Exemple #1
0
        public void Startup()
        {
            m_gameServices = new GameServices();

            m_mainWindowViewModel = new MainWindowViewModel(m_gameServices);

            StartupFinished.Raise(this);
        }
Exemple #2
0
        public void CheckSetup()
        {
            bool exists         = SettingsManager.Instance.LoadOrCreateSettings();
            bool validApiOrUser = ApiHelper.IsKeyValid(SettingsManager.Instance.Settings["api"]["key"]) &&
                                  ApiHelper.IsUserValid(SettingsManager.Instance.Settings["api"]["key"], SettingsManager.Instance.Settings["api"]["user"]);

            if (!exists || !validApiOrUser)
            {
                if (exists && !validApiOrUser)
                {
                    BrowserViewModel.Instance.SendNotification(NotificationType.Danger, StringStorage.Get("Message.NoAPIorUsername"));
                }

                BrowserViewModel.Instance.AttachedJavascriptWrapper.Modal.Show("#generateSettingsModal");
                cefOsuApp.SetupFinished += (object sender, EventArgs e) =>
                {
                    cefOsuApp.GetWindow().Dispatcher.Invoke(() =>
                    {
                        Task.Run(async() =>
                        {
                            BrowserViewModel.Instance.AttachedJavascriptWrapper.SetElementDisabled("#settingsConfirmButton", true);
                            BrowserViewModel.Instance.AttachedJavascriptWrapper.SetHtml("#settingsConfirmButton", "<span class=\"spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span> saving");

                            Task task = ProcessSetup();
                            if (await Task.WhenAny(task, Task.Delay(5000)) != task)
                            {
                                BrowserViewModel.Instance.SendNotification(NotificationType.Danger, StringStorage.Get("Message.SomethingWrong"));
                            }

                            //MessageBox.Show(apiKey);
                            BrowserViewModel.Instance.AttachedJavascriptWrapper.SetElementDisabled("#settingsConfirmButton", false);
                            BrowserViewModel.Instance.AttachedJavascriptWrapper.SetHtml("#settingsConfirmButton", "Save");
                        });
                    });
                };
            }
            else
            {
                StartupFinished?.Invoke(null, null);
            }
        }
Exemple #3
0
 // Trigger
 public void OnGameStartupFinished()
 {
     StartupFinished?.Invoke();
 }