4 protected string m_s2FAText;
5 protected string m_sName;
6 protected string m_sCode;
8 protected ref array<SCR_EditBoxComponent> m_aEditBoxComponents = {};
10 protected Widget m_wCodeWrapper;
12 protected const int EDIT_BOX_INITIAL_FOCUS_DELAY = 100;
13 protected const int EDIT_BOX_FLICKER_TIME = 400;
25 super.OnMenuOpen(preset);
31 array<ref Widget> editBoxes = {};
34 foreach (Widget w : editBoxes)
41 BindEditBoxInputEvent(comp);
50 override void OnMenuClose()
54 GetGame().GetCallqueue().Remove(OnFailDelayed);
55 GetGame().GetCallqueue().Remove(ActivateFirstEditBox);
59 override void OnConfirm()
66 if (!VerifyFormatting(code))
68 ShowWarningMessage(
true);
72 GetGame().GetBackendApi().SetCredentialsItem(EBackendCredentials.EBCRED_NAME,
m_sName);
73 GetGame().GetBackendApi().SetCredentialsItem(EBackendCredentials.EBCRED_PWD,
m_sCode);
74 GetGame().GetBackendApi().SetCredentialsItem(EBackendCredentials.EBCRED_2FA_TOKEN, code);
91 super.OnFailDelayed(
callback, code, restCode, apiCode);
98 override bool VerifyFormatting(
string text)
100 if (!IsCodeComplete() || text.Contains(
" "))
103 for (
int i = 0; i < text.Length(); i++)
105 string char = text[i];
106 int asciiCode =
char.ToAscii();
108 if (asciiCode < 48 || asciiCode > 57)
112 return super.VerifyFormatting(text);
117 protected void ActivateFirstEditBox()
127 comp.m_OnTextChange.Insert(OnTextChange);
132 protected void OnTextChange(
string text)
134 if (m_bIsLoading || text.IsEmpty())
141 string value = comp.GetValue();
144 comp.ActivateWriteMode(
true);
151 if (IsCodeComplete())
157 protected bool IsCodeComplete()
163 protected void Clear()
169 comp.SetValue(
string.Empty);
172 GetGame().GetCallqueue().Remove(comp.ResetOverlayColor);
174 comp.ChangeOverlayColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
178 ActivateFirstEditBox();