mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Implement OsuScreen::CanBeatmapChange and use it in the music controller
This commit is contained in:
parent
ee2c649971
commit
5450499415
@ -298,21 +298,22 @@ namespace osu.Game
|
||||
|
||||
private Container overlayContent;
|
||||
|
||||
private OsuScreen currentScreen;
|
||||
public readonly Bindable<OsuScreen> CurrentScreen = new Bindable<OsuScreen>();
|
||||
|
||||
private FrameworkConfigManager frameworkConfig;
|
||||
|
||||
private void screenChanged(Screen newScreen)
|
||||
{
|
||||
currentScreen = newScreen as OsuScreen;
|
||||
CurrentScreen.Value = newScreen as OsuScreen;
|
||||
|
||||
if (currentScreen == null)
|
||||
if (CurrentScreen.Value == null)
|
||||
{
|
||||
Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
//central game screen change logic.
|
||||
if (!currentScreen.ShowOverlays)
|
||||
if (!CurrentScreen.Value.ShowOverlays)
|
||||
{
|
||||
settings.State = Visibility.Hidden;
|
||||
Toolbar.State = Visibility.Hidden;
|
||||
@ -362,7 +363,7 @@ namespace osu.Game
|
||||
|
||||
mainContent.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight };
|
||||
|
||||
Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden;
|
||||
Cursor.State = CurrentScreen.Value?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void screenAdded(Screen newScreen)
|
||||
|
@ -16,13 +16,14 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Overlays.Music;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -39,7 +40,9 @@ namespace osu.Game.Overlays
|
||||
private Drawable currentBackground;
|
||||
private DragBar progressBar;
|
||||
|
||||
private IconButton prevButton;
|
||||
private IconButton playButton;
|
||||
private IconButton nextButton;
|
||||
private IconButton playlistButton;
|
||||
|
||||
private SpriteText title, artist;
|
||||
@ -50,9 +53,13 @@ namespace osu.Game.Overlays
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
|
||||
private readonly Bindable<OsuScreen> currentScreenBacking = new Bindable<OsuScreen>();
|
||||
|
||||
private Container dragContainer;
|
||||
private Container playerContainer;
|
||||
|
||||
private bool canChangeBeatmap;
|
||||
|
||||
public MusicController()
|
||||
{
|
||||
Width = 400;
|
||||
@ -81,7 +88,7 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game, OsuColour colours, LocalisationEngine localisation)
|
||||
private void load(OsuGame game, OsuColour colours, LocalisationEngine localisation)
|
||||
{
|
||||
this.localisation = localisation;
|
||||
|
||||
@ -153,7 +160,7 @@ namespace osu.Game.Overlays
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new[]
|
||||
{
|
||||
new IconButton
|
||||
prevButton = new IconButton
|
||||
{
|
||||
Action = prev,
|
||||
Icon = FontAwesome.fa_step_backward,
|
||||
@ -165,7 +172,7 @@ namespace osu.Game.Overlays
|
||||
Action = play,
|
||||
Icon = FontAwesome.fa_play_circle_o,
|
||||
},
|
||||
new IconButton
|
||||
nextButton = new IconButton
|
||||
{
|
||||
Action = next,
|
||||
Icon = FontAwesome.fa_step_forward,
|
||||
@ -197,6 +204,7 @@ namespace osu.Game.Overlays
|
||||
};
|
||||
|
||||
beatmapBacking.BindTo(game.Beatmap);
|
||||
currentScreenBacking.BindTo(game.CurrentScreen);
|
||||
|
||||
playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, EasingTypes.OutQuint);
|
||||
}
|
||||
@ -206,9 +214,24 @@ namespace osu.Game.Overlays
|
||||
beatmapBacking.ValueChanged += beatmapChanged;
|
||||
beatmapBacking.TriggerChange();
|
||||
|
||||
currentScreenBacking.ValueChanged += screenChanged;
|
||||
currentScreenBacking.TriggerChange();
|
||||
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
private void screenChanged(OsuScreen newScreen)
|
||||
{
|
||||
canChangeBeatmap = newScreen?.CanChangeBeatmap ?? false;
|
||||
|
||||
prevButton.Enabled = canChangeBeatmap;
|
||||
playButton.Enabled = canChangeBeatmap;
|
||||
nextButton.Enabled = canChangeBeatmap;
|
||||
playlistButton.Enabled = canChangeBeatmap;
|
||||
|
||||
progressBar.IsEnabled = canChangeBeatmap;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
@ -250,12 +273,16 @@ namespace osu.Game.Overlays
|
||||
|
||||
private void prev()
|
||||
{
|
||||
if(!canChangeBeatmap) return;
|
||||
|
||||
queuedDirection = TransformDirection.Prev;
|
||||
playlist.PlayPrevious();
|
||||
}
|
||||
|
||||
private void next()
|
||||
{
|
||||
if (!canChangeBeatmap) return;
|
||||
|
||||
queuedDirection = TransformDirection.Next;
|
||||
playlist.PlayNext();
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ namespace osu.Game.Screens
|
||||
|
||||
internal virtual bool AllowRulesetChange => true;
|
||||
|
||||
internal virtual bool CanChangeBeatmap => true;
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
@ -32,6 +32,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
internal override bool ShowOverlays => false;
|
||||
|
||||
internal override bool CanChangeBeatmap => false;
|
||||
|
||||
internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor;
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
|
@ -279,5 +279,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
modeChangeButtons.Current.TriggerChange();
|
||||
}
|
||||
|
||||
internal override bool CanChangeBeatmap => false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user