mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Merge pull request #20353 from Drison64/fix-timelineZoom-zero
EditorBeatmap's TimelineZoom should never be zero
This commit is contained in:
commit
1914c41d0d
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
@ -66,6 +67,18 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddUntilStep("Scroll container is loaded", () => scrollContainer.LoadState >= LoadState.Loaded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInitialZoomOutOfRange()
|
||||
{
|
||||
AddStep("Invalid ZoomableScrollContainer throws ArgumentException", () =>
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
_ = new ZoomableScrollContainer(1, 60, 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWidthInitialization()
|
||||
{
|
||||
|
@ -196,7 +196,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
defaultTimelineZoom = getZoomLevelForVisibleMilliseconds(6000);
|
||||
|
||||
float initialZoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||
float initialZoom = (float)(defaultTimelineZoom * (editorBeatmap.BeatmapInfo.TimelineZoom == 0 ? 1 : editorBeatmap.BeatmapInfo.TimelineZoom));
|
||||
float minimumZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||
float maximumZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||
|
||||
|
@ -87,6 +87,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
if (minimum > maximum)
|
||||
throw new ArgumentException($"{nameof(minimum)} ({minimum}) must be less than {nameof(maximum)} ({maximum})");
|
||||
|
||||
if (initial < minimum || initial > maximum)
|
||||
throw new ArgumentException($"{nameof(initial)} ({initial}) must be between {nameof(minimum)} ({minimum}) and {nameof(maximum)} ({maximum})");
|
||||
|
||||
minZoom = minimum;
|
||||
maxZoom = maximum;
|
||||
CurrentZoom = zoomTarget = initial;
|
||||
|
Loading…
Reference in New Issue
Block a user