Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BlockedUsersDialogUI.c
Go to the documentation of this file.
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
18
21
22 protected SocialComponent m_SocialComponent;
23
25
26 // Save the widget with the userID it belongs to, to get the correct ID from the focused widget
28 protected ref array<Widget> m_aUserList = {};
29
30
31 //------------------------------------------------------------------------------------------------
33 {
34 super.OnMenuOpen(preset);
35
38 return;
39
41
44 {
45 m_UnblockButton.m_OnActivated.Insert(UnblockAskConfirmation);
46 m_UnblockButton.SetVisible(false, false);
47 }
48
49 // Show "View Gamecard" only for ps users
52 m_GamecardButton.SetVisible(false);
53
54 GetGame().OnInputDeviceUserChangedInvoker().Insert(OnInputTypeChanged);
55
56 }
57
58 //----------------------------------------------------------------------------------------------
59 protected void OnInputTypeChanged(EInputDeviceType old, EInputDeviceType newDevice)
60 {
62 return;
63
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;
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
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
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();
175 return;
176
178 if (!comp)
179 return;
180
181 comp.SetButtonsVisibility(false);
182 }
183
184 //------------------------------------------------------------------------------------------------
185 protected void UnblockAskConfirmation()
186 {
188
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
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 {
226 {
227 SCR_WidgetHelper.RemoveAllChildren(m_wUserListWidget);
228 }
229 GetGame().OnInputDeviceUserChangedInvoker().Remove(OnInputTypeChanged);
230 }
231
232 //------------------------------------------------------------------------------------------------
234 {
235 m_wCurrentSelectedEntry.RemoveFromHierarchy();
238 m_UnblockButton.SetEnabled(false);
239 GetGame().GetGameBlocklist().UpdateBlockList();
240 }
241
242 //------------------------------------------------------------------------------------------------
248}
ArmaReforgerScripted GetGame()
Definition game.c:1398
InputManager GetInputManager()
Data structure for block list response.
static const ResourceName BLOCKED_USER_DIALOG_CONFIG
void SetButtonsVisibility(bool newVis)
void SetPlayerName(string name)
Show the name of the player.
SCR_ModularButtonComponent GetUnblockButton()
string GetPlayerName()
SCR_ModularButtonComponent GetProfileButton()
void SetPlatfrom(PlatformKind platform)
Show the players platform.
const ResourceName BLOCKED_USER_DIALOG_CONFIG
SCR_InputButtonComponent m_GamecardButton
void OnEntryFocusLost(SCR_ModularButtonComponent modularButton)
ref map< Widget, BlockListItem > m_mUserList
ref BackendCallback m_BlocklistCallback
void OnInputTypeChanged(EInputDeviceType old, EInputDeviceType newDevice)
SCR_InputButtonComponent m_UnblockButton
void OnBlockedListUpdated(bool success)
void OnEntryFocused(SCR_ModularButtonComponent modularButton)
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
static SCR_ConfigurableDialogUi CreateFromPreset(ResourceName presetsResourceName, string tag, SCR_ConfigurableDialogUi customDialogObj=null)
Creates a dialog from preset.
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
Definition Types.c:486