diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 0b50db1f72..e715cb64bd 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -16,7 +16,6 @@ using osu.Desktop.Updater; using osu.Framework; using osu.Framework.Platform.Windows; using osu.Framework.Screens; -using osu.Game.Screens; using osu.Game.Screens.Menu; namespace osu.Desktop @@ -63,9 +62,10 @@ namespace osu.Desktop } } - protected override void ScreenChanged(OsuScreen current, Screen newScreen) + protected override void ScreenChanged(IScreen lastScreen, IScreen newScreen) { - base.ScreenChanged(current, newScreen); + base.ScreenChanged(lastScreen, newScreen); + switch (newScreen) { case Intro _: diff --git a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs index da2427ff6f..284e1b7c2a 100644 --- a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs +++ b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Framework.Screens; using osu.Game.Screens; using osu.Game.Screens.Menu; using osuTK.Graphics; @@ -57,7 +58,7 @@ namespace osu.Game.Tests.Visual public OsuLogo Logo; private TestScreen screen; - public bool ScreenLoaded => screen.IsCurrentScreen; + public bool ScreenLoaded => screen.IsCurrentScreen(); public TestLoader(double delay) { @@ -96,7 +97,7 @@ namespace osu.Game.Tests.Visual { public TestScreen() { - Child = new Box + InternalChild = new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.DarkSlateGray, @@ -107,7 +108,7 @@ namespace osu.Game.Tests.Visual protected override void LogoArriving(OsuLogo logo, bool resuming) { base.LogoArriving(logo, resuming); - Child.FadeInFromZero(200); + InternalChild.FadeInFromZero(200); } } } diff --git a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs index 602108d078..aab94036ab 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using osu.Framework.Graphics; +using osu.Framework.Screens; using osu.Game.Screens; using osu.Game.Screens.Multi; @@ -15,15 +16,15 @@ namespace osu.Game.Tests.Visual { int index = 0; - OsuScreen currentScreen = new TestMultiplayerSubScreen(index); + ScreenStack screenStack = new ScreenStack(new TestMultiplayerSubScreen(index)) { RelativeSizeAxes = Axes.Both }; Children = new Drawable[] { - currentScreen, - new Header(currentScreen) + screenStack, + new Header(screenStack) }; - AddStep("push multi screen", () => currentScreen.Push(currentScreen = new TestMultiplayerSubScreen(++index))); + AddStep("push multi screen", () => screenStack.CurrentScreen.Push(new TestMultiplayerSubScreen(++index))); } private class TestMultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen diff --git a/osu.Game.Tests/Visual/TestCaseMultiScreen.cs b/osu.Game.Tests/Visual/TestCaseMultiScreen.cs index 88265d146f..af2db996f5 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiScreen.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiScreen.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using NUnit.Framework; +using osu.Framework.Screens; using osu.Game.Screens.Multi; using osu.Game.Screens.Multi.Lounge; using osu.Game.Screens.Multi.Lounge.Components; diff --git a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs index 2240af39be..23e5fcfb47 100644 --- a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs +++ b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs @@ -3,6 +3,7 @@ using System.Threading; using osu.Framework.Allocation; +using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Screens.Play; @@ -26,7 +27,7 @@ namespace osu.Game.Tests.Visual AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre)); - AddUntilStep(() => !loader.IsCurrentScreen, "wait for no longer current"); + AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current"); AddStep("load slow dummy beatmap", () => { @@ -42,7 +43,7 @@ namespace osu.Game.Tests.Visual Scheduler.AddDelayed(() => slow.Ready = true, 5000); }); - AddUntilStep(() => !loader.IsCurrentScreen, "wait for no longer current"); + AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current"); } protected class SlowLoadPlayer : Player diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs index 82da609e49..36b6857098 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs @@ -19,16 +19,18 @@ namespace osu.Game.Tests.Visual public class TestCaseScreenBreadcrumbControl : OsuTestCase { private readonly ScreenBreadcrumbControl breadcrumbs; - private Screen currentScreen, changedScreen; + private readonly ScreenStack screenStack; public TestCaseScreenBreadcrumbControl() { - TestScreen startScreen; OsuSpriteText titleText; + IScreen startScreen = new TestScreenOne(); + screenStack = new ScreenStack(startScreen) { RelativeSizeAxes = Axes.Both }; + Children = new Drawable[] { - currentScreen = startScreen = new TestScreenOne(), + screenStack, new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -37,7 +39,7 @@ namespace osu.Game.Tests.Visual Spacing = new Vector2(10), Children = new Drawable[] { - breadcrumbs = new ScreenBreadcrumbControl(startScreen) + breadcrumbs = new ScreenBreadcrumbControl(screenStack) { RelativeSizeAxes = Axes.X, }, @@ -46,12 +48,7 @@ namespace osu.Game.Tests.Visual }, }; - breadcrumbs.Current.ValueChanged += s => - { - titleText.Text = $"Changed to {s.ToString()}"; - changedScreen = s; - }; - + breadcrumbs.Current.ValueChanged += s => titleText.Text = $"Changed to {s.ToString()}"; breadcrumbs.Current.TriggerChange(); waitForCurrent(); @@ -60,18 +57,14 @@ namespace osu.Game.Tests.Visual pushNext(); waitForCurrent(); - AddStep(@"make start current", () => - { - startScreen.MakeCurrent(); - currentScreen = startScreen; - }); + AddStep(@"make start current", () => startScreen.MakeCurrent()); waitForCurrent(); pushNext(); waitForCurrent(); AddAssert(@"only 2 items", () => breadcrumbs.Items.Count() == 2); - AddStep(@"exit current", () => changedScreen.Exit()); - AddAssert(@"current screen is first", () => startScreen == changedScreen); + AddStep(@"exit current", () => screenStack.CurrentScreen.Exit()); + AddAssert(@"current screen is first", () => startScreen == screenStack.CurrentScreen); } [BackgroundDependencyLoader] @@ -80,8 +73,8 @@ namespace osu.Game.Tests.Visual breadcrumbs.StripColour = colours.Blue; } - private void pushNext() => AddStep(@"push next screen", () => currentScreen = ((TestScreen)currentScreen).PushNext()); - private void waitForCurrent() => AddUntilStep(() => currentScreen.IsCurrentScreen, "current screen"); + private void pushNext() => AddStep(@"push next screen", () => ((TestScreen)screenStack.CurrentScreen).PushNext()); + private void waitForCurrent() => AddUntilStep(() => screenStack.CurrentScreen.IsCurrentScreen(), "current screen"); private abstract class TestScreen : OsuScreen { @@ -91,14 +84,14 @@ namespace osu.Game.Tests.Visual public TestScreen PushNext() { TestScreen screen = CreateNextScreen(); - Push(screen); + this.Push(screen); return screen; } protected TestScreen() { - Child = new FillFlowContainer + InternalChild = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs index 5823fad93a..c8fd93df66 100644 --- a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs @@ -50,6 +50,7 @@ namespace osu.Game.Graphics.Cursor if (!CanShowCursor) { currentTarget?.Cursor?.Hide(); + currentTarget = null; return; } diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs index adcf401546..ed8f5e3b34 100644 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -10,45 +10,26 @@ namespace osu.Game.Graphics.UserInterface /// /// A which follows the active screen (and allows navigation) in a stack. /// - public class ScreenBreadcrumbControl : BreadcrumbControl + public class ScreenBreadcrumbControl : BreadcrumbControl { - private Screen last; - - public ScreenBreadcrumbControl(Screen initialScreen) + public ScreenBreadcrumbControl(ScreenStack stack) { - Current.ValueChanged += newScreen => - { - if (last != newScreen && !newScreen.IsCurrentScreen) - newScreen.MakeCurrent(); - }; + stack.ScreenPushed += onPushed; + stack.ScreenExited += onExited; - onPushed(initialScreen); + Current.ValueChanged += newScreen => newScreen.MakeCurrent(); } - private void screenChanged(Screen newScreen) + private void onPushed(IScreen lastScreen, IScreen newScreen) { - if (newScreen == null) return; - - if (last != null) - { - last.Exited -= screenChanged; - last.ModePushed -= onPushed; - } - - last = newScreen; - - newScreen.Exited += screenChanged; - newScreen.ModePushed += onPushed; - Current.Value = newScreen; + AddItem(newScreen); } - private void onPushed(Screen screen) + private void onExited(IScreen lastScreen, IScreen newScreen) { - Items.ToList().SkipWhile(i => i != Current.Value).Skip(1).ForEach(RemoveItem); - AddItem(screen); - - screenChanged(screen); + Current.Value = newScreen; + Items.ToList().SkipWhile(s => s != Current.Value).Skip(1).ForEach(RemoveItem); } } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 3dde3d2c60..881fd92f8d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -79,27 +79,21 @@ namespace osu.Game public virtual Storage GetStorageForStableInstall() => null; - private Intro intro - { - get - { - Screen screen = screenStack; - while (screen != null && !(screen is Intro)) - screen = screen.ChildScreen; - return screen as Intro; - } - } - public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight; private IdleTracker idleTracker; public readonly Bindable OverlayActivationMode = new Bindable(); - private OsuScreen screenStack; - + private ParallaxContainer backgroundParallax; + private ScreenStack backgroundStack; + private ScreenStack screenStack; private VolumeOverlay volume; private OnScreenDisplay onscreenDisplay; + private OsuLogo osuLogo; + + private MainMenu menuScreen; + private Intro introScreen; private Bindable configRuleset; private readonly Bindable ruleset = new Bindable(); @@ -173,6 +167,8 @@ namespace osu.Game dependencies.CacheAs(ruleset); dependencies.CacheAs>(ruleset); + dependencies.Cache(osuLogo = new OsuLogo()); + // bind config int to database RulesetInfo configRuleset = LocalConfig.GetBindable(OsuSetting.Ruleset); ruleset.Value = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First(); @@ -211,6 +207,12 @@ namespace osu.Game /// The beatmap to select. public void PresentBeatmap(BeatmapSetInfo beatmap) { + if (menuScreen == null) + { + Schedule(() => PresentBeatmap(beatmap)); + return; + } + CloseAllOverlays(false); void setBeatmap() @@ -235,16 +237,15 @@ namespace osu.Game } } - switch (currentScreen) + switch (screenStack.CurrentScreen) { case SongSelect _: break; default: // navigate to song select if we are not already there. - var menu = (MainMenu)intro.ChildScreen; - menu.MakeCurrent(); - menu.LoadToSolo(); + menuScreen.MakeCurrent(); + menuScreen.LoadToSolo(); break; } @@ -270,9 +271,7 @@ namespace osu.Game scoreLoad?.Cancel(); - var menu = intro.ChildScreen; - - if (menu == null) + if (menuScreen == null) { scoreLoad = Schedule(() => LoadScore(score, false)); return; @@ -293,7 +292,7 @@ namespace osu.Game return; } - if (!currentScreen.AllowExternalScreenChange) + if ((screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange != true) { notifications.Post(new SimpleNotification { @@ -312,9 +311,9 @@ namespace osu.Game void loadScore() { - if (!menu.IsCurrentScreen) + if (!menuScreen.IsCurrentScreen()) { - menu.MakeCurrent(); + menuScreen.MakeCurrent(); this.Delay(500).Schedule(loadScore, out scoreLoad); return; } @@ -324,7 +323,7 @@ namespace osu.Game Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); Beatmap.Value.Mods.Value = databasedScoreInfo.Mods; - currentScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); + menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); } } @@ -338,11 +337,6 @@ namespace osu.Game { base.LoadComplete(); - // The next time this is updated is in UpdateAfterChildren, which occurs too late and results - // in the cursor being shown for a few frames during the intro. - // This prevents the cursor from showing until we have a screen with CursorVisible = true - MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; - // todo: all archive managers should be able to be looped here. SkinManager.PostNotification = n => notifications?.Post(n); SkinManager.GetStableStorage = GetStorageForStableInstall; @@ -352,6 +346,8 @@ namespace osu.Game BeatmapManager.PresentBeatmap = PresentBeatmap; + Container logoContainer; + AddRange(new Drawable[] { new VolumeControlReceptor @@ -360,10 +356,18 @@ namespace osu.Game ActionRequested = action => volume.Adjust(action), ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise), }, + backgroundParallax = new ParallaxContainer + { + RelativeSizeAxes = Axes.Both, + Scale = new Vector2(1.06f), + Child = backgroundStack = new ScreenStack { RelativeSizeAxes = Axes.Both } + }, screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays) { RelativeSizeAxes = Axes.Both, + Child = screenStack = new ScreenStack { RelativeSizeAxes = Axes.Both } }, + logoContainer = new Container { RelativeSizeAxes = Axes.Both }, overlayContent = new Container { RelativeSizeAxes = Axes.Both, @@ -372,12 +376,15 @@ namespace osu.Game idleTracker = new IdleTracker(6000) }); - loadComponentSingleFile(screenStack = new Loader(), d => + screenStack.ScreenPushed += screenPushed; + screenStack.ScreenExited += screenExited; + + loadComponentSingleFile(osuLogo, logoContainer.Add); + + loadComponentSingleFile(new Loader { - screenStack.ModePushed += screenAdded; - screenStack.Exited += screenRemoved; - screenContainer.Add(screenStack); - }); + RelativeSizeAxes = Axes.Both + }, screenStack.Push); loadComponentSingleFile(Toolbar = new Toolbar { @@ -385,7 +392,7 @@ namespace osu.Game OnHome = delegate { CloseAllOverlays(false); - intro?.ChildScreen?.MakeCurrent(); + menuScreen?.MakeCurrent(); }, }, floatingOverlayContent.Add); @@ -601,7 +608,7 @@ namespace osu.Game public bool OnPressed(GlobalAction action) { - if (intro == null) return false; + if (introScreen == null) return false; switch (action) { @@ -658,25 +665,9 @@ namespace osu.Game private Container floatingOverlayContent; - private OsuScreen currentScreen; private FrameworkConfigManager frameworkConfig; private ScalingContainer screenContainer; - protected override bool OnExiting() - { - if (screenStack.ChildScreen == null) return false; - - if (intro == null) return true; - - if (!intro.DidLoadMenu || intro.ChildScreen != null) - { - Scheduler.Add(intro.MakeCurrent); - return true; - } - - return base.OnExiting(); - } - /// /// Use to programatically exit the game as if the user was triggering via alt-f4. /// Will keep persisting until an exit occurs (exit may be blocked multiple times). @@ -695,7 +686,7 @@ namespace osu.Game // we only want to apply these restrictions when we are inside a screen stack. // the use case for not applying is in visual/unit tests. - bool applyBeatmapRulesetRestrictions = !currentScreen?.AllowBeatmapRulesetChange ?? false; + bool applyBeatmapRulesetRestrictions = !(screenStack.CurrentScreen as IOsuScreen)?.AllowBeatmapRulesetChange ?? false; ruleset.Disabled = applyBeatmapRulesetRestrictions; Beatmap.Disabled = applyBeatmapRulesetRestrictions; @@ -703,7 +694,7 @@ namespace osu.Game screenContainer.Padding = new MarginPadding { Top = ToolbarOffset }; overlayContent.Padding = new MarginPadding { Top = ToolbarOffset }; - MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; + MenuCursorContainer.CanShowCursor = (screenStack.CurrentScreen as IOsuScreen)?.CursorVisible ?? false; } /// @@ -732,24 +723,38 @@ namespace osu.Game this.ruleset.Disabled = rulesetDisabled; } - protected virtual void ScreenChanged(OsuScreen current, Screen newScreen) + protected virtual void ScreenChanged(IScreen lastScreen, IScreen newScreen) { - currentScreen = (OsuScreen)newScreen; + if (newScreen is IOsuScreen newOsuScreen) + backgroundParallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * newOsuScreen.BackgroundParallaxAmount; + + switch (newScreen) + { + case Intro intro: + introScreen = intro; + break; + case MainMenu menu: + menuScreen = menu; + break; + } } - private void screenAdded(Screen newScreen) + private void screenPushed(IScreen lastScreen, IScreen newScreen) { - ScreenChanged(currentScreen, newScreen); + if (newScreen is IOsuScreen newOsuScreen && newOsuScreen.Background != null) + backgroundStack.Push(newOsuScreen.Background); + + ScreenChanged(lastScreen, newScreen); Logger.Log($"Screen changed → {newScreen}"); - - newScreen.ModePushed += screenAdded; - newScreen.Exited += screenRemoved; } - private void screenRemoved(Screen newScreen) + private void screenExited(IScreen lastScreen, IScreen newScreen) { - ScreenChanged(currentScreen, newScreen); - Logger.Log($"Screen changed ← {currentScreen}"); + if (newScreen is IOsuScreen newOsuScreen) + newOsuScreen.Background?.MakeCurrent(); + + ScreenChanged(lastScreen, newScreen); + Logger.Log($"Screen changed ← {newScreen}"); if (newScreen == null) Exit(); diff --git a/osu.Game/Overlays/AccountCreation/AccountCreationScreen.cs b/osu.Game/Overlays/AccountCreation/AccountCreationScreen.cs index 371428d988..f6ff98e8ca 100644 --- a/osu.Game/Overlays/AccountCreation/AccountCreationScreen.cs +++ b/osu.Game/Overlays/AccountCreation/AccountCreationScreen.cs @@ -8,22 +8,22 @@ namespace osu.Game.Overlays.AccountCreation { public abstract class AccountCreationScreen : Screen { - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); - Content.FadeOut().Delay(200).FadeIn(200); + this.FadeOut().Delay(200).FadeIn(200); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { base.OnResuming(last); - Content.FadeIn(200); + this.FadeIn(200); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { base.OnSuspending(next); - Content.FadeOut(200); + this.FadeOut(200); } } } diff --git a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs index bfc437f763..e2ec18fa11 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs @@ -44,7 +44,7 @@ namespace osu.Game.Overlays.AccountCreation { this.api = api; - Children = new Drawable[] + InternalChildren = new Drawable[] { new FillFlowContainer { @@ -143,7 +143,7 @@ namespace osu.Game.Overlays.AccountCreation focusNextTextbox(); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); processingOverlay.Hide(); diff --git a/osu.Game/Overlays/AccountCreation/ScreenWarning.cs b/osu.Game/Overlays/AccountCreation/ScreenWarning.cs index 082eb8a51f..99a61eef35 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenWarning.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenWarning.cs @@ -26,12 +26,12 @@ namespace osu.Game.Overlays.AccountCreation private const string help_centre_url = "/help/wiki/Help_Centre#login"; - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { if (string.IsNullOrEmpty(api.ProvidedUsername)) { - Content.FadeOut(); - Push(new ScreenEntry()); + this.FadeOut(); + this.Push(new ScreenEntry()); return; } @@ -46,7 +46,7 @@ namespace osu.Game.Overlays.AccountCreation if (string.IsNullOrEmpty(api.ProvidedUsername)) return; - Children = new Drawable[] + InternalChildren = new Drawable[] { new Sprite { @@ -104,7 +104,7 @@ namespace osu.Game.Overlays.AccountCreation new DangerousSettingsButton { Text = "I understand. This account isn't for me.", - Action = () => Push(new ScreenEntry()) + Action = () => this.Push(new ScreenEntry()) }, furtherAssistance = new LinkFlowContainer(cp => { cp.TextSize = 12; }) { diff --git a/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs b/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs index 5b7dc21be8..952a875539 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Screens; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Settings; using osu.Game.Screens.Menu; @@ -16,7 +17,7 @@ namespace osu.Game.Overlays.AccountCreation [BackgroundDependencyLoader] private void load() { - Child = new FillFlowContainer + InternalChild = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, @@ -56,7 +57,7 @@ namespace osu.Game.Overlays.AccountCreation { Text = "Let's create an account!", Margin = new MarginPadding { Vertical = 120 }, - Action = () => Push(new ScreenWarning()) + Action = () => this.Push(new ScreenWarning()) } } }; diff --git a/osu.Game/Overlays/AccountCreationOverlay.cs b/osu.Game/Overlays/AccountCreationOverlay.cs index 9bc4119716..e077f3981c 100644 --- a/osu.Game/Overlays/AccountCreationOverlay.cs +++ b/osu.Game/Overlays/AccountCreationOverlay.cs @@ -6,6 +6,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API; @@ -82,7 +83,7 @@ namespace osu.Game.Overlays base.PopIn(); this.FadeIn(transition_time, Easing.OutQuint); - if (welcomeScreen.ChildScreen != null) + if (welcomeScreen.GetChildScreen() != null) welcomeScreen.MakeCurrent(); } diff --git a/osu.Game/Screens/BackgroundScreen.cs b/osu.Game/Screens/BackgroundScreen.cs index ed477c9d0b..95109a554a 100644 --- a/osu.Game/Screens/BackgroundScreen.cs +++ b/osu.Game/Screens/BackgroundScreen.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading; using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Input.Events; @@ -12,6 +11,12 @@ namespace osu.Game.Screens { public abstract class BackgroundScreen : Screen, IEquatable { + protected BackgroundScreen() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + } + public virtual bool Equals(BackgroundScreen other) { return other?.GetType() == GetType(); @@ -26,64 +31,40 @@ namespace osu.Game.Screens return false; } - public override void Push(Screen screen) - { - // When trying to push a non-loaded screen, load it asynchronously and re-invoke Push - // once it's done. - if (screen.LoadState == LoadState.NotLoaded) - { - LoadComponentAsync(screen, d => Push((BackgroundScreen)d)); - return; - } - - // Make sure the in-progress loading is complete before pushing the screen. - while (screen.LoadState < LoadState.Ready) - Thread.Sleep(1); - - try - { - base.Push(screen); - } - catch (ScreenAlreadyExitedException) - { - // screen may have exited before the push was successful. - } - } - protected override void Update() { base.Update(); - Content.Scale = new Vector2(1 + x_movement_amount / DrawSize.X * 2); + Scale = new Vector2(1 + x_movement_amount / DrawSize.X * 2); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { - Content.FadeOut(); - Content.MoveToX(x_movement_amount); + this.FadeOut(); + this.MoveToX(x_movement_amount); - Content.FadeIn(transition_length, Easing.InOutQuart); - Content.MoveToX(0, transition_length, Easing.InOutQuart); + this.FadeIn(transition_length, Easing.InOutQuart); + this.MoveToX(0, transition_length, Easing.InOutQuart); base.OnEntering(last); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { - Content.MoveToX(-x_movement_amount, transition_length, Easing.InOutQuart); + this.MoveToX(-x_movement_amount, transition_length, Easing.InOutQuart); base.OnSuspending(next); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { - Content.FadeOut(transition_length, Easing.OutExpo); - Content.MoveToX(x_movement_amount, transition_length, Easing.OutExpo); + this.FadeOut(transition_length, Easing.OutExpo); + this.MoveToX(x_movement_amount, transition_length, Easing.OutExpo); return base.OnExiting(next); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { - Content.MoveToX(0, transition_length, Easing.OutExpo); + this.MoveToX(0, transition_length, Easing.OutExpo); base.OnResuming(last); } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index e326cdb0ca..8ebc9ceb18 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Backgrounds } b.Depth = newDepth; - Add(Background = b); + AddInternal(Background = b); Background.BlurSigma = BlurTarget; })); }); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBlack.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBlack.cs index c097d25178..bbf56908f9 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBlack.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBlack.cs @@ -12,14 +12,14 @@ namespace osu.Game.Screens.Backgrounds { public BackgroundScreenBlack() { - Child = new Box + InternalChild = new Box { Colour = Color4.Black, RelativeSizeAxes = Axes.Both, }; } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { Show(); } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs index 041391db1e..8970ab0a1b 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs @@ -12,7 +12,7 @@ namespace osu.Game.Screens.Backgrounds public BackgroundScreenCustom(string textureName) { this.textureName = textureName; - Add(new Background(textureName)); + AddInternal(new Background(textureName)); } public override bool Equals(BackgroundScreen other) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index f924cf9805..5254657132 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Backgrounds Background?.FadeOut(800, Easing.InOutSine); Background?.Expire(); - Add(Background = newBackground); + AddInternal(Background = newBackground); currentDisplay++; } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 9bccefc508..099f4afbb2 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Edit SummaryTimeline timeline; PlaybackControl playback; - Children = new[] + InternalChildren = new[] { new Container { @@ -96,7 +96,7 @@ namespace osu.Game.Screens.Edit { new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap), new EditorMenuItemSpacer(), - new EditorMenuItem("Exit", MenuItemType.Standard, Exit) + new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit) } } } @@ -194,20 +194,20 @@ namespace osu.Game.Screens.Edit return true; } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { Beatmap.Value.Track?.Stop(); base.OnResuming(last); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); Background.FadeColour(Color4.DarkGray, 500); Beatmap.Value.Track?.Stop(); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { Background.FadeColour(Color4.White, 500); if (Beatmap.Value.Track != null) diff --git a/osu.Game/Screens/IOsuScreen.cs b/osu.Game/Screens/IOsuScreen.cs new file mode 100644 index 0000000000..2a07d8cd3c --- /dev/null +++ b/osu.Game/Screens/IOsuScreen.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2019 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Screens; + +namespace osu.Game.Screens +{ + public interface IOsuScreen : IScreen + { + /// + /// Whether the beatmap or ruleset should be allowed to be changed by the user or game. + /// Used to mark exclusive areas where this is strongly prohibited, like gameplay. + /// + bool AllowBeatmapRulesetChange { get; } + + bool AllowExternalScreenChange { get; } + + /// + /// Whether this allows the cursor to be displayed. + /// + bool CursorVisible { get; } + + BackgroundScreen Background { get; } + + float BackgroundParallaxAmount { get; } + } +} diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index a59a8a77ef..d83fe1dc23 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -55,11 +55,11 @@ namespace osu.Game.Screens protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler(); - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); - LoadComponentAsync(precompiler = CreateShaderPrecompiler(), Add); + LoadComponentAsync(precompiler = CreateShaderPrecompiler(), AddInternal); LoadComponentAsync(loadableScreen = CreateLoadableScreen()); checkIfLoaded(); @@ -73,7 +73,7 @@ namespace osu.Game.Screens return; } - Push(loadableScreen); + this.Push(loadableScreen); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 22261f328a..d4869a6ad8 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -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(); } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 8d9cd8dbe9..ffd7e5546f 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -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); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 974e42dda0..8af39343f4 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -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; } diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index 2849fd89e0..ced778e345 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Multi private readonly OsuSpriteText screenType; private readonly HeaderBreadcrumbControl breadcrumbs; - public Header(Screen initialScreen) + public Header(ScreenStack stack) { RelativeSizeAxes = Axes.X; Height = HEIGHT; @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Multi }, }, }, - breadcrumbs = new HeaderBreadcrumbControl(initialScreen) + breadcrumbs = new HeaderBreadcrumbControl(stack) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -103,8 +103,8 @@ namespace osu.Game.Screens.Multi private class HeaderBreadcrumbControl : ScreenBreadcrumbControl { - public HeaderBreadcrumbControl(Screen initialScreen) - : base(initialScreen) + public HeaderBreadcrumbControl(ScreenStack stack) + : base(stack) { } diff --git a/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs b/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs index 4796ffc05c..e3267b01ab 100644 --- a/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs +++ b/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs @@ -3,7 +3,7 @@ namespace osu.Game.Screens.Multi { - public interface IMultiplayerSubScreen + public interface IMultiplayerSubScreen : IOsuScreen { string ShortTitle { get; } } diff --git a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs index d9633218eb..8b0a6b15c3 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Multi.Lounge RoomInspector inspector; - Children = new Drawable[] + InternalChildren = new Drawable[] { Filter = new FilterControl { Depth = -1 }, content = new Container @@ -81,7 +81,7 @@ namespace osu.Game.Screens.Multi.Lounge Filter.Search.Current.ValueChanged += s => filterRooms(); Filter.Tabs.Current.ValueChanged += t => filterRooms(); - Filter.Search.Exit += Exit; + Filter.Search.Exit += this.Exit; } protected override void UpdateAfterChildren() @@ -101,20 +101,20 @@ namespace osu.Game.Screens.Multi.Lounge GetContainingInputManager().ChangeFocus(Filter.Search); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); Filter.Search.HoldFocus = true; } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { Filter.Search.HoldFocus = false; // no base call; don't animate return false; } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { base.OnSuspending(next); Filter.Search.HoldFocus = false; @@ -142,10 +142,10 @@ namespace osu.Game.Screens.Multi.Lounge public void Push(Room room) { // Handles the case where a room is clicked 3 times in quick succession - if (!IsCurrentScreen) + if (!this.IsCurrentScreen()) return; - Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s))); + this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s))); } } } diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index a7932e1131..58ca42e293 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Multi.Match GridContainer bottomRow; MatchSettingsOverlay settings; - Children = new Drawable[] + InternalChildren = new Drawable[] { new GridContainer { @@ -108,7 +108,7 @@ namespace osu.Game.Screens.Multi.Match }, }; - header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect { Selected = addPlaylistItem }); + header.OnRequestSelectBeatmap = () => this.Push(new MatchSongSelect { Selected = addPlaylistItem }); header.Tabs.Current.ValueChanged += t => { const float fade_duration = 500; @@ -126,7 +126,7 @@ namespace osu.Game.Screens.Multi.Match } }; - chat.Exit += Exit; + chat.Exit += this.Exit; } [BackgroundDependencyLoader] @@ -135,7 +135,7 @@ namespace osu.Game.Screens.Multi.Match beatmapManager.ItemAdded += beatmapAdded; } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { manager?.PartRoom(); return base.OnExiting(next); @@ -194,11 +194,9 @@ namespace osu.Game.Screens.Multi.Match { default: case GameTypeTimeshift _: - pushGameplayScreen?.Invoke(new PlayerLoader(() => { - var player = new TimeshiftPlayer(room, room.Playlist.First().ID); - player.Exited += _ => leaderboard.RefreshScores(); - - return player; + pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(room, room.Playlist.First().ID) + { + Exited = () => leaderboard.RefreshScores() })); break; } diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index ce0eddbee3..80e0a206b9 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -28,12 +28,11 @@ namespace osu.Game.Screens.Multi { private readonly MultiplayerWaveContainer waves; - public override bool AllowBeatmapRulesetChange => currentSubScreen?.AllowBeatmapRulesetChange ?? base.AllowBeatmapRulesetChange; + public override bool AllowBeatmapRulesetChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowBeatmapRulesetChange ?? base.AllowBeatmapRulesetChange; private readonly OsuButton createButton; private readonly LoungeSubScreen loungeSubScreen; - - private OsuScreen currentSubScreen; + private readonly ScreenStack screenStack; [Cached(Type = typeof(IRoomManager))] private RoomManager roomManager; @@ -43,11 +42,13 @@ namespace osu.Game.Screens.Multi public Multiplayer() { - Child = waves = new MultiplayerWaveContainer + InternalChild = waves = new MultiplayerWaveContainer { RelativeSizeAxes = Axes.Both, }; + screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen(this.Push)) { RelativeSizeAxes = Axes.Both }; + waves.AddRange(new Drawable[] { new Container @@ -74,9 +75,9 @@ namespace osu.Game.Screens.Multi { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = Header.HEIGHT }, - Child = loungeSubScreen = new LoungeSubScreen(Push), + Child = screenStack }, - new Header(loungeSubScreen), + new Header(screenStack), createButton = new HeaderButton { Anchor = Anchor.TopRight, @@ -97,8 +98,8 @@ namespace osu.Game.Screens.Multi roomManager = new RoomManager() }); - screenAdded(loungeSubScreen); - loungeSubScreen.Exited += _ => Exit(); + screenStack.ScreenPushed += screenPushed; + screenStack.ScreenExited += screenExited; } private readonly IBindable isIdle = new BindableBool(); @@ -120,7 +121,7 @@ namespace osu.Game.Screens.Multi private void updatePollingRate(bool idle) { - roomManager.TimeBetweenPolls = !IsCurrentScreen || !(currentSubScreen is LoungeSubScreen) ? 0 : (idle ? 120000 : 15000); + roomManager.TimeBetweenPolls = !this.IsCurrentScreen() || !(screenStack.CurrentScreen is LoungeSubScreen) ? 0 : (idle ? 120000 : 15000); Logger.Log($"Polling adjusted to {roomManager.TimeBetweenPolls}"); } @@ -133,28 +134,28 @@ namespace osu.Game.Screens.Multi private void forcefullyExit() { // This is temporary since we don't currently have a way to force screens to be exited - if (IsCurrentScreen) - Exit(); + if (this.IsCurrentScreen()) + this.Exit(); else { - MakeCurrent(); + this.MakeCurrent(); Schedule(forcefullyExit); } } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { - Content.FadeIn(); + this.FadeIn(); base.OnEntering(last); waves.Show(); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { waves.Hide(); - Content.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut(); + this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut(); cancelLooping(); loungeSubScreen.MakeCurrent(); @@ -163,20 +164,20 @@ namespace osu.Game.Screens.Multi return base.OnExiting(next); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { base.OnResuming(last); - Content.FadeIn(250); - Content.ScaleTo(1, 250, Easing.OutSine); + this.FadeIn(250); + this.ScaleTo(1, 250, Easing.OutSine); updatePollingRate(isIdle.Value); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { - Content.ScaleTo(1.1f, 250, Easing.InSine); - Content.FadeOut(250); + this.ScaleTo(1.1f, 250, Easing.InSine); + this.FadeOut(250); cancelLooping(); roomManager.TimeBetweenPolls = 0; @@ -202,9 +203,9 @@ namespace osu.Game.Screens.Multi { base.Update(); - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; - if (currentSubScreen is MatchSubScreen) + if (screenStack.CurrentScreen is MatchSubScreen) { var track = Beatmap.Value.Track; if (track != null) @@ -221,25 +222,18 @@ namespace osu.Game.Screens.Multi createButton.Hide(); } - else if (currentSubScreen is LoungeSubScreen) + else if (screenStack.CurrentScreen is LoungeSubScreen) createButton.Show(); } - private void screenAdded(Screen newScreen) - { - currentSubScreen = (OsuScreen)newScreen; - updatePollingRate(isIdle.Value); + private void screenPushed(IScreen lastScreen, IScreen newScreen) + => updatePollingRate(isIdle.Value); - newScreen.ModePushed += screenAdded; - newScreen.Exited += screenRemoved; - } - - private void screenRemoved(Screen newScreen) + private void screenExited(IScreen lastScreen, IScreen newScreen) { - if (currentSubScreen is MatchSubScreen) + if (lastScreen is MatchSubScreen) cancelLooping(); - currentSubScreen = (OsuScreen)newScreen; updatePollingRate(isIdle.Value); } diff --git a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs index 5a7eaafba5..6549408482 100644 --- a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs +++ b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs @@ -9,40 +9,40 @@ namespace osu.Game.Screens.Multi { public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen { - protected virtual Drawable TransitionContent => Content; + protected virtual Drawable TransitionContent => this; public virtual string ShortTitle => Title; - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); - Content.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); TransitionContent.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { - Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); TransitionContent.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); return base.OnExiting(next); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { base.OnResuming(last); - Content.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { base.OnSuspending(next); - Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); TransitionContent.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); } } diff --git a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs index 84d0ca3621..1262326391 100644 --- a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs +++ b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Threading; using osu.Framework.Allocation; using osu.Framework.Logging; +using osu.Framework.Screens; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Multiplayer; @@ -18,6 +19,8 @@ namespace osu.Game.Screens.Multi.Play { public class TimeshiftPlayer : Player { + public Action Exited; + private readonly Room room; private readonly int playlistItemId; @@ -50,7 +53,7 @@ namespace osu.Game.Screens.Multi.Play Schedule(() => { ValidForResume = false; - Exit(); + this.Exit(); }); }; @@ -60,6 +63,16 @@ namespace osu.Game.Screens.Multi.Play Thread.Sleep(1000); } + public override bool OnExiting(IScreen next) + { + if (base.OnExiting(next)) + return true; + + Exited?.Invoke(); + + return false; + } + protected override ScoreInfo CreateScore() { submitScore(); @@ -79,6 +92,13 @@ namespace osu.Game.Screens.Multi.Play api.Queue(request); } + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + Exited = null; + } + protected override Results CreateResults(ScoreInfo score) => new MatchResults(score, room); } } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 69f2b6ef9d..67a0455ead 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -11,19 +11,17 @@ using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Framework.Screens; using osu.Game.Beatmaps; -using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; using osu.Game.Rulesets; using osu.Game.Screens.Menu; -using osuTK; using osu.Game.Overlays; using osu.Framework.Graphics.Containers; namespace osu.Game.Screens { - public abstract class OsuScreen : Screen, IKeyBindingHandler, IHasDescription + public abstract class OsuScreen : Screen, IOsuScreen, IKeyBindingHandler, IHasDescription { - public BackgroundScreen Background { get; private set; } + public BackgroundScreen Background { get; } /// /// A user-facing title for this screen. @@ -56,31 +54,31 @@ namespace osu.Game.Screens /// protected virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All; - /// - /// Whether this allows the cursor to be displayed. - /// public virtual bool CursorVisible => true; protected new OsuGameBase Game => base.Game as OsuGameBase; - private OsuLogo logo; + [Resolved] + private OsuLogo logo { get; set; } - /// - /// Whether the beatmap or ruleset should be allowed to be changed by the user or game. - /// Used to mark exclusive areas where this is strongly prohibited, like gameplay. - /// public virtual bool AllowBeatmapRulesetChange => true; protected readonly Bindable Beatmap = new Bindable(); - protected virtual float BackgroundParallaxAmount => 1; - - private ParallaxContainer backgroundParallaxContainer; + public virtual float BackgroundParallaxAmount => 1; protected readonly Bindable Ruleset = new Bindable(); private SampleChannel sampleExit; + protected OsuScreen() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + Background = CreateBackground(); + } + [BackgroundDependencyLoader(true)] private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable ruleset) { @@ -105,11 +103,11 @@ namespace osu.Game.Screens public virtual bool OnPressed(GlobalAction action) { - if (!IsCurrentScreen) return false; + if (!this.IsCurrentScreen()) return false; if (action == GlobalAction.Back && AllowBackButton) { - Exit(); + this.Exit(); return true; } @@ -118,7 +116,7 @@ namespace osu.Game.Screens public bool OnReleased(GlobalAction action) => action == GlobalAction.Back && AllowBackButton; - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { sampleExit?.Play(); applyArrivingDefaults(true); @@ -126,68 +124,24 @@ namespace osu.Game.Screens base.OnResuming(last); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { base.OnSuspending(next); onSuspendingLogo(); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { - OsuScreen lastOsu = last as OsuScreen; - - BackgroundScreen bg = CreateBackground(); - - if (lastOsu?.Background != null) - { - backgroundParallaxContainer = lastOsu.backgroundParallaxContainer; - - if (bg == null || lastOsu.Background.Equals(bg)) - //we can keep the previous mode's background. - Background = lastOsu.Background; - else - { - lastOsu.Background.Push(Background = bg); - } - } - else if (bg != null) - { - // this makes up for the fact our padding changes when the global toolbar is visible. - bg.Scale = new Vector2(1.06f); - - AddInternal(backgroundParallaxContainer = new ParallaxContainer - { - Depth = float.MaxValue, - Children = new[] - { - Background = bg - } - }); - } - - if ((logo = lastOsu?.logo) == null) - LoadComponentAsync(logo = new OsuLogo { Alpha = 0 }, AddInternal); - applyArrivingDefaults(false); base.OnEntering(last); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { if (ValidForResume && logo != null) onExitingLogo(); - OsuScreen nextOsu = next as OsuScreen; - - if (Background != null && !Background.Equals(nextOsu?.Background)) - { - Background.Exit(); - - //We need to use MakeCurrent in case we are jumping up multiple game screens. - nextOsu?.Background?.MakeCurrent(); - } - if (base.OnExiting(next)) return true; @@ -214,12 +168,9 @@ namespace osu.Game.Screens { logo.AppendAnimatingAction(() => { - if (IsCurrentScreen) LogoArriving(logo, isResuming); + if (this.IsCurrentScreen()) LogoArriving(logo, isResuming); }, true); - if (backgroundParallaxContainer != null) - backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; - OverlayActivationMode.Value = InitialOverlayActivationMode; updateOverlayStates?.Invoke(); @@ -227,7 +178,7 @@ namespace osu.Game.Screens private void onExitingLogo() { - logo.AppendAnimatingAction(() => { LogoExiting(logo); }, false); + logo.AppendAnimatingAction(() => LogoExiting(logo), false); } /// @@ -239,7 +190,7 @@ namespace osu.Game.Screens private void onSuspendingLogo() { - logo.AppendAnimatingAction(() => { LogoSuspending(logo); }, false); + logo.AppendAnimatingAction(() => LogoSuspending(logo), false); } /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f243f1016d..26e87d21d4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton - protected override float BackgroundParallaxAmount => 0.1f; + public override float BackgroundParallaxAmount => 0.1f; protected override bool HideOverlaysOnEnter => true; @@ -166,7 +166,7 @@ namespace osu.Game.Screens.Play if (!ScoreProcessor.Mode.Disabled) config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode); - Children = new Drawable[] + InternalChildren = new Drawable[] { pauseContainer = new PauseContainer(offsetClock, adjustableClock) { @@ -225,7 +225,7 @@ namespace osu.Game.Screens.Play { Action = () => { - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; fadeOut(true); Restart(); @@ -260,18 +260,18 @@ namespace osu.Game.Screens.Play private void performUserRequestedExit() { - if (!IsCurrentScreen) return; - Exit(); + if (!this.IsCurrentScreen()) return; + this.Exit(); } public void Restart() { - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; sampleRestart?.Play(); ValidForResume = false; RestartRequested?.Invoke(); - Exit(); + this.Exit(); } private ScheduledDelegate onCompletionEvent; @@ -290,13 +290,13 @@ namespace osu.Game.Screens.Play { onCompletionEvent = Schedule(delegate { - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; var score = CreateScore(); if (RulesetContainer.ReplayScore == null) scoreManager.Import(score, true); - Push(CreateResults(score)); + this.Push(CreateResults(score)); onCompletionEvent = null; }); @@ -331,15 +331,15 @@ namespace osu.Game.Screens.Play return true; } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); if (!LoadedBeatmapSuccessfully) return; - Content.Alpha = 0; - Content + Alpha = 0; + this .ScaleTo(0.7f) .ScaleTo(1, 750, Easing.OutQuint) .Delay(250) @@ -368,13 +368,13 @@ namespace osu.Game.Screens.Play pauseContainer.FadeIn(750, Easing.OutQuint); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { fadeOut(); base.OnSuspending(next); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { if (onCompletionEvent != null) { @@ -401,7 +401,7 @@ namespace osu.Game.Screens.Play private void fadeOut(bool instant = false) { float fadeOutDuration = instant ? 0 : 250; - Content.FadeOut(fadeOutDuration); + this.FadeOut(fadeOutDuration); Background?.FadeColour(Color4.White, fadeOutDuration, Easing.OutQuint); } @@ -425,7 +425,7 @@ namespace osu.Game.Screens.Play protected override void UpdateBackgroundElements() { - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; base.UpdateBackgroundElements(); diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 44866846d2..c8c3d63e28 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -51,14 +51,14 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load() { - Add(info = new BeatmapMetadataDisplay(Beatmap.Value) + AddInternal(info = new BeatmapMetadataDisplay(Beatmap.Value) { Alpha = 0, Anchor = Anchor.Centre, Origin = Anchor.Centre, }); - Add(new FillFlowContainer + AddInternal(new FillFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Play private void playerLoaded(Player player) => info.Loading = false; - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { base.OnResuming(last); @@ -105,21 +105,21 @@ namespace osu.Game.Screens.Play private void contentIn() { - Content.ScaleTo(1, 650, Easing.OutQuint); - Content.FadeInFromZero(400); + this.ScaleTo(1, 650, Easing.OutQuint); + this.FadeInFromZero(400); } private void contentOut() { - Content.ScaleTo(0.7f, 300, Easing.InQuint); - Content.FadeOut(250); + this.ScaleTo(0.7f, 300, Easing.InQuint); + this.FadeOut(250); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); - Content.ScaleTo(0.7f); + this.ScaleTo(0.7f); contentIn(); @@ -170,7 +170,7 @@ namespace osu.Game.Screens.Play private void pushWhenLoaded() { - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; try { @@ -191,7 +191,7 @@ namespace osu.Game.Screens.Play this.Delay(250).Schedule(() => { - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; loadTask = null; @@ -200,9 +200,9 @@ namespace osu.Game.Screens.Play ValidForResume = false; if (player.LoadedBeatmapSuccessfully) - Push(player); + this.Push(player); else - Exit(); + this.Exit(); }); }, 500); } @@ -218,15 +218,15 @@ namespace osu.Game.Screens.Play pushDebounce = null; } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { base.OnSuspending(next); cancelLoad(); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { - Content.ScaleTo(0.7f, 150, Easing.InQuint); + this.ScaleTo(0.7f, 150, Easing.InQuint); this.FadeOut(150); cancelLoad(); diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 61dc70c4ae..ac5aec2196 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Play ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); DimLevel.ValueChanged += _ => UpdateBackgroundElements(); @@ -49,7 +49,7 @@ namespace osu.Game.Screens.Play InitializeBackgroundElements(); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { base.OnResuming(last); InitializeBackgroundElements(); @@ -66,7 +66,7 @@ namespace osu.Game.Screens.Play /// protected virtual void UpdateBackgroundElements() { - if (!IsCurrentScreen) return; + if (!this.IsCurrentScreen()) return; Background?.FadeColour(OsuColour.Gray(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint); Background?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint); diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index bf9e3bcd27..155fc57f1a 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Ranking private IEnumerable allCircles => new Drawable[] { circleOuterBackground, circleInner, circleOuter }; - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 2500, Easing.OutQuint); @@ -98,7 +98,7 @@ namespace osu.Game.Screens.Ranking } } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { allCircles.ForEach(c => { @@ -107,7 +107,7 @@ namespace osu.Game.Screens.Ranking Background.ScaleTo(1f, transition_time / 4, Easing.OutQuint); - Content.FadeOut(transition_time / 4); + this.FadeOut(transition_time / 4); return base.OnExiting(next); } @@ -115,7 +115,7 @@ namespace osu.Game.Screens.Ranking [BackgroundDependencyLoader] private void load(OsuColour colours) { - Children = new Drawable[] + InternalChildren = new Drawable[] { new AspectContainer { @@ -260,7 +260,7 @@ namespace osu.Game.Screens.Ranking { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Action = Exit + Action = this.Exit }, }; diff --git a/osu.Game/Screens/ScreenWhiteBox.cs b/osu.Game/Screens/ScreenWhiteBox.cs index 1131152d5f..3447f317a1 100644 --- a/osu.Game/Screens/ScreenWhiteBox.cs +++ b/osu.Game/Screens/ScreenWhiteBox.cs @@ -30,7 +30,7 @@ namespace osu.Game.Screens protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2"); - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); @@ -38,51 +38,51 @@ namespace osu.Game.Screens if (last != null) popButton.Alpha = 1; - Content.Alpha = 0; + Alpha = 0; textContainer.Position = new Vector2(DrawSize.X / 16, 0); boxContainer.ScaleTo(0.2f); boxContainer.RotateTo(-20); - using (Content.BeginDelayedSequence(300, true)) + using (BeginDelayedSequence(300, true)) { boxContainer.ScaleTo(1, transition_time, Easing.OutElastic); boxContainer.RotateTo(0, transition_time / 2, Easing.OutQuint); textContainer.MoveTo(Vector2.Zero, transition_time, Easing.OutExpo); - Content.FadeIn(transition_time, Easing.OutExpo); + this.FadeIn(transition_time, Easing.OutExpo); } } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { textContainer.MoveTo(new Vector2(DrawSize.X / 16, 0), transition_time, Easing.OutExpo); - Content.FadeOut(transition_time, Easing.OutExpo); + this.FadeOut(transition_time, Easing.OutExpo); return base.OnExiting(next); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { base.OnSuspending(next); textContainer.MoveTo(new Vector2(-(DrawSize.X / 16), 0), transition_time, Easing.OutExpo); - Content.FadeOut(transition_time, Easing.OutExpo); + this.FadeOut(transition_time, Easing.OutExpo); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { base.OnResuming(last); textContainer.MoveTo(Vector2.Zero, transition_time, Easing.OutExpo); - Content.FadeIn(transition_time, Easing.OutExpo); + this.FadeIn(transition_time, Easing.OutExpo); } public ScreenWhiteBox() { FillFlowContainer childModeButtons; - Children = new Drawable[] + InternalChildren = new Drawable[] { boxContainer = new Container { @@ -148,7 +148,7 @@ namespace osu.Game.Screens Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Alpha = 0, - Action = Exit + Action = this.Exit }, childModeButtons = new FillFlowContainer { @@ -171,7 +171,7 @@ namespace osu.Game.Screens HoverColour = getColourFor(t).Lighten(0.2f), Action = delegate { - Push(Activator.CreateInstance(t) as Screen); + this.Push(Activator.CreateInstance(t) as Screen); } }); } diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index e1d71fdd05..0c4228fda7 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Screens; + namespace osu.Game.Screens.Select { public class EditSongSelect : SongSelect @@ -9,7 +11,7 @@ namespace osu.Game.Screens.Select protected override bool OnStart() { - Exit(); + this.Exit(); return true; } } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 5763b84e89..a9da7d7705 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -3,6 +3,7 @@ using System; using Humanizer; +using osu.Framework.Screens; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi; @@ -28,8 +29,8 @@ namespace osu.Game.Screens.Select Selected?.Invoke(item); - if (IsCurrentScreen) - Exit(); + if (this.IsCurrentScreen()) + this.Exit(); return true; } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index a7de93b11d..ed5b6c16de 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Select }, Key.Number3); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { player = null; @@ -64,7 +64,7 @@ namespace osu.Game.Screens.Select LoadComponentAsync(player = new PlayerLoader(() => new Player()), l => { - if (IsCurrentScreen) Push(player); + if (this.IsCurrentScreen())this.Push(player); }); return true; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 2f212a2564..b8840a0eb1 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -88,7 +88,7 @@ namespace osu.Game.Screens.Select const float carousel_width = 640; const float filter_height = 100; - AddRange(new Drawable[] + AddRangeInternal(new Drawable[] { new ParallaxContainer { @@ -156,8 +156,8 @@ namespace osu.Game.Screens.Select Background = { Width = 2 }, Exit = () => { - if (IsCurrentScreen) - Exit(); + if (this.IsCurrentScreen()) + this.Exit(); }, }, } @@ -182,7 +182,7 @@ namespace osu.Game.Screens.Select if (ShowFooter) { - Add(FooterPanels = new Container + AddInternal(FooterPanels = new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -193,7 +193,7 @@ namespace osu.Game.Screens.Select Bottom = Footer.HEIGHT, }, }); - Add(Footer = new Footer + AddInternal(Footer = new Footer { OnBack = ExitFromBack, }); @@ -210,7 +210,7 @@ namespace osu.Game.Screens.Select }); } - BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new SoloResults(s)); + BeatmapDetails.Leaderboard.ScoreSelected += s =>this.Push(new SoloResults(s)); } [BackgroundDependencyLoader(true)] @@ -281,13 +281,13 @@ namespace osu.Game.Screens.Select return; } - Exit(); + this.Exit(); } public void Edit(BeatmapInfo beatmap = null) { Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap ?? beatmapNoDebounce); - Push(new Editor()); + this.Push(new Editor()); } /// @@ -331,7 +331,7 @@ namespace osu.Game.Screens.Select { if (beatmap is DummyWorkingBeatmap) return; - if (IsCurrentScreen && !Carousel.SelectBeatmap(beatmap?.BeatmapInfo, false)) + if (this.IsCurrentScreen() && !Carousel.SelectBeatmap(beatmap?.BeatmapInfo, false)) // If selecting new beatmap without bypassing filters failed, there's possibly a ruleset mismatch if (beatmap?.BeatmapInfo?.Ruleset != null && beatmap.BeatmapInfo.Ruleset != Ruleset.Value) { @@ -411,7 +411,7 @@ namespace osu.Game.Screens.Select } } - if (IsCurrentScreen) ensurePlayingSelected(preview); + if (this.IsCurrentScreen()) ensurePlayingSelected(preview); UpdateBeatmap(Beatmap.Value); } @@ -431,11 +431,11 @@ namespace osu.Game.Screens.Select Carousel.SelectNextRandom(); } - protected override void OnEntering(Screen last) + public override void OnEntering(IScreen last) { base.OnEntering(last); - Content.FadeInFromZero(250); + this.FadeInFromZero(250); FilterControl.Activate(); } @@ -476,7 +476,7 @@ namespace osu.Game.Screens.Select logo.FadeOut(logo_transition / 2, Easing.Out); } - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { BeatmapDetails.Leaderboard.RefreshScores(); @@ -490,26 +490,26 @@ namespace osu.Game.Screens.Select base.OnResuming(last); - Content.FadeIn(250); + this.FadeIn(250); - Content.ScaleTo(1, 250, Easing.OutSine); + this.ScaleTo(1, 250, Easing.OutSine); FilterControl.Activate(); } - protected override void OnSuspending(Screen next) + public override void OnSuspending(IScreen next) { ModSelect.Hide(); - Content.ScaleTo(1.1f, 250, Easing.InSine); + this.ScaleTo(1.1f, 250, Easing.InSine); - Content.FadeOut(250); + this.FadeOut(250); FilterControl.Deactivate(); base.OnSuspending(next); } - protected override bool OnExiting(Screen next) + public override bool OnExiting(IScreen next) { if (ModSelect.State == Visibility.Visible) { @@ -521,7 +521,7 @@ namespace osu.Game.Screens.Select beatmapInfoWedge.State = Visibility.Hidden; - Content.FadeOut(100); + this.FadeOut(100); FilterControl.Deactivate(); @@ -627,7 +627,7 @@ namespace osu.Game.Screens.Select public override bool OnPressed(GlobalAction action) { - if (!IsCurrentScreen) return false; + if (!this.IsCurrentScreen()) return false; switch (action) { diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 754f34f00f..40673af68a 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -22,6 +22,7 @@ using osuTK; using osuTK.Graphics; using osu.Framework.IO.Stores; using osu.Framework.Graphics.Shapes; +using osu.Framework.Screens; namespace osu.Game.Screens.Tournament { @@ -70,13 +71,13 @@ namespace osu.Game.Screens.Tournament if (!TeamList.Teams.Any()) { - Exit(); + this.Exit(); return; } drawingsConfig = new DrawingsConfigManager(storage); - Children = new Drawable[] + InternalChildren = new Drawable[] { new Box { diff --git a/osu.Game/Tests/Visual/ScreenTestCase.cs b/osu.Game/Tests/Visual/ScreenTestCase.cs index e610fafa7b..d11cee060d 100644 --- a/osu.Game/Tests/Visual/ScreenTestCase.cs +++ b/osu.Game/Tests/Visual/ScreenTestCase.cs @@ -28,16 +28,16 @@ namespace osu.Game.Tests.Visual { nextScreen = screen; - if (IsCurrentScreen) + if (this.IsCurrentScreen()) { - Push(screen); + this.Push(screen); nextScreen = null; } else - MakeCurrent(); + this.MakeCurrent(); }); - protected override void OnResuming(Screen last) + public override void OnResuming(IScreen last) { base.OnResuming(last); if (nextScreen != null) diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index 47bf787bb5..b24a4da6b8 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -6,6 +6,7 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics.Shapes; using osu.Framework.Lists; +using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1abd17e056..33700a50b0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -12,13 +12,13 @@ + - diff --git a/osu.sln b/osu.sln index bf1b6d60e1..11bf458854 100644 --- a/osu.sln +++ b/osu.sln @@ -27,6 +27,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Taiko.Tes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Osu.Tests", "osu.Game.Rulesets.Osu.Tests\osu.Game.Rulesets.Osu.Tests.csproj", "{6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework", "..\osu-framework\osu.Framework\osu.Framework.csproj", "{93F341C2-AFA0-467F-B295-6639DD1A6249}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework.NativeLibs", "..\osu-framework\osu.Framework.NativeLibs\osu.Framework.NativeLibs.csproj", "{CB667825-98B9-4B86-B477-F67CD8E9E1CE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -81,6 +85,14 @@ Global {6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}.Release|Any CPU.Build.0 = Release|Any CPU + {93F341C2-AFA0-467F-B295-6639DD1A6249}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93F341C2-AFA0-467F-B295-6639DD1A6249}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93F341C2-AFA0-467F-B295-6639DD1A6249}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93F341C2-AFA0-467F-B295-6639DD1A6249}.Release|Any CPU.Build.0 = Release|Any CPU + {CB667825-98B9-4B86-B477-F67CD8E9E1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB667825-98B9-4B86-B477-F67CD8E9E1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB667825-98B9-4B86-B477-F67CD8E9E1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB667825-98B9-4B86-B477-F67CD8E9E1CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE