mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Pass adjustable clocks to components, rather than relying on the track
This commit is contained in:
parent
c8f6a6980b
commit
d05947ef48
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -19,8 +20,12 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
{
|
{
|
||||||
private readonly IconButton playButton;
|
private readonly IconButton playButton;
|
||||||
|
|
||||||
public PlaybackControl()
|
private readonly IAdjustableClock adjustableClock;
|
||||||
|
|
||||||
|
public PlaybackControl(IAdjustableClock adjustableClock)
|
||||||
{
|
{
|
||||||
|
this.adjustableClock = adjustableClock;
|
||||||
|
|
||||||
PlaybackTabControl tabs;
|
PlaybackTabControl tabs;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -54,22 +59,22 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
tabs.Current.ValueChanged += newValue => Track.Tempo.Value = newValue;
|
tabs.Current.ValueChanged += newValue => Beatmap.Value.Track.Tempo.Value = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void togglePause()
|
private void togglePause()
|
||||||
{
|
{
|
||||||
if (Track.IsRunning)
|
if (adjustableClock.IsRunning)
|
||||||
Track.Stop();
|
adjustableClock.Stop();
|
||||||
else
|
else
|
||||||
Track.Start();
|
adjustableClock.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
playButton.Icon = Track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
playButton.Icon = adjustableClock.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlaybackTabControl : OsuTabControl<double>
|
private class PlaybackTabControl : OsuTabControl<double>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Components
|
namespace osu.Game.Screens.Edit.Components
|
||||||
{
|
{
|
||||||
@ -13,8 +14,12 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
|
|
||||||
private readonly OsuSpriteText trackTimer;
|
private readonly OsuSpriteText trackTimer;
|
||||||
|
|
||||||
public TimeInfoContainer()
|
private readonly IAdjustableClock adjustableClock;
|
||||||
|
|
||||||
|
public TimeInfoContainer(IAdjustableClock adjustableClock)
|
||||||
{
|
{
|
||||||
|
this.adjustableClock = adjustableClock;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
trackTimer = new OsuSpriteText
|
trackTimer = new OsuSpriteText
|
||||||
@ -32,7 +37,7 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
trackTimer.Text = TimeSpan.FromMilliseconds(Track.CurrentTime).ToString(@"mm\:ss\:fff");
|
trackTimer.Text = TimeSpan.FromMilliseconds(adjustableClock.CurrentTime).ToString(@"mm\:ss\:fff");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
@ -19,8 +20,12 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|||||||
{
|
{
|
||||||
private readonly Drawable marker;
|
private readonly Drawable marker;
|
||||||
|
|
||||||
public MarkerPart()
|
private readonly IAdjustableClock adjustableClock;
|
||||||
|
|
||||||
|
public MarkerPart(IAdjustableClock adjustableClock)
|
||||||
{
|
{
|
||||||
|
this.adjustableClock = adjustableClock;
|
||||||
|
|
||||||
Add(marker = new MarkerVisualisation());
|
Add(marker = new MarkerVisualisation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,12 +58,12 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|||||||
seekTo(markerPos / DrawWidth * Beatmap.Value.Track.Length);
|
seekTo(markerPos / DrawWidth * Beatmap.Value.Track.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seekTo(double time) => Beatmap.Value?.Track.Seek(time);
|
private void seekTo(double time) => adjustableClock.Seek(time);
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
marker.X = (float)(Beatmap.Value?.Track.CurrentTime ?? 0);
|
marker.X = (float)adjustableClock.CurrentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadBeatmap(WorkingBeatmap beatmap)
|
protected override void LoadBeatmap(WorkingBeatmap beatmap)
|
||||||
|
@ -6,6 +6,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||||
|
|
||||||
@ -18,13 +19,13 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary
|
|||||||
{
|
{
|
||||||
private readonly Drawable timelineBar;
|
private readonly Drawable timelineBar;
|
||||||
|
|
||||||
public SummaryTimeline()
|
public SummaryTimeline(IAdjustableClock adjustableClock)
|
||||||
{
|
{
|
||||||
TimelinePart markerPart, controlPointPart, bookmarkPart, breakPart;
|
TimelinePart markerPart, controlPointPart, bookmarkPart, breakPart;
|
||||||
|
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
markerPart = new MarkerPart { RelativeSizeAxes = Axes.Both },
|
markerPart = new MarkerPart(adjustableClock) { RelativeSizeAxes = Axes.Both },
|
||||||
controlPointPart = new ControlPointPart
|
controlPointPart = new ControlPointPart
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
|
@ -115,9 +115,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Right = 10 },
|
Padding = new MarginPadding { Right = 10 },
|
||||||
Child = timeInfo = new TimeInfoContainer { RelativeSizeAxes = Axes.Both },
|
Child = timeInfo = new TimeInfoContainer(adjustableClock) { RelativeSizeAxes = Axes.Both },
|
||||||
},
|
},
|
||||||
timeline = new SummaryTimeline
|
timeline = new SummaryTimeline(adjustableClock)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
@ -125,7 +125,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Left = 10 },
|
Padding = new MarginPadding { Left = 10 },
|
||||||
Child = playback = new PlaybackControl { RelativeSizeAxes = Axes.Both },
|
Child = playback = new PlaybackControl(adjustableClock) { RelativeSizeAxes = Axes.Both },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Screens.Edit.Screens.Compose.Timeline;
|
using osu.Game.Screens.Edit.Screens.Compose.Timeline;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose
|
namespace osu.Game.Screens.Edit.Screens.Compose
|
||||||
@ -87,14 +86,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose
|
|||||||
};
|
};
|
||||||
|
|
||||||
timeline.Beatmap.BindTo(Beatmap);
|
timeline.Beatmap.BindTo(Beatmap);
|
||||||
Beatmap.ValueChanged += beatmapChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void beatmapChanged(WorkingBeatmap newBeatmap)
|
var ruleset = Beatmap.Value.BeatmapInfo.Ruleset?.CreateInstance();
|
||||||
{
|
|
||||||
composerContainer.Clear();
|
|
||||||
|
|
||||||
var ruleset = newBeatmap.BeatmapInfo.Ruleset?.CreateInstance();
|
|
||||||
if (ruleset == null)
|
if (ruleset == null)
|
||||||
{
|
{
|
||||||
Logger.Log("Beatmap doesn't have a ruleset assigned.");
|
Logger.Log("Beatmap doesn't have a ruleset assigned.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user