1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Merge branch 'master' into resources-via-nuget

This commit is contained in:
Dean Herbert 2019-01-31 18:40:45 +09:00 committed by GitHub
commit 09056fd0d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 765 additions and 635 deletions

View File

@ -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 _:

View File

@ -88,7 +88,12 @@ namespace osu.Game.Rulesets.Osu.Difficulty
private double computeAimValue()
{
double aimValue = Math.Pow(5.0f * Math.Max(1.0f, Attributes.AimStrain / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
double rawAim = Attributes.AimStrain;
if (mods.Any(m => m is OsuModTouchDevice))
rawAim = Math.Pow(rawAim, 0.8);
double aimValue = Math.Pow(5.0f * Math.Max(1.0f, rawAim / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
// Longer maps are worth more
double lengthBonus = 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) +

View File

@ -0,0 +1,16 @@
// 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.
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModTouchDevice : Mod
{
public override string Name => "Touch Device";
public override string Acronym => "TD";
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
}
}

View File

@ -82,6 +82,9 @@ namespace osu.Game.Rulesets.Osu
if (mods.HasFlag(LegacyMods.Target))
yield return new OsuModTarget();
if (mods.HasFlag(LegacyMods.TouchDevice))
yield return new OsuModTouchDevice();
}
public override IEnumerable<Mod> GetModsFor(ModType type)

View File

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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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,

View File

@ -163,18 +163,14 @@ namespace osu.Game.Beatmaps
downloadNotification.Progress = progress;
};
request.Success += data =>
request.Success += filename =>
{
downloadNotification.Text = $"Importing {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}";
Task.Factory.StartNew(() =>
{
BeatmapSetInfo importedBeatmap;
// This gets scheduled back to the update thread, but we want the import to run in the background.
using (var stream = new MemoryStream(data))
using (var archive = new ZipArchiveReader(stream, beatmapSetInfo.ToString()))
importedBeatmap = Import(archive);
var importedBeatmap = Import(filename);
downloadNotification.CompletionClickAction = () =>
{

View File

@ -150,25 +150,9 @@ namespace osu.Game.Database
{
notification.Text = $"Importing ({++current} of {paths.Length})\n{Path.GetFileName(path)}";
TModel import;
using (ArchiveReader reader = getReaderFrom(path))
imported.Add(import = Import(reader));
imported.Add(Import(path));
notification.Progress = (float)current / paths.Length;
// We may or may not want to delete the file depending on where it is stored.
// e.g. reconstructing/repairing database with items from default storage.
// Also, not always a single file, i.e. for LegacyFilesystemReader
// TODO: Add a check to prevent files from storage to be deleted.
try
{
if (import != null && File.Exists(path))
File.Delete(path);
}
catch (Exception e)
{
Logger.Error(e, $@"Could not delete original file after import ({Path.GetFileName(path)})");
}
}
catch (Exception e)
{
@ -195,6 +179,34 @@ namespace osu.Game.Database
}
}
/// <summary>
/// Import one <see cref="TModel"/> from the filesystem and delete the file on success.
/// </summary>
/// <param name="path">The archive location on disk.</param>
/// <returns>The imported model, if successful.</returns>
public TModel Import(string path)
{
TModel import;
using (ArchiveReader reader = getReaderFrom(path))
import = Import(reader);
// We may or may not want to delete the file depending on where it is stored.
// e.g. reconstructing/repairing database with items from default storage.
// Also, not always a single file, i.e. for LegacyFilesystemReader
// TODO: Add a check to prevent files from storage to be deleted.
try
{
if (import != null && File.Exists(path))
File.Delete(path);
}
catch (Exception e)
{
Logger.Error(e, $@"Could not delete original file after import ({Path.GetFileName(path)})");
}
return import;
}
protected virtual void PresentCompletedImport(IEnumerable<TModel> imported)
{
}

View File

@ -50,6 +50,7 @@ namespace osu.Game.Graphics.Cursor
if (!CanShowCursor)
{
currentTarget?.Cursor?.Hide();
currentTarget = null;
return;
}

View File

@ -10,45 +10,30 @@ namespace osu.Game.Graphics.UserInterface
/// <summary>
/// A <see cref="BreadcrumbControl"/> which follows the active screen (and allows navigation) in a <see cref="Screen"/> stack.
/// </summary>
public class ScreenBreadcrumbControl : BreadcrumbControl<Screen>
public class ScreenBreadcrumbControl : BreadcrumbControl<IScreen>
{
private Screen last;
public ScreenBreadcrumbControl(ScreenStack stack)
{
stack.ScreenPushed += onPushed;
stack.ScreenExited += onExited;
public ScreenBreadcrumbControl(Screen initialScreen)
{
Current.ValueChanged += newScreen =>
{
if (last != newScreen && !newScreen.IsCurrentScreen)
newScreen.MakeCurrent();
};
onPushed(null, stack.CurrentScreen);
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;
AddItem(newScreen);
Current.Value = 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);
if (newScreen != null)
Current.Value = newScreen;
screenChanged(screen);
Items.ToList().SkipWhile(s => s != Current.Value).Skip(1).ForEach(RemoveItem);
}
}
}

View File

@ -1,15 +1,18 @@
// 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.
using System.IO;
using osu.Framework.IO.Network;
namespace osu.Game.Online.API
{
public abstract class APIDownloadRequest : APIRequest
{
private string filename;
protected override WebRequest CreateWebRequest()
{
var request = new WebRequest(Uri);
var request = new FileWebRequest(filename = Path.GetTempFileName(), Uri);
request.DownloadProgress += request_Progress;
return request;
}
@ -23,11 +26,11 @@ namespace osu.Game.Online.API
private void onSuccess()
{
Success?.Invoke(WebRequest.ResponseData);
Success?.Invoke(filename);
}
public event APIProgressHandler Progress;
public new event APISuccessHandler<byte[]> Success;
public new event APISuccessHandler<string> Success;
}
}

View File

@ -79,27 +79,23 @@ 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<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
private OsuScreen screenStack;
private BackgroundScreenStack backgroundStack;
private ParallaxContainer backgroundParallax;
private ScreenStack screenStack;
private VolumeOverlay volume;
private OnScreenDisplay onscreenDisplay;
private OsuLogo osuLogo;
private MainMenu menuScreen;
private Intro introScreen;
private Bindable<int> configRuleset;
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
@ -173,6 +169,8 @@ namespace osu.Game
dependencies.CacheAs(ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(ruleset);
dependencies.Cache(osuLogo = new OsuLogo());
// bind config int to database RulesetInfo
configRuleset = LocalConfig.GetBindable<int>(OsuSetting.Ruleset);
ruleset.Value = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First();
@ -211,6 +209,12 @@ namespace osu.Game
/// <param name="beatmap">The beatmap to select.</param>
public void PresentBeatmap(BeatmapSetInfo beatmap)
{
if (menuScreen == null)
{
Schedule(() => PresentBeatmap(beatmap));
return;
}
CloseAllOverlays(false);
void setBeatmap()
@ -233,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;
}
@ -268,9 +271,7 @@ namespace osu.Game
scoreLoad?.Cancel();
var menu = intro.ChildScreen;
if (menu == null)
if (menuScreen == null)
{
scoreLoad = Schedule(() => LoadScore(score, false));
return;
@ -291,7 +292,7 @@ namespace osu.Game
return;
}
if (!currentScreen.AllowExternalScreenChange)
if ((screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange != true)
{
notifications.Post(new SimpleNotification
{
@ -310,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;
}
@ -322,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)));
}
}
@ -336,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;
@ -350,6 +346,8 @@ namespace osu.Game
BeatmapManager.PresentBeatmap = PresentBeatmap;
Container logoContainer;
AddRange(new Drawable[]
{
new VolumeControlReceptor
@ -361,6 +359,16 @@ namespace osu.Game
screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays)
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
backgroundParallax = new ParallaxContainer
{
RelativeSizeAxes = Axes.Both,
Child = backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both },
},
screenStack = new ScreenStack { RelativeSizeAxes = Axes.Both },
logoContainer = new Container { RelativeSizeAxes = Axes.Both },
}
},
overlayContent = new Container
{
@ -370,12 +378,17 @@ namespace osu.Game
idleTracker = new GameIdleTracker(6000)
});
loadComponentSingleFile(screenStack = new Loader(), d =>
dependencies.Cache(backgroundStack);
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
{
@ -383,7 +396,7 @@ namespace osu.Game
OnHome = delegate
{
CloseAllOverlays(false);
intro?.ChildScreen?.MakeCurrent();
menuScreen?.MakeCurrent();
},
}, floatingOverlayContent.Add);
@ -617,7 +630,7 @@ namespace osu.Game
public bool OnPressed(GlobalAction action)
{
if (intro == null) return false;
if (introScreen == null) return false;
switch (action)
{
@ -674,19 +687,20 @@ 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 (screenStack.CurrentScreen is Loader)
return false;
if (intro == null) return true;
if (introScreen == null)
return true;
if (!intro.DidLoadMenu || intro.ChildScreen != null)
if (!introScreen.DidLoadMenu || !(screenStack.CurrentScreen is Intro))
{
Scheduler.Add(intro.MakeCurrent);
Scheduler.Add(introScreen.MakeCurrent);
return true;
}
@ -711,7 +725,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;
@ -719,7 +733,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;
}
/// <summary>
@ -748,24 +762,41 @@ 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;
switch (newScreen)
{
case Intro intro:
introScreen = intro;
break;
case MainMenu menu:
menuScreen = menu;
break;
}
private void screenAdded(Screen newScreen)
if (newScreen is IOsuScreen newOsuScreen)
{
ScreenChanged(currentScreen, newScreen);
backgroundParallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * newOsuScreen.BackgroundParallaxAmount;
OverlayActivationMode.Value = newOsuScreen.InitialOverlayActivationMode;
if (newOsuScreen.HideOverlaysOnEnter)
CloseAllOverlays();
else
Toolbar.State = Visibility.Visible;
}
}
private void screenPushed(IScreen lastScreen, IScreen newScreen)
{
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}");
ScreenChanged(lastScreen, newScreen);
Logger.Log($"Screen changed ← {newScreen}");
if (newScreen == null)
Exit();

