mirror of
https://github.com/ppy/osu.git
synced 2025-02-08 20:23:21 +08:00
Merge pull request #28809 from bdach/mania-timeline-zooms-composer
Match mania editor playfield time range with timeline zoom
This commit is contained in:
commit
00cab0ec0a
@ -6,6 +6,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -18,6 +19,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
public BindableBool ShowSpeedChanges { get; } = new BindableBool();
|
public BindableBool ShowSpeedChanges { get; } = new BindableBool();
|
||||||
|
|
||||||
|
public double? TimelineTimeRange { get; set; }
|
||||||
|
|
||||||
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
||||||
|
|
||||||
public DrawableManiaEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods)
|
public DrawableManiaEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods)
|
||||||
@ -38,5 +41,11 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Size = Vector2.One
|
Size = Vector2.One
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
TargetTimeRange = TimelineTimeRange == null || ShowSpeedChanges.Value ? ComputeScrollTime(Config.Get<int>(ManiaRulesetSetting.ScrollSpeed)) : TimelineTimeRange.Value;
|
||||||
|
base.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
@ -14,6 +13,7 @@ using osu.Game.Rulesets.Mania.UI;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -21,7 +21,10 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
public partial class ManiaHitObjectComposer : ScrollingHitObjectComposer<ManiaHitObject>
|
public partial class ManiaHitObjectComposer : ScrollingHitObjectComposer<ManiaHitObject>
|
||||||
{
|
{
|
||||||
private DrawableManiaEditorRuleset drawableRuleset;
|
private DrawableManiaEditorRuleset drawableRuleset = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private EditorScreenWithTimeline? screenWithTimeline { get; set; }
|
||||||
|
|
||||||
public ManiaHitObjectComposer(Ruleset ruleset)
|
public ManiaHitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
@ -72,7 +75,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
if (!double.TryParse(split[0], out double time) || !int.TryParse(split[1], out int column))
|
if (!double.TryParse(split[0], out double time) || !int.TryParse(split[1], out int column))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ManiaHitObject current = remainingHitObjects.FirstOrDefault(h => h.StartTime == time && h.Column == column);
|
ManiaHitObject? current = remainingHitObjects.FirstOrDefault(h => h.StartTime == time && h.Column == column);
|
||||||
|
|
||||||
if (current == null)
|
if (current == null)
|
||||||
continue;
|
continue;
|
||||||
@ -83,5 +86,13 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
remainingHitObjects = remainingHitObjects.Where(h => h != current && h.StartTime >= current.StartTime).ToList();
|
remainingHitObjects = remainingHitObjects.Where(h => h != current && h.StartTime >= current.StartTime).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (screenWithTimeline?.TimelineArea.Timeline != null)
|
||||||
|
drawableRuleset.TimelineTimeRange = EditorClock.TrackLength / screenWithTimeline.TimelineArea.Timeline.CurrentZoom / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,10 @@ using osu.Framework.Audio.Track;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Input.Handlers;
|
using osu.Game.Input.Handlers;
|
||||||
@ -56,13 +57,18 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||||
private readonly BindableInt configScrollSpeed = new BindableInt();
|
private readonly BindableInt configScrollSpeed = new BindableInt();
|
||||||
private double smoothTimeRange;
|
|
||||||
|
private double currentTimeRange;
|
||||||
|
protected double TargetTimeRange;
|
||||||
|
|
||||||
// Stores the current speed adjustment active in gameplay.
|
// Stores the current speed adjustment active in gameplay.
|
||||||
private readonly Track speedAdjustmentTrack = new TrackVirtual(0);
|
private readonly Track speedAdjustmentTrack = new TrackVirtual(0);
|
||||||
|
|
||||||
private ISkinSource currentSkin = null!;
|
private ISkinSource currentSkin = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private GameHost gameHost { get; set; } = null!;
|
||||||
|
|
||||||
public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
|
public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
@ -101,9 +107,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true);
|
configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true);
|
||||||
|
|
||||||
Config.BindWith(ManiaRulesetSetting.ScrollSpeed, configScrollSpeed);
|
Config.BindWith(ManiaRulesetSetting.ScrollSpeed, configScrollSpeed);
|
||||||
configScrollSpeed.BindValueChanged(speed => this.TransformTo(nameof(smoothTimeRange), ComputeScrollTime(speed.NewValue), 200, Easing.OutQuint));
|
configScrollSpeed.BindValueChanged(speed => TargetTimeRange = ComputeScrollTime(speed.NewValue));
|
||||||
|
|
||||||
TimeRange.Value = smoothTimeRange = ComputeScrollTime(configScrollSpeed.Value);
|
TimeRange.Value = TargetTimeRange = currentTimeRange = ComputeScrollTime(configScrollSpeed.Value);
|
||||||
|
|
||||||
KeyBindingInputManager.Add(new ManiaTouchInputArea());
|
KeyBindingInputManager.Add(new ManiaTouchInputArea());
|
||||||
}
|
}
|
||||||
@ -144,7 +150,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
// This scaling factor preserves the scroll speed as the scroll length varies from changes to the hit position.
|
// This scaling factor preserves the scroll speed as the scroll length varies from changes to the hit position.
|
||||||
float scale = lengthToHitPosition / length_to_default_hit_position;
|
float scale = lengthToHitPosition / length_to_default_hit_position;
|
||||||
|
|
||||||
TimeRange.Value = smoothTimeRange * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value * scale;
|
// we're intentionally using the game host's update clock here to decouple the time range tween from the gameplay clock (which can be arbitrarily paused, or even rewinding)
|
||||||
|
currentTimeRange = Interpolation.DampContinuously(currentTimeRange, TargetTimeRange, 50, gameHost.UpdateThread.Clock.ElapsedFrameTime);
|
||||||
|
TimeRange.Value = currentTimeRange * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -13,13 +13,12 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Cached]
|
[Cached]
|
||||||
public abstract partial class EditorScreenWithTimeline : EditorScreen
|
public abstract partial class EditorScreenWithTimeline : EditorScreen
|
||||||
{
|
{
|
||||||
public const float PADDING = 10;
|
public TimelineArea TimelineArea { get; private set; } = null!;
|
||||||
|
|
||||||
public Container TimelineContent { get; private set; } = null!;
|
|
||||||
|
|
||||||
public Container MainContent { get; private set; } = null!;
|
public Container MainContent { get; private set; } = null!;
|
||||||
|
|
||||||
private LoadingSpinner spinner = null!;
|
private LoadingSpinner spinner = null!;
|
||||||
|
private Container timelineContent = null!;
|
||||||
|
|
||||||
protected EditorScreenWithTimeline(EditorScreenMode type)
|
protected EditorScreenWithTimeline(EditorScreenMode type)
|
||||||
: base(type)
|
: base(type)
|
||||||
@ -60,7 +59,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
TimelineContent = new Container
|
timelineContent = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
@ -108,7 +107,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
MainContent.Add(content);
|
MainContent.Add(content);
|
||||||
content.FadeInFromZero(300, Easing.OutQuint);
|
content.FadeInFromZero(300, Easing.OutQuint);
|
||||||
|
|
||||||
LoadComponentAsync(new TimelineArea(CreateTimelineContent()), TimelineContent.Add);
|
LoadComponentAsync(TimelineArea = new TimelineArea(CreateTimelineContent()), timelineContent.Add);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user