mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 10:22:54 +08:00
Move TimelineZoom
out of BeatmapInfo
This commit is contained in:
parent
6685c5ab74
commit
7f2a6f6f5a
@ -115,7 +115,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual(1.8, beatmap.DistanceSpacing);
|
||||
Assert.AreEqual(4, beatmap.BeatmapInfo.BeatDivisor);
|
||||
Assert.AreEqual(4, beatmap.GridSize);
|
||||
Assert.AreEqual(2, beatmap.BeatmapInfo.TimelineZoom);
|
||||
Assert.AreEqual(2, beatmap.TimelineZoom);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual(1.8, beatmap.DistanceSpacing);
|
||||
Assert.AreEqual(4, beatmapInfo.BeatDivisor);
|
||||
Assert.AreEqual(4, beatmap.GridSize);
|
||||
Assert.AreEqual(2, beatmapInfo.TimelineZoom);
|
||||
Assert.AreEqual(2, beatmap.TimelineZoom);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("Set beat divisor", () => Editor.Dependencies.Get<BindableBeatDivisor>().Value = 16);
|
||||
AddStep("Set timeline zoom", () =>
|
||||
{
|
||||
originalTimelineZoom = EditorBeatmap.BeatmapInfo.TimelineZoom;
|
||||
originalTimelineZoom = EditorBeatmap.TimelineZoom;
|
||||
|
||||
var timeline = Editor.ChildrenOfType<Timeline>().Single();
|
||||
InputManager.MoveMouseTo(timeline);
|
||||
@ -81,19 +81,19 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
AddAssert("Ensure timeline zoom changed", () =>
|
||||
{
|
||||
changedTimelineZoom = EditorBeatmap.BeatmapInfo.TimelineZoom;
|
||||
changedTimelineZoom = EditorBeatmap.TimelineZoom;
|
||||
return !Precision.AlmostEquals(changedTimelineZoom, originalTimelineZoom);
|
||||
});
|
||||
|
||||
SaveEditor();
|
||||
|
||||
AddAssert("Beatmap has correct beat divisor", () => EditorBeatmap.BeatmapInfo.BeatDivisor == 16);
|
||||
AddAssert("Beatmap has correct timeline zoom", () => EditorBeatmap.BeatmapInfo.TimelineZoom == changedTimelineZoom);
|
||||
AddAssert("Beatmap has correct timeline zoom", () => EditorBeatmap.TimelineZoom == changedTimelineZoom);
|
||||
|
||||
ReloadEditorToSameBeatmap();
|
||||
|
||||
AddAssert("Beatmap still has correct beat divisor", () => EditorBeatmap.BeatmapInfo.BeatDivisor == 16);
|
||||
AddAssert("Beatmap still has correct timeline zoom", () => EditorBeatmap.BeatmapInfo.TimelineZoom == changedTimelineZoom);
|
||||
AddAssert("Beatmap still has correct timeline zoom", () => EditorBeatmap.TimelineZoom == changedTimelineZoom);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -132,6 +132,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public int GridSize { get; set; }
|
||||
|
||||
public double TimelineZoom { get; set; } = 1.0;
|
||||
|
||||
IBeatmap IBeatmap.Clone() => Clone();
|
||||
|
||||
public Beatmap<T> Clone() => (Beatmap<T>)MemberwiseClone();
|
||||
|
@ -76,6 +76,7 @@ namespace osu.Game.Beatmaps
|
||||
beatmap.SamplesMatchPlaybackRate = original.SamplesMatchPlaybackRate;
|
||||
beatmap.DistanceSpacing = original.DistanceSpacing;
|
||||
beatmap.GridSize = original.GridSize;
|
||||
beatmap.TimelineZoom = original.TimelineZoom;
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
@ -415,7 +415,6 @@ namespace osu.Game.Beatmaps
|
||||
DifficultyName = decodedInfo.DifficultyName,
|
||||
OnlineID = decodedInfo.OnlineID,
|
||||
BeatDivisor = decodedInfo.BeatDivisor,
|
||||
TimelineZoom = decodedInfo.TimelineZoom,
|
||||
MD5Hash = memoryStream.ComputeMD5Hash(),
|
||||
EndTimeObjectCount = decoded.HitObjects.Count(h => h is IHasDuration),
|
||||
TotalObjectCount = decoded.HitObjects.Count
|
||||
|
@ -143,8 +143,6 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public int BeatDivisor { get; set; } = 4;
|
||||
|
||||
public double TimelineZoom { get; set; } = 1.0;
|
||||
|
||||
/// <summary>
|
||||
/// The time in milliseconds when last exiting the editor with this beatmap loaded.
|
||||
/// </summary>
|
||||
|
@ -341,7 +341,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
break;
|
||||
|
||||
case @"TimelineZoom":
|
||||
beatmap.BeatmapInfo.TimelineZoom = Math.Max(0, Parsing.ParseDouble(pair.Value));
|
||||
beatmap.TimelineZoom = Math.Max(0, Parsing.ParseDouble(pair.Value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
writer.WriteLine(FormattableString.Invariant($"DistanceSpacing: {beatmap.DistanceSpacing}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"BeatDivisor: {beatmap.BeatmapInfo.BeatDivisor}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"GridSize: {beatmap.GridSize}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"TimelineZoom: {beatmap.BeatmapInfo.TimelineZoom}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"TimelineZoom: {beatmap.TimelineZoom}"));
|
||||
}
|
||||
|
||||
private void handleMetadata(TextWriter writer)
|
||||
|
@ -97,6 +97,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
int GridSize { get; internal set; }
|
||||
|
||||
double TimelineZoom { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a shallow-clone of this beatmap and returns it.
|
||||
/// </summary>
|
||||
|
@ -391,6 +391,12 @@ namespace osu.Game.Rulesets.Difficulty
|
||||
set => baseBeatmap.GridSize = value;
|
||||
}
|
||||
|
||||
public double TimelineZoom
|
||||
{
|
||||
get => baseBeatmap.TimelineZoom;
|
||||
set => baseBeatmap.TimelineZoom = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
Scheduler.AddOnce(applyVisualOffset, beatmap);
|
||||
}, true);
|
||||
|
||||
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||
Zoom = (float)(defaultTimelineZoom * editorBeatmap.TimelineZoom);
|
||||
}
|
||||
|
||||
private void applyVisualOffset(IBindable<WorkingBeatmap> beatmap)
|
||||
@ -215,7 +215,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
float minimumZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||
float maximumZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||
|
||||
float initialZoom = (float)Math.Clamp(defaultTimelineZoom * (editorBeatmap.BeatmapInfo.TimelineZoom == 0 ? 1 : editorBeatmap.BeatmapInfo.TimelineZoom), minimumZoom, maximumZoom);
|
||||
float initialZoom = (float)Math.Clamp(defaultTimelineZoom * (editorBeatmap.TimelineZoom == 0 ? 1 : editorBeatmap.TimelineZoom), minimumZoom, maximumZoom);
|
||||
|
||||
SetupZoom(initialZoom, minimumZoom, maximumZoom);
|
||||
|
||||
@ -237,7 +237,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
protected override void OnZoomChanged()
|
||||
{
|
||||
base.OnZoomChanged();
|
||||
editorBeatmap.BeatmapInfo.TimelineZoom = Zoom / defaultTimelineZoom;
|
||||
editorBeatmap.TimelineZoom = Zoom / defaultTimelineZoom;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
|
@ -238,6 +238,12 @@ namespace osu.Game.Screens.Edit
|
||||
set => PlayableBeatmap.GridSize = value;
|
||||
}
|
||||
|
||||
public double TimelineZoom
|
||||
{
|
||||
get => PlayableBeatmap.TimelineZoom;
|
||||
set => PlayableBeatmap.TimelineZoom = value;
|
||||
}
|
||||
|
||||
public IBeatmap Clone() => (EditorBeatmap)MemberwiseClone();
|
||||
|
||||
private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;
|
||||
|
Loading…
Reference in New Issue
Block a user