Exemplo n.º 1
0
        public void GameUpdate()
        {
            var updates = Scheduler.UnqueueUpdates();

            if (updates > 0)
            {
                Zoom(Math.Min(Track.Zoom, 12) * (_zoomPerTick));
            }
            if (_autosavewatch.Elapsed.TotalMinutes >= 5)
            {
                _autosavewatch.Restart();
                new Thread(() => { Track.BackupTrack(false); }).Start();
            }
            if (Canvas.GetOpenWindows().Count != 0)
            {
                Invalidate();
            }
            if (Track.Playing)
            {
                Track.Update(updates);
                if (Track.Frame % 40 == 0)
                {
                    var sp = AudioPlayback.SongPosition;
                    if (Math.Abs(((Track.CurrentFrame / 40f) + CurrentSong.Offset) - sp) > 0.1)
                    {
                        UpdateSongPosition(Track.CurrentFrame / 40f);
                    }
                }
            }
            if (Track.Animating && Track.Paused)
            {
                AllowTrackRender = true;
            }
        }
        public void GameUpdate()
        {
            GameUpdateHandleInput();
            var updates = Scheduler.UnqueueUpdates();

            if (updates > 0)
            {
                Invalidate();
                if (Track.Playing)
                {
                    if (InputUtils.Check(Hotkey.PlaybackZoom))
                    {
                        Zoom(0.08f);
                    }
                    else if (InputUtils.Check(Hotkey.PlaybackUnzoom))
                    {
                        Zoom(-0.08f);
                    }
                }
            }
            var qp = (!Track.PlaybackMode) ? InputUtils.Check(Hotkey.EditorQuickPan) : false;

            if (qp != _handToolOverride)
            {
                _handToolOverride = qp;
                if (_handToolOverride == false)
                {
                    HandTool.Stop();
                }
                Invalidate();
                UpdateCursor();
            }
            if (_autosavewatch.Elapsed.TotalMinutes >= 5)
            {
                _autosavewatch.Restart();
                new Thread(() => { Track.BackupTrack(false); }).Start();
            }
            if (Canvas.GetOpenWindows().Count != 0)
            {
                Invalidate();
            }


            if (Track.Playing)
            {
                if (ReversePlayback)
                {
                    Track.ActiveTriggers.Clear();//we don't want wonky unpredictable behavior
                    for (int i = 0; i < updates; i++)
                    {
                        Track.PreviousFrame();
                        Track.UpdateCamera(true);
                    }
                }
                else
                {
                    Track.Update(updates);
                }
            }
            AudioService.EnsureSync();
            if (Program.NewVersion != null)
            {
                Canvas.ShowOutOfDate();
            }
        }
Exemplo n.º 3
0
 protected override void OnMouseDown(MouseButtonEventArgs e)
 {
     base.OnMouseDown(e);
     try
     {
         InputUtils.UpdateMouse(e.Mouse);
         if (linerider.IO.TrackRecorder.Recording)
         {
             return;
         }
         var r = _input.ProcessMouseMessage(e);
         _uicursor = _input.MouseCaptured;
         if (Canvas.GetOpenWindows().Count != 0)
         {
             UpdateCursor();
             return;
         }
         if (!r)
         {
             InputUtils.ProcessMouseHotkeys();
             if (!Track.Playing)
             {
                 bool dragstart = false;
                 if (Track.Offset == 0 &&
                     e.Button == MouseButton.Left &&
                     InputUtils.Check(Hotkey.EditorMoveStart))
                 {
                     var gamepos = ScreenPosition + (new Vector2d(e.X, e.Y) / Track.Zoom);
                     dragstart = Game.Rider.GetBounds(
                         Track.GetStart()).Contains(
                         gamepos.X,
                         gamepos.Y);
                     if (dragstart)
                     {
                         // 5 is arbitrary, but i assume that's a decent
                         // place to assume the user has done "work"
                         if (!Track.MoveStartWarned && Track.LineCount > 5)
                         {
                             var popup = MessageBox.Show(Canvas,
                                                         "You're about to move the start position of the rider." +
                                                         " This cannot be undone, and may drastically change how your track plays." +
                                                         "\nAre you sure you want to do this?", "Warning", MessageBox.ButtonType.OkCancel);
                             popup.RenameButtons("I understand");
                             popup.Dismissed += (o, args) =>
                             {
                                 if (popup.Result == Gwen.DialogResult.OK)
                                 {
                                     Track.MoveStartWarned = true;
                                 }
                             };
                         }
                         else
                         {
                             _dragRider = dragstart;
                         }
                     }
                 }
                 if (!_dragRider && !dragstart)
                 {
                     if (e.Button == MouseButton.Left)
                     {
                         CurrentTools.SelectedTool.OnMouseDown(new Vector2d(e.X, e.Y));
                     }
                     else if (e.Button == MouseButton.Right)
                     {
                         CurrentTools.SelectedTool.OnMouseRightDown(new Vector2d(e.X, e.Y));
                     }
                 }
             }
             else if (CurrentTools.SelectedTool == CurrentTools.PencilTool && CurrentTools.PencilTool.DrawingScenery)
             {
                 if (e.Button == MouseButton.Left)
                 {
                     CurrentTools.PencilTool.OnMouseDown(new Vector2d(e.X, e.Y));
                 }
             }
         }
         UpdateCursor();
         Invalidate();
     }
     catch (Exception ex)
     {
         // SDL2 backend eats exceptions.
         // we have to manually crash.
         Program.Crash(ex, true);
         Close();
     }
 }