3 protected Faction m_PlayerFaction;
5 protected static SCR_PlayerControllerGroupComponent s_PlayerGroupController;
7 protected static ref ScriptInvoker s_OnJoinGroupRequestSent;
10 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout,
int index)
12 super.OnTabCreate(menuRoot, buttonsLayout,
index);
15 CreateAddGroupButton();
16 CreateJoinGroupButton();
17 CreateAcceptInviteButton();
18 CreateGroupSettingsButton();
19 SetupNameChangeButton();
20 SetupPrivateChecker();
28 Widget chatPanel = menuRoot.FindAnyWidget(
"ChatPanel");
36 override void OnTabShow()
42 if (m_ChatPanelComponent)
44 m_ChatPanelComponent.GetOnChatOpen().Insert(OnChatOpen);
45 m_ChatPanelComponent.GetOnChatClosed().Insert(OnChatClosed);
46 if (m_ChatPanelComponent.IsOpen())
49 if (m_ChatPanelComponent.GetFadeOut() ==
false)
51 Widget chatContent = m_wMenuRoot.FindAnyWidget(
"ChatContent");
53 chatContent.SetVisible(
true);
57 chatAnimator.GetOnStateChanged().Insert(OnAnimatorStateChanged);
61 m_GroupManager.GetOnPlayableGroupRemoved().Insert(UpdateGroupsMenu);
62 m_GroupManager.GetOnPlayableGroupCreated().Insert(UpdateGroupsMenu);
63 m_GroupManager.GetOnNewGroupsAllowedChanged().Insert(UpdateGroupsMenu);
64 SCR_AIGroup.GetOnPlayerAdded().Insert(UpdateGroupsMenu);
65 SCR_AIGroup.GetOnPlayerRemoved().Insert(UpdateGroupsMenu);
66 SCR_AIGroup.GetOnPlayerLeaderChanged().Insert(UpdateGroupsMenu);
67 SCR_AIGroup.GetOnPrivateGroupChanged().Insert(UpdateGroupsMenu);
68 SCR_AIGroup.GetOnCustomNameChanged().Insert(UpdateGroupsMenu);
69 SCR_AIGroup.GetOnCustomDescriptionChanged().Insert(UpdateGroupsMenu);
70 SCR_AIGroup.GetOnFlagSelected().Insert(UpdateGroupsMenu);
71 SCR_AIGroup.GetOnFrequencyChanged().Insert(UpdateGroupsMenu);
73 SetAcceptButtonStatus();
78 if (!s_PlayerGroupController)
79 s_PlayerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
83 static ScriptInvoker GetOnJoingGroupRequestSent()
85 if (!s_OnJoinGroupRequestSent)
86 s_OnJoinGroupRequestSent =
new ScriptInvoker();
88 return s_OnJoinGroupRequestSent;
92 void UpdateGroupsMenu()
94 m_wGridWidget = m_wMenuRoot.FindAnyWidget(
"GroupList");
95 if (!m_wGridWidget || !m_AddGroupButton || !m_ButtonLayout || !m_GroupSettingsButton)
98 SetAcceptButtonStatus();
99 InitGroups(s_PlayerGroupController);
105 groupMenu.UpdateTabs();
109 override void OnTabHide()
116 m_GroupManager.GetOnPlayableGroupRemoved().Remove(UpdateGroupsMenu);
117 m_GroupManager.GetOnPlayableGroupCreated().Remove(UpdateGroupsMenu);
118 m_GroupManager.GetOnNewGroupsAllowedChanged().Remove(UpdateGroupsMenu);
121 if (m_ChatPanelComponent)
123 m_ChatPanelComponent.GetOnChatOpen().Remove(OnChatOpen);
124 m_ChatPanelComponent.GetOnChatClosed().Remove(OnChatClosed);
127 SCR_AIGroup.GetOnPlayerAdded().Remove(UpdateGroupsMenu);
128 SCR_AIGroup.GetOnPlayerRemoved().Remove(UpdateGroupsMenu);
129 SCR_AIGroup.GetOnPlayerLeaderChanged().Remove(UpdateGroupsMenu);
130 SCR_AIGroup.GetOnPrivateGroupChanged().Remove(UpdateGroupsMenu);
131 SCR_AIGroup.GetOnCustomNameChanged().Remove(UpdateGroupsMenu);
132 SCR_AIGroup.GetOnCustomDescriptionChanged().Remove(UpdateGroupsMenu);
133 SCR_AIGroup.GetOnFlagSelected().Remove(UpdateGroupsMenu);
134 SCR_AIGroup.GetOnFrequencyChanged().Remove(UpdateGroupsMenu);
136 if (s_PlayerGroupController)
137 s_PlayerGroupController.GetOnInviteReceived().Remove(SetAcceptButtonStatus);
139 SetNavigationButtonVisibile(m_GroupSettingsButton,
false);
143 protected void CreateAddGroupButton()
145 m_AddGroupButton = CreateNavigationButton(
"MenuAddGroup", CREATE_GROUP,
true);
146 if (!m_AddGroupButton)
148 m_AddGroupButton.GetRootWidget().SetZOrder(0);
149 m_AddGroupButton.m_OnActivated.Insert(CreateNewGroup);
153 protected void CreateJoinGroupButton()
155 m_JoinGroupButton = CreateNavigationButton(
"MenuJoinGroup", JOIN_GROUP,
true);
156 if (!m_JoinGroupButton)
158 m_JoinGroupButton.GetRootWidget().SetZOrder(0);
159 m_JoinGroupButton.m_OnActivated.Insert(JoinSelectedGroup);
163 protected void CreateAcceptInviteButton()
165 m_AcceptInviteButton = CreateNavigationButton(
"GroupAcceptInvite", ACCEPT_INVITE,
true);
166 if (!m_AcceptInviteButton)
168 m_AcceptInviteButton.GetRootWidget().SetZOrder(0);
169 m_AcceptInviteButton.m_OnActivated.Insert(AcceptInvite);
170 s_PlayerGroupController.GetOnInviteReceived().Insert(SetAcceptButtonStatus);
171 SetAcceptButtonStatus()
175 protected void CreateGroupSettingsButton()
177 m_GroupSettingsButton = CreateNavigationButton(
"MenuSettingsGroup",
"#AR-Player_Groups_Settings",
true,
false);
178 if (!m_GroupSettingsButton)
180 m_GroupSettingsButton.GetRootWidget().SetZOrder(0);
181 m_GroupSettingsButton.m_OnActivated.Insert(OpenGroupSettingsDialog);
185 protected void ChangeGroupPublicState()
187 SCR_PlayerControllerGroupComponent playerComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
188 if (!playerComponent)
193 SCR_AIGroup playerGroup = groupsManager.FindGroup(playerComponent.GetGroupID());
194 playerComponent.RequestPrivateGroupChange(playerComponent.GetPlayerID() , !playerGroup.IsPrivate());
198 protected void OpenGroupSettingsDialog()
204 protected static void CreateNewGroup()
206 if (!s_PlayerGroupController)
209 s_PlayerGroupController.SetSelectedGroupID(-1);
210 s_PlayerGroupController.RequestCreateGroup();
214 static void JoinSelectedGroup()
216 if (!s_PlayerGroupController)
219 s_PlayerGroupController.RequestJoinGroup(s_PlayerGroupController.GetSelectedGroupID());
223 static void RequestJoinPrivateGroup()
227 SCR_AIGroup group = groupManager.FindGroup(s_PlayerGroupController.GetSelectedGroupID());
231 if (s_PlayerGroupController)
233 s_PlayerGroupController.PlayerRequestToJoinPrivateGroup(s_PlayerGroupController.GetPlayerID(), Replication.FindId(group));
234 SCR_NotificationsComponent.SendToPlayer(s_PlayerGroupController.GetPlayerID(),
ENotification.GROUPS_REQUEST_SENT, group.GetGroupID());
235 if (s_OnJoinGroupRequestSent)
236 GetOnJoingGroupRequestSent().Invoke();
241 static void SetSelectedGroup(
int groupID)
243 s_PlayerGroupController.SetSelectedGroupID(groupID);
249 s_PlayerGroupController.AcceptInvite();
250 SetAcceptButtonStatus();
254 void SetAcceptButtonStatus()
256 if (s_PlayerGroupController.GetGroupInviteID() == -1)
258 m_AcceptInviteButton.SetEnabled(
false);
262 SCR_AIGroup group = m_GroupManager.FindGroup(s_PlayerGroupController.GetGroupInviteID());
266 m_AcceptInviteButton.SetEnabled(
false);
267 s_PlayerGroupController.SetGroupInviteID(-1);
270 m_AcceptInviteButton.SetEnabled(
true);
275 private void OnConfirm()
278 if (s_PlayerGroupController.GetGroupID() != -1)
285 s_PlayerGroupController.RequestCreateGroup();
288 s_PlayerGroupController.RequestJoinGroup(newPlayerGroup.GetGroupID());
292 protected void OnChatOpen()
294 Widget chatContent = m_wMenuRoot.FindAnyWidget(
"ChatContent");
296 chatContent.SetVisible(
true);
300 protected void OnChatClosed()
304 Widget chatContent = m_wMenuRoot.FindAnyWidget(
"ChatContent");
306 chatContent.SetVisible(
false);
312 chatAnimator.GetOnStateChanged().Insert(OnAnimatorStateChanged);
316 protected void OnAnimatorStateChanged(
int formerState,
int actualState)
318 if (formerState == 2 && actualState == 3)
320 Widget chatContent = m_wMenuRoot.FindAnyWidget(
"ChatContent");
322 chatContent.SetVisible(
false);
323 m_ChatPanelComponent.GetFadeInOutAnimator().GetOnStateChanged().Remove(OnAnimatorStateChanged);
328 protected void SetupNameChangeButton()
330 ButtonWidget nameChangeButton = ButtonWidget.Cast(
GetRootWidget().FindAnyWidget(
"ChangeNameButton"));
331 if (!nameChangeButton)
338 buttonComp.m_OnClicked.Insert(OpenGroupSettingsDialog);
342 protected void SetupPrivateChecker()
344 ButtonWidget privateChecker = ButtonWidget.Cast(
GetRootWidget().FindAnyWidget(
"PrivateChecker"));
352 buttonComp.m_OnClicked.Insert(OnPrivateCheckerClicked);
356 protected void OnPrivateCheckerClicked()
358 SCR_AIGroup group = m_GroupManager.FindGroup(s_PlayerGroupController.GetGroupID());
362 s_PlayerGroupController.RequestPrivateGroupChange(s_PlayerGroupController.GetPlayerID() , !group.IsPrivate());
367 static void UpdatePlayerGroupController()
369 if (!s_PlayerGroupController)
370 s_PlayerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();