Skip to content

Commit

Permalink
fix(ui): mitigate pop-up camera state bugs (#9330)
Browse files Browse the repository at this point in the history
* fix: pop-up not returning cursor when triggered when camera is in a certain state

* fix: shift logic to _popup

* fix: linting
  • Loading branch information
2hwk authored and Saschl committed Nov 5, 2024
1 parent 9ff072d commit 4d4d040
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ class NXPopUp {

_showPopUp(params) {
try {
Coherent.trigger('UNFOCUS_INPUT_FIELD'); // Needed to return focus back to camera if it has been taken elsewhere.
SimVar.SetSimVarValue('A:COCKPIT CAMERA HEADLOOK', 'Enum', 2); // Toggles freelook off if it is on and forces on the mouse cursor
Coherent.trigger("SHOW_POP_UP", params);
} catch (e) {
console.error(e);
Expand Down
150 changes: 0 additions & 150 deletions fbw-a380x/src/systems/shared/src/popup.ts

This file was deleted.

15 changes: 9 additions & 6 deletions fbw-common/src/systems/shared/src/popup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
/**
* NotificationParams container for popups to package popup metadata
*/
Expand All @@ -15,12 +16,12 @@ export type NotificationParams = {
};

/**
* PopUp utility class to create a pop-up UI element
* PopUpDialog utility class to create a pop-up UI element
*
* Usage:
* import { PopUp } from '@flybywiresim/fbw-sdk';
* import { PopUpDialog } from '@flybywiresim/fbw-sdk';
* ...
* const popup = new PopUp();
* const popup = new PopUpDialog();
* popup.showPopUp("CRITICAL SETTING CHANGED", "Your message here", "small", yesFunc, noFunc);
* popup.showInformation("CRITICAL MESSAGE", "Your message here", "small", yesFunc);
*/
Expand All @@ -33,14 +34,14 @@ export class PopUpDialog {
* Creates a Popup
*/
constructor() {
const title = 'A32NX POPUP';
const title = 'FBW POPUP';
const time = new Date().getTime();
this.popupListener = undefined;
this.params = {
__Type: 'SNotificationParams',
buttons: [
new NotificationButton('TT:MENU.YES', `A32NX_POP_${title}_${time}_YES`),
new NotificationButton('TT:MENU.NO', `A32NX_POP_${title}_${time}_NO`),
new NotificationButton('TT:MENU.YES', `FBW_POP_${title}_${time}_YES`),
new NotificationButton('TT:MENU.NO', `FBW_POP_${title}_${time}_NO`),
],
style: 'normal',
displayGlobalPopup: true,
Expand All @@ -59,6 +60,8 @@ export class PopUpDialog {
*/
/* eslint-disable no-underscore-dangle */
_showPopUp(params: any = {}): void {
Coherent.trigger('UNFOCUS_INPUT_FIELD', uuidv4()); // Needed to mitigate an issue when ALT-TAB or using toggle free look
SimVar.SetSimVarValue('A:COCKPIT CAMERA HEADLOOK', 'Enum', 2); // Toggles freelook off if it is on and forces on the mouse cursor
Coherent.trigger('SHOW_POP_UP', params);
}

Expand Down

0 comments on commit 4d4d040

Please sign in to comment.