mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Removed dragbar from MusicController
This commit is contained in:
parent
94fdf0390d
commit
ce2242a979
@ -8,12 +8,14 @@ using System.Threading.Tasks;
|
|||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -38,7 +40,7 @@ namespace osu.Game.Overlays
|
|||||||
private const float bottom_black_area_height = 55;
|
private const float bottom_black_area_height = 55;
|
||||||
|
|
||||||
private Drawable currentBackground;
|
private Drawable currentBackground;
|
||||||
private DragBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
private IconButton playButton;
|
private IconButton playButton;
|
||||||
private IconButton playlistButton;
|
private IconButton playlistButton;
|
||||||
@ -183,13 +185,13 @@ namespace osu.Game.Overlays
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
progressBar = new DragBar
|
progressBar = new ProgressBar
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Height = progress_height,
|
Height = progress_height,
|
||||||
Colour = colours.Yellow,
|
FillColour = colours.Yellow,
|
||||||
SeekRequested = seek
|
OnSeek = progress => current?.Track.Seek(progress)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -224,7 +226,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
var track = current.Track;
|
var track = current.Track;
|
||||||
|
|
||||||
progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length));
|
progressBar.Progress = track.CurrentTime;
|
||||||
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
||||||
|
|
||||||
if (track.HasCompleted && !track.Looping) next();
|
if (track.HasCompleted && !track.Looping) next();
|
||||||
@ -266,8 +268,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private void beatmapChanged(WorkingBeatmap beatmap)
|
private void beatmapChanged(WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
progressBar.IsEnabled = beatmap != null;
|
|
||||||
|
|
||||||
TransformDirection direction = TransformDirection.None;
|
TransformDirection direction = TransformDirection.None;
|
||||||
|
|
||||||
if (current != null)
|
if (current != null)
|
||||||
@ -293,10 +293,19 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
current = beatmapBacking.Value;
|
current = beatmapBacking.Value;
|
||||||
|
|
||||||
|
updateProgressBar(current?.Track);
|
||||||
updateDisplay(beatmapBacking, direction);
|
updateDisplay(beatmapBacking, direction);
|
||||||
queuedDirection = null;
|
queuedDirection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateProgressBar(Track t)
|
||||||
|
{
|
||||||
|
if (t?.IsLoaded ?? false)
|
||||||
|
progressBar.EndTime = t.Length;
|
||||||
|
else if (t != null)
|
||||||
|
t.OnLoaded += loadedTrack => progressBar.EndTime = loadedTrack.Length;
|
||||||
|
}
|
||||||
|
|
||||||
private ScheduledDelegate pendingBeatmapSwitch;
|
private ScheduledDelegate pendingBeatmapSwitch;
|
||||||
|
|
||||||
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
|
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
|
||||||
@ -352,12 +361,6 @@ namespace osu.Game.Overlays
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seek(float position)
|
|
||||||
{
|
|
||||||
var track = current?.Track;
|
|
||||||
track?.Seek(track.Length * position);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
base.PopIn();
|
base.PopIn();
|
||||||
@ -417,5 +420,49 @@ namespace osu.Game.Overlays
|
|||||||
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ProgressBar : SliderBar<double>
|
||||||
|
{
|
||||||
|
public Action<double> OnSeek;
|
||||||
|
|
||||||
|
private Box fill;
|
||||||
|
|
||||||
|
public Color4 FillColour
|
||||||
|
{
|
||||||
|
set { fill.Colour = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double EndTime
|
||||||
|
{
|
||||||
|
set { CurrentNumber.MaxValue = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Progress
|
||||||
|
{
|
||||||
|
set { CurrentNumber.Value = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressBar()
|
||||||
|
{
|
||||||
|
CurrentNumber.MinValue = 0;
|
||||||
|
CurrentNumber.MaxValue = 1;
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
fill = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateValue(float value)
|
||||||
|
{
|
||||||
|
fill.Width = value * UsableWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnUserChange() => OnSeek?.Invoke(Current);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user