Beispiel #1
0
        public void SetServerTimeZone(string lang)
        {
            if (string.IsNullOrEmpty(lang))
            {
                return;
            }
            CurrentRegion = TccUtils.RegionEnumFromLanguage(lang);// region.StartsWith("EU") ? "EU" : region;

            //App.Settings.LastLanguage = lang; //TODO: needed?
            if (!_serverTimezones.ContainsKey(CurrentRegion))
            {
                CurrentRegion             = RegionEnum.EU;
                App.Settings.LastLanguage = "EU-EN";
                TccMessageBox.Show("TCC", SR.CannotDetectCurrentRegion, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            var timezone = TimeZoneInfo.GetSystemTimeZones().FirstOrDefault(x => x.Id == _serverTimezones[CurrentRegion].Timezone);

            ResetHour = _serverTimezones[CurrentRegion].ResetHour;

            if (timezone != null)
            {
                ServerHourOffsetFromUtc = timezone.IsDaylightSavingTime(DateTime.UtcNow + timezone.BaseUtcOffset)
                    ? timezone.BaseUtcOffset.Hours + 1
                    : timezone.BaseUtcOffset.Hours;
                ServerHourOffsetFromLocal = -TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).Hours + ServerHourOffsetFromUtc;
            }

            if (WindowManager.ViewModels.DashboardVM.Markers.FirstOrDefault(x => x.Name.Equals(CurrentRegion + " server time")) == null)
            {
                WindowManager.ViewModels.DashboardVM.Markers.Add(new TimeMarker(ServerHourOffsetFromLocal, CurrentRegion + " server time"));
            }

            CheckReset();
            WindowManager.ViewModels.DashboardVM.LoadEvents(DateTime.Now.DayOfWeek, CurrentRegion.ToString());
        }
Beispiel #2
0
        private async void OnStartup(object sender, StartupEventArgs e)
        {
            _running   = true;
            AppVersion = TccUtils.GetTccVersion();
            Log.Config(Path.Combine(BasePath, "logs"), AppVersion); // NLog when?
            ParseStartupArgs(e.Args.ToList());
            if (!File.Exists(Path.Combine(BasePath, SettingsGlobals.SettingsFileName)))
            {
                FirstStart = true;
            }
            BaseDispatcher             = Dispatcher.CurrentDispatcher;
            BaseDispatcher.Thread.Name = "Main";
            RunningDispatchers         = new ConcurrentDictionary <int, Dispatcher>();

            TccMessageBox.CreateAsync();
            if (IsAlreadyRunning() && !Debugger.IsAttached)
            {
                if (!ToolboxMode)
                {
                    TccMessageBox.Show(SR.AnotherInstanceRunning, MessageBoxType.Information);
                }
                Current.Shutdown();
                return;
            }
            if (!Debugger.IsAttached)
            {
                AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler.HandleGlobalException;
            }

            Loading = true;
            await Setup();

            Loading = false;

            if (FirstStart)
            {
                new WelcomeWindow().Show();
            }

            //Tester.Enable();
            //Tester.ShowDebugWindow();
        }
Beispiel #3
0
        public void SetServerTimeZone(string lang)
        {
            if (string.IsNullOrEmpty(lang))
            {
                return;
            }
            CurrentRegion = TccUtils.RegionEnumFromLanguage(lang);// region.StartsWith("EU") ? "EU" : region;

            SettingsHolder.LastLanguage = lang;
            if (!_serverTimezones.ContainsKey(CurrentRegion))
            {
                CurrentRegion = RegionEnum.EU;
                SettingsHolder.LastLanguage = "EU-EN";
                TccMessageBox.Show("TCC",
                                   "Current region could not be detected, so TCC will load EU-EN database. To force a specific language, use Region Override setting in Misc Settings.",
                                   MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            var timezone = TimeZoneInfo.GetSystemTimeZones().FirstOrDefault(x => x.Id == _serverTimezones[CurrentRegion].Timezone);

            ResetHour = _serverTimezones[CurrentRegion].ResetHour;

            if (timezone != null)
            {
                ServerHourOffsetFromUtc = timezone.IsDaylightSavingTime(DateTime.UtcNow + timezone.BaseUtcOffset)
                    ? timezone.BaseUtcOffset.Hours + 1
                    : timezone.BaseUtcOffset.Hours;
                ServerHourOffsetFromLocal = -TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours + ServerHourOffsetFromUtc;
            }

            if (WindowManager.Dashboard.VM.Markers.FirstOrDefault(x => x.Name.Equals(CurrentRegion + " server time")) == null)
            {
                WindowManager.Dashboard.VM.Markers.Add(new TimeMarker(ServerHourOffsetFromLocal, CurrentRegion + " server time"));
            }

            CheckReset();
            WindowManager.Dashboard.VM.LoadEvents(DateTime.Now.DayOfWeek, CurrentRegion.ToString());
        }
Beispiel #4
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);
            }
        }