View File

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

View File

@ -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();

View File

@ -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; })
{

View File

@ -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())
}
}
};

View File

@ -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();
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
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<BackgroundScreen>
{
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);
}
}

View File

@ -0,0 +1,32 @@
// 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.
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osuTK;
namespace osu.Game.Screens
{
public class BackgroundScreenStack : ScreenStack
{
public BackgroundScreenStack()
{
Scale = new Vector2(1.06f);
RelativeSizeAxes = Axes.Both;
}
//public float ParallaxAmount { set => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * value; }
public new void Push(BackgroundScreen screen)
{
if (screen == null)
return;
if (EqualityComparer<BackgroundScreen>.Default.Equals((BackgroundScreen)CurrentScreen, screen))
return;
base.Push(screen);
}
}
}

View File

@ -37,7 +37,7 @@ namespace osu.Game.Screens.Backgrounds
}
b.Depth = newDepth;
Add(Background = b);
AddInternal(Background = b);
Background.BlurSigma = BlurTarget;
}));
});

View File

@ -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();
}

View File

@ -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)

View File

@ -42,7 +42,7 @@ namespace osu.Game.Screens.Backgrounds
Background?.FadeOut(800, Easing.InOutSine);
Background?.Expire();
Add(Background = newBackground);
AddInternal(Background = newBackground);
currentDisplay++;
}

