Convert everything to use IScreen

This commit is contained in:
smoogipoo
2019-01-23 20:52:00 +09:00
parent d86f2e04b4
commit 8ea7ec6445
47 changed files with 426 additions and 457 deletions

View File

@ -31,22 +31,19 @@ namespace osu.Game.Screens.Menu
public override bool AllowExternalScreenChange => true;
private readonly BackgroundScreenDefault background;
private Screen songSelect;
private readonly MenuSideFlashes sideFlashes;
protected override BackgroundScreen CreateBackground() => background;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
public MainMenu()
{
background = new BackgroundScreenDefault();
Children = new Drawable[]
InternalChildren = new Drawable[]
{
new ExitConfirmOverlay
{
Action = Exit,
Action = this.Exit,
},
new ParallaxContainer
{
@ -55,12 +52,12 @@ namespace osu.Game.Screens.Menu
{
buttons = new ButtonSystem
{
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new Editor()); },
OnChart = delegate { this.Push(new ChartListing()); },
OnDirect = delegate {this.Push(new OnlineListing()); },
OnEdit = delegate {this.Push(new Editor()); },
OnSolo = onSolo,
OnMulti = delegate { Push(new Multiplayer()); },
OnExit = Exit,
OnMulti = delegate {this.Push(new Multiplayer()); },
OnExit = this.Exit,
}
}
},
@ -73,10 +70,10 @@ namespace osu.Game.Screens.Menu
{
case ButtonSystemState.Initial:
case ButtonSystemState.Exit:
background.FadeColour(Color4.White, 500, Easing.OutSine);
Background.FadeColour(Color4.White, 500, Easing.OutSine);
break;
default:
background.FadeColour(OsuColour.Gray(0.8f), 500, Easing.OutSine);
Background.FadeColour(OsuColour.Gray(0.8f), 500, Easing.OutSine);
break;
}
};
@ -85,8 +82,6 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader(true)]
private void load(OsuGame game = null)
{
LoadComponentAsync(background);
if (game != null)
{
buttons.OnSettings = game.ToggleSettings;
@ -104,7 +99,7 @@ namespace osu.Game.Screens.Menu
public void LoadToSolo() => Schedule(onSolo);
private void onSolo() => Push(consumeSongSelect());
private void onSolo() =>this.Push(consumeSongSelect());
private Screen consumeSongSelect()
{
@ -113,7 +108,7 @@ namespace osu.Game.Screens.Menu
return s;
}
protected override void OnEntering(Screen last)
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
buttons.FadeInFromZero(500);
@ -148,8 +143,8 @@ namespace osu.Game.Screens.Menu
const float length = 300;
Content.FadeIn(length, Easing.OutQuint);
Content.MoveTo(new Vector2(0, 0), length, Easing.OutQuint);
this.FadeIn(length, Easing.OutQuint);
this.MoveTo(new Vector2(0, 0), length, Easing.OutQuint);
sideFlashes.Delay(length).FadeIn(64, Easing.InQuint);
}
@ -164,13 +159,13 @@ namespace osu.Game.Screens.Menu
private void beatmap_ValueChanged(WorkingBeatmap newValue)
{
if (!IsCurrentScreen)
if (!this.IsCurrentScreen())
return;
background.Next();
((BackgroundScreenDefault)Background).Next();
}
protected override void OnSuspending(Screen next)
public override void OnSuspending(IScreen next)
{
base.OnSuspending(next);
@ -178,26 +173,26 @@ namespace osu.Game.Screens.Menu
buttons.State = ButtonSystemState.EnteringMode;
Content.FadeOut(length, Easing.InSine);
Content.MoveTo(new Vector2(-800, 0), length, Easing.InSine);
this.FadeOut(length, Easing.InSine);
this.MoveTo(new Vector2(-800, 0), length, Easing.InSine);
sideFlashes.FadeOut(64, Easing.OutQuint);
}
protected override void OnResuming(Screen last)
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
background.Next();
((BackgroundScreenDefault)Background).Next();
//we may have consumed our preloaded instance, so let's make another.
preloadSongSelect();
}
protected override bool OnExiting(Screen next)
public override bool OnExiting(IScreen next)
{
buttons.State = ButtonSystemState.Exit;
Content.FadeOut(3000);
this.FadeOut(3000);
return base.OnExiting(next);
}
@ -205,7 +200,7 @@ namespace osu.Game.Screens.Menu
{
if (!e.Repeat && e.ControlPressed && e.ShiftPressed && e.Key == Key.D)
{
Push(new Drawings());
this.Push(new Drawings());
return true;
}