From c71f6223f2fb6167d1d53b6640cc287011c82831 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 1 Sep 2024 11:08:29 +0100 Subject: [PATCH] Add snapping and fix glitchy movement at bottom --- src/emdui/MainWindow.xaml.cs | 4 +++- src/emdui/Ui/Animation/TimelineSeries.xaml.cs | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/emdui/MainWindow.xaml.cs b/src/emdui/MainWindow.xaml.cs index ab7a6da..436fbae 100644 --- a/src/emdui/MainWindow.xaml.cs +++ b/src/emdui/MainWindow.xaml.cs @@ -781,7 +781,9 @@ public void SetEntity(int i, int t, double value) return; var denormalizedValue = (Wrap(value - 1) + 1) / 2; - var rawValue = (short)((int)(denormalizedValue * 4096) % 4096); + var rawValue = value <= -1 + ? (short)(2049) + : (short)((int)(denormalizedValue * 4096) % 4096); var v = frame.Angles[i / 3]; if (iC == 0) v.x = rawValue; diff --git a/src/emdui/Ui/Animation/TimelineSeries.xaml.cs b/src/emdui/Ui/Animation/TimelineSeries.xaml.cs index a3df70b..e697991 100644 --- a/src/emdui/Ui/Animation/TimelineSeries.xaml.cs +++ b/src/emdui/Ui/Animation/TimelineSeries.xaml.cs @@ -137,6 +137,11 @@ protected override void OnPreviewMouseDown(MouseButtonEventArgs e) protected override void OnPreviewMouseMove(MouseEventArgs e) { + if (e.LeftButton == MouseButtonState.Released) + { + _grabbedPoint = null; + } + if (_grabbedPoint != null) { var time = _grabbedPoint.Time; @@ -145,6 +150,11 @@ protected override void OnPreviewMouseMove(MouseEventArgs e) new Vector(_grabbedPoint.Width / 2, _grabbedPoint.Height / 2); var oldValue = _points[time]; var newValue = YToValue(newPoint.Y); + if ((Keyboard.Modifiers & ModifierKeys.Control) != 0) + { + newValue = Math.Round(newValue / 0.25) * 0.25; + } + _grabbedPoint.Value = newValue; _points[time] = newValue; Refresh();