View File

@ -28,7 +28,7 @@ namespace osu.Game.Screens.Edit
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override bool HideOverlaysOnEnter => true;
public override bool HideOverlaysOnEnter => true;
public override bool AllowBeatmapRulesetChange => false;
private Box bottomBackground;
@ -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)

View File

@ -0,0 +1,39 @@
// 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.
using osu.Framework.Screens;
using osu.Game.Overlays;
namespace osu.Game.Screens
{
public interface IOsuScreen : IScreen
{
/// <summary>
/// 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.
/// </summary>
bool AllowBeatmapRulesetChange { get; }
bool AllowExternalScreenChange { get; }
/// <summary>
/// Whether this <see cref="OsuScreen"/> allows the cursor to be displayed.
/// </summary>
bool CursorVisible { get; }
/// <summary>
/// Whether all overlays should be hidden when this screen is entered or resumed.
/// </summary>
bool HideOverlaysOnEnter { get; }
/// <summary>
/// Whether overlays should be able to be opened once this screen is entered or resumed.
/// </summary>
OverlayActivation InitialOverlayActivationMode { get; }
/// <summary>
/// The amount of parallax to be applied while this screen is displayed.
/// </summary>
float BackgroundParallaxAmount { get; }
}
}

View File

@ -17,9 +17,9 @@ namespace osu.Game.Screens
{
private bool showDisclaimer;
protected override bool HideOverlaysOnEnter => true;
public override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
protected override bool AllowBackButton => false;
@ -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]

View File

@ -23,8 +23,8 @@ namespace osu.Game.Screens.Menu
private Color4 iconColour;
private LinkFlowContainer textFlow;
protected override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool HideOverlaysOnEnter => true;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool CursorVisible => false;
@ -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

@ -34,8 +34,8 @@ namespace osu.Game.Screens.Menu
private SampleChannel welcome;
private SampleChannel seeya;
protected override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool HideOverlaysOnEnter => true;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool CursorVisible => false;
@ -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,21 @@ 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 +168,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

@ -25,28 +25,25 @@ namespace osu.Game.Screens.Menu
{
private readonly ButtonSystem buttons;
protected override bool HideOverlaysOnEnter => buttons.State == ButtonSystemState.Initial;
public override bool HideOverlaysOnEnter => buttons.State == ButtonSystemState.Initial;
protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial;
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;
}

View File

@ -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)
{
}

View File

