4 protected SCR_PlayerControllerGroupComponent m_PlayerGroupController;
6 protected int m_iLastSelectedPlayerId;
9 override void OnMenuUpdate(
float tDelta)
11 GetGame().GetInputManager().ActivateContext(
"GroupMenuContext");
15 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout,
int index)
17 super.OnTabCreate(menuRoot, buttonsLayout,
index);
20 m_PlayerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
21 if (!m_PlayerGroupController)
24 CreateAddGroupButton();
25 CreateJoinGroupButton();
26 CreateAcceptInviteButton();
27 CreateGroupSettingsButton();
28 CreateViewProfileButton();
29 SetupNameChangeButton();
30 SetupPrivateChecker();
34 override void OnTabShow()
38 UpdateViewProfileButton(
true);
41 OverlayWidget header = OverlayWidget.Cast(m_wMenuRoot.FindAnyWidget(
"SortHeader"));
43 header.SetVisible(
false);
44 ScrollLayoutWidget scrollWidget = ScrollLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget(
"ScrollLayout0"));
46 scrollWidget.SetVisible(
false);
47 HorizontalLayoutWidget footerLeft = HorizontalLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget(
"FooterLeft"));
49 footerLeft.SetVisible(
false);
55 m_GroupManager.GetOnPlayableGroupRemoved().Insert(UpdateGroupsMenu);
56 m_GroupManager.GetOnPlayableGroupCreated().Insert(UpdateGroupsMenu);
59 SCR_AIGroup.GetOnPlayerAdded().Insert(UpdateGroupsMenu);
60 SCR_AIGroup.GetOnPlayerRemoved().Insert(UpdateGroupsMenu);
61 SCR_AIGroup.GetOnPlayerLeaderChanged().Insert(UpdateGroupsMenu);
62 SCR_AIGroup.GetOnPrivateGroupChanged().Insert(UpdateGroupsMenu);
63 SCR_AIGroup.GetOnCustomNameChanged().Insert(UpdateGroupsMenu);
64 SCR_AIGroup.GetOnFlagSelected().Insert(UpdateGroupsMenu);
65 SCR_AIGroup.GetOnCustomDescriptionChanged().Insert(UpdateGroupsMenu);
69 SetAcceptButtonStatus();
73 void UpdateGroupsMenu()
76 if (!playerController || !m_wMenuRoot)
79 SetAcceptButtonStatus();
81 m_wGridWidget = m_wMenuRoot.FindAnyWidget(
"GroupList");
82 InitGroups(m_PlayerGroupController);
86 override void OnTabHide()
95 override void OnTabRemove()
101 m_GroupManager.GetOnPlayableGroupRemoved().Remove(UpdateGroupsMenu);
102 m_GroupManager.GetOnPlayableGroupCreated().Remove(UpdateGroupsMenu);
105 SCR_AIGroup.GetOnPlayerAdded().Remove(UpdateGroupsMenu);
106 SCR_AIGroup.GetOnPlayerRemoved().Remove(UpdateGroupsMenu);
107 SCR_AIGroup.GetOnPlayerLeaderChanged().Remove(UpdateGroupsMenu);
108 SCR_AIGroup.GetOnCustomNameChanged().Remove(UpdateGroupsMenu);
109 SCR_AIGroup.GetOnFlagSelected().Remove(UpdateGroupsMenu);
110 SCR_AIGroup.GetOnCustomDescriptionChanged().Remove(UpdateGroupsMenu);
111 m_PlayerGroupController.GetOnInviteReceived().Remove(SetAcceptButtonStatus);
114 OverlayWidget header = OverlayWidget.Cast(m_wMenuRoot.FindAnyWidget(
"SortHeader"));
116 header.SetVisible(
true);
117 ScrollLayoutWidget scrollWidget = ScrollLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget(
"ScrollLayout0"));
119 scrollWidget.SetVisible(
true);
120 HorizontalLayoutWidget footerLeft = HorizontalLayoutWidget.Cast(m_wMenuRoot.FindAnyWidget(
"FooterLeft"));
122 footerLeft.SetVisible(
true);
129 protected void CreateNewGroup()
131 if (!m_PlayerGroupController)
134 m_PlayerGroupController.SetSelectedGroupID(-1);
135 m_PlayerGroupController.RequestCreateGroup();
139 protected void JoinSelectedGroup()
141 if (!m_PlayerGroupController)
143 m_PlayerGroupController.RequestJoinGroup(m_PlayerGroupController.GetSelectedGroupID());
149 m_PlayerGroupController.AcceptInvite();
150 SetAcceptButtonStatus();
154 void SetAcceptButtonStatus()
156 if (!m_AcceptInviteButton)
159 if (m_PlayerGroupController.GetGroupInviteID() == -1)
161 m_AcceptInviteButton.SetEnabled(
false);
165 SCR_AIGroup group = m_GroupManager.FindGroup(m_PlayerGroupController.GetGroupInviteID());
169 m_AcceptInviteButton.SetEnabled(
false);
170 m_PlayerGroupController.SetGroupInviteID(-1);
173 m_AcceptInviteButton.SetEnabled(
true);
178 protected void CreateAddGroupButton()
180 m_AddGroupButton = CreateNavigationButton(
"MenuAddGroup", CREATE_GROUP,
true);
181 if (!m_AddGroupButton)
183 m_AddGroupButton.GetRootWidget().SetZOrder(0);
184 m_AddGroupButton.m_OnActivated.Insert(CreateNewGroup);
188 protected void CreateJoinGroupButton()
190 m_JoinGroupButton = CreateNavigationButton(
"MenuJoinGroup", JOIN_GROUP,
true);
191 if (!m_JoinGroupButton)
193 m_JoinGroupButton.GetRootWidget().SetZOrder(0);
194 m_JoinGroupButton.m_OnActivated.Insert(JoinSelectedGroup);
198 protected void CreateAcceptInviteButton()
200 m_AcceptInviteButton = CreateNavigationButton(
"GroupAcceptInvite", ACCEPT_INVITE,
true);
201 if (!m_AcceptInviteButton)
203 m_AcceptInviteButton.GetRootWidget().SetZOrder(0);
204 m_AcceptInviteButton.m_OnActivated.Insert(AcceptInvite);
205 m_PlayerGroupController.GetOnInviteReceived().Insert(SetAcceptButtonStatus);
206 SetAcceptButtonStatus();
210 protected void CreateGroupSettingsButton()
212 m_GroupSettingsButton = CreateNavigationButton(
"MenuSettingsGroup",
"#AR-Player_Groups_Settings",
true,
false);
213 if (!m_GroupSettingsButton)
215 m_GroupSettingsButton.GetRootWidget().SetZOrder(0);
216 m_GroupSettingsButton.m_OnActivated.Insert(OpenGroupSettingsDialog);
220 protected void CreateViewProfileButton()
222 m_ViewProfileButton = CreateNavigationButton(
"MenuViewProfile",
"",
true);
223 if (!m_ViewProfileButton)
231 m_ViewProfileButton.GetRootWidget().AddHandler(handler);
234 UpdateViewProfileButton(
true);
236 m_ViewProfileButton.GetRootWidget().SetZOrder(0);
237 m_ViewProfileButton.m_OnActivated.Insert(OnViewProfile);
241 protected void UpdateViewProfileButton(
bool forceHidden =
false)
243 if (!m_ViewProfileButton)
246 SetNavigationButtonVisibile(m_ViewProfileButton, !forceHidden &&
GetGame().GetPlayerManager().IsUserProfileAvailable(m_iLastSelectedPlayerId));
250 protected void OnPlayerTileFocus(
int id)
252 m_iLastSelectedPlayerId = id;
253 UpdateViewProfileButton();
257 protected void OnPlayerTileFocusLost(
int id)
259 UpdateViewProfileButton(
true);
263 protected void OnViewProfile()
265 GetGame().GetPlayerManager().ShowUserProfile(m_iLastSelectedPlayerId);
269 protected void ChangeGroupPublicState()
271 SCR_PlayerControllerGroupComponent playerComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
272 if (!playerComponent)
277 SCR_AIGroup playerGroup = groupsManager.FindGroup(playerComponent.GetGroupID());
278 playerComponent.RequestPrivateGroupChange(playerComponent.GetPlayerID() , !playerGroup.IsPrivate());
282 protected void OpenGroupSettingsDialog()
287 protected void SetupNameChangeButton()
289 ButtonWidget nameChangeButton = ButtonWidget.Cast(
GetRootWidget().FindAnyWidget(
"ChangeNameButton"));
290 if (!nameChangeButton)
297 buttonComp.m_OnClicked.Insert(OpenGroupSettingsDialog);
301 protected void SetupPrivateChecker()
303 ButtonWidget privateChecker = ButtonWidget.Cast(
GetRootWidget().FindAnyWidget(
"PrivateChecker"));
311 buttonComp.m_OnClicked.Insert(OnPrivateCheckerClicked);
316 protected void OnPrivateCheckerClicked()
318 SCR_AIGroup group = m_GroupManager.FindGroup(m_PlayerGroupController.GetGroupID());
322 m_PlayerGroupController.RequestPrivateGroupChange(m_PlayerGroupController.GetPlayerID() , !group.IsPrivate());