Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GroupMenu.c
Go to the documentation of this file.
2 {
3  //------------------------------------------------------------------------------------------------
4  override void OnMenuOpen()
5  {
6  super.OnMenuOpen();
7 
8  SCR_InputButtonComponent cancel = SCR_InputButtonComponent.GetInputButtonComponent("Back", GetRootWidget());
9  if (cancel)
10  cancel.m_OnActivated.Insert(Close);
11 
12  SCR_AIGroup.GetOnJoinPrivateGroupRequest().Insert(UpdateTabs);
13  SCR_AIGroup.GetOnPlayerLeaderChanged().Insert(UpdateTabs);
14  }
15 
16  //------------------------------------------------------------------------------------------------
17  override void OnMenuShow()
18  {
19  super.OnMenuShow();
20 
21  UpdateTabs();
22  }
23 
24  //------------------------------------------------------------------------------------------------
25  override void OnMenuClose()
26  {
27  super.OnMenuClose();
28 
29  SCR_AIGroup.GetOnJoinPrivateGroupRequest().Remove(UpdateTabs);
30  SCR_AIGroup.GetOnPlayerLeaderChanged().Remove(UpdateTabs);
31  }
32 
33  // TODO: move tab related stuff to super menu component and use an enum instead of magic numbers
34  //------------------------------------------------------------------------------------------------
35  void UpdateTabs()
36  {
37  SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
38  if (!groupsManager)
39  return;
40 
41  int playerID = GetGame().GetPlayerController().GetPlayerId();
42 
43  SCR_AIGroup group = groupsManager.GetPlayerGroup(playerID);
44  if (!group)
45  return;
46 
47  if (!groupsManager.IsPlayerInAnyGroup(playerID) || !group.IsPlayerLeader(playerID))
48  {
49  m_SuperMenuComponent.GetTabView().EnableTab(1, false, true);
50  return;
51  }
52 
53  m_SuperMenuComponent.GetTabView().EnableTab(1, true, true);
54 
55  array<int> requesters = {};
56  group.GetRequesterIDs(requesters);
57 
58  if (requesters.IsEmpty())
59  {
60  m_SuperMenuComponent.GetTabView().ShowIcon(1, false);
61  }
62  else
63  {
64  m_SuperMenuComponent.GetTabView().ShowIcon(1, true);
65 
66  Widget notificationIcon = m_SuperMenuComponent.GetTabView().GetEntryIcon(1);
67  if (!notificationIcon)
68  return;
69 
70  TextWidget text = TextWidget.Cast(notificationIcon.FindAnyWidget("NotificationCount"));
71  if (!text)
72  return;
73 
74  if (requesters.Count() > 99)
75  text.SetText("99+");
76  else
77  text.SetText(requesters.Count().ToString());
78  }
79  }
80 }
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_GroupMenu
Definition: SCR_GroupMenu.c:1
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_SuperMenuBase
Definition: SCR_SuperMenuBase.c:6
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_GroupsManagerComponent.c:1320
SCR_AIGroup
Definition: SCR_AIGroup.c:68
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1