@ -3,8 +3,10 @@
namespace osu.Game.Screens.Multi
{
public interface IMultiplayerSubScreen
public interface IMultiplayerSubScreen : IOsuScreen
{
string Title { get; }
string ShortTitle { get; }
}
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
@ -17,6 +16,8 @@ namespace osu.Game.Screens.Multi.Lounge
{
public class LoungeSubScreen : MultiplayerSubScreen
{
public override string Title => "Lounge";
protected readonly FilterControl Filter;
private readonly Container content;
@ -24,20 +25,13 @@ namespace osu.Game.Screens.Multi.Lounge
private readonly Action<Screen> pushGameplayScreen;
private readonly ProcessingOverlay processingOverlay;
[Resolved(CanBeNull = true)]
private IRoomManager roomManager { get; set; }
public override string Title => "Lounge";
protected override Drawable TransitionContent => content;
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
{
this.pushGameplayScreen = pushGameplayScreen;
RoomInspector inspector;
Children = new Drawable[]
InternalChildren = new Drawable[]
{
Filter = new FilterControl { Depth = -1 },
content = new Container
@ -81,7 +75,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()
@ -91,8 +85,8 @@ namespace osu.Game.Screens.Multi.Lounge
content.Padding = new MarginPadding
{
Top = Filter.DrawHeight,
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + HORIZONTAL_OVERFLOW_PADDING,
Right = SearchableListOverlay.WIDTH_PADDING + HORIZONTAL_OVERFLOW_PADDING,
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
Right = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
};
}
@ -101,20 +95,19 @@ namespace osu.Game.Screens.Multi.Lounge
Filter.Search.TakeFocus();
}
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;
return base.OnExiting(next);
}
protected override void OnSuspending(Screen next)
public override void OnSuspending(IScreen next)
{
base.OnSuspending(next);
Filter.Search.HoldFocus = false;
@ -123,13 +116,13 @@ namespace osu.Game.Screens.Multi.Lounge
private void filterRooms()
{
rooms.Filter(Filter.CreateCriteria());
roomManager?.Filter(Filter.CreateCriteria());
Manager?.Filter(Filter.CreateCriteria());
}
private void joinRequested(Room room)
{
processingOverlay.Show();
roomManager?.JoinRoom(room, r =>
Manager?.JoinRoom(room, r =>
{
Push(room);
processingOverlay.Hide();
@ -142,10 +135,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)));
}
}
}

View File

@ -21,6 +21,7 @@ namespace osu.Game.Screens.Multi.Match
public class MatchSubScreen : MultiplayerSubScreen
{
public override bool AllowBeatmapRulesetChange => false;
public override string Title => room.RoomID.Value == null ? "New room" : room.Name.Value;
public override string ShortTitle => "room";
@ -36,12 +37,6 @@ namespace osu.Game.Screens.Multi.Match
[Resolved]
private BeatmapManager beatmapManager { get; set; }
[Resolved(CanBeNull = true)]
private OsuGame game { get; set; }
[Resolved(CanBeNull = true)]
private IRoomManager manager { get; set; }
public MatchSubScreen(Room room, Action<Screen> pushGameplayScreen)
{
this.room = room;
@ -55,7 +50,7 @@ namespace osu.Game.Screens.Multi.Match
GridContainer bottomRow;
MatchSettingsOverlay settings;
Children = new Drawable[]
InternalChildren = new Drawable[]
{
new GridContainer
{
@ -77,7 +72,7 @@ namespace osu.Game.Screens.Multi.Match
{
Padding = new MarginPadding
{
Left = 10 + HORIZONTAL_OVERFLOW_PADDING,
Left = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
Right = 10,
Vertical = 10,
},
@ -89,7 +84,7 @@ namespace osu.Game.Screens.Multi.Match
Padding = new MarginPadding
{
Left = 10,
Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
Right = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
Vertical = 10,
},
RelativeSizeAxes = Axes.Both,
@ -118,10 +113,9 @@ namespace osu.Game.Screens.Multi.Match
},
};
header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect
header.OnRequestSelectBeatmap = () => this.Push(new MatchSongSelect
{
Selected = addPlaylistItem,
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }
});
header.Tabs.Current.ValueChanged += t =>
@ -141,7 +135,11 @@ namespace osu.Game.Screens.Multi.Match
}
};
chat.Exit += Exit;
chat.Exit += () =>
{
if (this.IsCurrentScreen())
this.Exit();
};
}
[BackgroundDependencyLoader]
@ -150,9 +148,9 @@ namespace osu.Game.Screens.Multi.Match
beatmapManager.ItemAdded += beatmapAdded;
}
protected override bool OnExiting(Screen next)
public override bool OnExiting(IScreen next)
{
manager?.PartRoom();
Manager?.PartRoom();
return base.OnExiting(next);
}
@ -169,7 +167,7 @@ namespace osu.Game.Screens.Multi.Match
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID);
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
Game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
}
private void setRuleset(RulesetInfo ruleset)
@ -177,7 +175,7 @@ namespace osu.Game.Screens.Multi.Match
if (ruleset == null)
return;
game?.ForcefullySetRuleset(ruleset);
Game?.ForcefullySetRuleset(ruleset);
}
private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() =>
@ -192,7 +190,7 @@ namespace osu.Game.Screens.Multi.Match
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == bindings.CurrentBeatmap.Value.OnlineBeatmapID);
if (localBeatmap != null)
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
Game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
});
private void addPlaylistItem(PlaylistItem item)
@ -209,11 +207,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;
}

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
@ -15,6 +16,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Input;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Multi.Lounge;
@ -24,31 +26,56 @@ using osuTK;
namespace osu.Game.Screens.Multi
{
[Cached]
public class Multiplayer : OsuScreen, IOnlineComponent
public class Multiplayer : CompositeDrawable, IOsuScreen, IOnlineComponent
{
private readonly MultiplayerWaveContainer waves;
public bool AllowBeatmapRulesetChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowBeatmapRulesetChange ?? true;
public bool AllowExternalScreenChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true;
public bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true;
public override bool AllowBeatmapRulesetChange => currentSubScreen?.AllowBeatmapRulesetChange ?? base.AllowBeatmapRulesetChange;
public bool HideOverlaysOnEnter => false;
public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public float BackgroundParallaxAmount => 1;
public bool ValidForResume { get; set; } = true;
public bool ValidForPush { get; set; } = true;
public override bool RemoveWhenNotAlive => false;
private readonly MultiplayerWaveContainer waves;
private readonly OsuButton createButton;
private readonly LoungeSubScreen loungeSubScreen;
private OsuScreen currentSubScreen;
private readonly ScreenStack screenStack;
[Cached(Type = typeof(IRoomManager))]
private RoomManager roomManager;
[Resolved]
private IBindableBeatmap beatmap { get; set; }
[Resolved]
private OsuGameBase game { get; set; }
[Resolved]
private APIAccess api { get; set; }
[Resolved(CanBeNull = true)]
private OsuLogo logo { get; set; }
public Multiplayer()
{
Child = waves = new MultiplayerWaveContainer
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
InternalChild = waves = new MultiplayerWaveContainer
{
RelativeSizeAxes = Axes.Both,
};
Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING };
screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen(this.Push)) { RelativeSizeAxes = Axes.Both };
Padding = new MarginPadding { Horizontal = -OsuScreen.HORIZONTAL_OVERFLOW_PADDING };
waves.AddRange(new Drawable[]
{
@ -76,9 +103,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,
@ -88,7 +115,7 @@ namespace osu.Game.Screens.Multi
Margin = new MarginPadding
{
Top = 10,
Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
Right = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
},
Text = "Create room",
Action = () => loungeSubScreen.Push(new Room
@ -99,8 +126,8 @@ namespace osu.Game.Screens.Multi
roomManager = new RoomManager()
});
screenAdded(loungeSubScreen);
loungeSubScreen.Exited += _ => Exit();
screenStack.ScreenPushed += screenPushed;
screenStack.ScreenExited += screenExited;
}
private readonly IBindable<bool> isIdle = new BindableBool();
@ -122,7 +149,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}");
}
@ -135,114 +162,106 @@ 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 void OnEntering(IScreen last)
{
Content.FadeIn();
this.FadeIn();
base.OnEntering(last);
waves.Show();
}
protected override bool OnExiting(Screen next)
public bool OnExiting(IScreen next)
{
waves.Hide();
Content.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut();
this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut();
cancelLooping();
if (screenStack.CurrentScreen != null)
loungeSubScreen.MakeCurrent();
updatePollingRate(isIdle.Value);
return base.OnExiting(next);
// the wave overlay transition takes longer than expected to run.
logo?.AppendAnimatingAction(() => logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut(), false);
return false;
}
protected override void OnResuming(Screen last)
public void OnResuming(IScreen last)
{
base.OnResuming(last);
this.FadeIn(250);
this.ScaleTo(1, 250, Easing.OutSine);
Content.FadeIn(250);
Content.ScaleTo(1, 250, Easing.OutSine);
logo?.AppendAnimatingAction(() => OsuScreen.ApplyLogoArrivingDefaults(logo), true);
updatePollingRate(isIdle.Value);
}
protected override void OnSuspending(Screen next)
public 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;
base.OnSuspending(next);
}
private void cancelLooping()
{
var track = Beatmap.Value.Track;
var track = beatmap.Value.Track;
if (track != null)
track.Looping = false;
}
protected override void LogoExiting(OsuLogo logo)
{
// the wave overlay transition takes longer than expected to run.
logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut();
base.LogoExiting(logo);
}
protected override void Update()
{
base.Update();
if (!IsCurrentScreen) return;
if (!this.IsCurrentScreen()) return;
if (currentSubScreen is MatchSubScreen)
if (screenStack.CurrentScreen is MatchSubScreen)
{
var track = Beatmap.Value.Track;
var track = beatmap.Value.Track;
if (track != null)
{
track.Looping = true;
if (!track.IsRunning)
{
Game.Audio.AddItemToList(track);
track.Seek(Beatmap.Value.Metadata.PreviewTime);
game.Audio.AddItemToList(track);
track.Seek(beatmap.Value.Metadata.PreviewTime);
track.Start();
}
}
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);
if (screenStack.CurrentScreen == null)
this.Exit();
}
protected override void Dispose(bool isDisposing)

