mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Merge branch 'master' into master
This commit is contained in:
@ -30,11 +30,8 @@ namespace osu.Game.Overlays
|
||||
public class MusicController : OsuFocusedOverlayContainer
|
||||
{
|
||||
private const float player_height = 130;
|
||||
|
||||
private const float transition_length = 800;
|
||||
|
||||
private const float progress_height = 10;
|
||||
|
||||
private const float bottom_black_area_height = 55;
|
||||
|
||||
private Drawable background;
|
||||
@ -49,16 +46,17 @@ namespace osu.Game.Overlays
|
||||
|
||||
private PlaylistOverlay playlist;
|
||||
|
||||
private BeatmapManager beatmaps;
|
||||
private LocalisationEngine localisation;
|
||||
|
||||
private BeatmapManager beatmaps;
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
private List<BeatmapSetInfo> beatmapSets;
|
||||
private BeatmapSetInfo currentSet;
|
||||
|
||||
private Container dragContainer;
|
||||
private Container playerContainer;
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
public MusicController()
|
||||
{
|
||||
Width = 400;
|
||||
@ -68,43 +66,16 @@ namespace osu.Game.Overlays
|
||||
AlwaysPresent = true;
|
||||
}
|
||||
|
||||
private Vector2 dragStart;
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
base.OnDragStart(state);
|
||||
dragStart = state.Mouse.Position;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
if (base.OnDrag(state)) return true;
|
||||
|
||||
Vector2 change = state.Mouse.Position - dragStart;
|
||||
|
||||
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
||||
change *= change.Length <= 0 ? 0 : (float)Math.Pow(change.Length, 0.7f) / change.Length;
|
||||
|
||||
dragContainer.MoveTo(change);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(InputState state)
|
||||
{
|
||||
dragContainer.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
|
||||
return base.OnDragEnd(state);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation)
|
||||
private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation)
|
||||
{
|
||||
this.beatmap.BindTo(beatmap);
|
||||
this.beatmaps = beatmaps;
|
||||
this.localisation = localisation;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
dragContainer = new Container
|
||||
dragContainer = new DragContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -224,8 +195,6 @@ namespace osu.Game.Overlays
|
||||
beatmaps.ItemAdded += handleBeatmapAdded;
|
||||
beatmaps.ItemRemoved += handleBeatmapRemoved;
|
||||
|
||||
beatmapBacking.BindTo(game.Beatmap);
|
||||
|
||||
playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
@ -246,10 +215,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
beatmapBacking.ValueChanged += beatmapChanged;
|
||||
beatmapBacking.DisabledChanged += beatmapDisabledChanged;
|
||||
beatmapBacking.TriggerChange();
|
||||
|
||||
beatmap.BindValueChanged(beatmapChanged, true);
|
||||
beatmap.BindDisabledChanged(beatmapDisabledChanged, true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
@ -286,7 +253,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
||||
|
||||
if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled && beatmapSets.Any())
|
||||
if (track.HasCompleted && !track.Looping && !beatmap.Disabled && beatmapSets.Any())
|
||||
next();
|
||||
}
|
||||
else
|
||||
@ -299,7 +266,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
if (track == null)
|
||||
{
|
||||
if (!beatmapBacking.Disabled)
|
||||
if (!beatmap.Disabled)
|
||||
next(true);
|
||||
return;
|
||||
}
|
||||
@ -317,8 +284,8 @@ namespace osu.Game.Overlays
|
||||
var playable = beatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? beatmapSets.LastOrDefault();
|
||||
if (playable != null)
|
||||
{
|
||||
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmapBacking);
|
||||
beatmapBacking.Value.Track.Restart();
|
||||
beatmap.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||
beatmap.Value.Track.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,8 +297,8 @@ namespace osu.Game.Overlays
|
||||
var playable = beatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).Skip(1).FirstOrDefault() ?? beatmapSets.FirstOrDefault();
|
||||
if (playable != null)
|
||||
{
|
||||
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmapBacking);
|
||||
beatmapBacking.Value.Track.Restart();
|
||||
beatmap.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||
beatmap.Value.Track.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,5 +452,36 @@ namespace osu.Game.Overlays
|
||||
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
||||
}
|
||||
}
|
||||
|
||||
private class DragContainer : Container
|
||||
{
|
||||
private Vector2 dragStart;
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
base.OnDragStart(state);
|
||||
dragStart = state.Mouse.Position;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
if (base.OnDrag(state)) return true;
|
||||
|
||||
Vector2 change = state.Mouse.Position - dragStart;
|
||||
|
||||
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
||||
change *= change.Length <= 0 ? 0 : (float)Math.Pow(change.Length, 0.7f) / change.Length;
|
||||
|
||||
this.MoveTo(change);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(InputState state)
|
||||
{
|
||||
this.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
|
||||
return base.OnDragEnd(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user