DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
VONManager.c
См. документацию.
37
41 override void HideVoiceNotification()
42 {
43 if (g_Game.IsMissionMainMenu())
44 {
45 return;
46 }
47
48 Mission mission = g_Game.GetMission();
49 mission.GetMicrophoneIcon().Show(false);
50 mission.HideVoiceLevelWidgets();
51 }
52
58 override void ShowVoiceNotification(int level, bool fading)
59 {
60 if (g_Game.IsMissionMainMenu())
61 {
62 return;
63 }
64
65 Mission mission = g_Game.GetMission();
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_MSSTORE
116 // ignore VON-related input if user is in an xbox party
117 if (GetGame().IsInPartyChat())
118 {
119 return;
120 }
121#endif
122#ifdef PLATFORM_XBOX
123 // ignore VON-related input if user is in an xbox party
124 if (g_Game.IsInPartyChat())
125 {
126 return;
127 }
128#endif
129#ifdef PLATFORM_MSSTORE
130 // ignore VON-related input if user is in an xbox party
131 if (g_Game.IsInPartyChat())
132 {
133 return;
134 }
135#endif
136
137 int oldLevel = g_Game.GetVoiceLevel();
138 if (oldLevel == -1) //VoN system not initialized!
139 return;
140
141 int newLevel = -1;
142
143 if (inp.LocalPress_ID(UAVoiceDistanceUp,false))
144 {
145 newLevel = ( oldLevel + 1 ) % ( VoiceLevelShout + 1 );
146 }
147
148 if (inp.LocalPress_ID(UAVoiceDistanceDown,false))
149 {
150 newLevel = oldLevel - 1;
151 if (newLevel < VoiceLevelWhisper) //nah...
152 {
153 newLevel = VoiceLevelShout;
154 }
155 }
156
157 if (newLevel > -1)
158 {
159 g_Game.SetVoiceLevel(newLevel);
160 if (g_Game.GetMission().IsVoNActive()) // icon is already visible, just update the range
161 {
163 }
164 else // Show the icon and let it fade out
165 {
166 int level = g_Game.GetVoiceLevel();
167 ShowVoiceNotification(level, true);
168 }
169 }
170 }
171
172 private void UpdateVoiceIcon()
173 {
174 Mission mission = g_Game.GetMission();
175 int rangeLevel = g_Game.GetVoiceLevel();
176
177 if (mission.IsVoNActive())
178 {
179 if (m_VoNToggled)
180 {
182 {
183 ShowVoiceNotification(rangeLevel, false);
184 }
185 else
186 {
187 ShowVoiceNotification(rangeLevel, true);
188 }
189 }
190 else
191 {
192 ShowVoiceNotification(rangeLevel, false);
193 }
194 }
195 else
196 {
198 }
199 }
200
205 {
207 }
208
214 override void OnEvent(EventType eventTypeId, Param params)
215 {
216 Mission mission = g_Game.GetMission();
217 switch (eventTypeId)
218 {
220 {
221 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
222 if (m_VoNToggled)
223 {
225 {
226 ShowVoiceNotification(g_Game.GetVoiceLevel(), false);
227 }
228 }
229 break;
230 }
231
233 {
234 // only handle this if we are in Voice Activation mode, so ignore if in PTT mode
235 if (m_VoNToggled)
236 {
238 {
240 }
241 }
242 break;
243 }
244
246 {
247 if (!mission)
248 {
249 break;
250 }
251
252 VONStateEventParams vonStateParams = VONStateEventParams.Cast( params );
253 mission.SetVoNActive(vonStateParams.param1);
254 m_VoNToggled = vonStateParams.param2;
255
257
258 m_OnVonStateEvent.Invoke();
259 break;
260 }
261
263 {
265 break;
266 }
267
269 {
270 VONStartSpeakingEventParams vonStartParams;
271 if (Class.CastTo(vonStartParams, params))
272 {
273 GetDayZGame().AddVoiceNotification(vonStartParams);
274 }
275 break;
276 }
277
279 {
280 VONStopSpeakingEventParams vonStopParams;
281 if (Class.CastTo(vonStopParams, params))
282 {
283 GetDayZGame().RemoveVoiceNotification(vonStopParams);
284 }
285 break;
286 }
287
289 {
291 break;
292 }
293 }
294 }
295}
296
299{
300 private static ref VONManagerBase m_VONManager = new VONManagerBase();
301
307 {
308 return m_VONManager;
309 }
310
314 static void Init()
315 {
316 delete m_VONManager;
318 }
319
323 static void CleanupInstance()
324 {
325 delete m_VONManager;
327 }
328
333 static bool IsVONToggled()
334 {
335 return m_VONManager.IsVonToggled();
336 }
337
343 {
344 GameOptions gameOptions = new GameOptions();
345 NumericOptionsAccess noa;
346 Class.CastTo(noa, gameOptions.GetOptionByType( OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER ));
347
348 return noa.ReadValue() <= g_Game.GetSoundScene().GetSilenceThreshold();
349 }
350}
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
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:172
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:333
static VONManagerBase GetInstance()
Main way to access VONManager functionality from script.
Определения VONManager.c:306
static void CleanupInstance()
Uninitializes VONManager, runs when user disconnects from server.
Определения VONManager.c:323
static ref VONManagerBase m_VONManager
Определения VONManager.c:300
static void Init()
Initializes VONManager, runs when user first connects to a server.
Определения VONManager.c:314
static bool IsVoiceThresholdMinimum()
Specifies whether user's voice activation threshold value is equal to the minimum voice activation th...
Определения VONManager.c:342
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:299
Определения CachedEquipmentStorage.c:4
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