View File

@ -1,49 +1,95 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
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.Overlays;
namespace osu.Game.Screens.Multi
{
public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen
public abstract class MultiplayerSubScreen : CompositeDrawable, IMultiplayerSubScreen, IKeyBindingHandler<GlobalAction>
{
protected virtual Drawable TransitionContent => Content;
public virtual bool AllowBeatmapRulesetChange => true;
public bool AllowExternalScreenChange => true;
public bool CursorVisible => true;
public bool HideOverlaysOnEnter => false;
public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public float BackgroundParallaxAmount => 1;
public bool ValidForResume { get; set; } = true;
public bool ValidForPush { get; set; } = true;
public override bool RemoveWhenNotAlive => false;
public abstract string Title { get; }
public virtual string ShortTitle => Title;
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
[Resolved]
protected IBindableBeatmap Beatmap { get; private set; }
Content.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
TransitionContent.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
[Resolved(CanBeNull = true)]
protected OsuGame Game { get; private set; }
[Resolved(CanBeNull = true)]
protected IRoomManager Manager { get; private set; }
protected MultiplayerSubScreen()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
}
protected override bool OnExiting(Screen next)
public virtual void OnEntering(IScreen last)
{
Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
TransitionContent.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
return base.OnExiting(next);
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
}
protected override void OnResuming(Screen last)
public virtual bool OnExiting(IScreen next)
{
base.OnResuming(last);
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
Content.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
return false;
}
protected override void OnSuspending(Screen next)
public virtual void OnResuming(IScreen last)
{
base.OnSuspending(next);
Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
TransitionContent.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
}
public virtual void OnSuspending(IScreen next)
{
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
}
public virtual bool OnPressed(GlobalAction action)
{
if (!this.IsCurrentScreen()) return false;
if (action == GlobalAction.Back)
{
this.Exit();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
public override string ToString() => Title;
}
}

View File

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

View File

@ -1,7 +1,6 @@
// 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.
using System;
using Microsoft.EntityFrameworkCore.Internal;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -11,17 +10,14 @@ 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<GlobalAction>, IHasDescription
public abstract class OsuScreen : Screen, IOsuScreen, IKeyBindingHandler<GlobalAction>, IHasDescription
{
/// <summary>
/// The amount of negative padding that should be applied to game background content which touches both the left and right sides of the screen.
@ -29,8 +25,6 @@ namespace osu.Game.Screens
/// </summary>
public const float HORIZONTAL_OVERFLOW_PADDING = 50;
public BackgroundScreen Background { get; private set; }
/// <summary>
/// A user-facing title for this screen.
/// </summary>
@ -42,80 +36,62 @@ namespace osu.Game.Screens
public virtual bool AllowExternalScreenChange => false;
/// <summary>
/// Override to create a BackgroundMode for the current screen.
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
/// </summary>
protected virtual BackgroundScreen CreateBackground() => null;
private Action updateOverlayStates;
/// <summary>
/// Whether all overlays should be hidden when this screen is entered or resumed.
/// </summary>
protected virtual bool HideOverlaysOnEnter => false;
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
public virtual bool HideOverlaysOnEnter => false;
/// <summary>
/// Whether overlays should be able to be opened once this screen is entered or resumed.
/// </summary>
protected virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
/// <summary>
/// Whether this <see cref="OsuScreen"/> allows the cursor to be displayed.
/// </summary>
public virtual bool CursorVisible => true;
protected new OsuGameBase Game => base.Game as OsuGameBase;
private OsuLogo logo;
/// <summary>
/// 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.
/// </summary>
public virtual bool AllowBeatmapRulesetChange => true;
protected readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
protected virtual float BackgroundParallaxAmount => 1;
private ParallaxContainer backgroundParallaxContainer;
public virtual float BackgroundParallaxAmount => 1;
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
private SampleChannel sampleExit;
protected BackgroundScreen Background => backgroundStack?.CurrentScreen as BackgroundScreen;
private BackgroundScreen localBackground;
[Resolved(canBeNull: true)]
private BackgroundScreenStack backgroundStack { get; set; }
[Resolved(canBeNull: true)]
private OsuLogo logo { get; set; }
protected OsuScreen()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
[BackgroundDependencyLoader(true)]
private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable<RulesetInfo> ruleset)
{
Beatmap.BindTo(beatmap);
Ruleset.BindTo(ruleset);
if (osu != null)
{
OverlayActivationMode.BindTo(osu.OverlayActivationMode);
updateOverlayStates = () =>
{
if (HideOverlaysOnEnter)
osu.CloseAllOverlays();
else
osu.Toolbar.State = Visibility.Visible;
};
}
sampleExit = audio.Sample.Get(@"UI/screen-back");
}
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;
}
@ -124,7 +100,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);
@ -132,71 +108,32 @@ 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);
backgroundStack?.Push(localBackground = CreateBackground());
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;
if (localBackground != null && backgroundStack?.CurrentScreen == localBackground)
backgroundStack?.Exit();
Beatmap.UnbindAll();
return false;
}
@ -205,6 +142,24 @@ namespace osu.Game.Screens
/// Fired when this screen was entered or resumed and the logo state is required to be adjusted.
/// </summary>
protected virtual void LogoArriving(OsuLogo logo, bool resuming)
{
ApplyLogoArrivingDefaults(logo);
}
private void applyArrivingDefaults(bool isResuming)
{
logo?.AppendAnimatingAction(() =>
{
if (this.IsCurrentScreen()) LogoArriving(logo, isResuming);
}, true);
}
/// <summary>
/// Applies default animations to an arriving logo.
/// Todo: This should not exist.
/// </summary>
/// <param name="logo">The logo to apply animations to.</param>
public static void ApplyLogoArrivingDefaults(OsuLogo logo)
{
logo.Action = null;
logo.FadeOut(300, Easing.OutQuint);
@ -216,24 +171,9 @@ namespace osu.Game.Screens
logo.Ripple = true;
}
private void applyArrivingDefaults(bool isResuming)
{
logo.AppendAnimatingAction(() =>
{
if (IsCurrentScreen) LogoArriving(logo, isResuming);
}, true);
if (backgroundParallaxContainer != null)
backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount;
OverlayActivationMode.Value = InitialOverlayActivationMode;
updateOverlayStates?.Invoke();
}
private void onExitingLogo()
{
logo.AppendAnimatingAction(() => { LogoExiting(logo); }, false);
logo?.AppendAnimatingAction(() => LogoExiting(logo), false);
}
/// <summary>
@ -245,7 +185,7 @@ namespace osu.Game.Screens
private void onSuspendingLogo()
{
logo.AppendAnimatingAction(() => { LogoSuspending(logo); }, false);
logo?.AppendAnimatingAction(() => LogoSuspending(logo), false);
}
/// <summary>
@ -254,5 +194,11 @@ namespace osu.Game.Screens
protected virtual void LogoSuspending(OsuLogo logo)
{
}
/// <summary>
/// Override to create a BackgroundMode for the current screen.
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
/// </summary>
protected virtual BackgroundScreen CreateBackground() => null;
}
}

