DayZ 1.24
Loading...
Searching...
No Matches
VONManager.c
Go to the documentation of this file.
37
41 override void HideVoiceNotification()
42 {
43 if (GetGame().IsMissionMainMenu())
44 return;
45
46 Mission mission = GetGame().GetMission();
47 mission.GetMicrophoneIcon().Show(false);
49 }
50
56 override void ShowVoiceNotification(int level, bool fading)
57 {
58 if (GetGame().IsMissionMainMenu())
59 return;
60
61 Mission mission = GetGame().GetMission();
63 WidgetFadeTimer micTimer = mission.GetMicWidgetFadeTimer();
66
67 // microphone icon
68 micTimer.Stop();
69 micIcon.SetAlpha(1.0);
70 micIcon.Show(true);
71
72 if (fading)
73 micTimer.FadeOut(micIcon, 3.0);
74
75 // range icons
76 for (int n = 0; n < voiceLeveWidgets.Count(); n++)
77 {
78 int voiceKey = voiceLeveWidgets.GetKey(n);
80
81 // stop fade timer since it will be refreshed
82 WidgetFadeTimer timer = voiceLevelTimers.Get(n);
83 timer.Stop();
84
85 // show widgets according to the level
86 if (voiceKey <= level)
87 {
88 voiceWidget.SetAlpha(1.0); // reset from possible previous fade out
89 voiceWidget.Show(true);
90
91 if (fading)
92 timer.FadeOut(voiceWidget, 3.0);
93 }
94 else
95 voiceWidget.Show(false);
96 }
97 }
98
103 override void HandleInput(Input inp)
104 {
105#ifdef PLATFORM_XBOX
106 // ignore VON-related input if user is in an xbox party
107 if (GetGame().IsInPartyChat())
108 return;
109#endif
110 int oldLevel = GetGame().GetVoiceLevel();
111 if (oldLevel == -1) //VoN system not initialized!
112 return;
113
114 int newLevel = -1;
115
116 if (inp.LocalPress_ID(UAVoiceDistanceUp, false))
117 newLevel = (oldLevel + 1) % (VoiceLevelShout + 1);
118
119 if (inp.LocalPress_ID(UAVoiceDistanceDown, false))
120 {
121 newLevel = oldLevel - 1;
122 if (newLevel < VoiceLevelWhisper) //nah...
124 }
125
126 if (newLevel > -1)
127 {
128 GetGame().SetVoiceLevel(newLevel);
130 }
131 }
132
133 private void UpdateVoiceIcon()
134 {
135 Mission mission = GetGame().GetMission();
136 int rangeLevel = GetGame().GetVoiceLevel();
137
138 if (mission.IsVoNActive())
139 {
140 if (m_VoNToggled)
141 {
144 else
146 }
147 else
149 }
150 else
152 }
153
158 {
160 }
161
168 {
169 Mission mission = GetGame().GetMission();
170 switch (eventTypeId)
171 {
173 {
174 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
175 if (m_VoNToggled)
176 {
178 ShowVoiceNotification(GetGame().GetVoiceLevel(), false);
179 }
180 break;
181 }
182
184 {
185 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
186 if (m_VoNToggled)
187 {
190 }
191 break;
192 }
193
195 {
196 if (!mission)
197 break;
198
202
204
205 m_OnVonStateEvent.Invoke();
206 break;
207 }
208
210 {
212 break;
213 }
214
216 {
219 GetDayZGame().AddVoiceNotification(vonStartParams);
220 break;
221 }
222
224 {
227 GetDayZGame().RemoveVoiceNotification(vonStopParams);
228 break;
229 }
230
232 {
234 break;
235 }
236 }
237 }
238}
239
242{
244
250 {
251 return m_VONManager;
252 }
253
257 static void Init()
258 {
259 delete m_VONManager;
261 }
262
266 static void CleanupInstance()
267 {
268 delete m_VONManager;
270 }
271
276 static bool IsVONToggled()
277 {
278 return m_VONManager.IsVonToggled();
279 }
280
286 {
289 Class.CastTo(noa, gameOptions.GetOptionByType(OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER));
290
291 return noa.ReadValue() <= GetGame().GetSoundScene().GetSilenceThreshold();
292 }
293}
DayZGame GetDayZGame()
Definition DayZGame.c:3530
Mission mission
bool m_VoNToggled
Definition VONManager.c:27
ref ScriptInvoker m_OnPartyChatChangedEvent
Definition VONManager.c:29
VONManagerBase Managed VONManagerImplementation()
Definition VONManager.c:26
void ~VONManagerImplementation()
Definition VONManager.c:32
ref ScriptInvoker m_OnVonStateEvent
Definition VONManager.c:28
void VONManagerBase()
Definition VONManager.c:31
void UpdateVoiceIcon()
Definition VONManager.c:133
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition input.c:11
TODO doc.
Definition EnScript.c:118
Mission class.
Definition gameplay.c:668
map< int, ref WidgetFadeTimer > GetVoiceLevelTimers()
Definition gameplay.c:826
void HideVoiceLevelWidgets()
Definition gameplay.c:790
WidgetFadeTimer GetMicWidgetFadeTimer()
Definition gameplay.c:820
ImageWidget GetMicrophoneIcon()
Definition gameplay.c:815
bool IsVoNActive()
Definition gameplay.c:791
map< int, ImageWidget > GetVoiceLevelWidgets()
Definition gameplay.c:824
void SetVoNActive(bool active)
Definition gameplay.c:792
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
void OnEvent(EventType eventTypeId, Param params)
bool m_VoNToggled
Definition VONManager.c:3
void HandleInput(Input inp)
void ShowVoiceNotification(int level, bool fading)
void VONManagerBase()
Definition VONManager.c:7
void HideVoiceNotification()
void OnVOIPThresholdChanged()
bool IsVonToggled()
Definition VONManager.c:18
ref ScriptInvoker m_OnVonStateEvent
Definition VONManager.c:4
ref ScriptInvoker m_OnPartyChatChangedEvent
Definition VONManager.c:5
Manager class which handles Voice-over-network functionality while player is connected to a server.
Definition VONManager.c:242
static bool IsVONToggled()
Specifies whether VON mode is toggled or not.
Definition VONManager.c:276
static VONManagerBase GetInstance()
Main way to access VONManager functionality from script.
Definition VONManager.c:249
static void CleanupInstance()
Uninitializes VONManager, runs when user disconnects from server.
Definition VONManager.c:266
static ref VONManagerBase m_VONManager
Definition VONManager.c:243
static void Init()
Initializes VONManager, runs when user first connects to a server.
Definition VONManager.c:257
static bool IsVoiceThresholdMinimum()
Specifies whether user's voice activation threshold value is equal to the minimum voice activation th...
Definition VONManager.c:285
const EventType PartyChatStatusChangedEventTypeID
no params
Definition gameplay.c:546
const EventType VONStartSpeakingEventTypeID
params: VONStartSpeakingEventParams
Definition gameplay.c:536
const EventType VONStateEventTypeID
params: VONStateEventParams
Definition gameplay.c:534
const EventType VONUserStoppedTransmittingAudioEventTypeID
no params
Definition gameplay.c:542
const EventType VONUserStartedTransmittingAudioEventTypeID
no params
Definition gameplay.c:540
const EventType VONStopSpeakingEventTypeID
params: VONStopSpeakingEventParams
Definition gameplay.c:538
const EventType MPSessionPlayerReadyEventTypeID
no params
Definition gameplay.c:466
proto native CGame GetGame()
OptionAccessType
C++ OptionAccessType.
Definition gameplay.c:1182
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
TypeID EventType
Definition EnWidgets.c:55