//public static DebugWindow DebugWindow;

        private void OnStartup(object sender, StartupEventArgs e)
        {
            Loading = true;
            //#if DEBUG
            //            DebugWindow = new DebugWindow();
            //            DebugWindow.Show();
            //#endif

            var v = Assembly.GetExecutingAssembly().GetName().Version;

            _version = $"TCC v{v.Major}.{v.Minor}.{v.Build}";
            InitSplashScreen();

            BaseDispatcher = Dispatcher.CurrentDispatcher;
            TccMessageBox.Create(); //Create it here in STA thread
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler;
#endif
            TryDeleteUpdater();

            SplashScreen.SetText("Checking for application updates...");
            UpdateManager.CheckAppVersion();

            SplashScreen.SetText("Checking for database updates...");
            UpdateManager.CheckDatabaseVersion();

            SplashScreen.SetText("Loading settings...");
            var sr = new SettingsReader();
            sr.LoadWindowSettings();
            sr.LoadSettings();

            Process.GetCurrentProcess().PriorityClass = Settings.HighPriority ? ProcessPriorityClass.High : ProcessPriorityClass.Normal;
            if (Settings.ForceSoftwareRendering)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            SplashScreen.SetText("Pre-loading databases...");
            SessionManager.InitDatabases(string.IsNullOrEmpty(Settings.LastRegion) ? "EU-EN" : Settings.LastRegion == "EU" ? "EU-EN" : Settings.LastRegion);

            SplashScreen.SetText("Initializing windows...");
            WindowManager.Init();

            //SplashScreen.SetText("Initializing Twitch connector...");
            //TwitchConnector.Instance.Init();

            SplashScreen.SetText("Initializing packet processor...");
            PacketProcessor.Init();
            TeraSniffer.Instance.NewConnection += TeraSniffer_OnNewConnection;
            TeraSniffer.Instance.EndConnection += TeraSniffer_OnEndConnection;
            TeraSniffer.Instance.Enabled        = true;
            WindowManager.FloatingButton.NotifyExtended("TCC", "Ready to connect.", NotificationType.Normal);
            SplashScreen.SetText("Starting");

            SessionManager.CurrentPlayer.Class    = Class.None;
            SessionManager.CurrentPlayer.Name     = "player";
            SessionManager.CurrentPlayer.EntityId = 10;
            TimeManager.Instance.SetServerTimeZone(Settings.LastRegion);
            ChatWindowManager.Instance.AddTccMessage(_version);
            SplashScreen.CloseWindowSafe();

            UpdateManager.StartCheck();

            if (Settings.LastRegion == "NA" || Settings.LastRegion == "")
            {
                WindowManager.FloatingButton.NotifyExtended("So long, and thanks for all the fish", ThankYou_mEME, NotificationType.Error, 15000);
            }

            if (Debug)
            {
                DebugStuff();
            }
            Loading = false;
        }
Exemple #2
0
        private async void OnStartup(object sender, StartupEventArgs e)
        {
            BaseDispatcher             = Dispatcher.CurrentDispatcher;
            BaseDispatcher.Thread.Name = "Main";
            TccMessageBox.Create(); //Create it here in STA thread
            if (IsRunning())
            {
                TccMessageBox.Show("Another instance of TCC is already running. Shutting down.",
                                   MessageBoxType.Information);
                Current.Shutdown();
                return;
            }

            Loading = true;
            var v = Assembly.GetExecutingAssembly().GetName().Version;

            AppVersion = $"TCC v{v.Major}.{v.Minor}.{v.Build}{(Experimental ? "-e" : "")}";
            InitSplashScreen();

            AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler.HandleGlobalException;
            UpdateManager.TryDeleteUpdater();

            SplashScreen.SetText("Checking for application updates...");
            await UpdateManager.CheckAppVersion();

            SplashScreen.SetText("Checking for database updates...");
            await UpdateManager.CheckIconsVersion();

            SplashScreen.SetText("Loading settings...");
            var sr = new SettingsReader();

            sr.LoadWindowSettings();
            sr.LoadSettings();

            Process.GetCurrentProcess().PriorityClass = SettingsHolder.HighPriority
                ? ProcessPriorityClass.High
                : ProcessPriorityClass.Normal;
            if (SettingsHolder.ForceSoftwareRendering)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            SplashScreen.SetText("Pre-loading databases...");
            UpdateManager.CheckDatabaseHash();
            SessionManager.InitDatabasesAsync(string.IsNullOrEmpty(SettingsHolder.LastLanguage) ? "EU-EN" :
                                              SettingsHolder.LastLanguage == "EU" ? "EU-EN" :
                                              SettingsHolder.LastLanguage);
            UpdateManager.CheckServersFile();

            SplashScreen.SetText("Initializing windows...");
            WindowManager.Init();

            SplashScreen.SetText("Initializing packet processor...");
            PacketAnalyzer.InitAsync();
            SplashScreen.SetText("Starting");

            TimeManager.Instance.SetServerTimeZone(SettingsHolder.LastLanguage);
            ChatWindowManager.Instance.AddTccMessage(AppVersion);
            SplashScreen.CloseWindowSafe();

            UpdateManager.StartPeriodicCheck();

            if (!Experimental && SettingsHolder.ExperimentalNotification && UpdateManager.IsExperimentalNewer())
            {
                WindowManager.FloatingButton.NotifyExtended("TCC experimental",
                                                            "An experimental version of TCC is available. Open System settings to download it or disable this notification.",
                                                            NotificationType.Success,
                                                            10000);
            }

            Loading = false;
        }