4 protected string m_sFlag;
5 protected ImageWidget m_wFlag;
8 protected string m_sName;
9 protected TextWidget m_wName;
12 protected string m_sPlayerCount;
13 protected TextWidget m_wPlayerCount;
16 protected string m_sPlayerList;
17 protected Widget m_wPlayerList;
19 [
Attribute(
"{E49B28A2FAEBA264}UI/layouts/Menus/DeployMenu/PlayerName.layout")]
20 protected ResourceName m_sPlayerName;
22 protected ref array<SCR_PlayerName> m_aPlayerNames = {};
23 protected Widget m_wRoot;
25 override void HandlerAttached(Widget w)
29 m_wFlag = ImageWidget.Cast(w.FindAnyWidget(m_sFlag));
31 m_wPlayerCount = TextWidget.Cast(w.FindAnyWidget(m_sPlayerCount));
32 m_wPlayerList = w.FindAnyWidget(m_sPlayerList);
35 void UpdatePlayerList()
39 void ShowPlayerList(
bool show)
44 protected void CreatePlayerName(
int pid)
50 playerName.SetPlayer(pid);
52 m_aPlayerNames.Insert(playerName);
61 protected int m_iLastPage;
63 [
Attribute(
"10",
params:
"0 inf", UIWidgets.EditBox,
"How much entries should be shown in list.")]
64 protected int m_iEntriesPerPage;
67 protected string m_sSpinBoxElementName;
70 protected string m_sPagingButtonLeft;
73 protected string m_sPagingButtonRight;
76 override event void HandlerAttached(Widget w)
78 super.HandlerAttached(w);
84 factionManager.GetOnPlayerFactionCountChanged().Insert(UpdatePagination);
85 factionManager.GetOnPlayerFactionCountChanged().Insert(UpdatePlayerList);
87 Widget spinboxW =
m_wRoot.FindAnyWidget(m_sSpinBoxElementName);
95 m_SpinBoxComp.m_OnChanged.Insert(UpdatePlayerList);
99 void SetFaction(
Faction faction)
107 if (m_wFlag && !scrFaction.GetFactionFlag().IsEmpty())
108 m_wFlag.LoadImageTexture(0, scrFaction.GetFactionFlag());
111 m_wName.SetText(scrFaction.GetFactionName());
113 UpdatePagination(faction);
121 protected void UpdatePagination(
Faction faction)
126 array<int> players = {};
129 int pageCount = players.Count() / m_iEntriesPerPage;
130 if ((players.Count() % m_iEntriesPerPage) > 0)
134 m_SpinBoxComp.ClearAll();
136 for (
int i = 0; i < pageCount; i++)
138 m_SpinBoxComp.AddItem(
"", i == pageCount - 1);
141 m_SpinBoxComp.SetCurrentItem(m_iLastPage);
144 HandleNavigationButtons();
149 protected int GetStartingIndex()
151 int page = m_SpinBoxComp.GetCurrentIndex();
155 return page * m_iEntriesPerPage;
159 protected void HandleNavigationButtons()
164 bool showButtons = m_SpinBoxComp.GetNumItems() > 1;
166 Widget button =
m_wRoot.FindAnyWidget(m_sPagingButtonLeft);
168 button.SetVisible(showButtons);
170 button =
m_wRoot.FindAnyWidget(m_sPagingButtonRight);
172 button.SetVisible(showButtons);
174 Widget spinboxW =
m_wRoot.FindAnyWidget(m_sSpinBoxElementName);
176 spinboxW.SetVisible(showButtons);
180 protected void SetLastIndex()
182 m_iLastPage = m_SpinBoxComp.GetCurrentIndex();
186 override void UpdatePlayerList()
191 m_aPlayerNames.Clear();
193 Widget child = m_wPlayerList.GetChildren();
196 Widget sibling = child.GetSibling();
197 child.RemoveFromHierarchy();
201 array<int> players = {};
204 int startIndex = GetStartingIndex();
205 if (players.IsEmpty() || startIndex < 0)
208 m_wPlayerCount.SetText(
"0");
212 int maxIndex = startIndex + (m_iEntriesPerPage-1);
213 for (
int i = startIndex; i <= maxIndex; i++)
215 if (i >= players.Count())
219 CreatePlayerName(players[i]);
223 m_wPlayerCount.SetText(players.Count().ToString());
227 override event void HandlerDeattached(Widget w)
229 super.HandlerDeattached(w);
234 factionManager.GetOnPlayerFactionCountChanged().Remove(UpdatePagination);
235 factionManager.GetOnPlayerFactionCountChanged().Remove(UpdatePlayerList);
251 if (m_wFlag && !group.GetGroupFlag().IsEmpty())
252 m_wFlag.LoadImageTexture(0, group.GetGroupFlag());
256 string name =
m_Group.GetCustomName();
259 string company, platoon, squad, character, format;
260 m_Group.GetCallsigns(company, platoon, squad, character, format);
261 name =
string.Format(
"%1 %2 %3 %4 %5", company, platoon, squad, character, format);
270 override void UpdatePlayerList()
272 if (!
m_Group || !m_wPlayerList)
275 m_aPlayerNames.Clear();
277 Widget child = m_wPlayerList.GetChildren();
280 Widget sibling = child.GetSibling();
281 child.RemoveFromHierarchy();
285 array<int> players =
m_Group.GetPlayerIDs();
286 foreach (
int pid : players)
288 CreatePlayerName(pid);
292 m_wPlayerCount.SetText(m_aPlayerNames.Count().ToString());
299 protected string m_sIcon;
300 protected ImageWidget m_wIcon;
303 protected string m_sName;
304 protected TextWidget m_wName;
306 protected ResourceName m_sIcons =
"{D17288006833490F}UI/Textures/Icons/icons_wrapperUI-32.imageset";
307 protected int m_iPlayerId;
309 override void HandlerAttached(Widget w)
315 void SetIcon(ResourceName icon)
324 void SetPlayer(
int pid)
338 protected void SetPlatform()
343 if (platform == PlatformKind.NONE)
344 icon =
"platform-windows";
345 else if (platform == PlatformKind.XBOX)
346 icon =
"platform-xbox";
347 else if (platform == PlatformKind.PSN)
348 icon =
"platform-playstation";
349 else if (platform == PlatformKind.STEAM)
350 icon =
"platform-windows";
353 m_wIcon.LoadImageFromSet(0, m_sIcons, icon);