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

@ -41,7 +41,7 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Children = new Drawable[]
InternalChildren = new Drawable[]
{
icon = new SpriteIcon
{
@ -116,7 +116,7 @@ namespace osu.Game.Screens.Menu
LoadComponentAsync(intro = new Intro());
}
protected override void OnEntering(Screen last)
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
@ -130,12 +130,12 @@ namespace osu.Game.Screens.Menu
supporterDrawables.ForEach(d => d.FadeOut().Delay(2000).FadeIn(500));
Content
this
.FadeInFromZero(500)
.Then(5500)
.FadeOut(250)
.ScaleTo(0.9f, 250, Easing.InQuint)
.Finally(d => Push(intro));
.Finally(d => this.Push(intro));
heart.FlashColour(Color4.White, 750, Easing.OutQuint).Loop();
}

View File

@ -111,7 +111,7 @@ namespace osu.Game.Screens.Menu
Scheduler.AddDelayed(delegate
{
DidLoadMenu = true;
Push(mainMenu);
this.Push(mainMenu);
}, delay_step_one);
}, delay_step_two);
}
@ -145,22 +145,22 @@ namespace osu.Game.Screens.Menu
}
}
protected override void OnSuspending(Screen next)
public override void OnSuspending(IScreen next)
{
Content.FadeOut(300);
this.FadeOut(300);
base.OnSuspending(next);
}
protected override bool OnExiting(Screen next)
public override bool OnExiting(IScreen next)
{
//cancel exiting if we haven't loaded the menu yet.
return !DidLoadMenu;
}
protected override void OnResuming(Screen last)
public override void OnResuming(IScreen last)
{
if (!(last is MainMenu))
Content.FadeIn(300);
this.FadeIn(300);
double fadeOutTime = EXIT_DELAY;
//we also handle the exit transition.
@ -169,7 +169,7 @@ namespace osu.Game.Screens.Menu
else
fadeOutTime = 500;
Scheduler.AddDelayed(Exit, fadeOutTime);
Scheduler.AddDelayed(this.Exit, fadeOutTime);
//don't want to fade out completely else we will stop running updates and shit will hit the fan.
Game.FadeTo(0.01f, fadeOutTime);

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;
}