Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_BlockedUsersDialogUI.c
Go to the documentation of this file.
1
class
SCR_BlockedUsersDialogUI
:
SCR_ConfigurableDialogUi
2
{
3
protected
const
ResourceName
ENTRY_WIDGET_NAME
=
"{3B2D99949BCE0542}UI/layouts/Menus/Dialogs/BlockedUsersEntry.layout"
;
4
protected
const
string
ENTRY_SCROLL_LIST
=
"Users"
;
5
protected
const
ResourceName
BLOCKED_USER_DIALOG_CONFIG
=
"{12C2EC09520BE302}Configs/Blocking/BlockedUsersDialog.conf"
;
6
7
protected
const
string
UNLOCK_BUTTON
=
"unblock"
;
8
protected
const
string
VIEW_GAMECARD_BUTTON
=
"viewGamecard"
;
9
10
protected
const
string
UNBLOCK_CONFIRM_MESSAGE
=
"#AR-Blocklist_Confirm"
;
11
12
protected
const
string
PLATFORM_
13
14
protected
int
m_iMaxBlockedUserAmount
= 10;
15
16
protected
Widget
m_wUserListWidget
;
17
Widget
m_wCurrentSelectedEntry
;
18
19
SCR_InputButtonComponent
m_UnblockButton
;
20
protected
SCR_InputButtonComponent
m_GamecardButton
;
21
22
protected
SocialComponent
m_SocialComponent
;
23
24
protected
ref
BackendCallback
m_BlocklistCallback
;
25
26
// Save the widget with the userID it belongs to, to get the correct ID from the focused widget
27
ref
map<Widget, BlockListItem>
m_mUserList
=
new
map<Widget, BlockListItem>
();
28
protected
ref array<Widget>
m_aUserList
= {};
29
30
31
//------------------------------------------------------------------------------------------------
32
override
void
OnMenuOpen
(
SCR_ConfigurableDialogUiPreset
preset)
33
{
34
super.OnMenuOpen(preset);
35
36
m_wUserListWidget
=
m_wRoot
.FindAnyWidget(
ENTRY_SCROLL_LIST
);
37
if
(!
m_wUserListWidget
)
38
return
;
39
40
ListBlockedUsers
();
41
42
m_UnblockButton
=
FindButton
(
UNLOCK_BUTTON
);
43
if
(
m_UnblockButton
)
44
{
45
m_UnblockButton
.m_OnActivated.Insert(
UnblockAskConfirmation
);
46
m_UnblockButton
.SetVisible(
false
,
false
);
47
}
48
49
// Show "View Gamecard" only for ps users
50
m_GamecardButton
=
FindButton
(
VIEW_GAMECARD_BUTTON
);
51
if
(
m_GamecardButton
)
52
m_GamecardButton
.SetVisible(
false
);
53
54
GetGame
().OnInputDeviceUserChangedInvoker().Insert(
OnInputTypeChanged
);
55
56
}
57
58
//----------------------------------------------------------------------------------------------
59
protected
void
OnInputTypeChanged
(EInputDeviceType old, EInputDeviceType newDevice)
60
{
61
if
(!
m_wCurrentSelectedEntry
)
62
return
;
63
64
SCR_BlockedUsersDialogEntryUIComponent
selectedEntryComp =
SCR_BlockedUsersDialogEntryUIComponent
.Cast(
m_wCurrentSelectedEntry
.FindHandler(
SCR_BlockedUsersDialogEntryUIComponent
));
65
if
(!selectedEntryComp)
66
return
;
67
68
switch
(newDevice){
69
case
EInputDeviceType.GAMEPAD:
70
selectedEntryComp.
SetButtonsVisibility
(
false
);
71
m_UnblockButton
.SetVisible(
true
,
false
);
72
break
;
73
74
case
EInputDeviceType.MOUSE:
75
selectedEntryComp.
SetButtonsVisibility
(
true
);
76
m_UnblockButton
.SetVisible(
false
,
false
);
77
break
;
78
79
case
EInputDeviceType.KEYBOARD:
80
selectedEntryComp.
SetButtonsVisibility
(
false
);
81
m_UnblockButton
.SetVisible(
true
,
false
);
82
break
;
83
}
84
85
}
86
87
//------------------------------------------------------------------------------------------------
88
protected
void
ListBlockedUsers
()
89
{
90
GameBlocklist
blocklist =
GetGame
().GetGameBlocklist();
91
blocklist.OnBlockListUpdateInvoker.Insert(
OnBlockedListUpdated
);
92
blocklist.UpdateBlockList();
93
}
94
95
//------------------------------------------------------------------------------------------------
96
protected
void
OnBlockedListUpdated
(
bool
success)
97
{
98
if
(!success)
99
return
;
100
101
SCR_WidgetHelper
.RemoveAllChildren(
m_wUserListWidget
);
102
103
array<BlockListItem> outItems = {};
104
105
GameBlocklist
blocklist =
GetGame
().GetGameBlocklist();
106
blocklist.GetBlockedPlayers(outItems);
107
108
WorkspaceWidget
workspace =
GetGame
().GetWorkspace();
109
Widget
entry;
110
RichTextWidget
entryText;
111
SCR_ModularButtonComponent button;
112
SCR_BlockedUsersDialogEntryUIComponent
entryComp;
113
114
m_mUserList
.Clear();
115
116
foreach
(
BlockListItem
item : outItems)
117
{
118
if
(!item)
119
continue
;
120
121
entry = workspace.CreateWidgets(
ENTRY_WIDGET_NAME
,
m_wUserListWidget
);
122
if
(!entry)
123
continue
;
124
125
entryComp =
SCR_BlockedUsersDialogEntryUIComponent
.Cast(entry.FindHandler(
SCR_BlockedUsersDialogEntryUIComponent
));
126
if
(!entryComp)
127
continue
;
128
129
entryComp.
SetPlatfrom
(item.GetPlatform());
130
entryComp.
SetPlayerName
(item.GetName());
131
entryComp.
GetProfileButton
().m_OnClicked.Insert(
OnViewGamecard
);
132
entryComp.
GetUnblockButton
().m_OnClicked.Insert(
UnblockAskConfirmation
);
133
134
// Save the widget & player ID
135
m_mUserList
.Insert(entry, item);
136
137
button = SCR_ModularButtonComponent.FindComponent(entry);
138
if
(button){
139
button.m_OnFocus.Insert(
OnEntryFocused
);
140
button.m_OnFocusLost.Insert(
OnEntryFocusLost
);
141
}
142
143
}
144
}
145
146
//------------------------------------------------------------------------------------------------
147
protected
void
OnEntryFocused
(SCR_ModularButtonComponent modularButton)
148
{
149
m_wCurrentSelectedEntry
= modularButton.GetRootWidget();
150
151
SCR_BlockedUsersDialogEntryUIComponent
comp =
SCR_BlockedUsersDialogEntryUIComponent
.Cast(
m_wCurrentSelectedEntry
.FindHandler(
SCR_BlockedUsersDialogEntryUIComponent
));
152
if
(!comp)
153
return
;
154
155
if
(
GetGame
().
GetInputManager
().GetLastUsedInputDevice() == EInputDeviceType.MOUSE)
156
{
157
comp.
SetButtonsVisibility
(
true
);
158
if
(
m_UnblockButton
)
159
m_UnblockButton
.SetVisible(
false
,
false
);
160
}
161
else
162
{
163
comp.
SetButtonsVisibility
(
false
);
164
if
(
m_UnblockButton
)
165
m_UnblockButton
.SetVisible(
true
,
false
);
166
}
167
168
}
169
170
//------------------------------------------------------------------------------------------------
171
protected
void
OnEntryFocusLost
(SCR_ModularButtonComponent modularButton)
172
{
173
m_wCurrentSelectedEntry
= modularButton.GetRootWidget();
174
if
(!
m_wCurrentSelectedEntry
)
175
return
;
176
177
SCR_BlockedUsersDialogEntryUIComponent
comp =
SCR_BlockedUsersDialogEntryUIComponent
.Cast(
m_wCurrentSelectedEntry
.FindHandler(
SCR_BlockedUsersDialogEntryUIComponent
));
178
if
(!comp)
179
return
;
180
181
comp.
SetButtonsVisibility
(
false
);
182
}
183
184
//------------------------------------------------------------------------------------------------
185
protected
void
UnblockAskConfirmation
()
186
{
187
string
playerName =
SCR_BlockedUsersDialogEntryUIComponent
.Cast(
m_wCurrentSelectedEntry
.FindHandler(
SCR_BlockedUsersDialogEntryUIComponent
)).
GetPlayerName
();
188
189
SCR_ConfigurableDialogUi
dialog =
new
SCR_ConfigurableDialogUi
();
190
SCR_ConfigurableDialogUi
.
CreateFromPreset
(
BLOCKED_USER_DIALOG_CONFIG
,
"unblock_player_confirm"
, dialog);
191
192
//dialog.SetMessage(string.Format(UNBLOCK_CONFIRM_MESSAGE, playerName));
193
TextWidget
txtWidget = dialog.
GetMessageWidget
();
194
txtWidget.SetTextFormat(
UNBLOCK_CONFIRM_MESSAGE
, playerName);
195
196
dialog.
m_OnConfirm
.Insert(
OnUserUnblock
);
197
}
198
199
//------------------------------------------------------------------------------------------------
200
protected
void
OnUserUnblock
()
201
{
202
BlockListItem
userItem;
203
204
m_mUserList
.Find(
m_wCurrentSelectedEntry
, userItem);
205
206
if
(!userItem)
207
return
;
208
209
m_BlocklistCallback
=
new
BackendCallback
();
210
m_BlocklistCallback
.SetOnSuccess(
OnBlocklistRequestSuccess
);
211
m_BlocklistCallback
.SetOnError(
OnBlocklistRequestError
);
212
userItem.DeleteBlock(
m_BlocklistCallback
);
213
}
214
215
//------------------------------------------------------------------------------------------------
216
protected
void
OnViewGamecard
()
217
{
218
//TODO: Fill in with view profile functionality once it's all implemented.
219
//GetGame().GetPlayerManager().ShowUserProfile(m_wCurrentSelectedEntry.GetUserID());
220
}
221
222
//------------------------------------------------------------------------------------------------
223
override
void
OnMenuClose
()
224
{
225
if
(
m_wUserListWidget
)
226
{
227
SCR_WidgetHelper
.RemoveAllChildren(
m_wUserListWidget
);
228
}
229
GetGame
().OnInputDeviceUserChangedInvoker().Remove(
OnInputTypeChanged
);
230
}
231
232
//------------------------------------------------------------------------------------------------
233
void
OnBlocklistRequestSuccess
()
234
{
235
m_wCurrentSelectedEntry
.RemoveFromHierarchy();
236
m_mUserList
.Remove(
m_wCurrentSelectedEntry
);
237
m_wCurrentSelectedEntry
= null;
238
m_UnblockButton
.SetEnabled(
false
);
239
GetGame
().GetGameBlocklist().UpdateBlockList();
240
}
241
242
//------------------------------------------------------------------------------------------------
243
void
OnBlocklistRequestError
()
244
{
245
SCR_BlockedUsersDialogUI
dialog =
new
SCR_BlockedUsersDialogUI
();
246
SCR_ConfigurableDialogUi
.
CreateFromPreset
(
SCR_AccountWidgetComponent
.
BLOCKED_USER_DIALOG_CONFIG
,
"block_failed_general"
, dialog);
247
}
248
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetInputManager
InputManager GetInputManager()
Definition
SCR_BaseManualCameraComponent.c:205
BackendCallback
Definition
Backend_Storage.c:5
BlockListItem
Data structure for block list response.
Definition
BlockListItem.c:14
GameBlocklist
Definition
GameBlocklist.c:8
ResourceName
Definition
ResourceName.c:13
RichTextWidget
Definition
RichTextWidget.c:13
SCR_AccountWidgetComponent
Definition
SCR_AccountWidgetComponent.c:2
SCR_AccountWidgetComponent::BLOCKED_USER_DIALOG_CONFIG
static const ResourceName BLOCKED_USER_DIALOG_CONFIG
Definition
SCR_AccountWidgetComponent.c:47
SCR_BlockedUsersDialogEntryUIComponent
Definition
SCR_BlockedUsersDialogEntryUIComponent.c:2
SCR_BlockedUsersDialogEntryUIComponent::SetButtonsVisibility
void SetButtonsVisibility(bool newVis)
Definition
SCR_BlockedUsersDialogEntryUIComponent.c:82
SCR_BlockedUsersDialogEntryUIComponent::SetPlayerName
void SetPlayerName(string name)
Show the name of the player.
Definition
SCR_BlockedUsersDialogEntryUIComponent.c:46
SCR_BlockedUsersDialogEntryUIComponent::GetUnblockButton
SCR_ModularButtonComponent GetUnblockButton()
Definition
SCR_BlockedUsersDialogEntryUIComponent.c:95
SCR_BlockedUsersDialogEntryUIComponent::GetPlayerName
string GetPlayerName()
Definition
SCR_BlockedUsersDialogEntryUIComponent.c:56
SCR_BlockedUsersDialogEntryUIComponent::GetProfileButton
SCR_ModularButtonComponent GetProfileButton()
Definition
SCR_BlockedUsersDialogEntryUIComponent.c:89
SCR_BlockedUsersDialogEntryUIComponent::SetPlatfrom
void SetPlatfrom(PlatformKind platform)
Show the players platform.
Definition
SCR_BlockedUsersDialogEntryUIComponent.c:63
SCR_BlockedUsersDialogUI
Definition
SCR_BlockedUsersDialogUI.c:2
SCR_BlockedUsersDialogUI::BLOCKED_USER_DIALOG_CONFIG
const ResourceName BLOCKED_USER_DIALOG_CONFIG
Definition
SCR_BlockedUsersDialogUI.c:5
SCR_BlockedUsersDialogUI::OnUserUnblock
void OnUserUnblock()
Definition
SCR_BlockedUsersDialogUI.c:200
SCR_BlockedUsersDialogUI::m_GamecardButton
SCR_InputButtonComponent m_GamecardButton
Definition
SCR_BlockedUsersDialogUI.c:20
SCR_BlockedUsersDialogUI::m_aUserList
ref array< Widget > m_aUserList
Definition
SCR_BlockedUsersDialogUI.c:28
SCR_BlockedUsersDialogUI::ListBlockedUsers
void ListBlockedUsers()
Definition
SCR_BlockedUsersDialogUI.c:88
SCR_BlockedUsersDialogUI::OnEntryFocusLost
void OnEntryFocusLost(SCR_ModularButtonComponent modularButton)
Definition
SCR_BlockedUsersDialogUI.c:171
SCR_BlockedUsersDialogUI::m_mUserList
ref map< Widget, BlockListItem > m_mUserList
Definition
SCR_BlockedUsersDialogUI.c:27
SCR_BlockedUsersDialogUI::m_BlocklistCallback
ref BackendCallback m_BlocklistCallback
Definition
SCR_BlockedUsersDialogUI.c:24
SCR_BlockedUsersDialogUI::OnInputTypeChanged
void OnInputTypeChanged(EInputDeviceType old, EInputDeviceType newDevice)
Definition
SCR_BlockedUsersDialogUI.c:59
SCR_BlockedUsersDialogUI::m_UnblockButton
SCR_InputButtonComponent m_UnblockButton
Definition
SCR_BlockedUsersDialogUI.c:19
SCR_BlockedUsersDialogUI::ENTRY_WIDGET_NAME
const ResourceName ENTRY_WIDGET_NAME
Definition
SCR_BlockedUsersDialogUI.c:3
SCR_BlockedUsersDialogUI::UNLOCK_BUTTON
const string UNLOCK_BUTTON
Definition
SCR_BlockedUsersDialogUI.c:7
SCR_BlockedUsersDialogUI::UNBLOCK_CONFIRM_MESSAGE
const string UNBLOCK_CONFIRM_MESSAGE
Definition
SCR_BlockedUsersDialogUI.c:10
SCR_BlockedUsersDialogUI::OnViewGamecard
void OnViewGamecard()
Definition
SCR_BlockedUsersDialogUI.c:216
SCR_BlockedUsersDialogUI::OnBlocklistRequestSuccess
void OnBlocklistRequestSuccess()
Definition
SCR_BlockedUsersDialogUI.c:233
SCR_BlockedUsersDialogUI::OnBlocklistRequestError
void OnBlocklistRequestError()
Definition
SCR_BlockedUsersDialogUI.c:243
SCR_BlockedUsersDialogUI::VIEW_GAMECARD_BUTTON
const string VIEW_GAMECARD_BUTTON
Definition
SCR_BlockedUsersDialogUI.c:8
SCR_BlockedUsersDialogUI::ENTRY_SCROLL_LIST
const string ENTRY_SCROLL_LIST
Definition
SCR_BlockedUsersDialogUI.c:4
SCR_BlockedUsersDialogUI::m_SocialComponent
SocialComponent m_SocialComponent
Definition
SCR_BlockedUsersDialogUI.c:22
SCR_BlockedUsersDialogUI::OnMenuClose
override void OnMenuClose()
Definition
SCR_BlockedUsersDialogUI.c:223
SCR_BlockedUsersDialogUI::OnBlockedListUpdated
void OnBlockedListUpdated(bool success)
Definition
SCR_BlockedUsersDialogUI.c:96
SCR_BlockedUsersDialogUI::m_wCurrentSelectedEntry
Widget m_wCurrentSelectedEntry
Definition
SCR_BlockedUsersDialogUI.c:17
SCR_BlockedUsersDialogUI::m_wUserListWidget
Widget m_wUserListWidget
Definition
SCR_BlockedUsersDialogUI.c:16
SCR_BlockedUsersDialogUI::m_iMaxBlockedUserAmount
int m_iMaxBlockedUserAmount
Definition
SCR_BlockedUsersDialogUI.c:14
SCR_BlockedUsersDialogUI::OnEntryFocused
void OnEntryFocused(SCR_ModularButtonComponent modularButton)
Definition
SCR_BlockedUsersDialogUI.c:147
SCR_BlockedUsersDialogUI::UnblockAskConfirmation
void UnblockAskConfirmation()
Definition
SCR_BlockedUsersDialogUI.c:185
SCR_BlockedUsersDialogUI::OnMenuOpen
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
Definition
SCR_BlockedUsersDialogUI.c:32
SCR_ConfigurableDialogUi
Definition
SCR_ConfigurableDialogUI.c:17
SCR_ConfigurableDialogUi::CreateFromPreset
static SCR_ConfigurableDialogUi CreateFromPreset(ResourceName presetsResourceName, string tag, SCR_ConfigurableDialogUi customDialogObj=null)
Creates a dialog from preset.
Definition
SCR_ConfigurableDialogUI.c:94
SCR_ConfigurableDialogUi::m_wRoot
Widget m_wRoot
Definition
SCR_ConfigurableDialogUI.c:66
SCR_ConfigurableDialogUi::GetMessageWidget
TextWidget GetMessageWidget()
Definition
SCR_ConfigurableDialogUI.c:291
SCR_ConfigurableDialogUi::FindButton
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
Definition
SCR_ConfigurableDialogUI.c:419
SCR_ConfigurableDialogUi::m_OnConfirm
ref ScriptInvoker m_OnConfirm
Definition
SCR_ConfigurableDialogUI.c:47
SCR_ConfigurableDialogUiPreset
Configuration for a dialog.
Definition
SCR_ConfigurableDialogUI.c:764
SCR_InputButtonComponent
Definition
SCR_InputButtonComponent.c:2
SCR_WidgetHelper
Definition
SCR_WidgetHelper.c:2
TextWidget
Definition
TextWidget.c:16
Widget
Definition
Widget.c:13
WorkspaceWidget
Definition
WorkspaceWidget.c:16
map
Definition
Types.c:486
scripts
Game
UI
Menu
SCR_BlockedUsersDialogUI.c
Generated by
1.17.0