mirror of
https://github.com/osukey/osukey.git
synced 2025-05-23 14:37:39 +09:00
Update public methods in line with future usage
This commit is contained in:
parent
de1ab56a2c
commit
2cbdf8c01c
@ -1,4 +1,4 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -63,6 +63,11 @@ namespace osu.Game.Overlays
|
|||||||
beatmapSets.Insert(index, beatmapSetInfo);
|
beatmapSets.Insert(index, beatmapSetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns whether the current beatmap track is playing.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsPlaying => beatmap.Value.Track.IsRunning;
|
||||||
|
|
||||||
private void handleBeatmapAdded(BeatmapSetInfo set) =>
|
private void handleBeatmapAdded(BeatmapSetInfo set) =>
|
||||||
Schedule(() => beatmapSets.Add(set));
|
Schedule(() => beatmapSets.Add(set));
|
||||||
|
|
||||||
@ -84,15 +89,18 @@ namespace osu.Game.Overlays
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toggle pause / play.
|
/// Toggle pause / play.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void TogglePause()
|
/// <returns>Whether the operation was successful.</returns>
|
||||||
|
public bool TogglePause()
|
||||||
{
|
{
|
||||||
var track = current?.Track;
|
var track = current?.Track;
|
||||||
|
|
||||||
if (track == null)
|
if (track == null)
|
||||||
{
|
{
|
||||||
if (!beatmap.Disabled)
|
if (beatmap.Disabled)
|
||||||
next(true);
|
return false;
|
||||||
return;
|
|
||||||
|
next(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track.IsRunning)
|
if (track.IsRunning)
|
||||||
@ -105,12 +113,15 @@ namespace osu.Game.Overlays
|
|||||||
track.Start();
|
track.Start();
|
||||||
IsUserPaused = false;
|
IsUserPaused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Play the previous track.
|
/// Play the previous track.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PrevTrack()
|
/// <returns>Whether the operation was successful.</returns>
|
||||||
|
public bool PrevTrack()
|
||||||
{
|
{
|
||||||
queuedDirection = TrackChangeDirection.Prev;
|
queuedDirection = TrackChangeDirection.Prev;
|
||||||
|
|
||||||
@ -121,15 +132,20 @@ namespace osu.Game.Overlays
|
|||||||
if (beatmap is Bindable<WorkingBeatmap> working)
|
if (beatmap is Bindable<WorkingBeatmap> working)
|
||||||
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||||
beatmap.Value.Track.Restart();
|
beatmap.Value.Track.Restart();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Play the next random or playlist track.
|
/// Play the next random or playlist track.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void NextTrack() => next();
|
/// <returns>Whether the operation was successful.</returns>
|
||||||
|
public bool NextTrack() => next();
|
||||||
|
|
||||||
private void next(bool instant = false)
|
private bool next(bool instant = false)
|
||||||
{
|
{
|
||||||
if (!instant)
|
if (!instant)
|
||||||
queuedDirection = TrackChangeDirection.Next;
|
queuedDirection = TrackChangeDirection.Next;
|
||||||
@ -141,7 +157,10 @@ namespace osu.Game.Overlays
|
|||||||
if (beatmap is Bindable<WorkingBeatmap> working)
|
if (beatmap is Bindable<WorkingBeatmap> working)
|
||||||
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||||
beatmap.Value.Track.Restart();
|
beatmap.Value.Track.Restart();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorkingBeatmap current;
|
private WorkingBeatmap current;
|
||||||
|
@ -138,7 +138,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Action = musicController.PrevTrack,
|
Action = () => musicController.PrevTrack(),
|
||||||
Icon = FontAwesome.Solid.StepBackward,
|
Icon = FontAwesome.Solid.StepBackward,
|
||||||
},
|
},
|
||||||
playButton = new MusicIconButton
|
playButton = new MusicIconButton
|
||||||
@ -147,14 +147,14 @@ namespace osu.Game.Overlays
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Scale = new Vector2(1.4f),
|
Scale = new Vector2(1.4f),
|
||||||
IconScale = new Vector2(1.4f),
|
IconScale = new Vector2(1.4f),
|
||||||
Action = musicController.TogglePause,
|
Action = () => musicController.TogglePause(),
|
||||||
Icon = FontAwesome.Regular.PlayCircle,
|
Icon = FontAwesome.Regular.PlayCircle,
|
||||||
},
|
},
|
||||||
nextButton = new MusicIconButton
|
nextButton = new MusicIconButton
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Action = musicController.NextTrack,
|
Action = () => musicController.NextTrack(),
|
||||||
Icon = FontAwesome.Solid.StepForward,
|
Icon = FontAwesome.Solid.StepForward,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user