Exemplo n.º 1
0
        private static async Task Setup()
        {
            TccUtils.SetAlignment();

            NoticeChecker.Init();

            TccSplashScreen.InitOnNewThread();

            if (!ToolboxMode)
            {
                UpdateManager.TryDeleteUpdater();

                SplashScreen.VM.BottomText = "Checking for application updates...";
                await UpdateManager.CheckAppVersion();
            }

            // ----------------------------
            SplashScreen.VM.Progress   = 10;
            SplashScreen.VM.BottomText = "Loading settings...";
            Settings = SettingsContainer.Load();
            WindowManager.InitSettingsWindow(); // need it in case language is not correct

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

            // ----------------------------
            SplashScreen.VM.Progress   = 30;
            SplashScreen.VM.BottomText = "Pre-loading databases...";
            UpdateManager.CheckDatabaseHash();
            SplashScreen.VM.Progress = 40;
            await Game.InitAsync();

            // ----------------------------
            SplashScreen.VM.Progress   = 50;
            SplashScreen.VM.BottomText = "Initializing widgets...";
            await WindowManager.Init();

            SplashScreen.VM.Progress = 60;
            StartDispatcherWatcher();

            // ----------------------------
            SplashScreen.VM.Progress   = 70;
            SplashScreen.VM.BottomText = "Checking for icon database updates...";
            _ = Task.Run(() => new IconsUpdater().CheckForUpdates());

            // ----------------------------
            SplashScreen.VM.BottomText     = "Initializing packet processor...";
            SplashScreen.VM.Progress       = 80;
            PacketAnalyzer.ProcessorReady += LoadModules;
            await PacketAnalyzer.InitAsync();

            // ----------------------------
            SplashScreen.VM.Progress   = 90;
            SplashScreen.VM.BottomText = "Starting";
            GameEventManager.Instance.SetServerTimeZone(Settings.LastLanguage);
            UpdateManager.StartPeriodicCheck();

            SplashScreen.VM.Progress = 100;
            SplashScreen.CloseWindowSafe();


            // ----------------------------
            Log.Chat($"{AppVersion} ready.");
            ReadyEvent?.Invoke();

            if (!Beta && Settings.BetaNotification && UpdateManager.IsBetaNewer())
            {
                Log.N("TCC beta available", SR.BetaAvailable, NotificationType.Success, 10000);
            }
        }