1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:42:54 +08:00

Show error message in popover

This commit is contained in:
Dean Herbert 2021-09-14 14:10:55 +09:00
parent 6851e0000d
commit e3c56f9ebd
2 changed files with 32 additions and 13 deletions

View File

@ -87,10 +87,10 @@ namespace osu.Game.Screens.OnlinePlay.Components
currentJoinRoomRequest.Failure += exception =>
{
// provide error output if the operation wasn't canceled and the error doesn't stem from an invalid password
if (!(exception is OperationCanceledException) && !((APIException)exception).Message.Equals("Invalid room password", StringComparison.Ordinal))
Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
onError?.Invoke(exception.ToString());
if (exception is OperationCanceledException)
return;
onError?.Invoke(exception.Message);
};
api.Queue(currentJoinRoomRequest);

View File

@ -14,7 +14,9 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Input.Bindings;
@ -189,9 +191,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
private OsuPasswordTextBox passwordTextbox;
private TriangleButton joinButton;
private ShakeContainer shakeContainer;
private OsuSpriteText errorText;
[BackgroundDependencyLoader]
private void load()
private void load(OsuColour colours)
{
Child = shakeContainer = new ShakeContainer
{
@ -201,19 +204,32 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
{
Spacing = new Vector2(5),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
passwordTextbox = new OsuPasswordTextBox
new FillFlowContainer
{
Width = 200,
PlaceholderText = "password",
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
passwordTextbox = new OsuPasswordTextBox
{
Width = 200,
PlaceholderText = "password",
},
joinButton = new TriangleButton
{
Width = 80,
Text = "Join Room",
}
}
},
joinButton = new TriangleButton
errorText = new OsuSpriteText
{
Width = 80,
Text = "Join Room",
}
Colour = colours.Red,
},
}
}
};
@ -225,6 +241,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
{
passwordTextbox.Text = string.Empty;
errorText.Text = error;
errorText.FadeOutFromOne(1000, Easing.In);
shakeContainer.Shake();
}