4 protected const string USERNAME_WIDGET =
"UserName";
5 protected const string PASSWORD_WIDGET =
"Password";
13 super.OnMenuOpen(preset);
16 string name =
GetGame().GetBackendApi().GetCredentialsItem(EBackendCredentials.EBCRED_NAME);
20 m_UserName.SetValue(name);
21 m_UserName.m_OnChanged.Insert(CheckFilledEditBoxes);
23 GetGame().GetWorkspace().SetFocusedWidget(m_UserName.GetRootWidget());
28 m_Password.m_OnChanged.Insert(CheckFilledEditBoxes);
30 CheckFilledEditBoxes();
34 override void OnConfirm()
36 if (m_bIsLoading || !m_UserName || !m_Password)
39 string user = m_UserName.GetValue().Trim();
41 if (!VerifyFormatting(user))
43 ShowWarningMessage(
true);
48 GetGame().GetBackendApi().SetCredentialsItem(EBackendCredentials.EBCRED_NAME, user);
49 GetGame().GetBackendApi().SetCredentialsItem(EBackendCredentials.EBCRED_PWD, m_Password.GetValue());
65 super.OnFailDelayed(
callback, code, restCode, apiCode);
70 override void ShowWarningMessage(
bool show)
72 super.ShowWarningMessage(show);
78 m_UserName.OnInvalidInput();
81 m_Password.OnInvalidInput();
86 override bool VerifyFormatting(
string text)
89 if (text.IsEmpty() || text.Contains(
" ") || !text.Contains(
"@") || text.LastIndexOf(
"@") == text.Length() - 1)
92 array<string> substrings = {};
93 text.Split(
"@", substrings,
true);
96 if (substrings.IsEmpty() || substrings.Count() != 2)
100 string domain = substrings[1];
101 if (domain.IsEmpty() || !domain.Contains(
".") || domain[0] ==
"." || domain.LastIndexOf(
".") == domain.Length() - 1)
105 for (
int i = 0; i < domain.Length(); i++)
107 string char = domain[i];
112 int ascii =
char.ToAscii();
114 bool number = ascii >= 48 && ascii <= 57;
115 bool capLetter = ascii >= 65 && ascii <= 90;
116 bool letter = ascii >= 97 && ascii <= 122;
118 if (!number && !capLetter && !letter)
122 return super.VerifyFormatting(text);
126 protected void CheckFilledEditBoxes()
128 m_bForceConfirmButtonDisabled = m_UserName.GetValue().IsEmpty() || m_Password.GetValue().IsEmpty();
130 m_ConfirmButton.SetEnabled(!m_bForceConfirmButtonDisabled &&
UpdateButtons());
144 super.OnMenuOpen(preset);