Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
playerlistscriptedwidget.c
Go to the documentation of this file.
1class PlayerListScriptedWidget extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4 protected ScrollWidget m_ScrollContainer;
5 protected Widget m_Content;
7
8 protected int m_TotalEntries;
10
11 void PlayerListScriptedWidget( Widget parent, string header_text = "" )
12 {
13 m_Root = g_Game.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
34 void Reload( SyncPlayerList player_list )
35 {
36 if ( player_list && player_list.m_PlayerList && m_Entries )
37 {
38 foreach ( string UID, PlayerListEntryScriptedWidget widget : m_Entries )
39 {
40 SyncPlayer player_found;
41 foreach ( SyncPlayer player : player_list.m_PlayerList )
42 {
43 if ( player && player.m_UID == UID )
44 {
45 player_found = player;
46 break;
47 }
48 }
49 if ( !player_found )
50 {
52 }
53 }
54
55 for ( int i = 0; i < player_list.m_PlayerList.Count(); i++ )
56 {
57 SyncPlayer player2 = player_list.m_PlayerList.Get( i );
59 m_Entries.Find( player2.m_UID, player_widget );
60 if ( !player_widget )
61 {
62 AddPlayer( player2.m_PlayerName, player2.m_UID, true );
63 }
64 }
65 }
66 }
67
68 bool IsEmpty()
69 {
70 return ( m_Entries.Count() == 0 );
71 }
72
73 void OnLoadServersAsync( GetServersResult result_list, EBiosError error, string response )
74 {
75
76 }
77
78 void Reload( BiosFriendInfoArray player_list )
79 {
80 if ( player_list && m_Entries )
81 {
82 foreach ( string UID, PlayerListEntryScriptedWidget widget : m_Entries )
83 {
84 BiosFriendInfo player_found;
85 int j = 0;
86 while ( !player_found && j < player_list.Count() )
87 {
88 if ( player_list[j].m_Uid == UID )
89 player_found = player_list[j];
90 j++;
91 }
92
93 if ( !player_found )
94 {
96 }
97 }
98
99 for ( int i = 0; i < player_list.Count(); i++ )
100 {
101 BiosFriendInfo player2 = player_list.Get( i );
102 PlayerListEntryScriptedWidget player_widget;
103 m_Entries.Find( player2.m_Uid, player_widget );
104 if ( !player_widget )
105 {
106 AddPlayer( player2.m_DisplayName, player2.m_Uid, false );
107 }
108 }
109 }
110 }
111
113 {
114 foreach ( BiosPrivacyUidResult result : player_list )
115 {
116 PlayerListEntryScriptedWidget player_widget;
117 m_Entries.Find( result.m_Uid, player_widget );
118 if ( player_widget )
119 {
120 player_widget.LoadPermissions( result.m_Results );
121 }
122 }
123 }
124
125 void ReloadLocal( map<string, bool> player_list )
126 {
127 if ( player_list )
128 {
129 for ( int i = 0; i < player_list.Count(); i++ )
130 {
131 string uid = player_list.GetKey( i );
132 bool muted = OnlineServices.IsPlayerMuted( uid );
133 PlayerListEntryScriptedWidget player_widget;
134 m_Entries.Find( uid, player_widget );
135 if ( player_widget )
136 {
137 player_widget.SetMute( muted );
138 }
139 }
140 }
141 }
142
144 {
145 if ( button && m_Entries )
146 {
147 foreach ( string UID, PlayerListEntryScriptedWidget widget : m_Entries )
148 {
149 if ( widget && widget.GetButtonWidget() == button )
150 {
151 return widget;
152 }
153 }
154 }
155
156 return null;
157 }
158
159 string FindPlayerByWidget( Widget button )
160 {
161 if ( button && m_Entries )
162 {
163 foreach ( string UID, PlayerListEntryScriptedWidget widget : m_Entries )
164 {
165 if ( widget && widget.GetButtonWidget() == button )
166 {
167 return UID;
168 }
169 }
170 }
171
172 return "";
173 }
174
175 void AddPlayer( string name, string UID, bool show_permissions )
176 {
177 if ( m_Entries )
178 {
179 m_Entries.Insert( UID, new PlayerListEntryScriptedWidget( m_Content, name, UID, show_permissions, this ) );
181 }
182 }
183
184 void RemovePlayer(string UID)
185 {
186 if (m_Entries)
187 {
189 if (m_Entries.Get(UID) == m_SelectedEntry)
190 {
191 for (int i = 0; i < m_Entries.Count() - 1; i++)
192 {
193 if (m_Entries.GetElement(i) != m_Entries.Get(UID))
194 continue;
195
196 // Select next possibe player entry after the one to delete if possible
197 if (i + 1 <= m_Entries.Count() - 1)
198 {
199 next_entry = m_Entries.GetElement(i + 1);
200 }
201 }
202 }
203
204 m_Entries.Remove(UID);
206
207 // If there is no other possibe player entry after the current one to select we try to select the first indexed one
208 if (!next_entry)
209 {
210 next_entry = m_Entries.GetElement(0);
211 }
212
213 // If we found a next entry to select from we select it in the UI class and focus on it
214 // if not we only deselect the current one as there is no other possible entry to focus on
215 if (next_entry)
216 {
217 SelectPlayer(next_entry);
218 }
219 else
220 {
221 if (m_SelectedEntry)
222 m_SelectedEntry.Deselect();
223 }
224
225 m_Content.Update();
226 }
227 }
228
229 bool IsMuted( string UID )
230 {
231 if ( m_Entries && m_Entries.Get( UID ) )
232 {
233 return m_Entries.Get( UID ).IsMuted();
234 }
235 return false;
236 }
237
238 bool IsGloballyMuted( string UID )
239 {
240 if ( m_Entries && m_Entries.Get( UID ) )
241 {
242 return m_Entries.Get( UID ).IsGloballyMuted();
243 }
244 return false;
245 }
246
247 void SetMute( string UID, bool mute )
248 {
249 if ( m_Entries && m_Entries.Get( UID ) )
250 {
251 m_Entries.Get( UID ).SetMute( mute );
252 }
253 }
254
255 void ToggleMute( string UID )
256 {
257 if ( m_Entries && m_Entries.Get( UID ) )
258 {
259 m_Entries.Get( UID ).ToggleMute();
260 }
261 }
262
267
269 {
270 if (m_SelectedEntry)
271 {
272 m_SelectedEntry.Deselect();
273 }
274
275 m_SelectedEntry = entry;
276
277 #ifdef PLATFORM_CONSOLE
278 // Focus on new selected entry as OnFocus event function will handle the rest
279 m_SelectedEntry.Focus();
280 #endif
281
282 if (g_Game.GetUIManager().GetMenu())
283 g_Game.GetUIManager().GetMenu().Refresh();
285 }
286
288 {
289 if ( entry )
290 {
291 float x, y;
292 float x_s, y_s;
293 float x_l, y_l;
294
295 Widget root = entry.GetButtonWidget().GetParent();
296 Widget first_child = root.GetParent().GetChildren();
297 Widget last_child = first_child;
298 while ( last_child )
299 {
300 if ( last_child.GetSibling() )
301 last_child = last_child.GetSibling();
302 else
303 break;
304 }
305
306 root.GetParent().Update();
307 root.Update();
308
309 m_ScrollContainer.GetScreenPos( x, y );
310 m_ScrollContainer.GetScreenSize( x_s, y_s );
311
312 float bottom_pos = y + y_s;
313
314 root.GetScreenPos( x_l, y_l );
315 root.GetScreenSize( x_s, y_s );
316
317 if ( root == first_child )
318 {
319 m_ScrollContainer.VScrollToPos01( 0 );
320 }
321 else if ( root == last_child )
322 {
323 m_ScrollContainer.VScrollToPos01( 1 );
324 }
325 else if ( y_l + y_s >= bottom_pos )
326 {
327 m_ScrollContainer.VScrollToPos( m_ScrollContainer.GetVScrollPos() + y_s );
328 }
329 else if ( y_l <= y )
330 {
331 m_ScrollContainer.VScrollToPos( m_ScrollContainer.GetVScrollPos() - y_s );
332 }
333 }
334 }
335}
EBiosError
Possible Error codes for bios API.
array< ref BiosPrivacyUidResult > BiosPrivacyUidResultArray
array< ref BiosFriendInfo > BiosFriendInfoArray
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
BiosFriendInfo represents friend information.
string m_Uid
The Uid of the friend.
string m_DisplayName
The Displayable nick name of the friend.
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:657
void PlayerListEntryScriptedWidget(Widget parent, string name, string uid, bool show_permissions, PlayerListScriptedWidget tab)
void SetMute(string UID, bool mute)
void Reload(BiosPrivacyUidResultArray player_list)
void ReloadLocal(map< string, bool > player_list)
void ScrollToEntry(PlayerListEntryScriptedWidget entry)
void AddPlayer(string name, string UID, bool show_permissions)
ref map< string, ref PlayerListEntryScriptedWidget > m_Entries
void OnLoadServersAsync(GetServersResult result_list, EBiosError error, string response)
void Reload(SyncPlayerList player_list)
void SelectPlayer(PlayerListEntryScriptedWidget entry)
void Reload(BiosFriendInfoArray player_list)
void PlayerListScriptedWidget(Widget parent, string header_text="")
string FindPlayerByWidget(Widget button)
PlayerListEntryScriptedWidget m_SelectedEntry
PlayerListEntryScriptedWidget FindEntryByWidget(Widget button)
PlayerListEntryScriptedWidget GetSelectedPlayer()
string m_UID
Keeping for backwards compatability with mods.
Definition syncplayer.c:8
string m_PlayerName
Definition syncplayer.c:11
ref array< ref SyncPlayer > m_PlayerList
DayZGame g_Game
Definition dayzgame.c:3942
proto native void SetFocus(Widget w)
WorkspaceWidget Widget
Defined in code.
Icon x
Icon y
Widget m_Root
Definition sizetochild.c:91