Exemplo n.º 1
0
        private void ClockScripts_Tick(object sender, EventArgs e)
        {
            if (Game.IsPaused || Game.IsLoading)
            {
                return;
            }

            bool   keyIsDown = Game.IsEnabledControlPressed(Control.CharacterWheel);
            string time      = DateTimeManager.GetTimeString();

            if (keyIsDown)
            {
                if (Main.configSettings.Show_Radar_OnKeyDown)
                {
                    Hud.IsRadarVisible = true;
                }
                _clockScroll += 1 * Game.LastFrameTime;
                if (_clockScroll > 0.02f)
                {
                    _clockScroll = 0.02f;
                }
            }
            else
            {
                _clockScroll -= 1 * Game.LastFrameTime;
                if (_clockScroll < -0.2f)
                {
                    _clockScroll = -0.2f;
                    if (Main.configSettings.Show_Radar_OnKeyDown)
                    {
                        Hud.IsRadarVisible = false;
                    }
                }
            }

            if (Main.configClock.Enable_Top_Clock)
            {
                Helpers.DrawText(new Vector2(0.5f, _clockScroll), time, true, true, 1.068f, 0, 0, 0, 200, Font.ChaletComprimeCologne);
                Helpers.DrawText(new Vector2(0.5f, _clockScroll), time, true, true, 1.066f, 240, 240, 240, 255, Font.ChaletComprimeCologne);
            }

            // Sync with machine
            if (DateTimeManager.CurrentClockMode == ClockMode.Sync)
            {
                DateTimeManager.Freeze(true);
                DateTimeManager.SetDate(DateTime.Now);
                DateTimeManager.SetTime(DateTime.Now.TimeOfDay);
            }
            // Vanilla game time
            else if (DateTimeManager.CurrentClockMode == ClockMode.Vanilla)
            {
                DateTimeManager.Freeze(false);
            }
            // Virtual game time
            else
            {
                DateTimeManager.Freeze(true);

                if (Game.GameTime > _timer)
                {
                    _timer = Game.GameTime + (int)Math.Round(1000 * DateTimeManager.CurrentTimerate);
                    DateTimeManager.AddSeconds(1);
                }
            }

            // Update Clock
            DateTimeManager.UpdateGameClock();
        }