DayZ 1.24
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;
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
38 {
39 delete m_Root;
40 }
41
43 {
44 return m_PlayerButton;
45 }
46
48 {
50 {
51 if (result.m_Permission == EBiosPrivacyPermission.COMMUNICATE_VOICE)
52 {
53 m_GlobalMute = !result.m_IsAllowed;
54 if (result.m_IsAllowed && !m_Mute)
55 m_MuteIcon.Show(false);
56 else if (!result.m_IsAllowed || m_Mute)
57 m_MuteIcon.Show(true);
58 }
59 }
60 }
61
62 string GetUID()
63 {
64 return m_UID;
65 }
66
67 bool IsMuted()
68 {
69 return m_Mute;
70 }
71
73 {
74 return m_GlobalMute;
75 }
76
77 void SetMute(bool mute)
78 {
79 m_Mute = mute;
80 m_MuteIcon.Show(mute);
81 }
82
84 {
85 if (!IsLocalPlayer() && !GetGame().GetWorld().IsDisabledReceivingVoN())
86 {
87 m_Mute = !m_Mute;
88 if (ScriptInputUserData.CanStoreInputUserData() && !m_GlobalMute)
89 {
90 OnlineServices.MutePlayer(m_UID, m_Mute);
91 m_MuteIcon.Show(m_Mute);
92 }
93 else
94 m_MuteIcon.Show(true);
95 }
96 else
97 {
98 m_MicrophoneIcon.Show(false);
99 m_MuteIcon.Show(false);
100 }
101 }
102
103 override bool OnMouseEnter(Widget w, int x, int y)
104 {
105 if (!m_Selected)
106 {
107#ifdef PLATFORM_CONSOLE
108 if (w == m_PlayerButton)
109 {
110 Select();
111 SetFocus(m_PlayerButton);
112 }
113#endif
114 return true;
115 }
116 return false;
117 }
118
119 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
120 {
121#ifdef PLATFORM_CONSOLE
122 if (w == m_PlayerButton)
123 {
124 Deselect();
125 return true;
126 }
127#endif
128 return false;
129 }
130
131 void Focus()
132 {
133 OnFocus(m_Root, 0, 0);
134 }
135
136 override bool OnFocus(Widget w, int x, int y)
137 {
138 if (!m_Selected)
139 {
140#ifdef PLATFORM_CONSOLE
141 if (w == m_PlayerButton)
142 Select();
143#endif
144 return true;
145 }
146 return false;
147 }
148
149 override bool OnFocusLost(Widget w, int x, int y)
150 {
151#ifdef PLATFORM_CONSOLE
152 if (w == m_PlayerButton)
153 Deselect();
154#endif
155 return false;
156 }
157
158 override bool OnDoubleClick(Widget w, int x, int y, int button)
159 {
160 if (button == MouseState.LEFT && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
161 {
162 if (!IsLocalPlayer())
164 }
165 return false;
166 }
167
168 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
169 {
170 if (button == MouseState.LEFT && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
171 {
172 if (w == m_MicrophoneIcon && !m_GlobalMute)
173 {
174 ToggleMute();
175 return true;
176 }
177 }
178 return false;
179 }
180
182 {
183 string local_uid;
184 if (GetGame().GetUserManager())
185 return GetGame().GetUserManager().GetSelectedUser().GetUid() == m_UID;
186 return false;
187 }
188
189 void Select(bool notify = true)
190 {
191 if (!m_Selected)
192 {
193 if (notify)
194 m_Tab.SelectPlayer(this);
195 m_Selected = true;
196 }
197 }
198
199 void Deselect()
200 {
201 if (m_Selected)
202 m_Selected = false;
203 }
204}
ActionInput GetInput()
Definition ActionBase.c:989
string m_Name
EBiosPrivacyPermission
EBiosPrivacyPermission represents possible privacy permissions.
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
Widget m_Root
Definition SizeToChild.c:85
BiosPrivacyPermissionResult represents the per permission result of the GetPermissionsAsync reqeust.
static void ShowUserProfile(string uid)
static bool MutePlayer(string id, bool mute)
proto static native bool CanStoreInputUserData()
map: item x vector(index, width, height)
Definition EnWidgets.c:651
override bool OnFocusLost(Widget w, int x, int y)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
override bool OnDoubleClick(Widget w, int x, int y, int button)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void LoadPermissions(BiosPrivacyPermissionResultArray results)
void PlayerListEntryScriptedWidget(Widget parent, string name, string uid, bool show_permissions, PlayerListScriptedWidget tab)
override bool OnFocus(Widget w, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
MouseState
Definition EnSystem.c:311
proto native void SetFocus(Widget w)
bool OnFocus(Widget w, int x, int y)