Exemple #1
0
 public void LineColorsChanged()
 {
     using (_tracksync.AcquireRead())
     {
         _renderer.RefreshTrack(_track);
     }
 }
 public static TrackReader AcquireRead(ResourceSync sync, Track track, EditorGrid cells)
 {
     return(new TrackReader(sync.AcquireRead(), track)
     {
         _editorcells = cells
     });
 }
Exemple #3
0
        public static bool CheckPressed(Hotkey hotkey)
        {
            List <Keybinding> keybindings;

            if (Settings.Keybinds.TryGetValue(hotkey, out keybindings))
            {
                using (_lock.AcquireRead())
                {
                    foreach (var bind in keybindings)
                    {
                        if (bind.IsEmpty)
                        {
                            continue;
                        }
                        if (CheckPressed(bind, ref _kbstate, ref _mousestate))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #4
0
        public void Render(float blend)
        {
            _invalidated = false;
            if (_refreshtrack)
            {
                using (_tracksync.AcquireRead())
                {
                    _renderer.RefreshTrack(_track);
                }
                _refreshtrack = false;
            }
            DrawOptions drawOptions = new DrawOptions();

            drawOptions.DrawFlag = _flag != null;
            if (drawOptions.DrawFlag)
            {
                drawOptions.FlagRider = _flag.State;
            }
            drawOptions.Blend        = blend;
            drawOptions.NightMode    = Settings.NightMode;
            drawOptions.GravityWells = Settings.Local.RenderGravityWells;
            drawOptions.LineColors   = !Settings.Local.PreviewMode && (!Playing || Settings.Local.ColorPlayback);
            drawOptions.KnobState    = KnobState.Hidden;
            if (!Playing && game.SelectedTool is MoveTool movetool)
            {
                drawOptions.KnobState = movetool.CanLifelock
                ? KnobState.LifeLock
                : KnobState.Shown;
            }
            drawOptions.Paused              = Paused;
            drawOptions.PlaybackMode        = PlaybackMode;
            drawOptions.Rider               = RenderRiderInfo.State;
            drawOptions.ShowContactLines    = Settings.Local.DrawContactPoints;
            drawOptions.ShowMomentumVectors = Settings.Local.MomentumVectors;
            drawOptions.Zoom           = Zoom;
            drawOptions.RiderDiagnosis = RenderRiderInfo.Diagnosis;
            int renderframe = Offset;

            if (Playing && Offset > 0 && blend < 1)
            {
                //interpolate between last frame and current one
                var current = Timeline.GetFrame(Offset);
                var prev    = Timeline.GetFrame(Offset - 1);
                drawOptions.Rider = Rider.Lerp(prev, current, blend);
                renderframe       = Offset - 1;
            }
            drawOptions.Iteration = IterationsOffset;
            if (!_loadingTrack)
            {
                var changes = Timeline.RequestFrameForRender(renderframe);
                foreach (var change in changes)
                {
                    GameLine line;
                    if (_track.LineLookup.TryGetValue(change, out line))
                    {
                        _renderer.RedrawLine(line);
                    }
                }
            }

            _renderer.Render(_track, Timeline, Camera, drawOptions);
        }
Exemple #5
0
        public void Render(float blend)
        {
            _invalidated = false;
            if (_refreshtrack)
            {
                using (_tracksync.AcquireRead())
                {
                    _renderer.RefreshTrack(_track);
                }
                _refreshtrack = false;
            }
            DrawOptions drawOptions = new DrawOptions();

            drawOptions.DrawFlag = _flag != null && !Settings.Local.RecordingMode;
            if (drawOptions.DrawFlag)
            {
                drawOptions.FlagRider = _flag.State;
            }
            drawOptions.Blend        = blend;
            drawOptions.NightMode    = Settings.NightMode;
            drawOptions.GravityWells = Settings.Editor.RenderGravityWells;
            drawOptions.LineColors   = !Settings.PreviewMode && (!Playing || Settings.ColorPlayback);
            drawOptions.KnobState    = KnobState.Hidden;
            var selectedtool = CurrentTools.SelectedTool;

            if (!Playing &&
                (selectedtool == CurrentTools.MoveTool ||
                 selectedtool == CurrentTools.SelectTool))
            {
                drawOptions.KnobState = KnobState.Shown;
            }
            drawOptions.Paused              = Paused;
            drawOptions.Rider               = RenderRiderInfo.State;
            drawOptions.ShowContactLines    = Settings.Editor.DrawContactPoints;
            drawOptions.ShowMomentumVectors = Settings.Editor.MomentumVectors;
            drawOptions.Zoom           = Zoom;
            drawOptions.RiderDiagnosis = RenderRiderInfo.Diagnosis;
            if (Settings.Local.TrackOverlay && !Playing)
            {
                drawOptions.OverlayFrame = Settings.Local.TrackOverlayFixed
                ? Settings.Local.TrackOverlayFixedFrame
                : Offset + Settings.Local.TrackOverlayOffset;
                drawOptions.OverlayFrame = MathHelper.Clamp(
                    drawOptions.OverlayFrame,
                    0,
                    FrameCount + 999);
            }
            int renderframe = Offset;

            if (Playing && Offset > 0 && blend < 1)
            {
                //interpolate between last frame and current one
                var current = Timeline.GetFrame(Offset);
                var prev    = Timeline.GetFrame(Offset - 1);
                drawOptions.Rider = Rider.Lerp(prev, current, blend);
                renderframe       = Offset - 1;
            }
            drawOptions.Iteration = IterationsOffset;
            // todo there's a race condition here where if the track finished
            // loading between this if statement and the render call above
            // and theres a line change queued, the line may not exist in
            // renderer, causing a crash
            if (!_loadingTrack)
            {
                var changes = Timeline.RequestFrameForRender(renderframe);
                foreach (var change in changes)
                {
                    GameLine line;
                    if (_track.LineLookup.TryGetValue(change, out line))
                    {
                        _renderer.RedrawLine(line);
                    }
                }
            }

            _renderer.Render(_track, Timeline, Camera, drawOptions);
        }