DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
VONManager.c
См. документацию.
37
41 override void HideVoiceNotification()
42 {
43 if (GetGame().IsMissionMainMenu())
44 {
45 return;
46 }
47
49 mission.GetMicrophoneIcon().Show(false);
50 mission.HideVoiceLevelWidgets();
51 }
52
58 override void ShowVoiceNotification(int level, bool fading)
59 {
60 if (GetGame().IsMissionMainMenu())
61 {
62 return;
63 }
64
66 ImageWidget micIcon = mission.GetMicrophoneIcon();
67 WidgetFadeTimer micTimer = mission.GetMicWidgetFadeTimer();
68 map<int,ImageWidget> voiceLeveWidgets = mission.GetVoiceLevelWidgets();
69 map<int,ref WidgetFadeTimer> voiceLevelTimers = mission.GetVoiceLevelTimers();
70
71 // microphone icon
72 micTimer.Stop();
73 micIcon.SetAlpha(1.0);
74 micIcon.Show(true);
75
76 if (fading)
77 {
78 micTimer.FadeOut(micIcon, 3.0);
79 }
80
81 // range icons
82 for( int n = 0; n < voiceLeveWidgets.Count(); n++ )
83 {
84 int voiceKey = voiceLeveWidgets.GetKey(n);
85 ImageWidget voiceWidget = voiceLeveWidgets.Get(n);
86
87 // stop fade timer since it will be refreshed
88 WidgetFadeTimer timer = voiceLevelTimers.Get(n);
89 timer.Stop();
90
91 // show widgets according to the level
92 if ( voiceKey <= level )
93 {
94 voiceWidget.SetAlpha(1.0); // reset from possible previous fade out
95 voiceWidget.Show(true);
96
97 if (fading)
98 {
99 timer.FadeOut(voiceWidget, 3.0);
100 }
101 }
102 else
103 {
104 voiceWidget.Show(false);
105 }
106 }
107 }
108
113 override void HandleInput(Input inp)
114 {
115#ifdef PLATFORM_XBOX
116 // ignore VON-related input if user is in an xbox party
117 if (GetGame().IsInPartyChat())
118 {
119 return;
120 }
121#endif
122 int oldLevel = GetGame().GetVoiceLevel();
123 if (oldLevel == -1) //VoN system not initialized!
124 return;
125
126 int newLevel = -1;
127
128 if (inp.LocalPress_ID(UAVoiceDistanceUp,false))
129 {
130 newLevel = ( oldLevel + 1 ) % ( VoiceLevelShout + 1 );
131 }
132
133 if (inp.LocalPress_ID(UAVoiceDistanceDown,false))
134 {
135 newLevel = oldLevel - 1;
136 if (newLevel < VoiceLevelWhisper) //nah...
137 {
138 newLevel = VoiceLevelShout;
139 }
140 }
141
142 if (newLevel > -1)
143 {
144 CGame game = GetGame();
145 game.SetVoiceLevel(newLevel);
146 if (game.GetMission().IsVoNActive()) // icon is already visible, just update the range
147 {
149 }
150 else // Show the icon and let it fade out
151 {
152 int level = GetGame().GetVoiceLevel();
153 ShowVoiceNotification(level, true);
154 }
155 }
156 }
157
158 private void UpdateVoiceIcon()
159 {
161 int rangeLevel = GetGame().GetVoiceLevel();
162
163 if (mission.IsVoNActive())
164 {
165 if (m_VoNToggled)
166 {
168 {
169 ShowVoiceNotification(rangeLevel, false);
170 }
171 else
172 {
173 ShowVoiceNotification(rangeLevel, true);
174 }
175 }
176 else
177 {
178 ShowVoiceNotification(rangeLevel, false);
179 }
180 }
181 else
182 {
184 }
185 }
186
191 {
193 }
194
200 override void OnEvent(EventType eventTypeId, Param params)
201 {
203 switch (eventTypeId)
204 {
206 {
207 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
208 if (m_VoNToggled)
209 {
211 {
212 ShowVoiceNotification(GetGame().GetVoiceLevel(), false);
213 }
214 }
215 break;
216 }
217
219 {
220 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
221 if (m_VoNToggled)
222 {
224 {
226 }
227 }
228 break;
229 }
230
232 {
233 if (!mission)
234 {
235 break;
236 }
237
238 VONStateEventParams vonStateParams = VONStateEventParams.Cast( params );
239 mission.SetVoNActive(vonStateParams.param1);
240 m_VoNToggled = vonStateParams.param2;
241
243
244 m_OnVonStateEvent.Invoke();
245 break;
246 }
247
249 {
251 break;
252 }
253
255 {
256 VONStartSpeakingEventParams vonStartParams;
257 if (Class.CastTo(vonStartParams, params))
258 {
259 GetDayZGame().AddVoiceNotification(vonStartParams);
260 }
261 break;
262 }
263
265 {
266 VONStopSpeakingEventParams vonStopParams;
267 if (Class.CastTo(vonStopParams, params))
268 {
269 GetDayZGame().RemoveVoiceNotification(vonStopParams);
270 }
271 break;
272 }
273
275 {
277 break;
278 }
279 }
280 }
281}
282
285{
286 private static ref VONManagerBase m_VONManager = new VONManagerBase();
287
293 {
294 return m_VONManager;
295 }
296
300 static void Init()
301 {
302 delete m_VONManager;
304 }
305
309 static void CleanupInstance()
310 {
311 delete m_VONManager;
313 }
314
319 static bool IsVONToggled()
320 {
321 return m_VONManager.IsVonToggled();
322 }
323
329 {
330 GameOptions gameOptions = new GameOptions();
331 NumericOptionsAccess noa;
332 Class.CastTo(noa, gameOptions.GetOptionByType( OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER ));
333
334 return noa.ReadValue() <= GetGame().GetSoundScene().GetSilenceThreshold();
335 }
336}
map
Определения ControlsXboxNew.c:4
DayZGame GetDayZGame()
Определения DayZGame.c:3870
Mission mission
Определения DisplayStatus.c:28
bool m_VoNToggled
Определения VONManager.c:27
ref ScriptInvoker m_OnPartyChatChangedEvent
Определения VONManager.c:29
VONManagerBase Managed VONManagerImplementation()
Определения VONManager.c:26
void ~VONManagerImplementation()
Определения VONManager.c:32
ref ScriptInvoker m_OnVonStateEvent
Определения VONManager.c:28
void VONManagerBase()
Определения VONManager.c:31
void UpdateVoiceIcon()
Определения VONManager.c:158
proto native AbstractSoundScene GetSoundScene()
proto native int GetVoiceLevel(Object player=null)
Get voice level of VoN (on both client and server) (VoiceLevelWhisper = 0, VoiceLevelNormal = 1,...
proto native void SetVoiceLevel(int level)
Set voice level of VoN (only on client) (VoiceLevelWhisper = 0, VoiceLevelNormal = 1,...
proto native Mission GetMission()
Определения DayZGame.c:890
Super root of all classes in Enforce script.
Определения EnScript.c:11
proto native OptionsAccess GetOptionByType(int accessType)
Get option by AccessType.
Определения gameplay.c:1461
proto native bool LocalPress_ID(int action, bool check_focus=true)
Returns true just in frame, when action was invoked (button was pressed)
Определения input.c:11
TODO doc.
Определения EnScript.c:118
bool IsVoNActive()
Определения gameplay.c:816
Mission class.
Определения gameplay.c:687
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
ScriptInvoker Class provide list of callbacks usage:
Определения tools.c:116
static bool IsVONToggled()
Specifies whether VON mode is toggled or not.
Определения VONManager.c:319
static VONManagerBase GetInstance()
Main way to access VONManager functionality from script.
Определения VONManager.c:292
static void CleanupInstance()
Uninitializes VONManager, runs when user disconnects from server.
Определения VONManager.c:309
static ref VONManagerBase m_VONManager
Определения VONManager.c:286
static void Init()
Initializes VONManager, runs when user first connects to a server.
Определения VONManager.c:300
static bool IsVoiceThresholdMinimum()
Specifies whether user's voice activation threshold value is equal to the minimum voice activation th...
Определения VONManager.c:328
void OnEvent(EventType eventTypeId, Param params)
bool m_VoNToggled
Определения VONManager.c:3
void HandleInput(Input inp)
void ShowVoiceNotification(int level, bool fading)
void VONManagerBase()
Определения VONManager.c:7
void HideVoiceNotification()
void OnVOIPThresholdChanged()
bool IsVonToggled()
Определения VONManager.c:18
ref ScriptInvoker m_OnVonStateEvent
Определения VONManager.c:4
ref ScriptInvoker m_OnPartyChatChangedEvent
Определения VONManager.c:5
Определения VONManager.c:2
Manager class which handles Voice-over-network functionality while player is connected to a server.
Определения VONManager.c:285
Param2< string, string > VONStartSpeakingEventParams
player name, player id
Определения gameplay.c:449
const EventType PartyChatStatusChangedEventTypeID
no params
Определения gameplay.c:561
Param2< bool, bool > VONStateEventParams
listening, toggled
Определения gameplay.c:447
Param2< string, string > VONStopSpeakingEventParams
player name, player id
Определения gameplay.c:451
const EventType VONStartSpeakingEventTypeID
params: VONStartSpeakingEventParams
Определения gameplay.c:551
const EventType VONStateEventTypeID
params: VONStateEventParams
Определения gameplay.c:549
const EventType VONUserStoppedTransmittingAudioEventTypeID
no params
Определения gameplay.c:557
const EventType VONUserStartedTransmittingAudioEventTypeID
no params
Определения gameplay.c:555
const EventType VONStopSpeakingEventTypeID
params: VONStopSpeakingEventParams
Определения gameplay.c:553
const EventType MPSessionPlayerReadyEventTypeID
no params
Определения gameplay.c:481
proto native CGame GetGame()
OptionAccessType
C++ OptionAccessType.
Определения gameplay.c:1224
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native float GetSilenceThreshold()
TypeID EventType
Определения EnWidgets.c:55