7 class SCR_PlayerListEntry
35 protected ResourceName m_sScoreboardRow =
"{65369923121A38E7}UI/layouts/Menus/PlayerList/PlayerListEntry.layout";
37 protected ref array<ref SCR_PlayerListEntry> m_aEntries =
new array<ref SCR_PlayerListEntry>();
38 protected ref map<int, SCR_ScoreInfo> m_aAllPlayersInfo =
new map<int, SCR_ScoreInfo>();
39 protected ref array<Faction> m_aFactions = {
null};
49 protected SCR_VoterComponent m_VoterComponent;
52 protected SCR_PlayerListEntry m_SelectedEntry;
53 protected SCR_PlayerControllerGroupComponent m_PlayerGroupController;
54 protected PlayerController m_PlayerController;
56 protected Widget m_wTable;
57 protected bool m_bFiltering;
58 protected float m_fTimeSkip;
60 protected const float TIME_STEP = 1.0;
62 protected const string ADD_FRIEND =
"#AR-PlayerList_AddFriend";
63 protected const string REMOVE_FRIEND =
"#AR-PlayerList_RemoveFriend";
64 protected const string MUTE =
"#AR-PlayerList_Mute";
65 protected const string UNMUTE =
"#AR-PlayerList_Unmute";
66 protected const string BLOCK =
"#AR-PlayerList_Block";
67 protected const string UNBLOCK =
"#AR-PlayerList_Unblock";
68 protected const string INVITE_PLAYER_VOTE =
"#AR-PlayerList_Invite";
69 protected const string MUTE_TEXTURE =
"sound-off";
70 protected const string OPTIONS_COMBO_ACCEPT =
"#AR-Group_AcceptJoinPrivateGroup";
71 protected const string OPTIONS_COMBO_CANCEL =
"#AR-Group_RefuseJoinPrivateGroup";
72 protected const string VOTING_PLAYER_COUNT_FORMAT =
"#AR-Voting_PlayerCountFormatting";
74 protected const string FILTER_FAV =
"Favourite";
75 protected const string FILTER_NAME =
"Name";
76 protected const string FILTER_FREQ =
"Freq";
77 protected const string FILTER_KILL =
"Kills";
78 protected const string FILTER_DEATH =
"Deaths";
79 protected const string FILTER_SCORE =
"Score";
80 protected const string FILTER_MUTE =
"Mute";
81 protected const string FILTER_BLOCK =
"Block";
83 protected static const ResourceName FACTION_COUNTER_LAYOUT =
"{5AD2CE85825EDA11}UI/layouts/Menus/PlayerList/FactionPlayerCounter.layout";
85 protected const int DEFAULT_SORT_INDEX = 1;
87 protected string m_sGameMasterIndicatorName =
"GameMasterIndicator";
89 protected static ref ScriptInvoker s_OnPlayerListMenu =
new ScriptInvoker();
91 protected ref Color m_PlayerNameSelfColor =
new Color(0.898, 0.541, 0.184, 1);
97 static ScriptInvoker GetOnPlayerListMenu()
99 return s_OnPlayerListMenu;
103 protected void InitSorting()
116 m_Header.m_OnChanged.Insert(OnHeaderChanged);
121 SCR_AIGroup.GetOnJoinPrivateGroupConfirm().Insert(SetEntryBackgrounColor);
122 SCR_AIGroup.GetOnJoinPrivateGroupCancel().Insert(SetEntryBackgrounColor);
125 ButtonWidget sortKills = ButtonWidget.Cast(w.FindAnyWidget(
"sortKills"));
126 ButtonWidget sortDeaths = ButtonWidget.Cast(w.FindAnyWidget(
"sortDeaths"));
127 ButtonWidget sortScore = ButtonWidget.Cast(w.FindAnyWidget(
"sortScore"));
130 sortKills.SetOpacity(0);
132 sortDeaths.SetOpacity(0);
134 sortScore.SetOpacity(0);
140 string filterName = sortHeader.GetSortElementName();
141 bool sortUp = sortHeader.GetSortOrderAscending();
142 Sort(filterName, sortUp);
147 protected void Sort(
string filterName,
bool sortUp)
149 if (filterName == FILTER_NAME)
151 else if (filterName == FILTER_FAV)
152 SortByFriends(sortUp);
153 else if (filterName == FILTER_FREQ)
154 SortByFrequency(sortUp);
155 else if (filterName == FILTER_KILL)
157 else if (filterName == FILTER_DEATH)
158 SortByDeaths(sortUp);
159 else if (filterName == FILTER_SCORE)
161 else if (filterName == FILTER_MUTE)
163 else if (filterName == FILTER_BLOCK)
164 SortByBlocked(sortUp);
168 void SortByMuted(
bool reverseSort =
false)
174 foreach (SCR_PlayerListEntry entry :
m_aEntries)
176 entry.m_wRow.SetZOrder(entry.m_Mute.IsToggled() *
direction);
181 void SortByBlocked(
bool reverseSort =
false)
187 foreach (SCR_PlayerListEntry entry :
m_aEntries)
189 entry.m_wRow.SetZOrder(entry.m_Block.IsToggled() *
direction);
194 void SortByName(
bool reverseSort =
false)
200 array<string> names = {};
201 foreach (SCR_PlayerListEntry entry :
m_aEntries)
204 names.Insert(entry.m_wName.GetText());
209 foreach (SCR_PlayerListEntry entry :
m_aEntries)
214 string text = entry.m_wName.GetText();
216 foreach (
int i,
string s : names)
229 void SortByFriends(
bool reverseSort =
false)
235 foreach (SCR_PlayerListEntry entry :
m_aEntries)
237 entry.m_wRow.SetZOrder(entry.m_Friend.IsToggled() *
direction);
242 void SortByFrequency(
bool reverseSort =
false)
248 foreach (SCR_PlayerListEntry entry :
m_aEntries)
250 entry.m_wRow.SetZOrder(entry.m_iSortFrequency *
direction);
255 void SortByKills(
bool reverseSort =
false)
261 foreach (SCR_PlayerListEntry entry :
m_aEntries)
265 entry.m_wRow.SetZOrder(score.m_iKills *
direction);
270 void SortByDeaths(
bool reverseSort =
false)
276 foreach (SCR_PlayerListEntry entry :
m_aEntries)
280 entry.m_wRow.SetZOrder(score.m_iDeaths *
direction);
285 void SortByScore(
bool reverseSort =
false)
291 foreach (SCR_PlayerListEntry entry :
m_aEntries)
298 score = m_ScoringSystem.GetPlayerScore(entry.m_iID);
302 entry.m_wRow.SetZOrder(score *
direction);
310 if (!m_SelectedEntry)
317 block.SetToggled(!block.IsToggled());
323 if (!m_SelectedEntry)
329 mute.SetToggled(!mute.IsToggled());
335 if (!m_SelectedEntry)
342 friend.SetToggled(!
friend.IsToggled());
352 foreach (
Faction playableFaction : m_aFactions)
354 if (comp.GetShownTabComponent().m_sTabButtonContent == playableFaction.GetFactionName())
355 faction = playableFaction;
358 int lowestZOrder =
int.MAX;
359 foreach (SCR_PlayerListEntry entry :
m_aEntries)
365 if (comp.GetShownTab() == 0)
366 entry.m_wRow.SetVisible(
true);
367 else if (faction == entry.m_Faction)
368 entry.m_wRow.SetVisible(
true);
370 entry.m_wRow.SetVisible(
false);
374 m_Header.SetCurrentSortElement(DEFAULT_SORT_INDEX,
ESortOrder.ASCENDING, useDefaultSortOrder:
true);
395 if (!m_SelectedEntry)
411 if (!m_SelectedEntry)
413 SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent().InvitePlayer(m_SelectedEntry.m_iID);
417 protected void OnViewProfile()
419 if (!m_SelectedEntry)
422 GetGame().GetPlayerManager().ShowUserProfile(m_SelectedEntry.m_iID);
429 foreach (SCR_PlayerListEntry entry :
m_aEntries)
431 if (entry.m_Mute != comp)
454 foreach (SCR_PlayerListEntry entry :
m_aEntries)
456 if (entry.m_Block != comp)
473 mute.SetToggled(
true);
474 mute.SetEnabled(!mute.IsEnabled());
490 void OnEntryFocused(Widget w)
495 foreach (SCR_PlayerListEntry entry :
m_aEntries)
500 Widget row = entry.m_wRow;
504 m_SelectedEntry = entry;
511 bool enablePlayerOptionList = CanOpenPlayerActionList(m_SelectedEntry);
515 if (m_SelectedEntry.m_Friend)
516 enableFriend = m_SelectedEntry.m_Friend.IsEnabled();
517 if (m_SelectedEntry.m_Mute)
518 enableMute = m_SelectedEntry.m_Mute.IsEnabled();
519 if (m_SelectedEntry.m_Block)
521 enableBlock = m_SelectedEntry.m_Block.IsEnabled();
522 if (m_SelectedEntry.m_Block.IsToggled())
527 if (m_SelectedEntry.m_PlayerActionList)
528 m_SelectedEntry.m_PlayerActionList.SetEnabled(enablePlayerOptionList);
536 m_Block.SetEnabled(enableBlock);
548 m_Mute.SetEnabled(enableMute);
556 m_Vote.SetEnabled(enablePlayerOptionList);
558 if (m_Invite && m_PlayerGroupController)
559 m_Invite.SetEnabled(m_PlayerGroupController.CanInvitePlayer(m_SelectedEntry.m_iID));
562 UpdateViewProfileButton(m_SelectedEntry.m_iID);
566 void OnEntryFocusLost(Widget w)
568 UpdateViewProfileButton(0,
true);
572 void FocusFirstItem()
575 int lowestZOrder =
int.MAX;
576 foreach (SCR_PlayerListEntry entry :
m_aEntries)
578 if (!entry.m_wRow.IsVisible())
581 int z = entry.m_wRow.GetZOrder();
582 if (z < lowestZOrder)
585 firstEntry = entry.m_wRow;
590 GetGame().GetWorkspace().SetFocusedWidget(firstEntry);
594 protected void UpdateViewProfileButton(
int playerId,
bool forceHidden =
false)
599 m_ViewProfile.SetVisible(!forceHidden &&
GetGame().GetPlayerManager().IsUserProfileAvailable(playerId),
false);
605 if (!m_VotingManager || !m_VoterComponent)
610 int playerID = GetVotingPlayerID(combo);
612 array<EVotingType> votingTypes = {};
613 for (
int i, count = m_VotingManager.GetVotingsAboutPlayer(playerID, votingTypes,
true,
true); i < count; i++)
616 info = m_VotingManager.GetVotingInfo(votingType);
620 Print(
"'SCR_PlayerListMenu' function 'SetupPlayerActionList' could not find votingInfo for vote: '" +
typename.EnumToString(
EVotingType, votingType) +
"' is it added to the voting component?", LogLevel.ERROR);
624 if (!m_VotingManager.IsVoting(votingType, playerID))
633 if (m_VoterComponent.DidVote(votingType, playerID))
635 int currentVotes, VotesRequired;
636 if (m_VotingManager.GetVoteCounts(votingType, playerID, currentVotes, VotesRequired))
644 if (!m_VoterComponent.HasAbstained(votingType, playerID))
647 int currentVotes, VotesRequired;
648 if (m_VotingManager.GetVoteCounts(votingType, playerID, currentVotes, VotesRequired))
662 int currentVotes, VotesRequired;
663 if (m_VotingManager.GetVoteCounts(votingType, playerID, currentVotes, VotesRequired))
680 array<int> requesters = {};
681 group.GetRequesterIDs(requesters);
683 if (requesters.Contains(playerID))
688 else if (m_PlayerGroupController.CanInvitePlayer(playerID))
695 if (!m_VoterComponent)
698 int playerID = GetVotingPlayerID(combo);
703 switch (comboData.GetComboEntryAction())
707 m_VoterComponent.Vote(comboData.GetComboEntryType(), playerID);
712 if (m_VoterComponent.DidVote(comboData.GetComboEntryType(), playerID))
713 m_VoterComponent.RemoveVote(comboData.GetComboEntryType(), playerID);
719 m_VoterComponent.AbstainVote(comboData.GetComboEntryType(), playerID);
724 SCR_PlayerControllerGroupComponent groupComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
726 groupComponent.InvitePlayer(playerID);
732 m_PlayerGroupController.AcceptJoinPrivateGroup(playerID,
true);
737 m_PlayerGroupController.AcceptJoinPrivateGroup(playerID,
false);
743 combo.SetCurrentItem(-1,
false,
false);
749 for (
int i, count =
m_aEntries.Count(); i < count; i++)
758 void SetEntryBackgrounColor(Color color)
768 array<int> requesters = {};
769 array<string> reqNames = {};
771 group.GetRequesterIDs(requesters);
773 foreach (
int req : requesters)
775 reqNames.Insert(
GetGame().GetPlayerManager().GetPlayerName(req));
778 if (!requesters.Contains(m_SelectedEntry.m_iID))
781 Widget w =
GetGame().GetWorkspace().FindAnyWidget(
"Button");
787 ImageWidget background = ImageWidget.Cast(m_SelectedEntry.m_wRow.FindAnyWidget(
"Background"));
789 background.SetColor(color);
796 foreach (SCR_PlayerListEntry entry :
m_aEntries)
798 if (entry.m_iID ==
id)
802 ImageWidget badgeTop, badgeMiddle, badgeBottom;
804 Widget w =
GetGame().GetWorkspace().CreateWidgets(m_sScoreboardRow, m_wTable);
808 SCR_PlayerListEntry entry =
new SCR_PlayerListEntry();
816 entry.m_PlayerActionList.m_OnOpened.Insert(SetupPlayerActionList);
817 entry.m_PlayerActionList.m_OnChanged.Insert(OnComboBoxConfirm);
818 entry.m_PlayerActionList.SetEnabled(CanOpenPlayerActionList(entry));
820 entry.m_wVotingNotification = entry.m_wRow.FindAnyWidget(
"VotingNotification");
821 entry.m_wVotingNotification.SetVisible(IsVotedAbout(entry));
825 entry.m_PlayerActionList.SetVisible(
false);
831 handler.m_OnFocus.Insert(OnEntryFocused);
832 handler.m_OnFocusLost.Insert(OnEntryFocusLost);
839 if (!info || playerId !=
id)
851 Faction faction = factionManager.GetPlayerFaction(entry.m_iID);
852 entry.m_Faction = faction;
855 Widget factionImage = w.FindAnyWidget(
"FactionImage");
860 factionImage.SetColor(entry.m_Faction.GetFactionColor());
862 factionImage.SetVisible(
false);
865 entry.m_wName = TextWidget.Cast(w.FindAnyWidget(
"PlayerName"));
869 entry.m_wName.SetText(
GetGame().GetPlayerManager().GetPlayerName(
id));
871 entry.m_wName.SetColor(m_PlayerNameSelfColor);
874 if (editorDelegateManager)
876 SCR_EditablePlayerDelegateComponent playerEditorDelegate = editorDelegateManager.GetDelegate(
id);
878 if (playerEditorDelegate)
880 playerEditorDelegate.GetOnLimitedEditorChanged().Insert(OnEditorRightsChanged);
881 UpdateGameMasterIndicator(entry, playerEditorDelegate.HasLimitedEditor());
885 entry.m_wFreq = TextWidget.Cast(w.FindAnyWidget(
"Freq"));
886 entry.m_wKills = TextWidget.Cast(w.FindAnyWidget(
"Kills"));
887 entry.m_wDeaths = TextWidget.Cast(w.FindAnyWidget(
"Deaths"));
888 entry.m_wScore = TextWidget.Cast(w.FindAnyWidget(
"Score"));
892 entry.m_wKills.SetText(entry.m_Info.m_iKills.ToString());
894 entry.m_wDeaths.SetText(entry.m_Info.m_iDeaths.ToString());
900 score = m_ScoringSystem.GetPlayerScore(
id);
902 entry.m_wScore.SetText(score.ToString());
909 entry.m_wKills.SetText(
"");
911 entry.m_wDeaths.SetText(
"");
913 entry.m_wScore.SetText(
"");
928 entry.m_wTaskIcon = entry.m_wRow.FindAnyWidget(
"TaskIcon");
929 entry.m_wLoadoutIcon = ImageWidget.Cast(entry.m_wRow.FindAnyWidget(
"LoadoutIcon"));
930 entry.m_wPlatformIcon = ImageWidget.Cast(entry.m_wRow.FindAnyWidget(
"PlatformIcon"));
932 ImageWidget background = ImageWidget.Cast(w.FindAnyWidget(
"Background"));
939 if (group && group.HasRequesterID(
id))
940 background.SetColor(m_PlayerNameSelfColor);
945 if (taskExecutor.GetAssignedTask())
947 entry.m_wTaskIcon.SetColor(entry.m_Faction.GetFactionColor());
951 entry.m_wTaskIcon.SetOpacity(0);
961 entryPlayerFaction = factionManager.GetPlayerFaction(entry.m_iID);
968 playerLoadout = loadoutManager.GetPlayerLoadout(entry.m_iID);
972 if (entry.m_wLoadoutIcon && (playerFaction != entryPlayerFaction))
973 entry.m_wLoadoutIcon.SetVisible(
false);
977 entry.m_wLoadoutIcon.SetVisible(
true);
979 if (entry.m_wLoadoutIcon && playerLoadout && entry.m_wLoadoutIcon.IsVisible())
981 Resource res = Resource.Load(playerLoadout.GetLoadoutResource());
982 IEntityComponentSource source =
SCR_BaseContainerTools.FindComponentSource(res,
"SCR_EditableCharacterComponent");
985 BaseContainer container = source.GetObject(
"m_UIInfo");
987 info.SetIconTo(entry.m_wLoadoutIcon);
990 if (entry.m_wPlatformIcon)
993 PlatformKind playerPlatform = playerManager.GetPlatformKind(entry.m_iID);
994 string iconName =
SCR_Global.GetPlatformName(playerPlatform);
995 entry.m_wPlatformIcon.LoadImageFromSet(0,
"{D17288006833490F}UI/Textures/Icons/icons_wrapperUI-32.imageset", iconName);
996 entry.m_wPlatformIcon.SetImage(0);
1000 Print(
"No platform icon detected in players list. This is against MS Xbox Live rules.", LogLevel.WARNING);
1004 badgeTop = ImageWidget.Cast(entry.m_wRow.FindAnyWidget(
"BadgeTop"));
1005 badgeMiddle = ImageWidget.Cast(entry.m_wRow.FindAnyWidget(
"BadgeMiddle"));
1006 badgeBottom = ImageWidget.Cast(entry.m_wRow.FindAnyWidget(
"BadgeBottom"));
1009 if (badgeTop && badgeMiddle && badgeBottom && entry.m_Faction)
1011 factionColor = entry.m_Faction.GetFactionColor();
1012 badgeTop.SetColor(factionColor);
1013 badgeMiddle.SetColor(factionColor);
1014 badgeBottom.SetColor(factionColor);
1018 if (IsLocalPlayer(entry.m_iID))
1021 entry.m_Friend.SetEnabled(
false);
1024 entry.m_Mute.SetEnabled(
false);
1027 entry.m_Block.SetEnabled(
false);
1038 entry.m_Mute.SetEnabled(
true);
1040 entry.m_Mute.SetToggled(
true);
1044 entry.m_Mute.SetToggled(
false);
1047 entry.m_Mute.SetEnabled(
false);
1050 entry.m_Mute.m_OnToggled.Insert(OnMuteClick);
1055 entry.m_Friend.SetEnabled(
false);
1056 entry.m_Friend.m_OnToggled.Insert(OnFriendClick);
1063 entry.m_Block.SetEnabled(
true);
1065 entry.m_Block.SetToggled(
true);
1069 entry.m_Block.SetToggled(
false);
1072 entry.m_Block.SetEnabled(
false);
1076 entry.m_Block.m_OnToggled.Insert(OnBlockClick);
1084 protected void OnEditorRightsChanged(
int playerID,
bool newLimited)
1086 foreach (SCR_PlayerListEntry entry :
m_aEntries)
1088 if (entry.m_iID == playerID)
1090 UpdateGameMasterIndicator(entry, newLimited);
1097 protected void UpdateGameMasterIndicator(SCR_PlayerListEntry entry,
bool editorIslimited)
1099 Widget gameMasterIndicator = entry.m_wRow.FindAnyWidget(m_sGameMasterIndicatorName);
1100 if (gameMasterIndicator)
1101 gameMasterIndicator.SetVisible(!editorIslimited);
1106 protected bool IsLocalPlayer(
int id)
1115 void RemoveEntry(notnull SCR_PlayerListEntry entry)
1118 entry.m_wRow.RemoveFromHierarchy();
1123 if (editorDelegateManager)
1125 SCR_EditablePlayerDelegateComponent playerEditorDelegate = editorDelegateManager.GetDelegate(entry.m_iID);
1127 if (playerEditorDelegate)
1129 playerEditorDelegate.GetOnLimitedEditorChanged().Remove(OnEditorRightsChanged);
1137 protected void OpenPauseMenu()
1144 protected void OnVotingChanged(
EVotingType type,
int value,
int playerID)
1152 protected void UpdateVoting()
1154 foreach (SCR_PlayerListEntry entry :
m_aEntries)
1156 entry.m_PlayerActionList.SetEnabled(CanOpenPlayerActionList(entry));
1157 entry.m_wVotingNotification.SetVisible(IsVotedAbout(entry));
1160 if (m_SelectedEntry)
1161 m_Vote.SetEnabled(CanOpenPlayerActionList(m_SelectedEntry));
1163 protected bool IsVotedAbout(SCR_PlayerListEntry entry)
1165 if (!entry || !m_VotingManager)
1168 array<EVotingType> votingTypes = {};
1169 int count = m_VotingManager.GetVotingsAboutPlayer(entry.m_iID, votingTypes,
false,
true);
1170 int validEntries = count;
1175 if (!m_VotingManager.IsVotingAvailable(voteType, entry.m_iID))
1179 return validEntries > 0;
1182 protected bool CanOpenPlayerActionList(SCR_PlayerListEntry entry)
1187 if (m_VotingManager)
1190 array<EVotingType> votingTypes = {};
1191 m_VotingManager.GetVotingsAboutPlayer(entry.m_iID, votingTypes,
true,
true);
1196 if (m_VotingManager.GetVotingInfo(votingType))
1202 if (m_PlayerGroupController.CanInvitePlayer(entry.m_iID))
1213 array<int> requesters = {};
1214 group.GetRequesterIDs(requesters);
1216 if (requesters.Contains(entry.m_iID))
1226 private void OnPlayerAdded(
int playerId)
1228 UpdatePlayerList(
true, playerId);
1230 private void OnPlayerRemoved(
int playerId)
1232 UpdatePlayerList(
false, playerId);
1234 private void OnScoreChanged()
1238 private void OnPlayerScoreChanged(
int playerId,
SCR_ScoreInfo scoreInfo)
1248 override void OnMenuOpen()
1258 hudManager.SetVisibleLayers(hudManager.GetVisibleLayers() & ~
EHudLayers.HIGH);
1263 m_PlayerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
1265 m_VoterComponent = SCR_VoterComponent.GetInstance();
1268 if (m_VotingManager)
1270 m_VotingManager.GetOnVotingEnd().Insert(OnVotingChanged);
1271 m_VotingManager.GetOnVotingStart().Insert(GetOnVotingStart);
1272 m_VotingManager.GetOnRemoveVote().Insert(OnVotingChanged);
1276 gameMode.GetOnPlayerRegistered().Insert(OnPlayerConnected);
1278 m_ScoringSystem = gameMode.GetScoringSystemComponent();
1279 if (m_ScoringSystem)
1281 m_ScoringSystem.GetOnPlayerAdded().Insert(OnPlayerAdded);
1282 m_ScoringSystem.GetOnPlayerRemoved().Insert(OnPlayerRemoved);
1283 m_ScoringSystem.GetOnPlayerScoreChanged().Insert(OnPlayerScoreChanged);
1284 m_ScoringSystem.GetOnFactionScoreChanged().Insert(OnFactionScoreChanged);
1286 array<int> players = {};
1288 playerManager.GetPlayers(players);
1291 foreach (
int playerId : players)
1292 m_aAllPlayersInfo.Insert(playerId, m_ScoringSystem.GetPlayerScoreInfo(playerId));
1295 FactionManager fm =
GetGame().GetFactionManager();
1298 fm.GetFactionsList(m_aFactions);
1304 Widget footer =
GetRootWidget().FindAnyWidget(
"FooterLeft");
1305 Widget footerBack =
GetRootWidget().FindAnyWidget(
"Footer");
1308 back.m_OnActivated.Insert(OnBack);
1314 m_Friend.m_OnActivated.Insert(OnAddFriend);
1321 m_Block.m_OnActivated.Insert(OnBlock);
1327 m_Mute.SetEnabled(
false);
1328 m_Mute.m_OnActivated.Insert(OnMute);
1333 filter.m_OnActivated.Insert(OnFilter);
1338 if (m_VotingManager)
1339 m_Vote.m_OnActivated.Insert(OnVoting);
1341 m_Vote.SetVisible(
false,
false);
1347 if (m_PlayerGroupController)
1348 m_Invite.m_OnActivated.Insert(OnInvite);
1350 m_Invite.SetVisible(
false,
false);
1356 UpdateViewProfileButton(0,
true);
1357 m_ViewProfile.m_OnActivated.Insert(OnViewProfile);
1361 if (!m_wTable || m_sScoreboardRow ==
string.Empty)
1368 array<int> ids = {};
1369 GetGame().GetPlayerManager().GetPlayers(ids);
1371 foreach (
int id : ids)
1373 CreateEntry(
id, editorDelegateManager);
1378 m_SuperMenuComponent.GetTabView().GetOnChanged().Insert(OnTabChanged);
1382 foreach (
Faction faction : m_aFactions)
1388 if (scrFaction && !scrFaction.IsPlayable())
1391 string name = faction.GetFactionName();
1392 m_SuperMenuComponent.GetTabView().AddTab(ResourceName.Empty,name);
1394 AddFactionPlayerCounter(faction);
1402 playerFaction = factionManager.GetLocalPlayerFaction();
1405 if (!groupsManager || !playerFaction)
1406 m_SuperMenuComponent.GetTabView().SetTabVisible(
EPlayerListTab.GROUPS,
false);
1407 UpdateFrequencies();
1409 s_OnPlayerListMenu.Invoke(
true);
1413 override void OnMenuUpdate(
float tDelta)
1419 DeleteDisconnectedEntries();
1423 GetGame().GetInputManager().ActivateContext(
"PlayerMenuContext");
1427 override void OnMenuFocusGained()
1429 GetGame().GetInputManager().AddActionListener(
"ShowScoreboard", EActionTrigger.DOWN, Close);
1432 m_Header.SetCurrentSortElement(DEFAULT_SORT_INDEX,
ESortOrder.ASCENDING, useDefaultSortOrder:
true);
1438 override void OnMenuFocusLost()
1440 GetGame().GetInputManager().RemoveActionListener(
"ShowScoreboard", EActionTrigger.DOWN, Close);
1447 override void OnMenuClose()
1449 super.OnMenuClose();
1453 hudManager.SetVisibleLayers(hudManager.GetVisibleLayers() |
EHudLayers.HIGH);
1458 if (editorDelegateManager)
1460 foreach (SCR_PlayerListEntry entry :
m_aEntries)
1464 SCR_EditablePlayerDelegateComponent playerEditorDelegate = editorDelegateManager.GetDelegate(entry.m_iID);
1466 if (playerEditorDelegate)
1468 playerEditorDelegate.GetOnLimitedEditorChanged().Remove(OnEditorRightsChanged);
1475 m_aFactions.Clear();
1477 if (m_ScoringSystem)
1479 m_ScoringSystem.GetOnPlayerAdded().Remove(OnPlayerAdded);
1480 m_ScoringSystem.GetOnPlayerRemoved().Remove(OnPlayerRemoved);
1481 m_ScoringSystem.GetOnPlayerScoreChanged().Remove(OnPlayerScoreChanged);
1482 m_ScoringSystem.GetOnFactionScoreChanged().Remove(OnFactionScoreChanged);
1485 s_OnPlayerListMenu.Invoke(
false);
1490 void OnPlayerConnected(
int id)
1492 GetGame().GetCallqueue().CallLater(UpdatePlayerList, 1000,
false,
true,
id);
1496 void UpdatePlayerList(
bool addPlayer,
int id)
1501 CreateEntry(
id, editorDelegateManager);
1507 OnHeaderChanged(m_Header);
1512 SCR_PlayerListEntry playerEntry;
1513 foreach (SCR_PlayerListEntry entry :
m_aEntries)
1515 if (entry.m_iID !=
id)
1518 playerEntry = entry;
1525 playerEntry.m_wRow.RemoveFromHierarchy();
1531 void UpdateFrequencies()
1536 set<int> localFrequencies =
new set<int>();
1540 SCR_Global.GetFrequencies(gadgetManager, localFrequencies);
1542 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(localPlayer.FindComponent(FactionAffiliationComponent));
1543 if (factionAffiliation)
1544 localFaction = factionAffiliation.GetAffiliatedFaction();
1547 foreach (SCR_PlayerListEntry entry :
m_aEntries)
1549 if (entry.m_Faction == localFaction)
1551 IEntity playerEntity =
GetGame().GetPlayerManager().GetPlayerControlledEntity(entry.m_iID);
1556 set<int> frequencies =
new set<int>();
1557 SCR_Global.GetFrequencies(gadgetManager, frequencies);
1558 if (!frequencies.IsEmpty())
1560 entry.m_iSortFrequency = frequencies[0];
1561 entry.m_wFreq.SetText(
SCR_FormatHelper.FormatFrequencies(frequencies, localFrequencies));
1566 entry.m_iSortFrequency =
int.MAX;
1567 entry.m_wFreq.SetText(
"-");
1569 GetGame().GetCallqueue().CallLater(UpdateFrequencies, 1000,
false);
1578 foreach (SCR_PlayerListEntry entry :
m_aEntries)
1582 if (!info || playerId != entry.m_iID)
1585 entry.m_Info = info;
1593 entry.m_wKills.SetText(entry.m_Info.m_iKills.ToString());
1594 if (entry.m_wDeaths)
1595 entry.m_wDeaths.SetText(entry.m_Info.m_iDeaths.ToString());
1600 if (m_ScoringSystem)
1601 score = m_ScoringSystem.GetPlayerScore(entry.m_iID);
1603 entry.m_wScore.SetText(score.ToString());
1611 OnHeaderChanged(m_Header);
1615 void CloseAllVoting()
1617 foreach (SCR_PlayerListEntry entry :
m_aEntries)
1619 if (entry.m_PlayerActionList && entry.m_PlayerActionList.IsOpened())
1620 entry.m_PlayerActionList.CloseList();
1625 void DeleteDisconnectedEntries()
1627 for (
int i =
m_aEntries.Count() - 1; i >= 0; i--)
1637 void AddFactionPlayerCounter(
Faction faction)
1640 if (!scriptedFaction)
1643 Widget contentLayout =
GetRootWidget().FindAnyWidget(
"FactionPlayerNumbersLayout");
1647 Widget factionTile =
GetGame().GetWorkspace().CreateWidgets(FACTION_COUNTER_LAYOUT, contentLayout);
1651 RichTextWidget playerCount = RichTextWidget.Cast(factionTile.FindAnyWidget(
"PlayerCount"));
1655 ImageWidget factionFlag = ImageWidget.Cast(factionTile.FindAnyWidget(
"FactionFlag"));
1660 factionFlag.LoadImageTexture(0, scriptedFaction.GetFactionFlag());
1661 factionFlag.GetImageSize(0, x, y);
1662 factionFlag.SetSize(x, y);
1664 playerCount.SetText(scriptedFaction.GetPlayerCount().ToString());
1672 protected SCR_EPlayerListComboType m_eComboEntryType;
1677 m_eComboEntryType = comboEntryType;
1678 m_eComboEntryAction = comboEntryAction;
1684 SCR_EPlayerListComboType GetComboEntryType()
1686 return m_eComboEntryType;
1694 return m_eComboEntryAction;