From fa9639c033514e455c3468b5d80df600494a86c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:04:04 +0000 Subject: [PATCH 1/2] Initial plan From 0d3b234b28dde35941a43ed265694216d0a77aba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:09:31 +0000 Subject: [PATCH 2/2] Handle oversized animation numeric values safely Agent-Logs-Url: https://github.com/TombEngine/Tomb-Editor/sessions/09dfe144-572a-4705-be25-5d041275f11b Co-authored-by: Nickelony <20436882+Nickelony@users.noreply.github.com> --- WadTool/Forms/FormAnimationEditor.cs | 41 ++++++++++++++++++---------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/WadTool/Forms/FormAnimationEditor.cs b/WadTool/Forms/FormAnimationEditor.cs index fa333693df..ec571118d3 100644 --- a/WadTool/Forms/FormAnimationEditor.cs +++ b/WadTool/Forms/FormAnimationEditor.cs @@ -491,15 +491,15 @@ private void SelectAnimation(AnimationNode node) if (node != null) { tbName.Text = node.WadAnimation.Name; - nudFramerate.Value = node.WadAnimation.FrameRate; - nudEndFrame.Value = node.WadAnimation.EndFrame; - nudNextAnim.Value = node.WadAnimation.NextAnimation; - nudNextFrame.Value = node.WadAnimation.NextFrame; - nudStartVertVel.Value = (decimal)node.WadAnimation.StartVelocity; - nudEndVertVel.Value = (decimal)node.WadAnimation.EndVelocity; - nudStartHorVel.Value = (decimal)node.WadAnimation.StartLateralVelocity; - nudEndHorVel.Value = (decimal)node.WadAnimation.EndLateralVelocity; - nudBlendFrameCount.Value = (decimal)node.WadAnimation.BlendFrameCount; + SetNumericValue(nudFramerate, node.WadAnimation.FrameRate); + SetNumericValue(nudEndFrame, node.WadAnimation.EndFrame); + SetNumericValue(nudNextAnim, node.WadAnimation.NextAnimation); + SetNumericValue(nudNextFrame, node.WadAnimation.NextFrame); + SetNumericValue(nudStartVertVel, (decimal)node.WadAnimation.StartVelocity); + SetNumericValue(nudEndVertVel, (decimal)node.WadAnimation.EndVelocity); + SetNumericValue(nudStartHorVel, (decimal)node.WadAnimation.StartLateralVelocity); + SetNumericValue(nudEndHorVel, (decimal)node.WadAnimation.EndLateralVelocity); + SetNumericValue(nudBlendFrameCount, (decimal)node.WadAnimation.BlendFrameCount); bezierCurveEditor.Value = node.WadAnimation.BlendCurve; cbBlendPreset.SelectedIndex = -1; @@ -535,6 +535,17 @@ private void SelectAnimation(AnimationNode node) _editor.Tool.AnimationEditorCurrentAnimationChanged(prevAnim, _editor.CurrentAnim); } + private static void SetNumericValue(DarkNumericUpDown control, decimal value) + { + if (value < control.Minimum) + control.Minimum = value; + + if (value > control.Maximum) + control.Maximum = value; + + control.Value = value; + } + private void UpdateSelection() { _editor.Selection = timeline.Selection; @@ -624,7 +635,7 @@ private void OnKeyframesListChanged() _frameCount = timeline.Value * _editor.CurrentAnim.WadAnimation.FrameRate; timeline.Minimum = 0; timeline.Maximum = _editor.CurrentAnim.DirectXAnimation.KeyFrames.Count - 1; - nudEndFrame.Value = _editor.CurrentAnim.WadAnimation.EndFrame; + SetNumericValue(nudEndFrame, _editor.CurrentAnim.WadAnimation.EndFrame); UpdateStatusLabel(); } else @@ -728,7 +739,7 @@ private void InflateAnimationBoundingBox(Vector3 value) InflateFrameBoundingBox(i, value, false); } - public void ResetEndFrame() => nudEndFrame.Value = _editor.GetRealNumberOfFrames() - 1; + public void ResetEndFrame() => SetNumericValue(nudEndFrame, _editor.GetRealNumberOfFrames() - 1); public void UpdateTransform() { @@ -1288,7 +1299,7 @@ private void UpdateAnimationParameter(Control control) // Fix visible values if (control is DarkTextBox) ((DarkTextBox)control).Text = result.ToString(); - else if (control is DarkNumericUpDown) ((DarkNumericUpDown)control).Value = (decimal)result; + else if (control is DarkNumericUpDown) SetNumericValue((DarkNumericUpDown)control, (decimal)result); // Don't update if not changed if (oldValue == result) @@ -1310,8 +1321,8 @@ private void UpdateAnimationParameter(Control control) _editor.CurrentAnim.WadAnimation.NextFrame = (ushort)result; break; case nameof(nudFramerate): - nudEndFrame.Value = (decimal)Math.Round(_editor.CurrentAnim.WadAnimation.EndFrame / - (_editor.CurrentAnim.WadAnimation.FrameRate / (float)result)); + SetNumericValue(nudEndFrame, (decimal)Math.Round(_editor.CurrentAnim.WadAnimation.EndFrame / + (_editor.CurrentAnim.WadAnimation.FrameRate / (float)result))); _editor.CurrentAnim.WadAnimation.FrameRate = (byte)result; break; case nameof(nudEndFrame): @@ -2865,4 +2876,4 @@ private void cbBlendPreset_SelectedIndexChanged(object sender, EventArgs e) bezierCurveEditor.UpdateUI(); } } -} \ No newline at end of file +}