DayZ 1.24
Loading...
Searching...
No Matches
PlayerListScriptedWidget.c
Go to the documentation of this file.
1class PlayerListScriptedWidget extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
5 protected Widget m_Content;
7
8 protected int m_TotalEntries;
9 protected PlayerListEntryScriptedWidget m_SelectedEntry;
10
12 {
13 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/xbox/ingamemenu_xbox/players_info_panel.layout", parent);
14 m_ScrollContainer = ScrollWidget.Cast(m_Root.FindAnyWidget("ScrollFrame"));
15 m_Content = m_Root.FindAnyWidget("Content");
16
18
19 m_ScrollContainer.VScrollToPos01(0);
20 }
21
23 {
24 delete m_Root;
25 }
26
28 {
29 if (m_Content && m_Content.GetChildren())
30 SetFocus(m_Content.GetChildren().FindAnyWidget("Button"));
31 m_ScrollContainer.VScrollToPos01(0);
32 }
33
35 {
36 if (player_list && player_list.m_PlayerList && m_Entries)
37 {
38 foreach (string UID, PlayerListEntryScriptedWidget widget : m_Entries)
39 {
41 foreach (SyncPlayer player : player_list.m_PlayerList)
42 {
43 if (player && player.m_UID == UID)
44 {
46 break;
47 }
48 }
49 if (!player_found)
51 }
52
53 for (int i = 0; i < player_list.m_PlayerList.Count(); i++)
54 {
55 SyncPlayer player2 = player_list.m_PlayerList.Get(i);
56 PlayerListEntryScriptedWidget player_widget;
57 m_Entries.Find(player2.m_UID, player_widget);
58 if (!player_widget)
59 AddPlayer(player2.m_PlayerName, player2.m_UID, true);
60 }
61 }
62 }
63
64 bool IsEmpty()
65 {
66 return (m_Entries.Count() == 0);
67 }
68
73
75 {
76 if (player_list && m_Entries)
77 {
78 foreach (string UID, PlayerListEntryScriptedWidget widget : m_Entries)
79 {
81 int j = 0;
82 while (!player_found && j < player_list.Count())
83 {
84 if (player_list[j].m_Uid == UID)
86 j++;
87 }
88
89 if (!player_found)
91 }
92
93 for (int i = 0; i < player_list.Count(); i++)
94 {
96 PlayerListEntryScriptedWidget player_widget;
97 m_Entries.Find(player2.m_Uid, player_widget);
98 if (!player_widget)
99 AddPlayer(player2.m_DisplayName, player2.m_Uid, false);
100 }
101 }
102 }
103
105 {
107 {
108 PlayerListEntryScriptedWidget player_widget;
109 m_Entries.Find(result.m_Uid, player_widget);
110 if (player_widget)
111 player_widget.LoadPermissions(result.m_Results);
112 }
113 }
114
116 {
117 if (player_list)
118 {
119 for (int i = 0; i < player_list.Count(); i++)
120 {
121 string uid = player_list.GetKey(i);
123 PlayerListEntryScriptedWidget player_widget;
124 m_Entries.Find(uid, player_widget);
125 if (player_widget)
126 player_widget.SetMute(muted);
127 }
128 }
129 }
130
131 PlayerListEntryScriptedWidget FindEntryByWidget(Widget button)
132 {
133 if (button && m_Entries)
134 {
135 foreach (string UID, PlayerListEntryScriptedWidget widget : m_Entries)
136 {
137 if (widget && widget.GetButtonWidget() == button)
138 return widget;
139 }
140 }
141
142 return null;
143 }
144
146 {
147 if (button && m_Entries)
148 {
149 foreach (string UID, PlayerListEntryScriptedWidget widget : m_Entries)
150 {
151 if (widget && widget.GetButtonWidget() == button)
152 return UID;
153 }
154 }
155
156 return "";
157 }
158
159 void AddPlayer(string name, string UID, bool show_permissions)
160 {
161 if (m_Entries)
162 {
163 m_Entries.Insert(UID, new PlayerListEntryScriptedWidget(m_Content, name, UID, show_permissions, this));
164 m_TotalEntries++;
165 }
166 }
167
168 void RemovePlayer(string UID)
169 {
170 if (m_Entries)
171 {
172 PlayerListEntryScriptedWidget next_entry;
173
174 if (m_Entries.Get(UID) == m_SelectedEntry)
175 {
176 for (int i = 0; i < m_Entries.Count() - 1; i++)
177 {
178 if (m_Entries.GetElement(i) == m_Entries.Get(UID))
179 next_entry = m_Entries.GetElement(i + 1);
180 }
181 }
182
183 m_Entries.Remove(UID);
184 m_TotalEntries--;
186 m_Content.Update();
187 }
188 }
189
190 bool IsMuted(string UID)
191 {
192 if (m_Entries && m_Entries.Get(UID))
193 return m_Entries.Get(UID).IsMuted();
194 return false;
195 }
196
197 bool IsGloballyMuted(string UID)
198 {
199 if (m_Entries && m_Entries.Get(UID))
200 return m_Entries.Get(UID).IsGloballyMuted();
201 return false;
202 }
203
204 void SetMute(string UID, bool mute)
205 {
206 if (m_Entries && m_Entries.Get(UID))
207 m_Entries.Get(UID).SetMute(mute);
208 }
209
210 void ToggleMute(string UID)
211 {
212 if (m_Entries && m_Entries.Get(UID))
213 m_Entries.Get(UID).ToggleMute();
214 }
215
216 PlayerListEntryScriptedWidget GetSelectedPlayer()
217 {
218 return m_SelectedEntry;
219 }
220
221 void SelectPlayer(PlayerListEntryScriptedWidget entry)
222 {
223 if (m_SelectedEntry)
224 m_SelectedEntry.Deselect();
225 m_SelectedEntry = entry;
226 if (GetGame().GetUIManager().GetMenu())
227 GetGame().GetUIManager().GetMenu().Refresh();
228 ScrollToEntry(entry);
229 }
230
231 void ScrollToEntry(PlayerListEntryScriptedWidget entry)
232 {
233 if (entry)
234 {
235 float x, y;
236 float x_s, y_s;
237 float x_l, y_l;
238
239 Widget root = entry.GetButtonWidget().GetParent();
240 Widget first_child = root.GetParent().GetChildren();
242 while (last_child)
243 {
244 if (last_child.GetSibling())
245 last_child = last_child.GetSibling();
246 else
247 break;
248 }
249
250 root.GetParent().Update();
251 root.Update();
252
253 m_ScrollContainer.GetScreenPos(x, y);
254 m_ScrollContainer.GetScreenSize(x_s, y_s);
255
256 float bottom_pos = y + y_s;
257
258 root.GetScreenPos(x_l, y_l);
259 root.GetScreenSize(x_s, y_s);
260
261 if (root == first_child)
262 m_ScrollContainer.VScrollToPos01(0);
263 else if (root == last_child)
264 m_ScrollContainer.VScrollToPos01(1);
265 else if (y_l + y_s >= bottom_pos)
266 m_ScrollContainer.VScrollToPos(m_ScrollContainer.GetVScrollPos() + y_s);
267 else if (y_l <= y)
268 m_ScrollContainer.VScrollToPos(m_ScrollContainer.GetVScrollPos() - y_s);
269 }
270 }
271}
EBiosError
Possible Error codes for bios API. This is the list of errors that can be returned from bios API....
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
Widget m_Root
Definition SizeToChild.c:85
BiosFriendInfo represents friend information.
BiosPrivacyUidResult represents the per user result of the GetPermissionsAsync request.
GetServersResult the output structure of the GetServers operation.
static bool IsPlayerMuted(string id)
map: item x vector(index, width, height)
Definition EnWidgets.c:651
void ReloadLocal(map< string, bool > player_list)
void Reload(BiosFriendInfoArray player_list)
void ScrollToEntry(PlayerListEntryScriptedWidget entry)
void PlayerListScriptedWidget(Widget parent, string header_text="")
PlayerListEntryScriptedWidget GetSelectedPlayer()
void SelectPlayer(PlayerListEntryScriptedWidget entry)
void AddPlayer(string name, string UID, bool show_permissions)
PlayerListEntryScriptedWidget FindEntryByWidget(Widget button)
PlayerListEntryScriptedWidget m_SelectedEntry
void SetMute(string UID, bool mute)
void PlayerListEntryScriptedWidget(Widget parent, string name, string uid, bool show_permissions, PlayerListScriptedWidget tab)
void Reload(BiosPrivacyUidResultArray player_list)
void Reload(SyncPlayerList player_list)
string FindPlayerByWidget(Widget button)
void OnLoadServersAsync(ref GetServersResult result_list, EBiosError error, string response)
ref map< string, ref PlayerListEntryScriptedWidget > m_Entries
proto native CGame GetGame()
proto native void SetFocus(Widget w)