Centralise join logic

This commit is contained in:
Dean Herbert 2021-10-19 15:27:51 +09:00
parent 32cbf6e54b
commit a589964dc7
1 changed files with 15 additions and 9 deletions

View File

@ -232,7 +232,21 @@ private void load(OsuColour colours, AudioManager audio)
sampleJoinFail = audio.Samples.Get(@"UI/password-fail");
joinButton.Action = () => lounge?.Join(room, passwordTextbox.Text, null, joinFailed);
joinButton.Action = performJoin;
}
protected override void LoadComplete()
{
base.LoadComplete();
Schedule(() => GetContainingInputManager().ChangeFocus(passwordTextbox));
passwordTextbox.OnCommit += (_, __) => performJoin();
}
private void performJoin()
{
lounge?.Join(room, passwordTextbox.Text, null, joinFailed);
GetContainingInputManager().TriggerFocusContention(passwordTextbox);
}
private void joinFailed(string error)
@ -252,14 +266,6 @@ private void joinFailed(string error)
sampleJoinFail?.Play();
}
protected override void LoadComplete()
{
base.LoadComplete();
Schedule(() => GetContainingInputManager().ChangeFocus(passwordTextbox));
passwordTextbox.OnCommit += (_, __) => lounge?.Join(room, passwordTextbox.Text, null, joinFailed);
}
}
}
}