View File

@ -40,11 +40,11 @@ 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;
public override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
public Action RestartRequested;
@ -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();

View File

@ -30,10 +30,12 @@ namespace osu.Game.Screens.Play
private Player player;
private Container content;
private BeatmapMetadataDisplay info;
private bool hideOverlays;
protected override bool HideOverlaysOnEnter => hideOverlays;
public override bool HideOverlaysOnEnter => hideOverlays;
private Task loadTask;
@ -51,14 +53,20 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader]
private void load()
{
Add(info = new BeatmapMetadataDisplay(Beatmap.Value)
InternalChild = content = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
info = new BeatmapMetadataDisplay(Beatmap.Value)
{
Alpha = 0,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
Add(new FillFlowContainer<PlayerSettingsGroup>
},
new FillFlowContainer<PlayerSettingsGroup>
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
@ -71,14 +79,16 @@ namespace osu.Game.Screens.Play
visualSettings = new VisualSettings(),
new InputSettings()
}
});
}
}
};
loadNewPlayer();
}
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 +115,21 @@ namespace osu.Game.Screens.Play
private void contentIn()
{
Content.ScaleTo(1, 650, Easing.OutQuint);
Content.FadeInFromZero(400);
content.ScaleTo(1, 650, Easing.OutQuint);
content.FadeInFromZero(400);
}
private void contentOut()
{
Content.ScaleTo(0.7f, 300, Easing.InQuint);
Content.FadeOut(250);
content.ScaleTo(0.7f, 300, Easing.InQuint);
content.FadeOut(250);
}
protected override void OnEntering(Screen last)
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
Content.ScaleTo(0.7f);
content.ScaleTo(0.7f);
contentIn();
@ -154,11 +164,12 @@ namespace osu.Game.Screens.Play
protected override void OnHoverLost(HoverLostEvent e)
{
if (GetContainingInputManager().HoveredDrawables.Contains(visualSettings))
if (GetContainingInputManager()?.HoveredDrawables.Contains(visualSettings) == true)
{
// show user setting preview
UpdateBackgroundElements();
}
base.OnHoverLost(e);
}
@ -170,7 +181,7 @@ namespace osu.Game.Screens.Play
private void pushWhenLoaded()
{
if (!IsCurrentScreen) return;
if (!this.IsCurrentScreen()) return;
try
{
@ -191,7 +202,7 @@ namespace osu.Game.Screens.Play
this.Delay(250).Schedule(() =>
{
if (!IsCurrentScreen) return;
if (!this.IsCurrentScreen()) return;
loadTask = null;
@ -200,9 +211,9 @@ namespace osu.Game.Screens.Play
ValidForResume = false;
if (player.LoadedBeatmapSuccessfully)
Push(player);
this.Push(player);
else
Exit();
this.Exit();
});
}, 500);
}
@ -218,15 +229,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);
content.ScaleTo(0.7f, 150, Easing.InQuint);
this.FadeOut(150);
cancelLoad();

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Play
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background;
protected new BackgroundScreenBeatmap Background => base.Background as BackgroundScreenBeatmap;
public override bool AllowBeatmapRulesetChange => false;
@ -40,7 +40,7 @@ namespace osu.Game.Screens.Play
ShowStoryboard = config.GetBindable<bool>(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
/// <param name="userChange"></param>
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);

