Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
playerlistentryscriptedwidget.c
Go to the documentation of this file.
1class PlayerListEntryScriptedWidget extends ScriptedWidgetEventHandler
2{
3 protected string m_Name;
4 protected string m_UID;
5 protected bool m_Mute;
6 protected bool m_GlobalMute;
7
8 protected Widget m_Root;
9 protected TextWidget m_PlayerName;
10 protected ImageWidget m_PlayerAvatar;
11 protected ImageWidget m_MicrophoneIcon;
12 protected ImageWidget m_MuteIcon;
13 protected ButtonWidget m_PlayerButton;
14
15 protected PlayerListScriptedWidget m_Tab;
16 protected bool m_Selected;
17
18 void PlayerListEntryScriptedWidget( Widget parent, string name, string uid, bool show_permissions, PlayerListScriptedWidget tab )
19 {
20 m_Name = name;
21 m_UID = uid;
22 m_Tab = tab;
23
24 m_Root = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/xbox/ingamemenu_xbox/player_info_entry.layout", parent );
25 m_PlayerName = TextWidget.Cast( m_Root.FindAnyWidget( "Name" ) );
26 m_PlayerAvatar = ImageWidget.Cast( m_Root.FindAnyWidget( "Avatar" ) );
27 m_MicrophoneIcon = ImageWidget.Cast( m_Root.FindAnyWidget( "Microphone" ) );
28 m_MuteIcon = ImageWidget.Cast( m_Root.FindAnyWidget( "Muted" ) );
29 m_PlayerButton = ButtonWidget.Cast( m_Root.FindAnyWidget( "Button" ) );
30
31 m_MicrophoneIcon.Show( show_permissions && !IsLocalPlayer() );
32
33 m_PlayerName.SetText( name );
34 m_Root.SetHandler( this );
35 }
36
37 void ~PlayerListEntryScriptedWidget()
38 {
39 delete m_Root;
40 }
41
42 Widget GetButtonWidget()
43 {
44 return m_PlayerButton;
45 }
46
47 void LoadPermissions( BiosPrivacyPermissionResultArray results )
48 {
49 foreach ( BiosPrivacyPermissionResult result : results )
50 {
51 if ( result.m_Permission == EBiosPrivacyPermission.COMMUNICATE_VOICE )
52 {
53 m_GlobalMute = !result.m_IsAllowed;
54 if ( result.m_IsAllowed && !m_Mute )
55 {
56 m_MuteIcon.Show( false );
57 }
58 else if ( !result.m_IsAllowed || m_Mute )
59 {
60 m_MuteIcon.Show( true );
61 }
62 }
63 }
64 }
65
66 string GetUID()
67 {
68 return m_UID;
69 }
70
71 bool IsMuted()
72 {
73 return m_Mute;
74 }
75
76 bool IsGloballyMuted()
77 {
78 return m_GlobalMute;
79 }
80
81 void SetMute( bool mute )
82 {
83 m_Mute = mute;
84 m_MuteIcon.Show( mute );
85 }
86
87 void ToggleMute()
88 {
89 if( !IsLocalPlayer() && !GetGame().GetWorld().IsDisabledReceivingVoN() )
90 {
91 m_Mute = !m_Mute;
92 if ( ScriptInputUserData.CanStoreInputUserData() && !m_GlobalMute )
93 {
94 OnlineServices.MutePlayer( m_UID, m_Mute );
95 m_MuteIcon.Show( m_Mute );
96 }
97 else
98 {
99 m_MuteIcon.Show( true );
100 }
101 }
102 else
103 {
104 m_MicrophoneIcon.Show( false );
105 m_MuteIcon.Show( false );
106 }
107 }
108
109 override bool OnMouseEnter( Widget w, int x, int y )
110 {
111 if( !m_Selected )
112 {
113 #ifdef PLATFORM_CONSOLE
114 if( w == m_PlayerButton )
115 {
116 Select();
117 SetFocus( m_PlayerButton );
118 }
119 #endif
120 return true;
121 }
122 return false;
123 }
124
125 override bool OnMouseLeave( Widget w, Widget enterW, int x, int y )
126 {
127 #ifdef PLATFORM_CONSOLE
128 if( w == m_PlayerButton )
129 {
130 Deselect();
131 return true;
132 }
133 #endif
134 return false;
135 }
136
137 void Focus()
138 {
139 SetFocus(m_PlayerButton);
140 }
141
142 override bool OnFocus( Widget w, int x, int y )
143 {
144 if( !m_Selected )
145 {
146 #ifdef PLATFORM_CONSOLE
147 if( w == m_PlayerButton )
148 {
149 Select();
150 }
151 #endif
152 return true;
153 }
154 return false;
155 }
156
157 override bool OnFocusLost( Widget w, int x, int y )
158 {
159 #ifdef PLATFORM_CONSOLE
160 if( w == m_PlayerButton )
161 {
162 Deselect();
163 }
164 #endif
165 return false;
166 }
167
168 override bool OnDoubleClick( Widget w, int x, int y, int button )
169 {
170 if( button == MouseState.LEFT && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() )
171 {
172 if( !IsLocalPlayer() )
173 {
175 }
176 }
177 return false;
178 }
179
180 override bool OnMouseButtonUp( Widget w, int x, int y, int button )
181 {
182 if( button == MouseState.LEFT && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() )
183 {
184 if( w == m_MicrophoneIcon && !m_GlobalMute )
185 {
186 ToggleMute();
187 return true;
188 }
189 }
190 return false;
191 }
192
193 bool IsLocalPlayer()
194 {
195 string local_uid;
196 if( GetGame().GetUserManager() )
197 {
198 return GetGame().GetUserManager().GetSelectedUser().GetUid() == m_UID;
199 }
200 return false;
201 }
202
203 void Select( bool notify = true )
204 {
205 if( !m_Selected )
206 {
207 if( notify )
208 {
209 m_Tab.SelectPlayer( this );
210 }
211 m_Selected = true;
212 }
213 }
214
215 void Deselect()
216 {
217 if( m_Selected )
218 {
219 m_Selected = false;
220 }
221 }
222}
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
EBiosPrivacyPermission
EBiosPrivacyPermission represents possible privacy permissions.
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
BiosPrivacyPermissionResult represents the per permission result of the GetPermissionsAsync reqeust.
proto native BiosUserManager GetUserManager()
static void ShowUserProfile(string uid)
static bool MutePlayer(string id, bool mute)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
MouseState
Definition ensystem.c:311
Icon x
Icon y
override bool OnDoubleClick(Widget w, int x, int y, int button)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition radialmenu.c:668
void Focus()
override bool OnFocusLost(Widget w, int x, int y)
override bool OnFocus(Widget w, int x, int y)
Widget m_Root
Definition sizetochild.c:91
class SyncedValue m_Name