Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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")]
7  protected ResourceName m_ButtonLayout;
8 
9  [Attribute("#AR-PauseMenu_Continue", UIWidgets.LocaleEditBox)]
10  protected LocalizedString m_sContinueButtonText;
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 
16  protected SCR_GroupsManagerComponent m_GroupManager;
17 
18  protected Widget m_wGridWidget;
19  protected SCR_InputButtonComponent m_AddGroupButton;
20  protected SCR_InputButtonComponent m_JoinGroupButton;
21  protected SCR_InputButtonComponent m_AcceptInviteButton;
22  protected SCR_InputButtonComponent m_GroupSettingsButton;
23 
24  //------------------------------------------------------------------------------------------------
25  protected void InitGroups(SCR_PlayerControllerGroupComponent playerGroupController)
26  {
27  if (!m_wGridWidget)
28  return;
29 
30  GetGame().GetCallqueue().Call(UpdateGroups, playerGroupController);
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  protected void UpdateGroups(SCR_PlayerControllerGroupComponent playerGroupController)
35  {
36  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
37  if (!factionManager)
38  return;
39 
40  SCR_Faction playerFaction = SCR_Faction.Cast(factionManager.GetLocalPlayerFaction());
41  if (!playerFaction)
42  return;
43 
44  SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
45  if (!groupManager)
46  return;
47 
48  if (!playerGroupController)
49  return;
50 
51  //no need to check playerFaction for null, because groups are not enabled for players without faction
52  m_AddGroupButton.SetEnabled(groupManager.CanCreateNewGroup(playerFaction));
53  Widget children = m_wGridWidget.GetChildren();
54  while (children)
55  {
56  m_wGridWidget.RemoveChild(children);
57  children = m_wGridWidget.GetChildren();
58  }
59 
60  // Group Settings Button
61  SetNavigationButtonVisibile(m_GroupSettingsButton, playerGroupController.IsPlayerLeaderOwnGroup() && groupManager.CanPlayersChangeAttributes());
62 
63  array<SCR_AIGroup> playableGroups = groupManager.GetPlayableGroupsByFaction(playerFaction);
64  if (!playableGroups)
65  return;
66 
67  int selectedGroupID = playerGroupController.GetSelectedGroupID();
68 
69  if (playableGroups.IsIndexValid(selectedGroupID) && m_wMenuRoot)
70  {
71  ImageWidget privateIcon = ImageWidget.Cast(m_wMenuRoot.FindAnyWidget("PrivateIconDetail"));
72  if (privateIcon)
73  privateIcon.SetVisible(playableGroups[selectedGroupID].IsPrivate());
74  }
75 
76  int groupCount = playableGroups.Count();
77 
78  for (int i = 0; i < groupCount; i++)
79  {
80  Widget groupTile = GetGame().GetWorkspace().CreateWidgets(m_ButtonLayout, m_wGridWidget);
81  if (!groupTile)
82  continue;
83 
84  ButtonWidget buttonWidget = ButtonWidget.Cast(groupTile.FindAnyWidget("Button"));
85  if (!buttonWidget)
86  continue;
87 
88  SCR_GroupTileButton buttonComponent = SCR_GroupTileButton.Cast(buttonWidget.FindHandler(SCR_GroupTileButton));
89  if (buttonComponent)
90  {
91  buttonComponent.SetGroupID(playableGroups[i].GetGroupID());
92  buttonComponent.SetGroupFaction(playerFaction);
93  buttonComponent.SetJoinGroupButton(m_JoinGroupButton);
94  buttonComponent.InitiateGroupTile();
95  if (playerGroupController.GetGroupID() == -1 && i == 0 && playerGroupController.GetSelectedGroupID() < 0)
96  GetGame().GetCallqueue().CallLater(buttonComponent.RefreshPlayers, 1, false);
97  if (selectedGroupID < 0 && playableGroups[i].GetGroupID() == playerGroupController.GetGroupID() )
98  GetGame().GetCallqueue().CallLater(buttonComponent.RefreshPlayers, 1, false);
99  if (selectedGroupID == playableGroups[i].GetGroupID())
100  GetGame().GetCallqueue().CallLater(buttonComponent.RefreshPlayers, 1, false);
101  }
102  }
103  }
104 }
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SubMenuBase
Definition: SCR_SubMenuBase.c:6
GetGroupID
int GetGroupID()
Definition: SCR_RestrictedDeployableSpawnPointComponent.c:507
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_GroupSubMenuBase
Definition: SCR_GroupSubMenuBase.c:1
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_GroupsManagerComponent.c:1320
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
LocalizedString
Definition: LocalizedString.c:21
SCR_Faction
Definition: SCR_Faction.c:6
SCR_GroupTileButton
Definition: SCR_GroupTileButton.c:106
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1