4 protected ScrollWidget m_ScrollContainer;
8 protected int m_TotalEntries;
9 protected PlayerListEntryScriptedWidget m_SelectedEntry;
11 void PlayerListScriptedWidget(
Widget parent,
string header_text =
"" )
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" );
19 m_ScrollContainer.VScrollToPos01( 0 );
22 void ~PlayerListScriptedWidget()
29 if ( m_Content && m_Content.GetChildren() )
30 SetFocus( m_Content.GetChildren().FindAnyWidget(
"Button" ) );
31 m_ScrollContainer.VScrollToPos01( 0 );
36 if ( player_list && player_list.m_PlayerList && m_Entries )
38 foreach (
string UID, PlayerListEntryScriptedWidget widget : m_Entries )
41 foreach (
SyncPlayer player : player_list.m_PlayerList )
43 if ( player && player.m_UID ==
UID )
45 player_found = player;
55 for (
int i = 0; i < player_list.m_PlayerList.Count(); i++ )
57 SyncPlayer player2 = player_list.m_PlayerList.Get( i );
58 PlayerListEntryScriptedWidget player_widget;
59 m_Entries.Find( player2.m_UID, player_widget );
62 AddPlayer( player2.m_PlayerName, player2.m_UID,
true );
70 return ( m_Entries.Count() == 0 );
80 if ( player_list && m_Entries )
82 foreach (
string UID, PlayerListEntryScriptedWidget widget : m_Entries )
86 while ( !player_found && j < player_list.Count() )
88 if ( player_list[j].m_Uid ==
UID )
89 player_found = player_list[j];
99 for (
int i = 0; i < player_list.Count(); i++ )
102 PlayerListEntryScriptedWidget player_widget;
103 m_Entries.Find( player2.m_Uid, player_widget );
104 if ( !player_widget )
106 AddPlayer( player2.m_DisplayName, player2.m_Uid,
false );
116 PlayerListEntryScriptedWidget player_widget;
117 m_Entries.Find( result.m_Uid, player_widget );
120 player_widget.LoadPermissions( result.m_Results );
129 for (
int i = 0; i < player_list.Count(); i++ )
131 string uid = player_list.GetKey( i );
133 PlayerListEntryScriptedWidget player_widget;
134 m_Entries.Find( uid, player_widget );
137 player_widget.SetMute( muted );
143 PlayerListEntryScriptedWidget FindEntryByWidget(
Widget button )
145 if ( button && m_Entries )
147 foreach (
string UID, PlayerListEntryScriptedWidget widget : m_Entries )
149 if ( widget && widget.GetButtonWidget() == button )
159 string FindPlayerByWidget(
Widget button )
161 if ( button && m_Entries )
163 foreach (
string UID, PlayerListEntryScriptedWidget widget : m_Entries )
165 if ( widget && widget.GetButtonWidget() == button )
175 void AddPlayer(
string name,
string UID,
bool show_permissions )
179 m_Entries.Insert(
UID,
new PlayerListEntryScriptedWidget( m_Content,
name,
UID, show_permissions,
this ) );
184 void RemovePlayer(
string UID )
188 PlayerListEntryScriptedWidget next_entry;
190 if ( m_Entries.Get(
UID ) == m_SelectedEntry )
192 for (
int i = 0; i < m_Entries.Count() - 1; i++ )
194 if ( m_Entries.GetElement( i ) == m_Entries.Get(
UID ) )
196 next_entry = m_Entries.GetElement( i + 1 );
201 m_Entries.Remove(
UID );
203 SelectPlayer( next_entry );
208 bool IsMuted(
string UID )
210 if ( m_Entries && m_Entries.Get(
UID ) )
212 return m_Entries.Get(
UID ).IsMuted();
217 bool IsGloballyMuted(
string UID )
219 if ( m_Entries && m_Entries.Get(
UID ) )
221 return m_Entries.Get(
UID ).IsGloballyMuted();
226 void SetMute(
string UID,
bool mute )
228 if ( m_Entries && m_Entries.Get(
UID ) )
230 m_Entries.Get(
UID ).SetMute( mute );
234 void ToggleMute(
string UID )
236 if ( m_Entries && m_Entries.Get(
UID ) )
238 m_Entries.Get(
UID ).ToggleMute();
242 PlayerListEntryScriptedWidget GetSelectedPlayer()
244 return m_SelectedEntry;
247 void SelectPlayer( PlayerListEntryScriptedWidget entry )
249 if ( m_SelectedEntry )
250 m_SelectedEntry.Deselect();
251 m_SelectedEntry = entry;
252 if (
GetGame().GetUIManager().GetMenu() )
253 GetGame().GetUIManager().GetMenu().Refresh();
265 Widget root = entry.GetButtonWidget().GetParent();
266 Widget first_child = root.GetParent().GetChildren();
267 Widget last_child = first_child;
270 if ( last_child.GetSibling() )
271 last_child = last_child.GetSibling();
276 root.GetParent().Update();
279 m_ScrollContainer.GetScreenPos(
x,
y );
280 m_ScrollContainer.GetScreenSize( x_s, y_s );
282 float bottom_pos =
y + y_s;
284 root.GetScreenPos( x_l, y_l );
285 root.GetScreenSize( x_s, y_s );
287 if ( root == first_child )
289 m_ScrollContainer.VScrollToPos01( 0 );
291 else if ( root == last_child )
293 m_ScrollContainer.VScrollToPos01( 1 );
295 else if ( y_l + y_s >= bottom_pos )
297 m_ScrollContainer.VScrollToPos( m_ScrollContainer.GetVScrollPos() + y_s );
301 m_ScrollContainer.VScrollToPos( m_ScrollContainer.GetVScrollPos() - y_s );