@@ -47,7 +47,7 @@ A32NX_Util.createMachine = (machineDef) => {
47
47
if ( valid ) {
48
48
machine . value = newState ;
49
49
}
50
- } ,
50
+ }
51
51
} ;
52
52
return machine ;
53
53
} ;
@@ -59,7 +59,7 @@ A32NX_Util.createMachine = (machineDef) => {
59
59
* @returns magnetic heading
60
60
*/
61
61
A32NX_Util . trueToMagnetic = ( heading , magVar ) => {
62
- return ( 720 + heading - ( magVar || SimVar . GetSimVarValue ( ' MAGVAR' , ' degree' ) ) ) % 360 ;
62
+ return ( 720 + heading - ( magVar || SimVar . GetSimVarValue ( " MAGVAR" , " degree" ) ) ) % 360 ;
63
63
} ;
64
64
65
65
/**
@@ -69,7 +69,7 @@ A32NX_Util.trueToMagnetic = (heading, magVar) => {
69
69
* @returns true heading
70
70
*/
71
71
A32NX_Util . magneticToTrue = ( heading , magVar ) => {
72
- return ( 720 + heading + ( magVar || SimVar . GetSimVarValue ( ' MAGVAR' , ' degree' ) ) ) % 360 ;
72
+ return ( 720 + heading + ( magVar || SimVar . GetSimVarValue ( " MAGVAR" , " degree" ) ) ) % 360 ;
73
73
} ;
74
74
75
75
/**
@@ -80,7 +80,7 @@ A32NX_Util.latLonToSpherical = (ll) => {
80
80
return [
81
81
Math . cos ( ll . lat * Avionics . Utils . DEG2RAD ) * Math . cos ( ll . long * Avionics . Utils . DEG2RAD ) ,
82
82
Math . cos ( ll . lat * Avionics . Utils . DEG2RAD ) * Math . sin ( ll . long * Avionics . Utils . DEG2RAD ) ,
83
- Math . sin ( ll . lat * Avionics . Utils . DEG2RAD ) ,
83
+ Math . sin ( ll . lat * Avionics . Utils . DEG2RAD )
84
84
] ;
85
85
} ;
86
86
@@ -174,9 +174,9 @@ A32NX_Util.getIsaTempDeviation = (alt = Simplane.getAltitude(), sat = Simplane.g
174
174
} ;
175
175
176
176
/**
177
- * Get the magvar to use for radials from a wp.
177
+ * Get the magvar to use for radials from a wp.
178
178
* @param {VhfNavaid } facility The waypoint.
179
- */
179
+ */
180
180
A32NX_Util . getRadialMagVar = ( facility ) => {
181
181
if ( facility . subSectionCode === 0 /* VhfNavaid */ ) {
182
182
if ( facility . stationDeclination !== undefined ) {
@@ -191,9 +191,10 @@ A32NX_Util.getRadialMagVar = (facility) => {
191
191
* Utility class to throttle instrument updates
192
192
*/
193
193
class UpdateThrottler {
194
+
194
195
/**
195
- * @param {number } intervalMs Interval between updates, in milliseconds
196
- */
196
+ * @param {number } intervalMs Interval between updates, in milliseconds
197
+ */
197
198
constructor ( intervalMs ) {
198
199
this . intervalMs = intervalMs ;
199
200
this . currentTime = 0 ;
@@ -206,14 +207,14 @@ class UpdateThrottler {
206
207
}
207
208
208
209
/**
209
- * Checks whether the instrument should be updated in the current frame according to the
210
- * configured update interval.
211
- *
212
- * @param {number } deltaTime
213
- * @param {boolean } [forceUpdate = false] - True if you want to force an update during this frame.
214
- * @returns -1 if the instrument should not update, or the time elapsed since the last
215
- * update in milliseconds
216
- */
210
+ * Checks whether the instrument should be updated in the current frame according to the
211
+ * configured update interval.
212
+ *
213
+ * @param {number } deltaTime
214
+ * @param {boolean } [forceUpdate = false] - True if you want to force an update during this frame.
215
+ * @returns -1 if the instrument should not update, or the time elapsed since the last
216
+ * update in milliseconds
217
+ */
217
218
canUpdate ( deltaTime , forceUpdate = false ) {
218
219
this . currentTime += deltaTime ;
219
220
const number = Math . floor ( ( this . currentTime + this . refreshOffset ) / this . intervalMs ) ;
@@ -236,9 +237,9 @@ A32NX_Util.UpdateThrottler = UpdateThrottler;
236
237
*/
237
238
class NotificationParams {
238
239
constructor ( ) {
239
- this . __Type = ' SNotificationParams' ;
240
+ this . __Type = " SNotificationParams" ;
240
241
this . buttons = [ ] ;
241
- this . style = ' normal' ;
242
+ this . style = " normal" ;
242
243
this . displayGlobalPopup = true ;
243
244
}
244
245
}
@@ -250,33 +251,33 @@ class NXPopUp {
250
251
constructor ( ) {
251
252
this . params = new NotificationParams ( ) ;
252
253
this . popupListener ;
253
- this . params . title = 'A339X POPUP' ;
254
+ this . params . title = "HDW POPUP" ;
254
255
this . params . time = new Date ( ) . getTime ( ) ;
255
- this . params . id = this . params . title + '_' + this . params . time ;
256
- this . params . contentData = ' Default Message' ;
257
- this . params . style = ' small' ;
258
- this . params . buttons . push ( new NotificationButton ( ' TT:MENU.YES' , ' HDW_POP_' + this . params . id + ' _YES' ) ) ;
259
- this . params . buttons . push ( new NotificationButton ( ' TT:MENU.NO' , ' HDW_POP_' + this . params . id + ' _NO' ) ) ;
256
+ this . params . id = this . params . title + "_" + this . params . time ;
257
+ this . params . contentData = " Default Message" ;
258
+ this . params . style = " small" ;
259
+ this . params . buttons . push ( new NotificationButton ( " TT:MENU.YES" , " HDW_POP_" + this . params . id + " _YES" ) ) ;
260
+ this . params . buttons . push ( new NotificationButton ( " TT:MENU.NO" , " HDW_POP_" + this . params . id + " _NO" ) ) ;
260
261
}
261
262
262
263
_showPopUp ( params ) {
263
264
try {
264
265
Coherent . trigger ( 'UNFOCUS_INPUT_FIELD' ) ; // Needed to return focus back to camera if it has been taken elsewhere.
265
266
SimVar . SetSimVarValue ( 'A:COCKPIT CAMERA HEADLOOK' , 'Enum' , 2 ) ; // Toggles freelook off if it is on and forces on the mouse cursor
266
- Coherent . trigger ( ' SHOW_POP_UP' , params ) ;
267
+ Coherent . trigger ( " SHOW_POP_UP" , params ) ;
267
268
} catch ( e ) {
268
269
console . error ( e ) ;
269
270
}
270
271
}
271
272
272
273
/**
273
- * Show popup with given or already initiated parameters
274
- * @param {string } title Title for popup - will show in menu bar
275
- * @param {string } message Popup message
276
- * @param {string } style Style/Type of popup. Valid types are small|normal|big|big-help
277
- * @param {function } callbackYes Callback function -> YES button is clicked.
278
- * @param {function } callbackNo Callback function -> NO button is clicked.
279
- */
274
+ * Show popup with given or already initiated parameters
275
+ * @param {string } title Title for popup - will show in menu bar
276
+ * @param {string } message Popup message
277
+ * @param {string } style Style/Type of popup. Valid types are small|normal|big|big-help
278
+ * @param {function } callbackYes Callback function -> YES button is clicked.
279
+ * @param {function } callbackNo Callback function -> NO button is clicked.
280
+ */
280
281
showPopUp ( title , message , style , callbackYes , callbackNo ) {
281
282
if ( title ) {
282
283
this . params . title = title ;
@@ -288,22 +289,22 @@ class NXPopUp {
288
289
this . params . style = style ;
289
290
}
290
291
if ( callbackYes ) {
291
- const yes = typeof callbackYes === ' function' ? callbackYes : ( ) => callbackYes ;
292
+ const yes = ( typeof callbackYes === " function" ) ? callbackYes : ( ) => callbackYes ;
292
293
Coherent . on ( `HDW_POP_${ this . params . id } _YES` , ( ) => {
293
294
Coherent . off ( `HDW_POP_${ this . params . id } _YES` , null , null ) ;
294
295
yes ( ) ;
295
296
} ) ;
296
297
}
297
298
if ( callbackNo ) {
298
- const no = typeof callbackNo === ' function' ? callbackNo : ( ) => callbackNo ;
299
+ const no = ( typeof callbackNo === " function" ) ? callbackNo : ( ) => callbackNo ;
299
300
Coherent . on ( `HDW_POP_${ this . params . id } _NO` , ( ) => {
300
301
Coherent . off ( `HDW_POP_${ this . params . id } _NO` , null , null ) ;
301
302
no ( ) ;
302
303
} ) ;
303
304
}
304
305
305
306
if ( ! this . popupListener ) {
306
- this . popupListener = RegisterViewListener ( ' JS_LISTENER_POPUP' , this . _showPopUp . bind ( null , this . params ) ) ;
307
+ this . popupListener = RegisterViewListener ( " JS_LISTENER_POPUP" , this . _showPopUp . bind ( null , this . params ) ) ;
307
308
} else {
308
309
this . _showPopUp ( ) ;
309
310
}
@@ -315,21 +316,22 @@ class NXPopUp {
315
316
*/
316
317
317
318
class NXNotifManager {
319
+
318
320
constructor ( ) {
319
- Coherent . on ( ' keyIntercepted' , ( key ) => this . registerIntercepts ( key ) ) ;
320
- Coherent . call ( ' INTERCEPT_KEY_EVENT' , ' PAUSE_TOGGLE' , 0 ) ;
321
- Coherent . call ( ' INTERCEPT_KEY_EVENT' , ' PAUSE_ON' , 0 ) ;
322
- Coherent . call ( ' INTERCEPT_KEY_EVENT' , ' PAUSE_OFF' , 0 ) ;
323
- Coherent . call ( ' INTERCEPT_KEY_EVENT' , ' PAUSE_SET' , 0 ) ;
321
+ Coherent . on ( " keyIntercepted" , ( key ) => this . registerIntercepts ( key ) ) ;
322
+ Coherent . call ( " INTERCEPT_KEY_EVENT" , " PAUSE_TOGGLE" , 0 ) ;
323
+ Coherent . call ( " INTERCEPT_KEY_EVENT" , " PAUSE_ON" , 0 ) ;
324
+ Coherent . call ( " INTERCEPT_KEY_EVENT" , " PAUSE_OFF" , 0 ) ;
325
+ Coherent . call ( " INTERCEPT_KEY_EVENT" , " PAUSE_SET" , 0 ) ;
324
326
this . notifications = [ ] ;
325
327
}
326
328
327
329
registerIntercepts ( key ) {
328
330
switch ( key ) {
329
- case ' PAUSE_TOGGLE' :
330
- case ' PAUSE_ON' :
331
- case ' PAUSE_OFF' :
332
- case ' PAUSE_SET' :
331
+ case " PAUSE_TOGGLE" :
332
+ case " PAUSE_ON" :
333
+ case " PAUSE_OFF" :
334
+ case " PAUSE_SET" :
333
335
this . notifications . forEach ( ( notif ) => {
334
336
notif . hideNotification ( ) ;
335
337
} ) ;
@@ -349,15 +351,15 @@ class NXNotifManager {
349
351
350
352
class NXNotif {
351
353
constructor ( ) {
352
- const title = 'A339X ALERT' ;
354
+ const title = "HDW ALERT" ;
353
355
this . time = new Date ( ) . getTime ( ) ;
354
356
this . params = {
355
357
id : `${ title } _${ this . time } ` ,
356
358
title,
357
- type : ' MESSAGE' ,
358
- theme : ' GAMEPLAY' ,
359
- image : ' IMAGE_NOTIFICATION' ,
360
- description : ' Default Message' ,
359
+ type : " MESSAGE" ,
360
+ theme : " GAMEPLAY" ,
361
+ image : " IMAGE_NOTIFICATION" ,
362
+ description : " Default Message" ,
361
363
timeout : 10000 ,
362
364
time : this . time ,
363
365
} ;
@@ -386,29 +388,29 @@ class NXNotif {
386
388
}
387
389
388
390
/**
389
- * Show notification with given or already initiated parametrs.
390
- * @param {string } params.title Title for notification - will show as the message header
391
- * @param {string } params.type Type of Notification - Valid types are MESSAGE|SUBTITLES
392
- * @param {string } params.theme Theme of Notification. Valid types are TIPS|GAMEPLAY|SYSTEM
393
- * @param {string } params.image Notification image. Valid types are IMAGE_NOTIFICATION|IMAGE_SCORE
394
- * @param {string } params.message Notification message
395
- * @param {number } params.timeout Time in ms before notification message will disappear
396
- */
391
+ * Show notification with given or already initiated parametrs.
392
+ * @param {string } params.title Title for notification - will show as the message header
393
+ * @param {string } params.type Type of Notification - Valid types are MESSAGE|SUBTITLES
394
+ * @param {string } params.theme Theme of Notification. Valid types are TIPS|GAMEPLAY|SYSTEM
395
+ * @param {string } params.image Notification image. Valid types are IMAGE_NOTIFICATION|IMAGE_SCORE
396
+ * @param {string } params.message Notification message
397
+ * @param {number } params.timeout Time in ms before notification message will disappear
398
+ */
397
399
showNotification ( params = { } ) {
398
400
this . setData ( params ) ;
399
401
400
402
if ( ! nxNotificationsListener ) {
401
- nxNotificationsListener = RegisterViewListener ( ' JS_LISTENER_NOTIFICATIONS' ) ;
403
+ nxNotificationsListener = RegisterViewListener ( " JS_LISTENER_NOTIFICATIONS" ) ;
402
404
}
403
- nxNotificationsListener . triggerToAllSubscribers ( ' SendNewNotification' , this . params ) ;
405
+ nxNotificationsListener . triggerToAllSubscribers ( " SendNewNotification" , this . params ) ;
404
406
setTimeout ( ( ) => {
405
407
this . hideNotification ( ) ;
406
408
} , this . params . timeout ) ;
407
409
}
408
410
409
411
// TODO FIXME: May break in the future, check every update
410
412
hideNotification ( ) {
411
- nxNotificationsListener . triggerToAllSubscribers ( ' HideNotification' , this . params . type , null , this . params . id ) ;
413
+ nxNotificationsListener . triggerToAllSubscribers ( " HideNotification" , this . params . type , null , this . params . id ) ;
412
414
}
413
415
}
414
416
0 commit comments