mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:33:22 +08:00
Compare commits
11 Commits
27f7808a86
...
9b029fa9e0
Author | SHA1 | Date | |
---|---|---|---|
|
9b029fa9e0 | ||
|
91439ea2cc | ||
|
514e72bffb | ||
|
04991315f9 | ||
|
4153f8d49d | ||
|
0f40671e69 | ||
|
50c2e65e3c | ||
|
6546fd3f81 | ||
|
ec88f7a712 | ||
|
4012e878b0 | ||
|
b8d3e64416 |
@ -1,12 +1,15 @@
|
||||
// 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.Linq;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK.Graphics;
|
||||
@ -14,14 +17,14 @@ using osuTK.Graphics;
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneLoaderAnimation : ScreenTestScene
|
||||
public class TestSceneLoader : ScreenTestScene
|
||||
{
|
||||
private TestLoader loader;
|
||||
|
||||
[Cached]
|
||||
private OsuLogo logo;
|
||||
|
||||
public TestSceneLoaderAnimation()
|
||||
public TestSceneLoader()
|
||||
{
|
||||
Child = logo = new OsuLogo
|
||||
{
|
||||
@ -42,33 +45,33 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
|
||||
LoadScreen(loader);
|
||||
});
|
||||
|
||||
AddAssert("spinner did not display", () => loader.LoadingSpinner?.Alpha == 0);
|
||||
|
||||
AddUntilStep("loaded", () => loader.ScreenLoaded);
|
||||
AddUntilStep("not current", () => !loader.IsCurrentScreen());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDelayedLoad()
|
||||
{
|
||||
AddStep("begin loading", () => LoadScreen(loader = new TestLoader()));
|
||||
AddUntilStep("wait for logo visible", () => loader.Logo?.Alpha > 0);
|
||||
AddUntilStep("wait for spinner visible", () => loader.LoadingSpinner?.Alpha > 0);
|
||||
AddStep("finish loading", () => loader.AllowLoad.Set());
|
||||
AddUntilStep("loaded", () => loader.Logo != null && loader.ScreenLoaded);
|
||||
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
|
||||
AddUntilStep("spinner gone", () => loader.LoadingSpinner?.Alpha == 0);
|
||||
AddUntilStep("loaded", () => loader.ScreenLoaded);
|
||||
AddUntilStep("not current", () => !loader.IsCurrentScreen());
|
||||
}
|
||||
|
||||
private class TestLoader : Loader
|
||||
{
|
||||
public readonly ManualResetEventSlim AllowLoad = new ManualResetEventSlim();
|
||||
|
||||
public OsuLogo Logo;
|
||||
public LoadingSpinner LoadingSpinner => this.ChildrenOfType<LoadingSpinner>().FirstOrDefault();
|
||||
private TestScreen screen;
|
||||
|
||||
public bool ScreenLoaded => screen.IsCurrentScreen();
|
||||
|
||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||
{
|
||||
Logo = logo;
|
||||
base.LogoArriving(logo, resuming);
|
||||
}
|
||||
|
||||
protected override OsuScreen CreateLoadableScreen() => screen = new TestScreen();
|
||||
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler(AllowLoad);
|
||||
|
@ -54,7 +54,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
.Select(index => new Channel(new User())
|
||||
{
|
||||
Name = $"Channel no. {index}",
|
||||
Topic = index == 3 ? null : $"We talk about the number {index} here"
|
||||
Topic = index == 3 ? null : $"We talk about the number {index} here",
|
||||
Type = index % 2 == 0 ? ChannelType.PM : ChannelType.Temporary
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
@ -100,28 +101,11 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("Channel selector was closed", () => chatOverlay.SelectionOverlayState == Visibility.Hidden);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCloseChannelWhileSelectorClosed()
|
||||
{
|
||||
AddStep("Join channel 1", () => channelManager.JoinChannel(channel1));
|
||||
AddStep("Join channel 2", () => channelManager.JoinChannel(channel2));
|
||||
|
||||
AddStep("Switch to channel 2", () => clickDrawable(chatOverlay.TabMap[channel2]));
|
||||
AddStep("Close channel 2", () => clickDrawable(((TestPrivateChannelTabItem)chatOverlay.TabMap[channel2]).CloseButton.Child));
|
||||
|
||||
AddAssert("Selector remained closed", () => chatOverlay.SelectionOverlayState == Visibility.Hidden);
|
||||
AddAssert("Current channel is channel 1", () => currentChannel == channel1);
|
||||
|
||||
AddStep("Close channel 1", () => clickDrawable(((TestPrivateChannelTabItem)chatOverlay.TabMap[channel1]).CloseButton.Child));
|
||||
|
||||
AddAssert("Selector is visible", () => chatOverlay.SelectionOverlayState == Visibility.Visible);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSearchInSelector()
|
||||
{
|
||||
AddStep("search for 'no. 2'", () => chatOverlay.ChildrenOfType<SearchTextBox>().First().Text = "no. 2");
|
||||
AddUntilStep("only channel 2 visible", () =>
|
||||
AddStep("Search for 'no. 2'", () => chatOverlay.ChildrenOfType<SearchTextBox>().First().Text = "no. 2");
|
||||
AddUntilStep("Only channel 2 visible", () =>
|
||||
{
|
||||
var listItems = chatOverlay.ChildrenOfType<ChannelListItem>().Where(c => c.IsPresent);
|
||||
return listItems.Count() == 1 && listItems.Single().Channel == channel2;
|
||||
@ -131,28 +115,28 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Test]
|
||||
public void TestChannelShortcutKeys()
|
||||
{
|
||||
AddStep("join 10 channels", () => channels.ForEach(channel => channelManager.JoinChannel(channel)));
|
||||
AddStep("close channel selector", () =>
|
||||
AddStep("Join channels", () => channels.ForEach(channel => channelManager.JoinChannel(channel)));
|
||||
AddStep("Close channel selector", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.Escape);
|
||||
InputManager.ReleaseKey(Key.Escape);
|
||||
});
|
||||
AddUntilStep("wait for close", () => chatOverlay.SelectionOverlayState == Visibility.Hidden);
|
||||
AddUntilStep("Wait for close", () => chatOverlay.SelectionOverlayState == Visibility.Hidden);
|
||||
|
||||
for (int zeroBasedIndex = 0; zeroBasedIndex < 10; ++zeroBasedIndex)
|
||||
{
|
||||
var oneBasedIndex = zeroBasedIndex + 1;
|
||||
var targetNumberKey = oneBasedIndex % 10;
|
||||
var targetChannel = channels[zeroBasedIndex];
|
||||
AddStep($"press Alt+{targetNumberKey}", () => pressChannelHotkey(targetNumberKey));
|
||||
AddAssert($"channel #{oneBasedIndex} is selected", () => currentChannel == targetChannel);
|
||||
AddStep($"Press Alt+{targetNumberKey}", () => pressChannelHotkey(targetNumberKey));
|
||||
AddAssert($"Channel #{oneBasedIndex} is selected", () => currentChannel == targetChannel);
|
||||
}
|
||||
}
|
||||
|
||||
private Channel expectedChannel;
|
||||
|
||||
[Test]
|
||||
public void TestCloseChannelWhileActive()
|
||||
public void TestCloseChannelBehaviour()
|
||||
{
|
||||
AddUntilStep("Join until dropdown has channels", () =>
|
||||
{
|
||||
@ -160,8 +144,11 @@ namespace osu.Game.Tests.Visual.Online
|
||||
return true;
|
||||
|
||||
// Using temporary channels because they don't hide their names when not active
|
||||
Channel toAdd = new Channel { Name = $"test channel {joinedChannels.Count()}", Type = ChannelType.Temporary };
|
||||
channelManager.JoinChannel(toAdd);
|
||||
channelManager.JoinChannel(new Channel
|
||||
{
|
||||
Name = $"Channel no. {joinedChannels.Count() + 11}",
|
||||
Type = ChannelType.Temporary
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
@ -176,6 +163,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
chatOverlay.ChannelTabControl.RemoveChannel(currentChannel);
|
||||
});
|
||||
AddAssert("Next channel selected", () => currentChannel == expectedChannel);
|
||||
AddAssert("Selector remained closed", () => chatOverlay.SelectionOverlayState == Visibility.Hidden);
|
||||
|
||||
// Depending on the window size, one more channel might need to be closed for the selectorTab to appear
|
||||
AddUntilStep("Close channels until selector visible", () =>
|
||||
@ -194,7 +182,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
expectedChannel = previousChannel;
|
||||
chatOverlay.ChannelTabControl.RemoveChannel(currentChannel);
|
||||
});
|
||||
AddAssert("Channel changed to previous", () => currentChannel == expectedChannel);
|
||||
AddAssert("Previous channel selected", () => currentChannel == expectedChannel);
|
||||
|
||||
// Standard channel closing
|
||||
AddStep("Switch to previous channel", () => chatOverlay.ChannelTabControl.SwitchTab(-1));
|
||||
@ -203,7 +191,38 @@ namespace osu.Game.Tests.Visual.Online
|
||||
expectedChannel = nextChannel;
|
||||
chatOverlay.ChannelTabControl.RemoveChannel(currentChannel);
|
||||
});
|
||||
AddAssert("Channel changed to next", () => currentChannel == expectedChannel);
|
||||
AddAssert("Next channel selected", () => currentChannel == expectedChannel);
|
||||
|
||||
// Selector reappearing after all channels closed
|
||||
AddUntilStep("Close all channels", () =>
|
||||
{
|
||||
if (!joinedChannels.Any())
|
||||
return true;
|
||||
|
||||
chatOverlay.ChannelTabControl.RemoveChannel(joinedChannels.Last());
|
||||
return false;
|
||||
});
|
||||
AddAssert("Selector is visible", () => chatOverlay.SelectionOverlayState == Visibility.Visible);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChannelCloseButton()
|
||||
{
|
||||
AddStep("Join 2 channels", () =>
|
||||
{
|
||||
channelManager.JoinChannel(channel1);
|
||||
channelManager.JoinChannel(channel2);
|
||||
});
|
||||
|
||||
// PM channel close button only appears when active
|
||||
AddStep("Select PM channel", () => clickDrawable(chatOverlay.TabMap[channel2]));
|
||||
AddStep("Click PM close button", () => clickDrawable(((TestPrivateChannelTabItem)chatOverlay.TabMap[channel2]).CloseButton.Child));
|
||||
AddAssert("PM channel closed", () => !channelManager.JoinedChannels.Contains(channel2));
|
||||
|
||||
// Non-PM chat channel close button only appears when hovered
|
||||
AddStep("Hover normal channel tab", () => InputManager.MoveMouseTo(chatOverlay.TabMap[channel1]));
|
||||
AddStep("Click normal close button", () => clickDrawable(((TestChannelTabItem)chatOverlay.TabMap[channel1]).CloseButton.Child));
|
||||
AddAssert("All channels closed", () => !channelManager.JoinedChannels.Any());
|
||||
}
|
||||
|
||||
private void pressChannelHotkey(int number)
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected Container MainContents;
|
||||
|
||||
protected const float TRANSITION_DURATION = 500;
|
||||
public const float TRANSITION_DURATION = 500;
|
||||
|
||||
private const float spin_duration = 900;
|
||||
|
||||
@ -27,7 +27,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// Constuct a new loading spinner.
|
||||
/// </summary>
|
||||
/// <param name="withBox">Whether the spinner should have a surrounding black box for visibility.</param>
|
||||
public LoadingSpinner(bool withBox = false)
|
||||
/// <param name="inverted">Whether colours should be inverted (black spinner instead of white).</param>
|
||||
public LoadingSpinner(bool withBox = false, bool inverted = false)
|
||||
{
|
||||
Size = new Vector2(60);
|
||||
|
||||
@ -45,7 +46,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
Colour = inverted ? Color4.White : Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = withBox ? 0.7f : 0
|
||||
},
|
||||
@ -53,6 +54,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = inverted ? Color4.Black : Color4.White,
|
||||
Scale = new Vector2(withBox ? 0.6f : 1),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Icon = FontAwesome.Solid.CircleNotch
|
||||
|
@ -5,12 +5,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shaders;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
||||
|
||||
namespace osu.Game.Screens
|
||||
@ -24,31 +26,12 @@ namespace osu.Game.Screens
|
||||
ValidForResume = false;
|
||||
}
|
||||
|
||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||
{
|
||||
base.LogoArriving(logo, resuming);
|
||||
|
||||
logo.BeatMatching = false;
|
||||
logo.Triangles = false;
|
||||
logo.RelativePositionAxes = Axes.None;
|
||||
logo.Origin = Anchor.BottomRight;
|
||||
logo.Anchor = Anchor.BottomRight;
|
||||
logo.Position = new Vector2(-40);
|
||||
logo.Scale = new Vector2(0.2f);
|
||||
|
||||
logo.Delay(500).FadeInFromZero(1000, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void LogoSuspending(OsuLogo logo)
|
||||
{
|
||||
base.LogoSuspending(logo);
|
||||
logo.FadeOut(logo.Alpha * 400);
|
||||
}
|
||||
|
||||
private OsuScreen loadableScreen;
|
||||
private ShaderPrecompiler precompiler;
|
||||
|
||||
private IntroSequence introSequence;
|
||||
private LoadingSpinner spinner;
|
||||
private ScheduledDelegate spinnerShow;
|
||||
|
||||
protected virtual OsuScreen CreateLoadableScreen()
|
||||
{
|
||||
@ -82,6 +65,17 @@ namespace osu.Game.Screens
|
||||
LoadComponentAsync(precompiler = CreateShaderPrecompiler(), AddInternal);
|
||||
LoadComponentAsync(loadableScreen = CreateLoadableScreen());
|
||||
|
||||
LoadComponentAsync(spinner = new LoadingSpinner(true, true)
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Margin = new MarginPadding(40),
|
||||
}, _ =>
|
||||
{
|
||||
AddInternal(spinner);
|
||||
spinnerShow = Scheduler.AddDelayed(spinner.Show, 200);
|
||||
});
|
||||
|
||||
checkIfLoaded();
|
||||
}
|
||||
|
||||
@ -93,7 +87,15 @@ namespace osu.Game.Screens
|
||||
return;
|
||||
}
|
||||
|
||||
this.Push(loadableScreen);
|
||||
spinnerShow?.Cancel();
|
||||
|
||||
if (spinner.State.Value == Visibility.Visible)
|
||||
{
|
||||
spinner.Hide();
|
||||
Scheduler.AddDelayed(() => this.Push(loadableScreen), LoadingSpinner.TRANSITION_DURATION);
|
||||
}
|
||||
else
|
||||
this.Push(loadableScreen);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Loading…
Reference in New Issue
Block a user