mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Add better messaging when connecting or failing
This commit is contained in:
parent
7c1e3d66eb
commit
63847890d1
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
@ -61,11 +62,25 @@ namespace osu.Game.Graphics.Containers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AddLink(string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action<SpriteText> creationParameters = null)
|
public void AddLink(string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action<SpriteText> creationParameters = null)
|
||||||
|
=> createLink(AddText(text, creationParameters), text, url, linkType, linkArgument, tooltipText);
|
||||||
|
|
||||||
|
public void AddLink(string text, Action action, string tooltipText = null, Action<SpriteText> creationParameters = null)
|
||||||
|
=> createLink(AddText(text, creationParameters), text, tooltipText: tooltipText, action: action);
|
||||||
|
|
||||||
|
public void AddLink(IEnumerable<SpriteText> text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null)
|
||||||
{
|
{
|
||||||
AddInternal(new DrawableLinkCompiler(AddText(text, creationParameters).ToList())
|
foreach (var t in text)
|
||||||
|
AddArbitraryDrawable(t);
|
||||||
|
|
||||||
|
createLink(text, null, url, linkType, linkArgument, tooltipText);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createLink(IEnumerable<Drawable> drawables, string text, string url = null, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action action = null)
|
||||||
|
{
|
||||||
|
AddInternal(new DrawableLinkCompiler(drawables.OfType<SpriteText>().ToList())
|
||||||
{
|
{
|
||||||
TooltipText = tooltipText ?? (url != text ? url : string.Empty),
|
TooltipText = tooltipText ?? (url != text ? url : string.Empty),
|
||||||
Action = () =>
|
Action = action ?? (() =>
|
||||||
{
|
{
|
||||||
switch (linkType)
|
switch (linkType)
|
||||||
{
|
{
|
||||||
@ -104,7 +119,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
default:
|
default:
|
||||||
throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
|
throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
|
||||||
}
|
}
|
||||||
},
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ using osu.Game.Graphics;
|
|||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using RectangleF = osu.Framework.Graphics.Primitives.RectangleF;
|
using RectangleF = osu.Framework.Graphics.Primitives.RectangleF;
|
||||||
using Container = osu.Framework.Graphics.Containers.Container;
|
using Container = osu.Framework.Graphics.Containers.Container;
|
||||||
|
|
||||||
@ -86,25 +87,29 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case APIState.Failing:
|
case APIState.Failing:
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = "Connection failing :(",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case APIState.Connecting:
|
case APIState.Connecting:
|
||||||
|
LinkFlowContainer linkFlow;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new LoadingAnimation
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
State = Visibility.Visible,
|
||||||
Origin = Anchor.Centre,
|
Anchor = Anchor.TopCentre,
|
||||||
Text = "Connecting...",
|
Origin = Anchor.TopCentre,
|
||||||
|
},
|
||||||
|
linkFlow = new LinkFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
TextAnchor = Anchor.TopCentre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Text = state == APIState.Failing ? "Connection is failing, will attempt to reconnect... " : "Attempting to connect... ",
|
||||||
Margin = new MarginPadding { Top = 10, Bottom = 10 },
|
Margin = new MarginPadding { Top = 10, Bottom = 10 },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
linkFlow.AddLink("cancel", api.Logout, string.Empty);
|
||||||
break;
|
break;
|
||||||
case APIState.Online:
|
case APIState.Online:
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
|
Loading…
Reference in New Issue
Block a user