Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_GroupSubMenuBase.c
Go to the documentation of this file.
2{
3 [Attribute("6", params: "1 100 1")]
4 protected int m_iMaxColumnNumber;
5
6 [Attribute("{17CCACBDA8CF5E32}UI/layouts/Menus/GroupSlection/GroupButton.layout")]
8
9 [Attribute("#AR-PauseMenu_Continue", UIWidgets.LocaleEditBox)]
11
12 protected const string CREATE_GROUP = "#AR_DeployMenu_AddNewGroup";
13 protected const string JOIN_GROUP = "#AR-DeployMenu_JoinGroup";
14 protected const string ACCEPT_INVITE = "#AR-DeployMenu_AcceptInvite";
15 protected const string DECLINE_INVITE = "#AR-Group_RefuseJoinPrivateGroup";
16 protected const string REMOVE_GROUP = "#AR-DeployMenu_RemoveGroup";
17 protected const string SETTINGS_GROUP = "#AR-Player_Groups_Settings";
18
20 protected SCR_PlayerControllerGroupComponent m_PlayerGroupController;
21
29
30 //------------------------------------------------------------------------------------------------
31 protected void InitGroups(SCR_PlayerControllerGroupComponent playerGroupController)
32 {
33 if (!m_wGridWidget)
34 return;
35
36 GetGame().GetCallqueue().Call(UpdateGroups, playerGroupController);
37 }
38
39 //------------------------------------------------------------------------------------------------
40 protected void UpdateGroups(SCR_PlayerControllerGroupComponent playerGroupController)
41 {
42 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
43 if (!factionManager)
44 return;
45
46 SCR_Faction playerFaction = SCR_Faction.Cast(factionManager.GetLocalPlayerFaction());
47 if (!playerFaction)
48 return;
49
50 SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
51 if (!groupManager)
52 return;
53
54 if (!playerGroupController)
55 return;
56
57 //no need to check playerFaction for null, because groups are not enabled for players without faction
58 m_AddGroupButton.SetEnabled(groupManager.CanCreateNewGroup(playerFaction));
59 Widget children = m_wGridWidget.GetChildren();
60 while (children)
61 {
62 m_wGridWidget.RemoveChild(children);
63 children = m_wGridWidget.GetChildren();
64 }
65
66 // Group Settings Button
67 SetNavigationButtonVisible(m_GroupSettingsButton, playerGroupController.IsPlayerLeaderOwnGroup() && groupManager.CanPlayersChangeAttributes());
68
69 array<SCR_AIGroup> playableGroups = groupManager.GetSortedPlayableGroupsByFaction(playerFaction);
70 if (!playableGroups)
71 return;
72
73 int selectedGroupID = playerGroupController.GetSelectedGroupID();
74
75 if (playableGroups.IsIndexValid(selectedGroupID) && m_wMenuRoot)
76 {
77 ImageWidget privateIcon = ImageWidget.Cast(m_wMenuRoot.FindAnyWidget("PrivateIconDetail"));
78 if (privateIcon)
79 privateIcon.SetVisible(playableGroups[selectedGroupID].IsPrivate());
80 }
81
82 int groupCount = playableGroups.Count();
83
84 for (int i = 0; i < groupCount; i++)
85 {
86 Widget groupTile = GetGame().GetWorkspace().CreateWidgets(m_ButtonLayout, m_wGridWidget);
87 if (!groupTile)
88 continue;
89
90 ButtonWidget buttonWidget = ButtonWidget.Cast(groupTile.FindAnyWidget("Button"));
91 if (!buttonWidget)
92 continue;
93
94 SCR_GroupTileButton buttonComponent = SCR_GroupTileButton.Cast(buttonWidget.FindHandler(SCR_GroupTileButton));
95 if (buttonComponent)
96 {
97 buttonComponent.SetGroupID(playableGroups[i].GetGroupID());
98 buttonComponent.SetGroupFaction(playerFaction);
101 buttonComponent.InitiateGroupTile();
102
103 if (MustRefreshList(selectedGroupID, playerGroupController.GetGroupID(), playableGroups[i].GetGroupID(), i))
104 GetGame().GetCallqueue().CallLater(buttonComponent.RefreshPlayers, 1, false);
105 }
106 }
107 }
108
109 //------------------------------------------------------------------------------------------------
110 protected bool MustRefreshList(int selectedGroupId, int playerGroupId, int otherGroupId, int groupIterator)
111 {
112 bool noSelection = selectedGroupId < 0;
113 bool isPlayerGroup = otherGroupId == playerGroupId;
114
115 return (playerGroupId == -1 && groupIterator == 0 && noSelection)
116 || (noSelection && isPlayerGroup)
117 || (selectedGroupId == otherGroupId);
118 }
119
120 //------------------------------------------------------------------------------------------------
121 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
122 {
123 super.OnTabCreate(menuRoot, buttonsLayout, index);
124
126 m_PlayerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
128 return;
129
138 }
139
140 //------------------------------------------------------------------------------------------------
141 override void OnTabShow()
142 {
143 super.OnTabShow();
144
145 //todo: This is a temporary solution because of how playerlist is implemented right now
146 OverlayWidget header = OverlayWidget.Cast(m_wMenuRoot.FindAnyWidget("SortHeader"));
147 if (header)
148 header.SetVisible(false);
149
150 ScrollLayoutWidget scrollWidget = ScrollLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget("ScrollLayout0"));
151 if (scrollWidget)
152 scrollWidget.SetVisible(false);
153
154 HorizontalLayoutWidget footerLeft = HorizontalLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget("FooterLeft"));
155 if (footerLeft)
156 footerLeft.SetVisible(false);
157
159
160 if (m_GroupManager)
161 {
162 m_GroupManager.GetOnPlayableGroupRemoved().Insert(UpdateGroupsMenu);
163 m_GroupManager.GetOnPlayableGroupCreated().Insert(UpdateGroupsMenu);
164 }
165
167 {
168 m_PlayerGroupController.GetOnInviteReceived().Insert(SetAcceptButtonStatus);
169 m_PlayerGroupController.GetOnSetSelectedGroupID().Insert(SetSelectedGroupButtonStatus);
170 }
171
181 }
182
183 //------------------------------------------------------------------------------------------------
185 {
187 if (!playerController || !m_wMenuRoot)
188 return;
189
191
192 m_wGridWidget = m_wMenuRoot.FindAnyWidget("GroupList");
194 }
195
196 //------------------------------------------------------------------------------------------------
197 override void OnTabRemove()
198 {
199 super.OnTabRemove();
200
201 SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
202 if (m_GroupManager)
203 {
204 m_GroupManager.GetOnPlayableGroupRemoved().Remove(UpdateGroupsMenu);
205 m_GroupManager.GetOnPlayableGroupCreated().Remove(UpdateGroupsMenu);
206 }
207
216
218 {
219 m_PlayerGroupController.GetOnInviteReceived().Remove(SetAcceptButtonStatus);
220 m_PlayerGroupController.GetOnSetSelectedGroupID().Remove(SetSelectedGroupButtonStatus);
221 }
222
223 //todo: This is a temporary solution because of how playerlist is implemented right now
224 OverlayWidget header = OverlayWidget.Cast(m_wMenuRoot.FindAnyWidget("SortHeader"));
225 if (header)
226 header.SetVisible(true);
227
228 ScrollLayoutWidget scrollWidget = ScrollLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget("ScrollLayout0"));
229 if (scrollWidget)
230 scrollWidget.SetVisible(true);
231
232 HorizontalLayoutWidget footerLeft = HorizontalLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget("FooterLeft"));
233 if (footerLeft)
234 footerLeft.SetVisible(true);
235 }
236
237 //------------------------------------------------------------------------------------------------
238 protected void CreateNewGroup()
239 {
240 SCR_Faction scrFaction = SCR_Faction.Cast(SCR_FactionManager.SGetLocalPlayerFaction());
241 if (!scrFaction)
242 return;
243
244 // checks if the group role config is set, if it's set it will open the CreateGroupSettingsDialog
245 // otherwise it will create a new group without a role
246 if (scrFaction.IsGroupRolesConfigured())
247 {
248 GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.CreateGroupSettingsDialog);
249 }
251 {
252 //we reset the selected group so the menu goes to players actual group, in this case newly created one
253 m_PlayerGroupController.SetSelectedGroupID(-1);
254 m_PlayerGroupController.RequestCreateGroup();
255 }
256 }
257
258 //------------------------------------------------------------------------------------------------
259 protected void JoinSelectedGroup()
260 {
261 SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
262 SCR_AIGroup group = groupManager.FindGroup(m_PlayerGroupController.GetSelectedGroupID());
263
264 if (!group)
265 return;
266
267 if (group.IsPrivate())
268 {
269 m_PlayerGroupController.PlayerRequestToJoinPrivateGroup(m_PlayerGroupController.GetPlayerID(), Replication.FindItemId(group));
270 SCR_NotificationsComponent.SendToPlayer(m_PlayerGroupController.GetPlayerID(), ENotification.GROUPS_REQUEST_SENT, group.GetGroupID());
271 }
272 else
273 {
274 m_PlayerGroupController.RequestJoinGroup(m_PlayerGroupController.GetSelectedGroupID());
275 }
276 }
277
278 //------------------------------------------------------------------------------------------------
279 protected void RemoveSelectedGroup()
280 {
281 m_PlayerGroupController.RequestRemoveGroup(m_PlayerGroupController.GetSelectedGroupID());
282 }
283
284 //------------------------------------------------------------------------------------------------
286 {
287 m_PlayerGroupController.AcceptInvite();
288 int SelectedGroupID = m_PlayerGroupController.GetSelectedGroupID();
289 SetSelectedGroupButtonStatus(SelectedGroupID);
290 }
291
292 //------------------------------------------------------------------------------------------------
294 {
295 m_PlayerGroupController.DeclineInvite();
296 int SelectedGroupID = m_PlayerGroupController.GetSelectedGroupID();
297 SetSelectedGroupButtonStatus(SelectedGroupID);
298 }
299
300 //------------------------------------------------------------------------------------------------
302 {
304 return;
305
306 int selectedGroupId = m_PlayerGroupController.GetSelectedGroupID();
307
308 if (!m_PlayerGroupController.HasInviteFromGroup(selectedGroupId))
309 {
310 m_AcceptInviteButton.SetVisible(false, false);
311 m_DeclineInviteButton.SetVisible(false, false);
312 }
313 else
314 {
315 SCR_AIGroup group = m_GroupManager.FindGroup(selectedGroupId);
316
317 if (!group)
318 {
319 m_AcceptInviteButton.SetVisible(false, false);
320 m_DeclineInviteButton.SetVisible(false, false);
321 m_PlayerGroupController.RemoveGroupInviteId(selectedGroupId);
322 return;
323 }
324
325 m_AcceptInviteButton.SetVisible(true, false);
326 m_DeclineInviteButton.SetVisible(true, false);
327 }
328 }
329
330 //------------------------------------------------------------------------------------------------
331 protected void SetSelectedGroupButtonStatus(int selectedGroupId)
332 {
333 bool canShow = selectedGroupId > -1 && !m_PlayerGroupController.HasInviteFromGroup(selectedGroupId);
334
335 m_JoinGroupButton.SetVisible(canShow, false);
336 m_AddGroupButton.SetVisible(canShow, false);
337
339 }
340
341 //------------------------------------------------------------------------------------------------
342 protected void CreateAddGroupButton()
343 {
345 if (!m_AddGroupButton)
346 return;
347
348 m_AddGroupButton.m_OnActivated.Insert(CreateNewGroup);
349 }
350
351 //------------------------------------------------------------------------------------------------
352 protected void CreateJoinGroupButton()
353 {
354 m_JoinGroupButton = CreateNavigationButton("MenuJoinGroup", JOIN_GROUP, true);
356 return;
357
358 m_JoinGroupButton.m_OnActivated.Clear();
359 m_JoinGroupButton.m_OnActivated.Insert(JoinSelectedGroup);
360 }
361
362 //------------------------------------------------------------------------------------------------
363 protected void CreateRemoveGroupButton()
364 {
365 m_RemoveGroupButton = CreateNavigationButton("MenuRemoveGroup", REMOVE_GROUP, true);
367 return;
368
369 m_RemoveGroupButton.m_OnActivated.Insert(RemoveSelectedGroup);
370 }
371
372 //------------------------------------------------------------------------------------------------
374 {
375 m_AcceptInviteButton = CreateNavigationButton("GroupAcceptInvite", ACCEPT_INVITE, true);
377 return;
378
379 m_AcceptInviteButton.m_OnActivated.Insert(AcceptInvite);
381 }
382
383 //------------------------------------------------------------------------------------------------
385 {
386 m_DeclineInviteButton = CreateNavigationButton("GroupDeclineInvite", DECLINE_INVITE, true);
388 return;
389
390 m_DeclineInviteButton.m_OnActivated.Insert(DeclineInvite);
392 }
393
394 //------------------------------------------------------------------------------------------------
396 {
397 m_GroupSettingsButton = CreateNavigationButton("MenuSettingsGroup", SETTINGS_GROUP, true);
399 return;
400
402 }
403
404 //------------------------------------------------------------------------------------------------
405 protected void ChangeGroupPublicState()
406 {
407 SCR_PlayerControllerGroupComponent playerComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
408 if (!playerComponent)
409 return;
410
411 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
412 if (!groupsManager)
413 return;
414
415 SCR_AIGroup playerGroup = groupsManager.FindGroup(playerComponent.GetGroupID());
416 playerComponent.RequestPrivateGroupChange(playerComponent.GetPlayerID(), !playerGroup.IsPrivate());
417 }
418
419 //------------------------------------------------------------------------------------------------
421 {
422 GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.VolunteerForGroupLeaderDialog);
423 }
424
425 //------------------------------------------------------------------------------------------------
426 protected void OpenGroupSettingsDialog()
427 {
428 GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.GroupSettingsDialog);
429 }
430
431 //------------------------------------------------------------------------------------------------
432 protected void SetupNameChangeButton()
433 {
434 ButtonWidget nameChangeButton = ButtonWidget.Cast(GetRootWidget().FindAnyWidget("ChangeNameButton"));
435 if (!nameChangeButton)
436 return;
437
438 SCR_ButtonImageComponent buttonComp = SCR_ButtonImageComponent.Cast(nameChangeButton.FindHandler(SCR_ButtonImageComponent));
439 if (!buttonComp)
440 return;
441
442 buttonComp.m_OnClicked.Insert(OpenGroupSettingsDialog);
443 }
444
445 //------------------------------------------------------------------------------------------------
446 protected void SetupPrivateChecker()
447 {
448 ButtonWidget privateChecker = ButtonWidget.Cast(GetRootWidget().FindAnyWidget("PrivateChecker"));
449 if (!privateChecker)
450 return;
451
452 SCR_ButtonCheckerComponent buttonComp = SCR_ButtonCheckerComponent.Cast(privateChecker.FindHandler(SCR_ButtonCheckerComponent));
453 if (!buttonComp)
454 return;
455
456 buttonComp.m_OnClicked.Insert(OnPrivateCheckerClicked);
457 }
458
459 //------------------------------------------------------------------------------------------------
460 protected void OnPrivateCheckerClicked()
461 {
462 SCR_AIGroup group = m_GroupManager.FindGroup(m_PlayerGroupController.GetGroupID());
463 if (!group)
464 return;
465
466 m_PlayerGroupController.RequestPrivateGroupChange(m_PlayerGroupController.GetPlayerID(), !group.IsPrivate());
467 }
468}
ChimeraMenuPreset
Menu presets.
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
bool IsPrivate()
int GetGroupID()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Main replication API.
Definition Replication.c:14
static ScriptInvoker GetOnPrivateGroupChanged()
static ScriptInvoker GetOnPlayerRemoved()
static ScriptInvoker GetOnCustomNameChanged()
static ScriptInvoker GetOnPlayerLeaderChanged()
static ScriptInvoker GetOnPlayerAdded()
bool IsPrivate()
int GetGroupID()
static ScriptInvoker GetOnFlagSelected()
static ScriptInvoker GetOnCustomDescriptionChanged()
bool IsGroupRolesConfigured()
SCR_InputButtonComponent m_DeclineInviteButton
SCR_InputButtonComponent m_RemoveGroupButton
override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
SCR_GroupsManagerComponent m_GroupManager
void InitGroups(SCR_PlayerControllerGroupComponent playerGroupController)
bool MustRefreshList(int selectedGroupId, int playerGroupId, int otherGroupId, int groupIterator)
LocalizedString m_sContinueButtonText
SCR_InputButtonComponent m_GroupSettingsButton
void SetSelectedGroupButtonStatus(int selectedGroupId)
SCR_InputButtonComponent m_AcceptInviteButton
SCR_InputButtonComponent m_AddGroupButton
void UpdateGroups(SCR_PlayerControllerGroupComponent playerGroupController)
SCR_PlayerControllerGroupComponent m_PlayerGroupController
SCR_InputButtonComponent m_JoinGroupButton
void SetJoinGroupButton(SCR_InputButtonComponent joinGroupButton)
static ScriptInvokerVoid GetOnGroupTileClicked()
void SetRemoveGroupButton(SCR_InputButtonComponent removeGroupButton)
void SetGroupFaction(Faction groupFaction)
SCR_InputButtonComponent CreateNavigationButton(string actionName, string label, bool rightFooter=false, bool show=true)
void SetNavigationButtonVisible(SCR_InputButtonComponent button, bool show, bool animate=false)
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()