View File

@ -55,7 +55,7 @@ namespace osu.Game.Screens.Ranking
private IEnumerable<Drawable> 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
},
};

View File

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

View File

@ -1,6 +1,8 @@
// 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.
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;
}
}

View File

@ -3,6 +3,8 @@
using System;
using Humanizer;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi;
@ -15,6 +17,11 @@ namespace osu.Game.Screens.Select
public string ShortTitle => "song selection";
public override string Title => ShortTitle.Humanize();
public MatchSongSelect()
{
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
}
protected override bool OnStart()
{
var item = new PlaylistItem
@ -28,8 +35,8 @@ namespace osu.Game.Screens.Select
Selected?.Invoke(item);
if (IsCurrentScreen)
Exit();
if (this.IsCurrentScreen())
this.Exit();
return true;
}

View File

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

View File

@ -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
{
@ -123,16 +123,6 @@ namespace osu.Game.Screens.Select
Padding = new MarginPadding { Top = 10, Right = 5 },
}
},
beatmapInfoWedge = new BeatmapInfoWedge
{
Size = wedged_container_size,
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding
{
Top = left_area_padding,
Right = left_area_padding,
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
@ -166,13 +156,23 @@ namespace osu.Game.Screens.Select
Background = { Width = 2 },
Exit = () =>
{
if (IsCurrentScreen)
Exit();
if (this.IsCurrentScreen())
this.Exit();
},
},
}
},
},
beatmapInfoWedge = new BeatmapInfoWedge
{
Size = wedged_container_size,
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding
{
Top = left_area_padding,
Right = left_area_padding,
},
},
new ResetScrollContainer(() => Carousel.ScrollToSelected())
{
RelativeSizeAxes = Axes.Y,
@ -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());
}
/// <summary>
@ -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)
{

View File

@ -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
{
@ -29,7 +30,7 @@ namespace osu.Game.Screens.Tournament
{
private const string results_filename = "drawings_results.txt";
protected override bool HideOverlaysOnEnter => true;
public override bool HideOverlaysOnEnter => true;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
@ -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
{

View File

@ -1,6 +1,8 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Game.Screens;
@ -11,38 +13,25 @@ namespace osu.Game.Tests.Visual
/// </summary>
public abstract class ScreenTestCase : OsuTestCase
{
private readonly TestOsuScreen baseScreen;
private readonly ScreenStack stack;
[Cached]
private BackgroundScreenStack backgroundStack;
protected ScreenTestCase()
{
Add(baseScreen = new TestOsuScreen());
Children = new Drawable[]
{
backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both },
stack = new ScreenStack { RelativeSizeAxes = Axes.Both }
};
}
protected void LoadScreen(OsuScreen screen) => baseScreen.LoadScreen(screen);
public class TestOsuScreen : OsuScreen
protected void LoadScreen(OsuScreen screen)
{
private OsuScreen nextScreen;
public void LoadScreen(OsuScreen screen) => Schedule(() =>
{
nextScreen = screen;
if (IsCurrentScreen)
{
Push(screen);
nextScreen = null;
}
else
MakeCurrent();
});
protected override void OnResuming(Screen last)
{
base.OnResuming(last);
if (nextScreen != null)
LoadScreen(nextScreen);
}
if (stack.CurrentScreen != null)
stack.Exit();
stack.Push(screen);
}
}
}

View File

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

View File

@ -15,8 +15,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2019.125.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.131.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -104,9 +104,9 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2019.125.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.125.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.131.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.131.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />