Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
LoginDialogUI.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
SCR_LoginDialogUI
:
SCR_LoginProcessDialogUI
3
{
4
protected
const
string
USERNAME_WIDGET
=
"UserName"
;
5
protected
const
string
PASSWORD_WIDGET
=
"Password"
;
6
7
protected
SCR_EditBoxComponent
m_UserName
;
8
protected
SCR_EditBoxComponent
m_Password
;
9
10
//------------------------------------------------------------------------------------------------
11
override
void
OnMenuOpen
(
SCR_ConfigurableDialogUiPreset
preset)
12
{
13
super.OnMenuOpen(preset);
14
15
// Load credentials
16
string
name =
BohemiaAccountApi
.GetEmail();
17
m_UserName
=
SCR_EditBoxComponent
.
GetEditBoxComponent
(
USERNAME_WIDGET
,
m_wRoot
);
18
if
(
m_UserName
)
19
{
20
m_UserName
.SetValue(name);
21
m_UserName
.m_OnChanged.Insert(
CheckFilledEditBoxes
);
22
23
GetGame
().GetWorkspace().SetFocusedWidget(
m_UserName
.GetRootWidget());
24
}
25
26
m_Password
=
SCR_EditBoxComponent
.
GetEditBoxComponent
(
PASSWORD_WIDGET
,
m_wRoot
);
27
if
(
m_Password
)
28
m_Password
.m_OnChanged.Insert(
CheckFilledEditBoxes
);
29
30
CheckFilledEditBoxes
();
31
}
32
33
//------------------------------------------------------------------------------------------------
34
override
void
OnConfirm
()
35
{
36
if
(
m_bIsLoading
|| !
m_UserName
|| !
m_Password
)
37
return
;
38
39
string
user =
m_UserName
.GetValue().Trim();
40
41
if
(!
VerifyFormatting
(user))
42
{
43
ShowWarningMessage
(
true
);
44
return
;
45
}
46
47
// Verify credentials
48
BohemiaAccountApi
.Link(
m_Callback
, user,
m_Password
.GetValue(),
""
);
49
50
super.OnConfirm();
51
}
52
53
//------------------------------------------------------------------------------------------------
54
override
void
OnFailDelayed
(
BackendCallback
callback)
55
{
56
if
(callback.GetHttpCode() ==
SCR_ELoginFailReason
.TWO_FACTOR_AUTHENTICATION)
57
{
58
SCR_LoginProcessDialogUI
.
Create2FADialog
(
m_UserName
.GetValue().Trim(),
m_Password
.GetValue());
59
Close
();
60
}
61
else
62
{
63
super.OnFailDelayed(callback);
64
}
65
}
66
67
//------------------------------------------------------------------------------------------------
68
override
void
ShowWarningMessage
(
bool
show)
69
{
70
super.ShowWarningMessage(show);
71
72
if
(!show)
73
return
;
74
75
if
(
m_UserName
)
76
m_UserName
.OnInvalidInput();
77
78
if
(
m_Password
)
79
m_Password
.OnInvalidInput();
80
}
81
82
//------------------------------------------------------------------------------------------------
83
// Username must be
[email protected]
format
84
override
bool
VerifyFormatting
(
string
text)
85
{
86
// check for spaces and @
87
if
(text.IsEmpty() || text.Contains(
" "
) || !text.Contains(
"@"
) || text.LastIndexOf(
"@"
) == text.Length() - 1)
88
return
false
;
89
90
array<string> substrings = {};
91
text.Split(
"@"
, substrings,
true
);
92
93
// make sure there's only one @
94
if
(substrings.IsEmpty() || substrings.Count() != 2)
95
return
false
;
96
97
// check if the domain contains . and it's not the last symbol
98
string
domain = substrings[1];
99
if
(domain.IsEmpty() || !domain.Contains(
"."
) || domain[0] ==
"."
|| domain.LastIndexOf(
"."
) == domain.Length() - 1)
100
return
false
;
101
102
// make sure there's no symbols except . in the domain string
103
for
(
int
i = 0; i < domain.Length(); i++)
104
{
105
string
char
= domain[i];
106
107
if
(
char
==
"."
)
108
continue
;
109
110
int
ascii =
char
.ToAscii();
111
112
bool
number = ascii >= 48 && ascii <= 57;
113
bool
capLetter = ascii >= 65 && ascii <= 90;
114
bool
letter = ascii >= 97 && ascii <= 122;
115
116
if
(!number && !capLetter && !letter)
117
return
false
;
118
}
119
120
return
super.VerifyFormatting(text);
121
}
122
123
//------------------------------------------------------------------------------------------------
124
protected
void
CheckFilledEditBoxes
()
125
{
126
m_bForceConfirmButtonDisabled
=
m_UserName
.GetValue().IsEmpty() ||
m_Password
.GetValue().IsEmpty();
127
if
(
m_ConfirmButton
)
128
m_ConfirmButton
.SetEnabled(!
m_bForceConfirmButtonDisabled
&&
UpdateButtons
());
129
}
130
}
131
132
//------------------------------------------------------------------------------------------------
133
class
SCR_LoginDialogConsoleUI :
SCR_LoginDialogUI
134
{
135
protected
const
string
OVERLAY_MAIN
=
"OverlayMain"
;
136
137
protected
OverlayWidget
m_wOverlayMain
;
138
139
//------------------------------------------------------------------------------------------------
140
override
void
OnMenuOpen
(
SCR_ConfigurableDialogUiPreset
preset)
141
{
142
super.OnMenuOpen(preset);
143
144
m_wOverlayMain
=
OverlayWidget
.Cast(
m_wRoot
.FindAnyWidget(
OVERLAY_MAIN
));
145
}
146
147
//------------------------------------------------------------------------------------------------
148
// The dialog has a unique structure so we need to attach the loading overlay to a different Widget than other dialogs
149
override
OverlayWidget
GetDialogBaseOverlay
()
150
{
151
return
m_wOverlayMain
;
152
}
153
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
OVERLAY_MAIN
SCR_LoginDialogUI OVERLAY_MAIN
GetDialogBaseOverlay
override OverlayWidget GetDialogBaseOverlay()
Definition
LoginDialogUI.c:149
m_wOverlayMain
OverlayWidget m_wOverlayMain
Definition
LoginDialogUI.c:137
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
SCR_ELoginFailReason
SCR_ELoginFailReason
Definition
SCR_LoginProcessDialogUI.c:372
OnMenuOpen
override void OnMenuOpen()
Definition
SCR_ProfileSuperMenu.c:12
BackendCallback
Definition
Backend_Storage.c:5
BohemiaAccountApi
Definition
BohemiaAccountApi.c:19
OverlayWidget
Definition
OverlayWidget.c:16
SCR_ConfigurableDialogUi::Close
void Close()
Definition
SCR_ConfigurableDialogUI.c:254
SCR_ConfigurableDialogUi::m_wRoot
Widget m_wRoot
Definition
SCR_ConfigurableDialogUI.c:66
SCR_ConfigurableDialogUiPreset
Configuration for a dialog.
Definition
SCR_ConfigurableDialogUI.c:764
SCR_EditBoxComponent
Definition
SCR_EditBoxComponent.c:9
SCR_EditBoxComponent::GetEditBoxComponent
static SCR_EditBoxComponent GetEditBoxComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_EditBoxComponent.c:382
SCR_LoginDialogUI
Definition
LoginDialogUI.c:3
SCR_LoginDialogUI::PASSWORD_WIDGET
const string PASSWORD_WIDGET
Definition
LoginDialogUI.c:5
SCR_LoginDialogUI::CheckFilledEditBoxes
void CheckFilledEditBoxes()
Definition
LoginDialogUI.c:124
SCR_LoginDialogUI::m_Password
SCR_EditBoxComponent m_Password
Definition
LoginDialogUI.c:8
SCR_LoginDialogUI::VerifyFormatting
override bool VerifyFormatting(string text)
Definition
LoginDialogUI.c:84
SCR_LoginDialogUI::OnFailDelayed
override void OnFailDelayed(BackendCallback callback)
Definition
LoginDialogUI.c:54
SCR_LoginDialogUI::OnMenuOpen
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
Definition
LoginDialogUI.c:11
SCR_LoginDialogUI::OnConfirm
override void OnConfirm()
Definition
LoginDialogUI.c:34
SCR_LoginDialogUI::ShowWarningMessage
override void ShowWarningMessage(bool show)
Definition
LoginDialogUI.c:68
SCR_LoginDialogUI::m_UserName
SCR_EditBoxComponent m_UserName
Definition
LoginDialogUI.c:7
SCR_LoginDialogUI::USERNAME_WIDGET
const string USERNAME_WIDGET
Definition
LoginDialogUI.c:4
SCR_LoginProcessDialogUI
Definition
SCR_LoginProcessDialogUI.c:6
SCR_LoginProcessDialogUI::m_Callback
ref BackendCallback m_Callback
Definition
SCR_LoginProcessDialogUI.c:32
SCR_LoginProcessDialogUI::UpdateButtons
bool UpdateButtons()
Definition
SCR_LoginProcessDialogUI.c:164
SCR_LoginProcessDialogUI::m_ConfirmButton
SCR_InputButtonComponent m_ConfirmButton
Definition
SCR_LoginProcessDialogUI.c:19
SCR_LoginProcessDialogUI::m_bIsLoading
bool m_bIsLoading
Definition
SCR_LoginProcessDialogUI.c:30
SCR_LoginProcessDialogUI::Create2FADialog
static void Create2FADialog(string name, string code)
Definition
SCR_LoginProcessDialogUI.c:66
SCR_LoginProcessDialogUI::m_bForceConfirmButtonDisabled
bool m_bForceConfirmButtonDisabled
Definition
SCR_LoginProcessDialogUI.c:29
scripts
Game
UI
Menu
LoginDialogUI.c
Generated by
1.17.0