From fe5e0fb53c4564bbc13f4f1e03b54fc000e5c9ac Mon Sep 17 00:00:00 2001
From: 2hwk <15316958+2hwk@users.noreply.github.com>
Date: Wed, 6 Nov 2024 05:38:55 +0800
Subject: [PATCH 1/2] fix(ui): mitigate pop-up camera state bugs (#9330)
* fix: pop-up not returning cursor when triggered when camera is in a certain state
* fix: shift logic to _popup
* fix: linting
---
.../html_ui/JS/fbw-a380x/A32NX_Util.js | 2 +
fbw-a380x/src/systems/shared/src/popup.ts | 150 ------------------
fbw-common/src/systems/shared/src/popup.ts | 15 +-
3 files changed, 11 insertions(+), 156 deletions(-)
delete mode 100644 fbw-a380x/src/systems/shared/src/popup.ts
diff --git a/fbw-a380x/src/base/flybywire-aircraft-a380-842/html_ui/JS/fbw-a380x/A32NX_Util.js b/fbw-a380x/src/base/flybywire-aircraft-a380-842/html_ui/JS/fbw-a380x/A32NX_Util.js
index a7a1712a486..056f8817ab1 100644
--- a/fbw-a380x/src/base/flybywire-aircraft-a380-842/html_ui/JS/fbw-a380x/A32NX_Util.js
+++ b/fbw-a380x/src/base/flybywire-aircraft-a380-842/html_ui/JS/fbw-a380x/A32NX_Util.js
@@ -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);
diff --git a/fbw-a380x/src/systems/shared/src/popup.ts b/fbw-a380x/src/systems/shared/src/popup.ts
deleted file mode 100644
index 2454e2a217e..00000000000
--- a/fbw-a380x/src/systems/shared/src/popup.ts
+++ /dev/null
@@ -1,150 +0,0 @@
-///
-
-/**
- * NotiticationParams container for popups to package popup metadata
- */
-export type NotiticationParams = {
- __Type: string;
- buttons: NotificationButton[];
- style: string;
- displayGlobalPopup: boolean;
- contentData: string;
- contentUrl: string;
- contentTemplate: string;
- id: string;
- title: string;
- time: number;
-};
-
-/**
- * PopUp utility class to create a pop-up UI element
- *
- * Usage:
- * import { PopUp } from '@shared/popup';
- * ...
- * const popup = new PopUp();
- * popup.showPopUp("CRITICAL SETTING CHANGED", "Your message here", "small", yesFunc, noFunc);
- * popup.showInformation("CRITICAL MESSAGE", "Your message here", "small", yesFunc);
- */
-export class PopUp {
- params: NotiticationParams;
-
- popupListener: any;
-
- /**
- * Creates a Popup
- */
- constructor() {
- const title = 'A32NX 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`),
- ],
- style: 'normal',
- displayGlobalPopup: true,
- contentData: 'Default Message',
- contentUrl: '', // i.e. "/templates/Controls/PopUp_EditPreset/PopUp_EditPreset.html";
- contentTemplate: '', // i.e. "popup-edit-preset";
- id: `${title}_${time}`,
- title,
- time,
- };
- }
-
- /**
- * Pass Popup display data to Coherent
- * @param params
- */
- /* eslint-disable no-underscore-dangle */
- _showPopUp(params: any = {}): void {
- Coherent.trigger('SHOW_POP_UP', params);
- }
-
- /**
- * Show popup with given or already initiated parameters
- * @param {string} title Title for popup - will show in menu bar
- * @param {string} message Popup message
- * @param {string} style Style/Type of popup. Valid types are small|normal|big|big-help
- * @param {function} callbackYes Callback function -> YES button is clicked.
- * @param {function} callbackNo Callback function -> NO button is clicked.
- */
- showPopUp(
- title: string,
- message: string,
- style: 'small' | 'normal' | 'big' | 'big-help',
- callbackYes: () => void,
- callbackNo: () => void,
- ): void {
- if (title) {
- this.params.title = title;
- }
- if (message) {
- this.params.contentData = message;
- }
- if (style) {
- this.params.style = style;
- }
- if (callbackYes) {
- const yes = typeof callbackYes === 'function' ? callbackYes : () => callbackYes;
- Coherent.on(`A32NX_POP_${this.params.id}_YES`, () => {
- Coherent.off(`A32NX_POP_${this.params.id}_YES`, null, null);
- yes();
- });
- }
- if (callbackNo) {
- const no = typeof callbackNo === 'function' ? callbackNo : () => callbackNo;
- Coherent.on(`A32NX_POP_${this.params.id}_NO`, () => {
- Coherent.off(`A32NX_POP_${this.params.id}_NO`, null, null);
- no();
- });
- }
-
- if (!this.popupListener) {
- this.popupListener = RegisterViewListener('JS_LISTENER_POPUP', this._showPopUp.bind(null, this.params));
- } else {
- this._showPopUp(this.params);
- }
- }
-
- /**
- * Show information with given or already initiated parameters
- * @param {string} title Title for popup - will show in menu bar
- * @param {string} message Popup message
- * @param {string} style Style/Type of popup. Valid types are small|normal|big|big-help
- * @param {function} callback Callback function -> OK button is clicked.
- */
- showInformation(
- title: string,
- message: string,
- style: 'small' | 'normal' | 'big' | 'big-help',
- callback: () => void,
- ): void {
- if (title) {
- this.params.title = title;
- }
- if (message) {
- this.params.contentData = message;
- }
- if (style) {
- this.params.style = style;
- }
- if (callback) {
- const yes = typeof callback === 'function' ? callback : () => callback;
- Coherent.on(`A32NX_POP_${this.params.id}_YES`, () => {
- Coherent.off(`A32NX_POP_${this.params.id}_YES`, null, null);
- yes();
- });
- }
- this.params.buttons = [new NotificationButton('TT:MENU.OK', `A32NX_POP_${this.params.id}_YES`)];
-
- if (!this.popupListener) {
- this.popupListener = RegisterViewListener('JS_LISTENER_POPUP', this._showPopUp.bind(null, this.params));
- } else {
- this._showPopUp(this.params);
- }
- }
-}
diff --git a/fbw-common/src/systems/shared/src/popup.ts b/fbw-common/src/systems/shared/src/popup.ts
index 91e93be077a..fb09ccf2aec 100644
--- a/fbw-common/src/systems/shared/src/popup.ts
+++ b/fbw-common/src/systems/shared/src/popup.ts
@@ -1,3 +1,4 @@
+import { v4 as uuidv4 } from 'uuid';
/**
* NotificationParams container for popups to package popup metadata
*/
@@ -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);
*/
@@ -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,
@@ -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);
}
From 3f289ac24a443d840f45a199bec6e60ab9388aeb Mon Sep 17 00:00:00 2001
From: Andreas Guther
Date: Tue, 5 Nov 2024 23:00:39 +0100
Subject: [PATCH 2/2] chore: try to improve deconflicting with CHANGELOG
(#9402)
---
.gitattributes | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.gitattributes b/.gitattributes
index 67ef805aada..82ee767d306 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -8,3 +8,6 @@
# line endings.
/fbw-a32nx/src/localization/flypad/*.json text eol=lf
/fbw-a32nx/src/localization/msfs/*.locPak text eol=lf
+
+# try to deconflict changelog
+.github/CHANGELOG.md merge=union