Exemple #1
0
        public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            // hack to prevent flicker, doesn't actually pause anything
            state.IsGameTimePaused = true;

            // Update is called every 25ms, so up to 25ms IGT can be lost if using delay and no auto-start
            if (_waitingForDelay)
            {
                if (state.CurrentTime.RealTime >= TimeSpan.Zero)
                {
                    _sessionTicksOffset = _sessionTicks;
                    _waitingForDelay    = false;
                }
                else
                {
                    state.SetGameTime(state.CurrentTime.RealTime);
                }
            }

            if (!_waitingForDelay)
            {
                // update game time, don't show negative time due to tick adjusting
                state.SetGameTime(this.GameTime >= TimeSpan.Zero ? this.GameTime : TimeSpan.Zero);
            }

            if (!this.Settings.ShowGameTime)
            {
                return;
            }

            this.InternalComponent.TimeValue =
                state.CurrentTime[state.CurrentTimingMethod == TimingMethod.GameTime
                    ? TimingMethod.RealTime : TimingMethod.GameTime];
            this.InternalComponent.InformationName = state.CurrentTimingMethod == TimingMethod.GameTime
                ? "Real Time" : "Game Time";

            _cache.Restart();
            _cache["TimeValue"]    = this.InternalComponent.ValueLabel.Text;
            _cache["TimingMethod"] = state.CurrentTimingMethod;
            if (invalidator != null && _cache.HasChanged)
            {
                invalidator.Invalidate(0f, 0f, width, height);
            }
        }
Exemple #2
0
        public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            if (state.CurrentPhase == TimerPhase.Ended)
            {
                state.SetGameTime(_endTime.HasValue ? _endTime.Value : TimeSpan.Zero);
            }
            else
            {
                if (state.CurrentTime.RealTime >= TimeSpan.Zero)
                {
                    // Update is called every 25ms, so up to 25ms can be lost if using delay
                    if (_waitingForDelay)
                    {
                        _removeTime      = _mapTime;
                        _waitingForDelay = false;
                    }

                    state.SetGameTime(state.CurrentPhase == TimerPhase.Running ||
                                      state.CurrentPhase == TimerPhase.Paused
                        ? this.GameTime : TimeSpan.Zero);
                }
            }

            if (!this.Settings.ShowGameTime)
            {
                return;
            }

            this.InternalComponent.TimeValue =
                state.CurrentTime[state.CurrentTimingMethod == TimingMethod.GameTime
                    ? TimingMethod.RealTime : TimingMethod.GameTime];
            this.InternalComponent.InformationName = state.CurrentTimingMethod == TimingMethod.GameTime
                ? "Real Time" : "Game Time";

            _cache.Restart();
            _cache["TimeValue"]    = this.InternalComponent.ValueLabel.Text;
            _cache["TimingMethod"] = state.CurrentTimingMethod;
            if (invalidator != null && _cache.HasChanged)
            {
                invalidator.Invalidate(0f, 0f, width, height);
            }
        }
        public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            // hack to prevent flicker, doesn't actually pause anything
            state.IsGameTimePaused = true;

            // Update is called every 25ms, so up to 25ms IGT can be lost if using delay and no auto-start
            if (_waitingForDelay)
            {
                if (state.CurrentTime.RealTime >= TimeSpan.Zero)
                {
                    _sessionTicksOffset = _sessionTicks;
                    _waitingForDelay    = false;
                }
                else
                {
                    state.SetGameTime(state.CurrentTime.RealTime);
                }
            }

            if (!_waitingForDelay)
            {
                // update game time, don't show negative time due to tick adjusting
                state.SetGameTime(this.GameTime >= TimeSpan.Zero ? this.GameTime : TimeSpan.Zero);
            }

            AltTimingComponent.Enabled = Settings.ShowGameTime.Value;
            TickCountComponent.Enabled = Settings.ShowTickCount.Value;

            _componentRenderer.Update(invalidator, state, width, height, mode);

            if (_componentRenderer.VisibleComponents.Any())
            {
                _cache.Restart();
                if (this.Settings.ShowGameTime.Value)
                {
                    // change this if we ever have new timing methods
                    TimingMethod method = state.CurrentTimingMethod;
                    if (Settings.ShowAltTime.Value)
                    {
                        method = (TimingMethod)(((int)method + 1) % 2);
                    }

                    this.AltTimingComponent.SetText(state.CurrentTime[method], Settings.GameTimeDecimalPlaces.Value);
                    this.AltTimingComponent.SetName(method == TimingMethod.RealTime ? "Real Time" : "Game Time");

                    _cache["TimeValue"]    = this.AltTimingComponent.Component.ValueLabel.Text;
                    _cache["TimingMethod"] = state.CurrentTimingMethod;
                }

                if (this.Settings.ShowTickCount.Value)
                {
                    TickCountComponent.SetText(((long)(GameTime.TotalSeconds / _intervalPerTick)).ToString());
                    _cache["TickCount"] = this.TickCountComponent.Component.ValueLabel.Text;
                }

                if (_cache.HasChanged)
                {
                    invalidator?.Invalidate(0f, 0f, width, height);
                }
            }

#if DEBUG
            if (_prevGameTime <= GameTime)
            {
                _prevGameTime = GameTime;
            }
            else
            {
                Debug.WriteLine($"game time sunk mid run" +
                                $"\n\ntotal ticks: {_totalTicks}\nsession ticks: {_sessionTicks}\n\n" +
                                $"game time now: {GameTime}\ngame time then: {_prevGameTime}");
            }
#endif
        }