DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
VONManager.c
См. документацию.
37
41 override void HideVoiceNotification()
42 {
43#ifdef NO_GUI
44 return;
45#endif
46 if (g_Game.IsMissionMainMenu())
47 {
48 return;
49 }
50
51 Mission mission = g_Game.GetMission();
52 mission.GetMicrophoneIcon().Show(false);
53 mission.HideVoiceLevelWidgets();
54 }
55
61 override void ShowVoiceNotification(int level, bool fading)
62 {
63 if (g_Game.IsMissionMainMenu())
64 {
65 return;
66 }
67
68 Mission mission = g_Game.GetMission();
69 ImageWidget micIcon = mission.GetMicrophoneIcon();
70 WidgetFadeTimer micTimer = mission.GetMicWidgetFadeTimer();
71 map<int,ImageWidget> voiceLeveWidgets = mission.GetVoiceLevelWidgets();
72 map<int,ref WidgetFadeTimer> voiceLevelTimers = mission.GetVoiceLevelTimers();
73
74 // microphone icon
75 micTimer.Stop();
76 micIcon.SetAlpha(1.0);
77 micIcon.Show(true);
78
79 if (fading)
80 {
81 micTimer.FadeOut(micIcon, 3.0);
82 }
83
84 // range icons
85 for( int n = 0; n < voiceLeveWidgets.Count(); n++ )
86 {
87 int voiceKey = voiceLeveWidgets.GetKey(n);
88 ImageWidget voiceWidget = voiceLeveWidgets.Get(n);
89
90 // stop fade timer since it will be refreshed
91 WidgetFadeTimer timer = voiceLevelTimers.Get(n);
92 timer.Stop();
93
94 // show widgets according to the level
95 if ( voiceKey <= level )
96 {
97 voiceWidget.SetAlpha(1.0); // reset from possible previous fade out
98 voiceWidget.Show(true);
99
100 if (fading)
101 {
102 timer.FadeOut(voiceWidget, 3.0);
103 }
104 }
105 else
106 {
107 voiceWidget.Show(false);
108 }
109 }
110 }
111
116 override void HandleInput(Input inp)
117 {
118#ifdef PLATFORM_MSSTORE
119 // ignore VON-related input if user is in an xbox party
120 if (GetGame().IsInPartyChat())
121 {
122 return;
123 }
124#endif
125#ifdef PLATFORM_XBOX
126 // ignore VON-related input if user is in an xbox party
127 if (g_Game.IsInPartyChat())
128 {
129 return;
130 }
131#endif
132#ifdef PLATFORM_MSSTORE
133 // ignore VON-related input if user is in an xbox party
134 if (g_Game.IsInPartyChat())
135 {
136 return;
137 }
138#endif
139
140 int oldLevel = g_Game.GetVoiceLevel();
141 if (oldLevel == -1) //VoN system not initialized!
142 return;
143
144 int newLevel = -1;
145
146 if (inp.LocalPress_ID(UAVoiceDistanceUp,false))
147 {
148 newLevel = ( oldLevel + 1 ) % ( VoiceLevelShout + 1 );
149 }
150
151 if (inp.LocalPress_ID(UAVoiceDistanceDown,false))
152 {
153 newLevel = oldLevel - 1;
154 if (newLevel < VoiceLevelWhisper) //nah...
155 {
156 newLevel = VoiceLevelShout;
157 }
158 }
159
160 if (newLevel > -1)
161 {
162 g_Game.SetVoiceLevel(newLevel);
163 if (g_Game.GetMission().IsVoNActive()) // icon is already visible, just update the range
164 {
166 }
167 else // Show the icon and let it fade out
168 {
169 int level = g_Game.GetVoiceLevel();
170 ShowVoiceNotification(level, true);
171 }
172 }
173 }
174
175 private void UpdateVoiceIcon()
176 {
177 Mission mission = g_Game.GetMission();
178 int rangeLevel = g_Game.GetVoiceLevel();
179
180 if (mission.IsVoNActive())
181 {
182 if (m_VoNToggled)
183 {
185 {
186 ShowVoiceNotification(rangeLevel, false);
187 }
188 else
189 {
190 ShowVoiceNotification(rangeLevel, true);
191 }
192 }
193 else
194 {
195 ShowVoiceNotification(rangeLevel, false);
196 }
197 }
198 else
199 {
201 }
202 }
203
208 {
210 }
211
217 override void OnEvent(EventType eventTypeId, Param params)
218 {
219 Mission mission = g_Game.GetMission();
220 switch (eventTypeId)
221 {
223 {
224 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
225 if (m_VoNToggled)
226 {
228 {
229 ShowVoiceNotification(g_Game.GetVoiceLevel(), false);
230 }
231 }
232 break;
233 }
234
236 {
237 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
238 if (m_VoNToggled)
239 {
241 {
243 }
244 }
245 break;
246 }
247
249 {
250 if (!mission)
251 {
252 break;
253 }
254
255 VONStateEventParams vonStateParams = VONStateEventParams.Cast( params );
256 mission.SetVoNActive(vonStateParams.param1);
257 m_VoNToggled = vonStateParams.param2;
258
260
261 m_OnVonStateEvent.Invoke();
262 break;
263 }
264
266 {
268 break;
269 }
270
272 {
273 VONStartSpeakingEventParams vonStartParams;
274 if (Class.CastTo(vonStartParams, params))
275 {
276 GetDayZGame().AddVoiceNotification(vonStartParams);
277 }
278 break;
279 }
280
282 {
283 VONStopSpeakingEventParams vonStopParams;
284 if (Class.CastTo(vonStopParams, params))
285 {
286 GetDayZGame().RemoveVoiceNotification(vonStopParams);
287 }
288 break;
289 }
290
292 {
294 break;
295 }
296 }
297 }
298}
299
302{
303 private static ref VONManagerBase m_VONManager = new VONManagerBase();
304
310 {
311 return m_VONManager;
312 }
313
317 static void Init()
318 {
319 delete m_VONManager;
321 }
322
326 static void CleanupInstance()
327 {
328 delete m_VONManager;
330 }
331
336 static bool IsVONToggled()
337 {
338 return m_VONManager.IsVonToggled();
339 }
340
346 {
347 GameOptions gameOptions = new GameOptions();
348 NumericOptionsAccess noa;
349 Class.CastTo(noa, gameOptions.GetOptionByType( OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER ));
350
351 return noa.ReadValue() <= g_Game.GetSoundScene().GetSilenceThreshold();
352 }
353}
DayZGame g_Game
Определения DayZGame.c:4074
DayZGame GetDayZGame()
Определения DayZGame.c:4076
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:175
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
Mission class.
Определения gameplay.c:686
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:
Определения 2_GameLib/DayZ/tools.c:116
static bool IsVONToggled()
Specifies whether VON mode is toggled or not.
Определения VONManager.c:336
static VONManagerBase GetInstance()
Main way to access VONManager functionality from script.
Определения VONManager.c:309
static void CleanupInstance()
Uninitializes VONManager, runs when user disconnects from server.
Определения VONManager.c:326
static ref VONManagerBase m_VONManager
Определения VONManager.c:303
static void Init()
Initializes VONManager, runs when user first connects to a server.
Определения VONManager.c:317
static bool IsVoiceThresholdMinimum()
Specifies whether user's voice activation threshold value is equal to the minimum voice activation th...
Определения VONManager.c:345
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:302
Определения Transport.c:70
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
OptionAccessType
C++ OptionAccessType.
Определения gameplay.c:1224
DayZGame GetGame()
Определения gameplay.c:636
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
TypeID EventType
Определения EnWidgets.c:55