DayZ 1.24
Loading...
Searching...
No Matches
VONManager.c File Reference

Go to the source code of this file.

Classes

class  VONManagerBase
 
class  VONManager
 Manager class which handles Voice-over-network functionality while player is connected to a server. More...
 

Functions

VONManagerBase Managed VONManagerImplementation ()
 
void VONManagerBase ()
 
void HideVoiceNotification ()
 Hides the VON notification completely and immediately.
 
void ShowVoiceNotification (int level, bool fading)
 Shows the voice notification.
 
void HandleInput (Input inp)
 Handles some VON related input.
 
void OnVOIPThresholdChanged ()
 Fires every time VOIP threshold value changes.
 
void OnEvent (EventType eventTypeId, Param params)
 Handles VON-related events.
 
bool IsVonToggled ()
 
void ~VONManagerImplementation ()
 
void UpdateVoiceIcon ()
 

Variables

bool m_VoNToggled
 
ref ScriptInvoker m_OnVonStateEvent
 
ref ScriptInvoker m_OnPartyChatChangedEvent
 

Function Documentation

◆ HandleInput()

override void HandleInput ( Input inp)
protected

Handles some VON related input.

Parameters
inpinput to handle

Definition at line 103 of file VONManager.c.

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 }
void UpdateVoiceIcon()
Definition VONManager.c:133
proto native CGame GetGame()

References GetGame(), and UpdateVoiceIcon().

◆ HideVoiceNotification()

override void HideVoiceNotification ( )
protected

Hides the VON notification completely and immediately.

Definition at line 41 of file VONManager.c.

42 {
43 if (GetGame().IsMissionMainMenu())
44 return;
45
46 Mission mission = GetGame().GetMission();
47 mission.GetMicrophoneIcon().Show(false);
49 }
Mission mission
Mission class.
Definition gameplay.c:668
void HideVoiceLevelWidgets()
Definition gameplay.c:790
ImageWidget GetMicrophoneIcon()
Definition gameplay.c:815

◆ IsVonToggled()

bool VONManagerImplementation::IsVonToggled ( )
protected

Definition at line 42 of file VONManager.c.

42 {
43 if (GetGame().IsMissionMainMenu())
44 return;
45

References GetGame(), Mission::GetMicrophoneIcon(), Mission::HideVoiceLevelWidgets(), and mission.

◆ OnEvent()

void VONManagerImplementation::OnEvent ( EventType eventTypeId,
Param params )
protected

Handles VON-related events.

Parameters
eventTypeIdevent that fired
paramsevent-specific parameters

Definition at line 167 of file VONManager.c.

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 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530
bool m_VoNToggled
Definition VONManager.c:27
ref ScriptInvoker m_OnPartyChatChangedEvent
Definition VONManager.c:29
void HideVoiceNotification()
Hides the VON notification completely and immediately.
Definition VONManager.c:41
ref ScriptInvoker m_OnVonStateEvent
Definition VONManager.c:28
void ShowVoiceNotification(int level, bool fading)
Shows the voice notification.
Definition VONManager.c:56
Super root of all classes in Enforce script.
Definition EnScript.c:11
void SetVoNActive(bool active)
Definition gameplay.c:792
Manager class which handles Voice-over-network functionality while player is connected to a server.
Definition VONManager.c:242
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
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), GetDayZGame(), GetGame(), VONManagerBase::HideVoiceNotification(), VONManager::IsVoiceThresholdMinimum(), m_OnPartyChatChangedEvent, m_OnVonStateEvent, m_VoNToggled, mission, MPSessionPlayerReadyEventTypeID, PartyChatStatusChangedEventTypeID, Mission::SetVoNActive(), VONManagerBase::ShowVoiceNotification(), UpdateVoiceIcon(), VONStartSpeakingEventTypeID, VONStateEventTypeID, VONStopSpeakingEventTypeID, VONUserStartedTransmittingAudioEventTypeID, and VONUserStoppedTransmittingAudioEventTypeID.

◆ OnVOIPThresholdChanged()

override void OnVOIPThresholdChanged ( )
protected

Fires every time VOIP threshold value changes.

Definition at line 157 of file VONManager.c.

158 {
160 }

References UpdateVoiceIcon().

◆ ShowVoiceNotification()

override void ShowVoiceNotification ( int level,
bool fading )
protected

Shows the voice notification.

Parameters
levelthe loudness of the player voice. 0 = whisper, 1 = normal, 2 = shout
fadingspecifies whether icon should slowly fade to invisibility after being displayed

Definition at line 56 of file VONManager.c.

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 }
map< int, ref WidgetFadeTimer > GetVoiceLevelTimers()
Definition gameplay.c:826
WidgetFadeTimer GetMicWidgetFadeTimer()
Definition gameplay.c:820
map< int, ImageWidget > GetVoiceLevelWidgets()
Definition gameplay.c:824

References GetGame(), Mission::GetMicrophoneIcon(), Mission::GetMicWidgetFadeTimer(), Mission::GetVoiceLevelTimers(), Mission::GetVoiceLevelWidgets(), and mission.

◆ UpdateVoiceIcon()

void UpdateVoiceIcon ( )
private

Definition at line 133 of file VONManager.c.

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 }
bool IsVoNActive()
Definition gameplay.c:791

References GetGame(), VONManagerBase::HideVoiceNotification(), VONManager::IsVoiceThresholdMinimum(), Mission::IsVoNActive(), m_VoNToggled, mission, and VONManagerBase::ShowVoiceNotification().

Referenced by HandleInput(), OnEvent(), and OnVOIPThresholdChanged().

◆ VONManagerBase()

void VONManagerImplementation::VONManagerBase ( )
protected

Definition at line 31 of file VONManager.c.

33 {
34 m_OnVonStateEvent.Clear();

Referenced by VONManager::CleanupInstance().

◆ VONManagerImplementation()

VONManagerBase Managed VONManagerImplementation ( )

Definition at line 1 of file VONManager.c.

27 {
30 }
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116

Referenced by VONManager::Init().

◆ ~VONManagerImplementation()

Definition at line 32 of file VONManager.c.

33 {
34 m_OnVonStateEvent.Clear();
36 }

References m_OnPartyChatChangedEvent, and m_OnVonStateEvent.

Variable Documentation

◆ m_OnPartyChatChangedEvent

ref ScriptInvoker m_OnPartyChatChangedEvent
protected

Definition at line 29 of file VONManager.c.

Referenced by OnEvent(), and ~VONManagerImplementation().

◆ m_OnVonStateEvent

ref ScriptInvoker m_OnVonStateEvent
protected

Definition at line 28 of file VONManager.c.

Referenced by OnEvent(), and ~VONManagerImplementation().

◆ m_VoNToggled

bool m_VoNToggled
protected

Definition at line 27 of file VONManager.c.

Referenced by OnEvent(), and UpdateVoiceIcon().