mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 15:02:54 +08:00
Update various components to handle new state
This commit is contained in:
parent
0e4244a692
commit
285f740e2a
@ -82,7 +82,7 @@ namespace osu.Game.Overlays.Login
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case APIState.RequiresSecondFactorAuth:
|
case APIState.RequiresSecondFactorAuth:
|
||||||
Child = form = new AccountVerificationForm();
|
Child = form = new SecondFactorAuthForm();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APIState.Failing:
|
case APIState.Failing:
|
||||||
|
@ -8,15 +8,20 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Login
|
namespace osu.Game.Overlays.Login
|
||||||
{
|
{
|
||||||
public partial class AccountVerificationForm : FillFlowContainer
|
public partial class SecondFactorAuthForm : FillFlowContainer
|
||||||
{
|
{
|
||||||
private OsuTextBox code = null!;
|
private OsuTextBox codeTextBox = null!;
|
||||||
private LinkFlowContainer explainText = null!;
|
private LinkFlowContainer explainText = null!;
|
||||||
|
private ErrorTextFlowContainer errorText = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -43,18 +48,18 @@ namespace osu.Game.Overlays.Login
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Text = "An email has been sent to you with a verification code. Enter the code.",
|
Text = "An email has been sent to you with a verification code. Enter the code.",
|
||||||
},
|
},
|
||||||
code = new OsuTextBox
|
codeTextBox = new OsuTextBox
|
||||||
{
|
{
|
||||||
PlaceholderText = "Enter code",
|
PlaceholderText = "Enter code",
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
TabbableContentContainer = this
|
TabbableContentContainer = this,
|
||||||
},
|
},
|
||||||
explainText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(weight: FontWeight.Regular))
|
explainText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(weight: FontWeight.Regular))
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
},
|
},
|
||||||
new ErrorTextFlowContainer
|
errorText = new ErrorTextFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
@ -78,6 +83,21 @@ namespace osu.Game.Overlays.Login
|
|||||||
explainText.AddText(" or ");
|
explainText.AddText(" or ");
|
||||||
explainText.AddLink("sign out", () => { });
|
explainText.AddLink("sign out", () => { });
|
||||||
explainText.AddText(".");
|
explainText.AddText(".");
|
||||||
|
|
||||||
|
codeTextBox.Current.BindValueChanged(code =>
|
||||||
|
{
|
||||||
|
if (code.NewValue.Length == 8)
|
||||||
|
{
|
||||||
|
api.AuthenticateSecondFactor(code.NewValue);
|
||||||
|
codeTextBox.Current.Disabled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (api.LastLoginError?.Message is string error)
|
||||||
|
{
|
||||||
|
errorText.Alpha = 1;
|
||||||
|
errorText.AddErrors(new[] { error });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool AcceptsFocus => true;
|
public override bool AcceptsFocus => true;
|
||||||
@ -86,7 +106,7 @@ namespace osu.Game.Overlays.Login
|
|||||||
|
|
||||||
protected override void OnFocus(FocusEvent e)
|
protected override void OnFocus(FocusEvent e)
|
||||||
{
|
{
|
||||||
Schedule(() => { GetContainingInputManager().ChangeFocus(code); });
|
Schedule(() => { GetContainingInputManager().ChangeFocus(codeTextBox); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -101,6 +101,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
switch (state.NewValue)
|
switch (state.NewValue)
|
||||||
{
|
{
|
||||||
|
case APIState.RequiresSecondFactorAuth:
|
||||||
case APIState.Connecting:
|
case APIState.Connecting:
|
||||||
TooltipText = ToolbarStrings.Connecting;
|
TooltipText = ToolbarStrings.Connecting;
|
||||||
spinner.Show();
|
spinner.Show();
|
||||||
|
Loading…
Reference in New Issue
Block a user